v0.14.0
SaveVertexDofOnTag.hpp
Go to the documentation of this file.
1 /** \file SaveVertexDofOnTag.hpp
2 
3 Save field DOFS on vertices/tags
4 This is another example how to use MoFEM::DofMethod when some operator for each
5 node need to be applied.
6 
7 */
8 
9 
10 
11 #ifndef __SAVEVERTEXDOFONTAG_HPP__
12 #define __SAVEVERTEXDOFONTAG_HPP__
13 
15 
16 /** \brief Save field DOFS on vertices/tags
17  */
19 
21  std::string tagName;
22  SaveVertexDofOnTag(MoFEM::Interface &m_field, std::string tag_name)
23  : mField(m_field), tagName(tag_name) {}
24 
25  Tag tH;
26 
29  if (!fieldPtr) {
31  "Null pointer, probably field not found");
32  }
33  if (fieldPtr->getSpace() != H1) {
35  "Field must be in H1 space");
36  }
37  std::vector<double> def_vals(fieldPtr->getNbOfCoeffs(), 0);
38  rval = mField.get_moab().tag_get_handle(tagName.c_str(), tH);
39  if (rval != MB_SUCCESS) {
40  CHKERR mField.get_moab().tag_get_handle(
41  tagName.c_str(), fieldPtr->getNbOfCoeffs(), MB_TYPE_DOUBLE, tH,
42  MB_TAG_CREAT | MB_TAG_SPARSE, &def_vals[0]);
43  }
44 
46  }
47 
51  }
52 
55  if (dofPtr->getEntType() != MBVERTEX)
57  EntityHandle ent = dofPtr->getEnt();
58  int rank = dofPtr->getNbOfCoeffs();
59  double tag_val[rank];
60 
61  CHKERR mField.get_moab().tag_get_data(tH, &ent, 1, tag_val);
62  tag_val[dofPtr->getDofCoeffIdx()] = dofPtr->getFieldData();
63  CHKERR mField.get_moab().tag_set_data(tH, &ent, 1, &tag_val);
65  }
66 };
67 
68 } // BasicFiniteElements
69 
70 #endif // __SAVEVERTEXDOFONTAG_HPP__
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
H1
@ H1
continuous field
Definition: definitions.h:85
EntityHandle
MoFEM::CoreInterface::get_comm
virtual MPI_Comm & get_comm() const =0
BasicFiniteElements::SaveVertexDofOnTag::tagName
std::string tagName
Definition: SaveVertexDofOnTag.hpp:21
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
MoFEM::DofMethod
Data structure to exchange data between mofem and User Loop Methods on entities.
Definition: LoopMethods.hpp:493
MoFEM::DofMethod::dofPtr
boost::shared_ptr< DofEntity > dofPtr
Definition: LoopMethods.hpp:505
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
MoFEM::Exceptions::rval
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Exceptions.hpp:74
BasicFiniteElements::SaveVertexDofOnTag::tH
Tag tH
Definition: SaveVertexDofOnTag.hpp:25
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:535
BasicFiniteElements::SaveVertexDofOnTag::operator()
MoFEMErrorCode operator()()
function is run for every finite element
Definition: SaveVertexDofOnTag.hpp:53
MoFEM::CoreInterface::get_moab
virtual moab::Interface & get_moab()=0
BasicFiniteElements::SaveVertexDofOnTag::postProcess
MoFEMErrorCode postProcess()
function is run at the end of loop
Definition: SaveVertexDofOnTag.hpp:48
BasicFiniteElements::SaveVertexDofOnTag::SaveVertexDofOnTag
SaveVertexDofOnTag(MoFEM::Interface &m_field, std::string tag_name)
Definition: SaveVertexDofOnTag.hpp:22
BasicFiniteElements
Definition: SaveVertexDofOnTag.hpp:14
BasicFiniteElements::SaveVertexDofOnTag
Save field DOFS on vertices/tags.
Definition: SaveVertexDofOnTag.hpp:18
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
BasicFiniteElements::SaveVertexDofOnTag::preProcess
MoFEMErrorCode preProcess()
function is run at the beginning of loop
Definition: SaveVertexDofOnTag.hpp:27
MoFEM::DofMethod::fieldPtr
boost::shared_ptr< Field > fieldPtr
Definition: LoopMethods.hpp:504
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
BasicFiniteElements::SaveVertexDofOnTag::mField
MoFEM::Interface & mField
Definition: SaveVertexDofOnTag.hpp:20