v0.15.0
Loading...
Searching...
No Matches
simple_l2_only.cpp File Reference
#include <MoFEM.hpp>

Go to the source code of this file.

Classes

struct  ElementsAndOps< DIM >
 
struct  ElementsAndOps< 2 >
 

Typedefs

using DomainEle = ElementsAndOps<SPACE_DIM>::DomainEle
 
using BoundaryEle = ElementsAndOps<SPACE_DIM>::BoundaryEle
 

Functions

int main (int argc, char *argv[])
 

Variables

static char help [] = "...\n\n"
 
constexpr int SPACE_DIM = 2
 

Typedef Documentation

◆ BoundaryEle

◆ DomainEle

Definition at line 27 of file simple_l2_only.cpp.

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 33 of file simple_l2_only.cpp.

33 {
34
35 // initialize petsc
36 MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
37
38 try {
39
40 // Create MoAB database
41 moab::Core moab_core;
42 moab::Interface &moab = moab_core;
43
44 // Create MoFEM database and link it to MoAB
45 MoFEM::Core mofem_core(moab);
46 MoFEM::Interface &m_field = mofem_core;
47
48 // Register DM Manager
49 DMType dm_name = "DMMOFEM";
50 CHKERR DMRegister_MoFEM(dm_name);
51
52 // Simple interface
53 Simple *simple_interface;
54 CHKERR m_field.getInterface(simple_interface);
55 {
56
57 // get options from command line
58 CHKERR simple_interface->getOptions();
59 // load mesh file
60 CHKERR simple_interface->loadFile();
61
62 CHKERR simple_interface->addDomainField("FIELD", L2,
64
65 CHKERR simple_interface->addMeshsetField("GLOBAL", NOFIELD, NOBASE, 3);
66 CHKERR simple_interface->addMeshsetField("FIELD", L2,
68
69 // Create vertices for meshset field. You have to do that, otherwise
70 // meshset field will have no DOFs.
71 std::array<double, 6> coords = {0, 0, 0, 0, 0, 0};
72 CHKERR m_field.create_vertices_and_add_to_field("GLOBAL", coords.data(),
73 2);
75 ->makeFieldEntitiesMultishared("GLOBAL", 0, NOISY);
77 ->setFieldEntitiesBitRefLevel("GLOBAL", BitRefLevel().set());
78
79 // I add vols to meshset, that is to integrate on side of mFE. That make
80 // "FIELD" adjacent to "GLOBAL", and all other "FIELD" adjacent to
81 // "FIELD". That would create dense matrix. In principle you will add only
82 // small subset of "FIELD" entities to "GLOBAL" meshset.
83 Range vols;
84 CHKERR m_field.get_moab().get_entities_by_dimension(0, SPACE_DIM, vols);
85 simple_interface->getMeshsetFiniteElementEntities().push_back(
86 vols); // create one meshset element
87
88 simple_interface->getAddBoundaryFE() = true;
89 simple_interface->getAddSkeletonFE() = true;
90
91 // set fields order
92 CHKERR simple_interface->setFieldOrder("FIELD", 1);
93 // setup problem
94 CHKERR simple_interface->setUp();
95
96 int count_skeleton_fe;
97 int count_side_fe;
98 int count_meshset_fe;
99 int count_meshset_side_fe;
100
101 PipelineManager *pipeline_mng = m_field.getInterface<PipelineManager>();
102
103 // Create OP for side FE
104 auto op_side_fe = new DomainEleOp(NOSPACE, DomainEleOp::OPSPACE);
105 op_side_fe->doWorkRhsHook = [&](DataOperator *op_ptr, int side,
106 EntityType type,
108 auto domain_op = static_cast<DomainEleOp *>(op_ptr);
110
111 MOFEM_LOG("SELF", Sev::verbose)
112 << "Side element name [ " << count_side_fe << " ] "
113 << domain_op->getFEName();
114
115 ++count_side_fe;
116
118 };
119
120 // Create side FE
121 auto side_fe = boost::make_shared<DomainEle>(m_field);
122 side_fe->getOpPtrVector().push_back(op_side_fe);
123
124 // Create boundary FE OP
125
126 auto do_work_rhs = [&](DataOperator *op_ptr, int side, EntityType type,
128 auto bdy_op = static_cast<BoundaryEleOp *>(op_ptr);
130
131 MOFEM_LOG("SELF", Sev::verbose)
132 << "Element name [ " << count_skeleton_fe << " ] "
133 << bdy_op->getFEName();
134
135 CHKERR bdy_op->loopSide(simple_interface->getDomainFEName(),
136 side_fe.get(), SPACE_DIM);
137
138 ++count_skeleton_fe;
139
141 };
142
143 auto op_bdy_fe = new BoundaryEleOp(NOSPACE, DomainEleOp::OPSPACE);
144 op_bdy_fe->doWorkRhsHook = do_work_rhs;
145
146 auto op_skeleton_fe = new BoundaryEleOp(NOSPACE, DomainEleOp::OPSPACE);
147 op_skeleton_fe->doWorkRhsHook = do_work_rhs;
148
149 // create meshset fe
150 auto op_meshset_side_fe = new DomainEleOp(NOSPACE, DomainEleOp::OPSPACE);
151 op_meshset_side_fe->doWorkRhsHook =
152 [&](DataOperator *op_ptr, int side, EntityType type,
154 auto domain_op = static_cast<DomainEleOp *>(op_ptr);
156
157 MOFEM_LOG("SELF", Sev::verbose)
158 << "Side element name [ " << count_side_fe << " ] "
159 << domain_op->getFEName();
160
161 ++count_meshset_side_fe;
162
164 };
165
166 auto meshset_side_fe = boost::make_shared<DomainEle>(m_field);
167 meshset_side_fe->getOpPtrVector().push_back(op_meshset_side_fe);
168
169 auto op_meshset_fe = new ForcesAndSourcesCore::UserDataOperator(
170 "GLOBAL", ForcesAndSourcesCore::UserDataOperator::OPROW);
171 op_meshset_fe->doWorkRhsHook = [&](DataOperator *op_ptr, int side,
172 EntityType type,
175 MOFEM_LOG("SELF", Sev::inform)
176 << "Meshset element name field data " << data.getFieldData();
177 MOFEM_LOG("SELF", Sev::inform)
178 << "Meshset element name indices " << data.getIndices();
179
180
181 CHKERR op_meshset_fe->loopSide(simple_interface->getDomainFEName(),
182 meshset_side_fe.get(), SPACE_DIM, 0,
183 boost::make_shared<Range>(vols));
184
185 ++count_meshset_fe;
187 };
188
189 // Count boundary
190 count_skeleton_fe = 0;
191 count_side_fe = 0;
192 count_meshset_fe = 0;
193 count_meshset_side_fe = 0;
194
195 pipeline_mng->getOpBoundaryRhsPipeline().push_back(op_bdy_fe);
196 pipeline_mng->getOpSkeletonRhsPipeline().push_back(op_skeleton_fe);
197 pipeline_mng->getOpMeshsetRhsPipeline().push_back(op_meshset_fe);
198 pipeline_mng->loopFiniteElements();
199
200 MOFEM_LOG("SELF", Sev::inform)
201 << "Number of elements " << count_skeleton_fe;
202 MOFEM_LOG("SELF", Sev::inform)
203 << "Number of side elements " << count_side_fe;
204 MOFEM_LOG("SELF", Sev::inform)
205 << "Number of meshset elements " << count_meshset_fe;
206 MOFEM_LOG("SELF", Sev::inform)
207 << "Number of meshset side elements " << count_meshset_side_fe;
208
209 if (count_skeleton_fe != 16)
210 SETERRQ(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
211 "Wrong numbers of FEs");
212 if (count_side_fe != 24)
213 SETERRQ(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
214 "Wrong numbers of side FEs");
215 if (count_meshset_fe != 2)
216 SETERRQ(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
217 "Wrong numbers of side FEs");
218 if (count_meshset_side_fe != 16)
219 SETERRQ(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
220 "Wrong numbers of side FEs");
221 }
222 }
224
225 // finish work cleaning memory, getting statistics, etc.
227
228 return 0;
229}
DomainEle::UserDataOperator DomainEleOp
Finire element operator type.
BoundaryEle::UserDataOperator BoundaryEleOp
@ NOISY
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base nme:nme847.
Definition definitions.h:60
@ NOBASE
Definition definitions.h:59
@ L2
field with C-1 continuity
Definition definitions.h:88
@ NOFIELD
scalar or vector of scalars describe (no true field)
Definition definitions.h:84
@ NOSPACE
Definition definitions.h:83
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_ATOM_TEST_INVALID
Definition definitions.h:40
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
Definition DMMoFEM.cpp:43
MoFEMErrorCode loopFiniteElements(SmartPetscObj< DM > dm=nullptr)
Iterate finite elements.
boost::ptr_deque< UserDataOperator > & getOpBoundaryRhsPipeline()
Get the Op Boundary Rhs Pipeline object.
boost::ptr_deque< UserDataOperator > & getOpSkeletonRhsPipeline()
Get the Op Skeleton Rhs Pipeline object.
#define MOFEM_LOG(channel, severity)
Log.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition Types.hpp:40
static char help[]
constexpr int SPACE_DIM
Managing BitRefLevels.
Managing BitRefLevels.
virtual moab::Interface & get_moab()=0
virtual MoFEMErrorCode create_vertices_and_add_to_field(const std::string name, const double coords[], int size, int verb=DEFAULT_VERBOSITY)=0
Create a vertices and add to field object.
Core (interface) class.
Definition Core.hpp:82
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition Core.cpp:72
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition Core.cpp:118
base operator to do operations at Gauss Pt. level
Deprecated interface functions.
Data on single entity (This is passed as argument to DataOperator::doWork)
PipelineManager interface.
boost::ptr_deque< UserDataOperator > & getOpMeshsetRhsPipeline()
Get the Op Meshset Rhs Pipeline object.
Simple interface for fast problem set-up.
Definition Simple.hpp:27
MoFEMErrorCode addDomainField(const std::string name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_ZERO, int verb=-1)
Add field on domain.
Definition Simple.cpp:261
bool & getAddBoundaryFE()
Get the addSkeletonFE.
Definition Simple.hpp:504
MoFEMErrorCode loadFile(const std::string options, const std::string mesh_file_name, LoadFileFunc loadFunc=defaultLoadFileFunc)
Load mesh file.
Definition Simple.cpp:191
MoFEMErrorCode addMeshsetField(const std::string name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_ZERO, int verb=-1)
Add meshset field.
Definition Simple.cpp:411
MoFEMErrorCode getOptions()
get options
Definition Simple.cpp:180
MoFEMErrorCode setFieldOrder(const std::string field_name, const int order, const Range *ents=NULL)
Set field order.
Definition Simple.cpp:575
auto & getMeshsetFiniteElementEntities()
Range of entities added to meshset finite element.
Definition Simple.hpp:449
bool & getAddSkeletonFE()
Get the addSkeletonFE.
Definition Simple.hpp:493
MoFEMErrorCode setUp(const PetscBool is_partitioned=PETSC_TRUE)
Setup problem.
Definition Simple.cpp:736
const std::string getDomainFEName() const
Get the Domain FE Name.
Definition Simple.hpp:389
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.

Variable Documentation

◆ help

char help[] = "...\n\n"
static

Definition at line 14 of file simple_l2_only.cpp.

◆ SPACE_DIM

int SPACE_DIM = 2
constexpr

Definition at line 16 of file simple_l2_only.cpp.