v0.14.0
VolumeCalculation.hpp
Go to the documentation of this file.
1 /** \file VolumeCalculation.hpp
2 
3  * \brief Operator can be used with any volume element to calculate sum of
4  * volumes of all volumes in the set
5 
6  */
7 
8 
9 
10 #ifndef __VOLUME_CALCULATION_HPP__
11 #define __VOLUME_CALCULATION_HPP__
12 
13 /**
14  * @brief Calculate volume
15  *
16  */
19 
21 
22  VolumeCalculation(const std::string &field_name, Vec volume_vec)
23  : MoFEM::VolumeElementForcesAndSourcesCore::UserDataOperator(
25  volumeVec(volume_vec) {}
26 
27  MoFEMErrorCode doWork(int row_side, EntityType row_type,
28  EntitiesFieldData::EntData &row_data) {
30 
31  // do it only once, no need to repeat this for edges,faces or tets
32  if (row_type != MBVERTEX)
34 
35  int nb_gauss_pts = row_data.getN().size1();
36  for (int gg = 0; gg != nb_gauss_pts; ++gg) {
37 
38  double vol = getVolume() * getGaussPts()(3, gg);
39 
40  CHKERR VecSetValue(volumeVec, 0, vol, ADD_VALUES);
41  }
42 
44  }
45 };
46 
47 #endif //__VOLUME_CALCULATION_HPP__
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
VolumeCalculation::doWork
MoFEMErrorCode doWork(int row_side, EntityType row_type, EntitiesFieldData::EntData &row_data)
Definition: VolumeCalculation.hpp:27
VolumeCalculation::VolumeCalculation
VolumeCalculation(const std::string &field_name, Vec volume_vec)
Definition: VolumeCalculation.hpp:22
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
MoFEM::VolumeElementForcesAndSourcesCore::UserDataOperator::getVolume
double getVolume() const
element volume (linear geometry)
Definition: VolumeElementForcesAndSourcesCore.hpp:161
VolumeCalculation::volumeVec
Vec volumeVec
Definition: VolumeCalculation.hpp:20
MoFEM::ForcesAndSourcesCore::UserDataOperator::getGaussPts
MatrixDouble & getGaussPts()
matrix of integration (Gauss) points for Volume Element
Definition: ForcesAndSourcesCore.hpp:1235
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:535
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
MoFEM::ForcesAndSourcesCore::UserDataOperator
Definition: ForcesAndSourcesCore.hpp:549
MoFEM::VolumeElementForcesAndSourcesCore::UserDataOperator
Definition: VolumeElementForcesAndSourcesCore.hpp:108
EntData
EntitiesFieldData::EntData EntData
Definition: child_and_parent.cpp:37
field_name
constexpr auto field_name
Definition: poisson_2d_homogeneous.cpp:13
EigenMatrix::Vec
const FTensor::Tensor2< T, Dim, Dim > Vec
Definition: MatrixFunction.hpp:66
VolumeCalculation
Calculate volume.
Definition: VolumeCalculation.hpp:17
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
MoFEM::ForcesAndSourcesCore::UserDataOperator::OPROW
@ OPROW
operator doWork function is executed on FE rows
Definition: ForcesAndSourcesCore.hpp:567