v0.10.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 
27 
28  Vec volumeVec;
29 
30  VolumeCalculation(const std::string &field_name,Vec volume_vec):
32  volumeVec(volume_vec) {
33  }
34 
35 
36 
38  int row_side,EntityType row_type,DataForcesAndSourcesCore::EntData &row_data
39  ) {
41 
42  //do it only once, no need to repeat this for edges,faces or tets
43  if(row_type != MBVERTEX) MoFEMFunctionReturnHot(0);
44 
45  int nb_gauss_pts = row_data.getN().size1();
46  for(int gg = 0;gg<nb_gauss_pts;gg++) {
47 
48  double vol = getVolume()*getGaussPts()(3,gg);
49  if(getHoGaussPtsDetJac().size()>0) {
50  vol *= getHoGaussPtsDetJac()[gg]; ///< higher order geometry
51  }
52 
53  ierr = VecSetValue(volumeVec,0,vol,ADD_VALUES); CHKERRG(ierr);
54 
55  }
56 
58  }
59 
60 };
61 
62 #endif //__VOLUME_CALCULATION_HPP__
MatrixDouble & getGaussPts()
matrix of integration (Gauss) points for Volume Element
MoFEMErrorCode doWork(int row_side, EntityType row_type, DataForcesAndSourcesCore::EntData &row_data)
VolumeElementForcesAndSourcesCoreSwitch< 0 > VolumeElementForcesAndSourcesCore
Volume finite element default.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:509
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:552
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:516
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
VolumeCalculation(const std::string &field_name, Vec volume_vec)
DataForcesAndSourcesCore::EntData EntData
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:67
Data operator to do calculations at integration points.Is inherited and implemented by user to do cal...