v0.15.0
Loading...
Searching...
No Matches
OpTotalEnergy Struct Reference

#include "tutorials/scl-12/src/electrostatics.hpp"

Inheritance diagram for OpTotalEnergy:
[legend]
Collaboration diagram for OpTotalEnergy:
[legend]

Public Member Functions

 OpTotalEnergy (const std::string &field_name, boost::shared_ptr< MatrixDouble > grad_u_negative, boost::shared_ptr< std::map< int, BlockData > > perm_block_sets_ptr, boost::shared_ptr< std::map< int, BlockData > > int_domain_block_sets_ptr, boost::shared_ptr< DataAtIntegrationPts > common_data_ptr, SmartPetscObj< Vec > petsc_vec_energy)
 
MoFEMErrorCode doWork (int side, EntityType type, EntData &data)
 

Private Attributes

boost::shared_ptr< MatrixDoublegradUNegative
 
boost::shared_ptr< std::map< int, BlockData > > permBlockSetsPtr
 
boost::shared_ptr< std::map< int, BlockData > > intDomainBlocksetsPtr
 
boost::shared_ptr< DataAtIntegrationPtscommonDataPtr
 
SmartPetscObj< Vec > petscTotalEnergy
 

Detailed Description

Definition at line 135 of file electrostatics.hpp.

Constructor & Destructor Documentation

◆ OpTotalEnergy()

OpTotalEnergy::OpTotalEnergy ( const std::string & field_name,
boost::shared_ptr< MatrixDouble > grad_u_negative,
boost::shared_ptr< std::map< int, BlockData > > perm_block_sets_ptr,
boost::shared_ptr< std::map< int, BlockData > > int_domain_block_sets_ptr,
boost::shared_ptr< DataAtIntegrationPts > common_data_ptr,
SmartPetscObj< Vec > petsc_vec_energy )
inline

Definition at line 136 of file electrostatics.hpp.

143 : DomainEleOp(field_name, DomainEleOp::OPROW),
144 gradUNegative(grad_u_negative), permBlockSetsPtr(perm_block_sets_ptr),
145 intDomainBlocksetsPtr(int_domain_block_sets_ptr),
146 commonDataPtr(common_data_ptr), petscTotalEnergy(petsc_vec_energy) {
147 std::fill(&doEntities[MBVERTEX], &doEntities[MBMAXTYPE], false);
148 doEntities[MBVERTEX] = true;
149 }
DomainEle::UserDataOperator DomainEleOp
Finire element operator type.
constexpr auto field_name
boost::shared_ptr< std::map< int, BlockData > > intDomainBlocksetsPtr
boost::shared_ptr< std::map< int, BlockData > > permBlockSetsPtr
boost::shared_ptr< DataAtIntegrationPts > commonDataPtr
SmartPetscObj< Vec > petscTotalEnergy
boost::shared_ptr< MatrixDouble > gradUNegative

Member Function Documentation

◆ doWork()

MoFEMErrorCode OpTotalEnergy::doWork ( int side,
EntityType type,
EntData & data )
inline

Definition at line 150 of file electrostatics.hpp.

150 {
152
153 auto t_negative_grad_u = getFTensor1FromMat<SPACE_DIM>(*gradUNegative);
155 double area = getMeasure();
156 auto t_w = getFTensor0IntegrationWeight();
157 auto nb_gauss_pts = getGaussPts().size2();
158 double totalEnergy = 0.0;
159 int index = 0;
160 // Total Energy Density = 0.5 * E^2 * Perm * Area
161 for (const auto &m : *intDomainBlocksetsPtr) {
162
163 double blockPermittivity = 0.0;
164
165 if (m.second.internalDomainEnts.find(getFEEntityHandle()) !=
166 m.second.internalDomainEnts.end()) {
167 for (const auto &n : *permBlockSetsPtr) {
168 if (n.second.domainEnts.find(getFEEntityHandle()) !=
169 n.second.domainEnts.end()) {
170 blockPermittivity = n.second.epsPermit;
171 }
172 }
173
174 for (int gg = 0; gg != nb_gauss_pts; gg++) {
175 totalEnergy += 0.5 * t_negative_grad_u(I) * t_negative_grad_u(I) *
176 blockPermittivity * t_w * area;
177 ++t_negative_grad_u;
178 ++t_w;
179 }
180 }
181 }
182 CHKERR VecSetValues(petscTotalEnergy, 1, &index, &totalEnergy, ADD_VALUES);
183
185 }
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
constexpr int SPACE_DIM
const double n
refractive index of diffusive medium
FTensor::Tensor1< FTensor::PackPtr< T *, S >, Tensor_Dim > getFTensor1FromMat(ublas::matrix< T, L, A > &data)
Get tensor rank 1 (vector) form data matrix.
MoFEMErrorCode VecSetValues(Vec V, const EntitiesFieldData::EntData &data, const double *ptr, InsertMode iora)
Assemble PETSc vector.
constexpr IntegrationType I
FTensor::Index< 'm', 3 > m

Member Data Documentation

◆ commonDataPtr

boost::shared_ptr<DataAtIntegrationPts> OpTotalEnergy::commonDataPtr
private

Definition at line 191 of file electrostatics.hpp.

◆ gradUNegative

boost::shared_ptr<MatrixDouble> OpTotalEnergy::gradUNegative
private

Definition at line 188 of file electrostatics.hpp.

◆ intDomainBlocksetsPtr

boost::shared_ptr<std::map<int, BlockData> > OpTotalEnergy::intDomainBlocksetsPtr
private

Definition at line 190 of file electrostatics.hpp.

◆ permBlockSetsPtr

boost::shared_ptr<std::map<int, BlockData> > OpTotalEnergy::permBlockSetsPtr
private

Definition at line 189 of file electrostatics.hpp.

◆ petscTotalEnergy

SmartPetscObj<Vec> OpTotalEnergy::petscTotalEnergy
private

Definition at line 192 of file electrostatics.hpp.


The documentation for this struct was generated from the following file: