v0.9.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 <users_modules/basic_finite_elements/poisson/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, DataForcesAndSourcesCore::EntData &row_data)
 This function is called by finite element. More...
 

Protected Member Functions

MoFEMErrorCode iNtegrate (DataForcesAndSourcesCore::EntData &data)
 Integrate local entity vector. More...
 
MoFEMErrorCode aSsemble (DataForcesAndSourcesCore::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 229 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 233 of file PoissonOperators.hpp.

Constructor & Destructor Documentation

◆ OpF()

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

Definition at line 235 of file PoissonOperators.hpp.

236  : OpBaseRhs<VolumeElementForcesAndSourcesCore::UserDataOperator>("U"),
237  fSource(f_source) {}

Member Function Documentation

◆ aSsemble()

MoFEMErrorCode PoissonExample::OpF::aSsemble ( DataForcesAndSourcesCore::EntData data)
protectedvirtual

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 292 of file PoissonOperators.hpp.

292  {
294  // get global indices of local vector
295  const int *indices = &*data.getIndices().data().begin();
296  // get values from local vector
297  const double *vals = &*locVec.data().begin();
298  Vec f = getFEMethod()->ksp_f != PETSC_NULL ? getFEMethod()->ksp_f
299  : getFEMethod()->snes_f;
300  // assemble vector
301  CHKERR VecSetValues(f, nbRows, indices, vals, ADD_VALUES);
303  }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
MoFEMErrorCode VecSetValues(Vec V, const DataForcesAndSourcesCore::EntData &data, const double *ptr, InsertMode iora)
Assemble PETSc vector.
#define CHKERR
Inline error check.
Definition: definitions.h:596
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ iNtegrate()

MoFEMErrorCode PoissonExample::OpF::iNtegrate ( DataForcesAndSourcesCore::EntData data)
protectedvirtual

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 252 of file PoissonOperators.hpp.

252  {
254  // set size of local vector
255  locVec.resize(nbRows, false);
256  // clear local entity vector
257  locVec.clear();
258  // get finite element volume
259  double vol = getVolume();
260  // get integration weights
261  auto t_w = getFTensor0IntegrationWeight();
262  // get base functions on entity
263  auto t_v = data.getFTensor0N();
264  // get coordinates at integration points
265  auto t_coords = getFTensor1CoordsAtGaussPts();
266  // loop over all integration points
267  for (int gg = 0; gg != nbIntegrationPts; gg++) {
268  // evaluate constant term
269  const double alpha =
270  vol * t_w * fSource(t_coords(NX), t_coords(NY), t_coords(NZ));
271  // get element of local vector
273  &*locVec.data().begin());
274  // loop over base functions
275  for (int rr = 0; rr != nbRows; rr++) {
276  // add to local vector source term
277  t_a -= alpha * t_v;
278  ++t_a; // move to next element of local vector
279  ++t_v; // move to next base function
280  }
281  ++t_w; // move to next integration weight
282  ++t_coords; // move to next physical coordinates at integration point
283  }
285  }
FTensor::Number< 0 > NX
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
FTensor::Number< 2 > NZ
FTensor::Number< 1 > NY
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

Member Data Documentation

◆ fSource

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

Definition at line 243 of file PoissonOperators.hpp.

◆ locVec

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

Definition at line 245 of file PoissonOperators.hpp.

◆ NX

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

Definition at line 240 of file PoissonOperators.hpp.

◆ NY

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

Definition at line 241 of file PoissonOperators.hpp.

◆ NZ

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

Definition at line 242 of file PoissonOperators.hpp.


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