v0.14.0
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
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. 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 219 of file PoissonOperators.hpp.

Member Typedef Documentation

◆ FSource

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

Definition at line 223 of file PoissonOperators.hpp.

Constructor & Destructor Documentation

◆ OpF()

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

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

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_NULL ? getFEMethod()->ksp_f
289  : getFEMethod()->snes_f;
290  // assemble vector
291  CHKERR VecSetValues(f, nbRows, indices, vals, ADD_VALUES);
293  }

◆ iNtegrate()

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

Integrate local entity vector.

Parameters
dataentity data on element row
Returns
error code

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  }

Member Data Documentation

◆ fSource

FSource PoissonExample::OpF::fSource
protected

Definition at line 233 of file PoissonOperators.hpp.

◆ locVec

VectorDouble PoissonExample::OpF::locVec
protected

Definition at line 235 of file PoissonOperators.hpp.

◆ NX

FTensor::Number<0> PoissonExample::OpF::NX
protected

Definition at line 230 of file PoissonOperators.hpp.

◆ NY

FTensor::Number<1> PoissonExample::OpF::NY
protected

Definition at line 231 of file PoissonOperators.hpp.

◆ NZ

FTensor::Number<2> PoissonExample::OpF::NZ
protected

Definition at line 232 of file PoissonOperators.hpp.


The documentation for this struct was generated from the following file:
MoFEM::VecSetValues
MoFEMErrorCode VecSetValues(Vec V, const EntitiesFieldData::EntData &data, const double *ptr, InsertMode iora)
Assemble PETSc vector.
Definition: EntitiesFieldData.hpp:1589
PoissonExample::OpF::NZ
FTensor::Number< 2 > NZ
Definition: PoissonOperators.hpp:232
MoFEM::EntitiesFieldData::EntData::getFTensor0N
FTensor::Tensor0< FTensor::PackPtr< double *, 1 > > getFTensor0N(const FieldApproximationBase base)
Get base function as Tensor0.
Definition: EntitiesFieldData.hpp:1502
PoissonExample::OpF::locVec
VectorDouble locVec
Definition: PoissonOperators.hpp:235
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
PoissonExample::OpF::NY
FTensor::Number< 1 > NY
Definition: PoissonOperators.hpp:231
MoFEM::EntitiesFieldData::EntData::getIndices
const VectorInt & getIndices() const
Get global indices of dofs on entity.
Definition: EntitiesFieldData.hpp:1214
PoissonExample::OpF::fSource
FSource fSource
Definition: PoissonOperators.hpp:233
FTensor::Tensor0
Definition: Tensor0.hpp:16
HenckyOps::f
auto f
Definition: HenckyOps.hpp:15
EigenMatrix::Vec
const FTensor::Tensor2< T, Dim, Dim > Vec
Definition: MatrixFunction.hpp:66
PoissonExample::OpF::NX
FTensor::Number< 0 > NX
Definition: PoissonOperators.hpp:230
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
PoissonExample::OpBaseRhs< VolumeElementForcesAndSourcesCore::UserDataOperator >::nbRows
int nbRows
< error code
Definition: PoissonOperators.hpp:207
PoissonExample::OpBaseRhs< VolumeElementForcesAndSourcesCore::UserDataOperator >::nbIntegrationPts
int nbIntegrationPts
number of integration points
Definition: PoissonOperators.hpp:208