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 
14 #include <MoFEM.hpp>
15 using namespace MoFEM;
16 
18 
19 /** \brief Save field DOFS on vertices/tags
20  */
22 
24  std::string tagName;
25  SaveVertexDofOnTag(MoFEM::Interface &m_field, std::string tag_name)
26  : mField(m_field), tagName(tag_name) {}
27 
28  Tag tH;
29 
32  if (!fieldPtr) {
33  SETERRQ(mField.get_comm(), MOFEM_DATA_INCONSISTENCY,
34  "Null pointer, probably field not found");
35  }
36  if (fieldPtr->getSpace() != H1) {
37  SETERRQ(mField.get_comm(), MOFEM_DATA_INCONSISTENCY,
38  "Field must be in H1 space");
39  }
40  std::vector<double> def_vals(fieldPtr->getNbOfCoeffs(), 0);
41  rval = mField.get_moab().tag_get_handle(tagName.c_str(), tH);
42  if (rval != MB_SUCCESS) {
43  CHKERR mField.get_moab().tag_get_handle(
44  tagName.c_str(), fieldPtr->getNbOfCoeffs(), MB_TYPE_DOUBLE, tH,
45  MB_TAG_CREAT | MB_TAG_SPARSE, &def_vals[0]);
46  }
47 
49  }
50 
54  }
55 
58  if (dofPtr->getEntType() != MBVERTEX)
60  EntityHandle ent = dofPtr->getEnt();
61  int rank = dofPtr->getNbOfCoeffs();
62  double tag_val[rank];
63 
64  CHKERR mField.get_moab().tag_get_data(tH, &ent, 1, tag_val);
65  tag_val[dofPtr->getDofCoeffIdx()] = dofPtr->getFieldData();
66  CHKERR mField.get_moab().tag_set_data(tH, &ent, 1, &tag_val);
68  }
69 };
70 
71 } // BasicFiniteElements
72 
73 #endif // __SAVEVERTEXDOFONTAG_HPP__
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:460
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:24
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
MoFEM.hpp
MoFEM::DofMethod
Data structure to exchange data between mofem and User Loop Methods on entities.
Definition: LoopMethods.hpp:493
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:28
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
BasicFiniteElements::SaveVertexDofOnTag::operator()
MoFEMErrorCode operator()()
function is run for every finite element
Definition: SaveVertexDofOnTag.hpp:56
MoFEM::CoreInterface::get_moab
virtual moab::Interface & get_moab()=0
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
BasicFiniteElements::SaveVertexDofOnTag::postProcess
MoFEMErrorCode postProcess()
function is run at the end of loop
Definition: SaveVertexDofOnTag.hpp:51
BasicFiniteElements::SaveVertexDofOnTag::SaveVertexDofOnTag
SaveVertexDofOnTag(MoFEM::Interface &m_field, std::string tag_name)
Definition: SaveVertexDofOnTag.hpp:25
BasicFiniteElements::SaveVertexDofOnTag::mField
MoFEM::Interface & mField
Definition: SaveVertexDofOnTag.hpp:23
BasicFiniteElements
Definition: SaveVertexDofOnTag.hpp:17
BasicFiniteElements::SaveVertexDofOnTag
Save field DOFS on vertices/tags.
Definition: SaveVertexDofOnTag.hpp:21
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:30
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359