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
14#include <MoFEM.hpp>
15using 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
29
32 if (!fieldPtr) {
34 "Null pointer, probably field not found");
35 }
36 if (fieldPtr->getSpace() != H1) {
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
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__
#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.
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
Save field DOFS on vertices/tags.
MoFEMErrorCode preProcess()
function is run at the beginning of loop
MoFEMErrorCode postProcess()
function is run at the end of loop
MoFEMErrorCode operator()()
function is run for every finite element
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 to exchange data between mofem and User Loop Methods on entities.
boost::shared_ptr< DofEntity > dofPtr
boost::shared_ptr< Field > fieldPtr