v0.14.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PoissonExample::OpF Struct Reference

Operator calculate source term,. More...

#include <users_modules/tutorials/cor-2to5/src/PoissonOperators.hpp>

Inheritance diagram for PoissonExample::OpF:
[legend]
Collaboration diagram for PoissonExample::OpF:
[legend]

Public Types

typedef boost::function< double(const double, const double, const double)> FSource
 

Public Member Functions

 OpF (FSource f_source)
 
- Public Member Functions inherited from PoissonExample::OpBaseRhs< VolumeElementForcesAndSourcesCore::UserDataOperator >
 OpBaseRhs (const std::string field_name)
 
MoFEMErrorCode doWork (int row_side, EntityType row_type, EntitiesFieldData::EntData &row_data)
 This function is called by finite element. More...
 
virtual MoFEMErrorCode iNtegrate (EntitiesFieldData::EntData &data)=0
 Class dedicated to integrate operator. More...
 
virtual MoFEMErrorCode aSsemble (EntitiesFieldData::EntData &data)=0
 Class dedicated to assemble operator to global system vector. More...
 

Protected Member Functions

MoFEMErrorCode iNtegrate (EntitiesFieldData::EntData &data)
 Integrate local entity vector. More...
 
MoFEMErrorCode aSsemble (EntitiesFieldData::EntData &data)
 assemble local entity vector to the global right hand side More...
 

Protected Attributes

FTensor::Number< 0 > NX
 
FTensor::Number< 1 > NY
 
FTensor::Number< 2 > NZ
 
FSource fSource
 
VectorDouble locVec
 
- Protected Attributes inherited from PoissonExample::OpBaseRhs< VolumeElementForcesAndSourcesCore::UserDataOperator >
int nbRows
 < error code More...
 
int nbIntegrationPts
 number of integration points More...
 

Detailed Description

Operator calculate source term,.

\[ \mathbf{F} = \int_\Omega \boldsymbol\phi f \textrm{d}\Omega \]

Definition at line 216 of file PoissonOperators.hpp.

Member Typedef Documentation

◆ FSource

typedef boost::function<double(const double, const double, const double)> PoissonExample::OpF::FSource
Examples
PoissonOperators.hpp.

Definition at line 220 of file PoissonOperators.hpp.

Constructor & Destructor Documentation

◆ OpF()

PoissonExample::OpF::OpF ( FSource  f_source)
inline

Definition at line 222 of file PoissonOperators.hpp.

223 : OpBaseRhs<VolumeElementForcesAndSourcesCore::UserDataOperator>("U"),
224 fSource(f_source) {}

Member Function Documentation

◆ aSsemble()

MoFEMErrorCode PoissonExample::OpF::aSsemble ( EntitiesFieldData::EntData &  data)
inlineprotectedvirtual

assemble local entity vector to the global right hand side

Parameters
dataentity data, i.e. global indices of local vector
Returns
error code

Implements PoissonExample::OpBaseRhs< VolumeElementForcesAndSourcesCore::UserDataOperator >.

Examples
PoissonOperators.hpp.

Definition at line 279 of file PoissonOperators.hpp.

279 {
281 // get global indices of local vector
282 const int *indices = &*data.getIndices().data().begin();
283 // get values from local vector
284 const double *vals = &*locVec.data().begin();
285 Vec f = getFEMethod()->ksp_f != PETSC_NULL ? getFEMethod()->ksp_f
286 : getFEMethod()->snes_f;
287 // assemble vector
288 CHKERR VecSetValues(f, nbRows, indices, vals, ADD_VALUES);
290 }
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535
const FTensor::Tensor2< T, Dim, Dim > Vec
MoFEMErrorCode VecSetValues(Vec V, const EntitiesFieldData::EntData &data, const double *ptr, InsertMode iora)
Assemble PETSc vector.

◆ iNtegrate()

MoFEMErrorCode PoissonExample::OpF::iNtegrate ( EntitiesFieldData::EntData &  data)
inlineprotectedvirtual

Integrate local entity vector.

Parameters
dataentity data on element row
Returns
error code

Implements PoissonExample::OpBaseRhs< VolumeElementForcesAndSourcesCore::UserDataOperator >.

Reimplemented in PoissonExample::OpResF_Domain.

Examples
PoissonOperators.hpp.

Definition at line 239 of file PoissonOperators.hpp.

239 {
241 // set size of local vector
242 locVec.resize(nbRows, false);
243 // clear local entity vector
244 locVec.clear();
245 // get finite element volume
246 double vol = getVolume();
247 // get integration weights
248 auto t_w = getFTensor0IntegrationWeight();
249 // get base functions on entity
250 auto t_v = data.getFTensor0N();
251 // get coordinates at integration points
252 auto t_coords = getFTensor1CoordsAtGaussPts();
253 // loop over all integration points
254 for (int gg = 0; gg != nbIntegrationPts; gg++) {
255 // evaluate constant term
256 const double alpha =
257 vol * t_w * fSource(t_coords(NX), t_coords(NY), t_coords(NZ));
258 // get element of local vector
260 &*locVec.data().begin());
261 // loop over base functions
262 for (int rr = 0; rr != nbRows; rr++) {
263 // add to local vector source term
264 t_a -= alpha * t_v;
265 ++t_a; // move to next element of local vector
266 ++t_v; // move to next base function
267 }
268 ++t_w; // move to next integration weight
269 ++t_coords; // move to next physical coordinates at integration point
270 }
272 }
FTensor::Number< 2 > NZ
FTensor::Number< 1 > NY
FTensor::Number< 0 > NX

Member Data Documentation

◆ fSource

FSource PoissonExample::OpF::fSource
protected
Examples
PoissonOperators.hpp.

Definition at line 230 of file PoissonOperators.hpp.

◆ locVec

VectorDouble PoissonExample::OpF::locVec
protected
Examples
PoissonOperators.hpp.

Definition at line 232 of file PoissonOperators.hpp.

◆ NX

FTensor::Number<0> PoissonExample::OpF::NX
protected
Examples
PoissonOperators.hpp.

Definition at line 227 of file PoissonOperators.hpp.

◆ NY

FTensor::Number<1> PoissonExample::OpF::NY
protected
Examples
PoissonOperators.hpp.

Definition at line 228 of file PoissonOperators.hpp.

◆ NZ

FTensor::Number<2> PoissonExample::OpF::NZ
protected
Examples
PoissonOperators.hpp.

Definition at line 229 of file PoissonOperators.hpp.


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