v0.15.0
Loading...
Searching...
No Matches
PoissonExample::OpF Struct Reference

Operator calculate source term,. More...

#include "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.
 
virtual MoFEMErrorCode iNtegrate (EntitiesFieldData::EntData &data)=0
 Class dedicated to integrate operator.
 
virtual MoFEMErrorCode aSsemble (EntitiesFieldData::EntData &data)=0
 Class dedicated to assemble operator to global system vector.
 

Protected Member Functions

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

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
 
int nbIntegrationPts
 number of integration points
 

Detailed Description

Operator calculate source term,.

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

Definition at line 219 of file PoissonOperators.hpp.

Member Typedef Documentation

◆ FSource

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

Definition at line 223 of file PoissonOperators.hpp.

Constructor & Destructor Documentation

◆ OpF()

PoissonExample::OpF::OpF ( FSource f_source)
inline
Examples
PoissonOperators.hpp.

Definition at line 225 of file PoissonOperators.hpp.

226 : OpBaseRhs<VolumeElementForcesAndSourcesCore::UserDataOperator>("U"),
227 fSource(f_source) {}

Member Function Documentation

◆ aSsemble()

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

assemble local entity vector to the global right hand side

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

Definition at line 282 of file PoissonOperators.hpp.

282 {
284 // get global indices of local vector
285 const int *indices = &*data.getIndices().data().begin();
286 // get values from local vector
287 const double *vals = &*locVec.data().begin();
288 Vec f = getFEMethod()->ksp_f != PETSC_NULLPTR ? getFEMethod()->ksp_f
289 : getFEMethod()->snes_f;
290 // assemble vector
291 CHKERR VecSetValues(f, nbRows, indices, vals, ADD_VALUES);
293 }
#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.
MoFEMErrorCode VecSetValues(Vec V, const EntitiesFieldData::EntData &data, const double *ptr, InsertMode iora)
Assemble PETSc vector.
const VectorInt & getIndices() const
Get global indices of dofs on entity.

◆ iNtegrate()

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

Integrate local entity vector.

Parameters
dataentity data on element row
Returns
error code
Examples
PoissonOperators.hpp.

Definition at line 242 of file PoissonOperators.hpp.

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

◆ locVec

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

Definition at line 235 of file PoissonOperators.hpp.

◆ NX

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

Definition at line 230 of file PoissonOperators.hpp.

◆ NY

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

Definition at line 231 of file PoissonOperators.hpp.

◆ NZ

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

Definition at line 232 of file PoissonOperators.hpp.


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