v0.13.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  * This file is part of MoFEM.
10  * MoFEM is free software: you can redistribute it and/or modify it under
11  * the terms of the GNU Lesser General Public License as published by the
12  * Free Software Foundation, either version 3 of the License, or (at your
13  * option) any later version.
14  *
15  * MoFEM is distributed in the hope that it will be useful, but WITHOUT
16  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18  * License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with MoFEM. If not, see <http://www.gnu.org/licenses/>. */
22 
23 #ifndef __VOLUME_CALCULATION_HPP__
24 #define __VOLUME_CALCULATION_HPP__
25 
26 /**
27  * @brief Calculate volume
28  *
29  */
32 
34 
35  VolumeCalculation(const std::string &field_name, Vec volume_vec)
37  field_name, UserDataOperator::OPROW),
38  volumeVec(volume_vec) {}
39 
40  MoFEMErrorCode doWork(int row_side, EntityType row_type,
41  EntitiesFieldData::EntData &row_data) {
43 
44  // do it only once, no need to repeat this for edges,faces or tets
45  if (row_type != MBVERTEX)
47 
48  int nb_gauss_pts = row_data.getN().size1();
49  for (int gg = 0; gg != nb_gauss_pts; ++gg) {
50 
51  double vol = getVolume() * getGaussPts()(3, gg);
52 
53  CHKERR VecSetValue(volumeVec, 0, vol, ADD_VALUES);
54  }
55 
57  }
58 };
59 
60 #endif //__VOLUME_CALCULATION_HPP__
ForcesAndSourcesCore::UserDataOperator UserDataOperator
EntitiesFieldData::EntData EntData
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:460
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
#define CHKERR
Inline error check.
Definition: definitions.h:548
VolumeElementForcesAndSourcesCoreSwitch< 0 > VolumeElementForcesAndSourcesCore
Volume finite element default.
const FTensor::Tensor2< T, Dim, Dim > Vec
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:67
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
MatrixDouble & getGaussPts()
matrix of integration (Gauss) points for Volume Element
Calculate volume.
MoFEMErrorCode doWork(int row_side, EntityType row_type, EntitiesFieldData::EntData &row_data)
VolumeCalculation(const std::string &field_name, Vec volume_vec)