v0.15.0
Loading...
Searching...
No Matches
SaveVertexDofOnTag.hpp
Go to the documentation of this file.
1/** \file SaveVertexDofOnTag.hpp
2
3Save field DOFS on vertices/tags
4This is another example how to use MoFEM::DofMethod when some operator for each
5node need to be applied.
6
7*/
8
9
10
11#ifndef __SAVEVERTEXDOFONTAG_HPP__
12#define __SAVEVERTEXDOFONTAG_HPP__
13
14namespace BasicFiniteElements {
15
16/** \brief Save field DOFS on vertices/tags
17 */
18struct SaveVertexDofOnTag : public MoFEM::DofMethod {
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
27 MoFEMErrorCode preProcess() {
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
48 MoFEMErrorCode postProcess() {
51 }
52
53 MoFEMErrorCode operator()() {
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__
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
@ H1
continuous field
Definition definitions.h:85
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
MoFEMErrorCode preProcess()
Pre-processing function executed at loop initialization.
MoFEMErrorCode postProcess()
Post-processing function executed at loop completion.
MoFEMErrorCode operator()()
Main operator function executed for each loop iteration.
SaveVertexDofOnTag(MoFEM::Interface &m_field, std::string tag_name)
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
Deprecated interface functions.
Data structure for user loop methods on degrees of freedom (DOFs)
boost::shared_ptr< DofEntity > dofPtr
Shared pointer to DOF entity data.
boost::shared_ptr< Field > fieldPtr
Shared pointer to field information.