v0.14.0
Classes | Typedefs | Functions | Variables
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 DomainEleOp = DomainEle::UserDataOperator
 
using BoundaryEle = ElementsAndOps< SPACE_DIM >::BoundaryEle
 
using BoundaryEleOp = BoundaryEle::UserDataOperator
 
using EntData = EntitiesFieldData::EntData
 

Functions

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

Variables

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

Typedef Documentation

◆ BoundaryEle

Definition at line 29 of file simple_l2_only.cpp.

◆ BoundaryEleOp

Examples
simple_l2_only.cpp.

Definition at line 30 of file simple_l2_only.cpp.

◆ DomainEle

Definition at line 27 of file simple_l2_only.cpp.

◆ DomainEleOp

Examples
simple_l2_only.cpp.

Definition at line 28 of file simple_l2_only.cpp.

◆ EntData

Examples
simple_l2_only.cpp.

Definition at line 31 of file simple_l2_only.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)
Examples
simple_l2_only.cpp.

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, 1);
66  CHKERR simple_interface->addMeshsetField("FIELD", L2,
68 
69  // I add vols to meshset, that is to integrate on side of mFE. That make
70  // "FIELD" adjacent to "GLOBAL", and all other "FIELD" adjacent to
71  // "FIELD". That would create dense matrix. In principle you will add only
72  // small subset of "FIELD" entities to "GLOBAL" meshset.
73  Range vols;
74  CHKERR m_field.get_moab().get_entities_by_dimension(0, SPACE_DIM, vols);
75  simple_interface->getMeshsetFiniteElementEntities().push_back(
76  vols); // create one meshset element
77 
78  simple_interface->getAddBoundaryFE() = true;
79  simple_interface->getAddSkeletonFE() = true;
80 
81  // set fields order
82  CHKERR simple_interface->setFieldOrder("FIELD", 1);
83  // setup problem
84  CHKERR simple_interface->setUp();
85 
86  int count_skeleton_fe;
87  int count_side_fe;
88  int count_meshset_fe;
89  int count_meshset_side_fe;
90 
91  PipelineManager *pipeline_mng = m_field.getInterface<PipelineManager>();
92 
93  // Create OP for side FE
94  auto op_side_fe = new DomainEleOp(NOSPACE, DomainEleOp::OPSPACE);
95  op_side_fe->doWorkRhsHook = [&](DataOperator *op_ptr, int side,
96  EntityType type,
98  auto domain_op = static_cast<DomainEleOp *>(op_ptr);
100 
101  MOFEM_LOG("SELF", Sev::verbose)
102  << "Side element name [ " << count_side_fe << " ] "
103  << domain_op->getFEName();
104 
105  ++count_side_fe;
106 
108  };
109 
110  // Create side FE
111  auto side_fe = boost::make_shared<DomainEle>(m_field);
112  side_fe->getOpPtrVector().push_back(op_side_fe);
113 
114  // Create boundary FE OP
115 
116  auto do_work_rhs = [&](DataOperator *op_ptr, int side, EntityType type,
118  auto bdy_op = static_cast<BoundaryEleOp *>(op_ptr);
120 
121  MOFEM_LOG("SELF", Sev::verbose)
122  << "Element name [ " << count_skeleton_fe << " ] "
123  << bdy_op->getFEName();
124 
125  CHKERR bdy_op->loopSide(simple_interface->getDomainFEName(),
126  side_fe.get(), SPACE_DIM);
127 
128  ++count_skeleton_fe;
129 
131  };
132 
133  auto op_bdy_fe = new BoundaryEleOp(NOSPACE, DomainEleOp::OPSPACE);
134  op_bdy_fe->doWorkRhsHook = do_work_rhs;
135 
136  auto op_skeleton_fe = new BoundaryEleOp(NOSPACE, DomainEleOp::OPSPACE);
137  op_skeleton_fe->doWorkRhsHook = do_work_rhs;
138 
139  // create meshset fe
140  auto op_meshset_side_fe = new DomainEleOp(NOSPACE, DomainEleOp::OPSPACE);
141  op_meshset_side_fe->doWorkRhsHook =
142  [&](DataOperator *op_ptr, int side, EntityType type,
144  auto domain_op = static_cast<DomainEleOp *>(op_ptr);
146 
147  MOFEM_LOG("SELF", Sev::verbose)
148  << "Side element name [ " << count_side_fe << " ] "
149  << domain_op->getFEName();
150 
151  ++count_meshset_side_fe;
152 
154  };
155 
156  auto meshset_side_fe = boost::make_shared<DomainEle>(m_field);
157  meshset_side_fe->getOpPtrVector().push_back(op_meshset_side_fe);
158 
159  auto op_meshset_fe = new ForcesAndSourcesCore::UserDataOperator(
160  "GLOBAL", ForcesAndSourcesCore::UserDataOperator::OPROW);
161  op_meshset_fe->doWorkRhsHook = [&](DataOperator *op_ptr, int side,
162  EntityType type,
165  MOFEM_LOG("SELF", Sev::inform)
166  << "Meshset element name " << data.getIndices();
167 
168  CHKERR op_meshset_fe->loopSide(simple_interface->getDomainFEName(),
169  meshset_side_fe.get(), SPACE_DIM, 0,
170  boost::make_shared<Range>(vols));
171 
172  ++count_meshset_fe;
174  };
175 
176  // Count boundary
177  count_skeleton_fe = 0;
178  count_side_fe = 0;
179  count_meshset_fe = 0;
180  count_meshset_side_fe = 0;
181 
182  pipeline_mng->getOpBoundaryRhsPipeline().push_back(op_bdy_fe);
183  pipeline_mng->getOpSkeletonRhsPipeline().push_back(op_skeleton_fe);
184  pipeline_mng->getOpMeshsetRhsPipeline().push_back(op_meshset_fe);
185  pipeline_mng->loopFiniteElements();
186 
187  MOFEM_LOG("SELF", Sev::inform)
188  << "Number of elements " << count_skeleton_fe;
189  MOFEM_LOG("SELF", Sev::inform)
190  << "Number of side elements " << count_side_fe;
191  MOFEM_LOG("SELF", Sev::inform)
192  << "Number of meshset elements " << count_meshset_fe;
193  MOFEM_LOG("SELF", Sev::inform)
194  << "Number of meshset side elements " << count_meshset_side_fe;
195 
196  if (count_skeleton_fe != 16)
197  SETERRQ(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
198  "Wrong numbers of FEs");
199  if (count_side_fe != 24)
200  SETERRQ(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
201  "Wrong numbers of side FEs");
202  if (count_meshset_fe != 1)
203  SETERRQ(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
204  "Wrong numbers of side FEs");
205  if (count_meshset_side_fe != 8)
206  SETERRQ(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
207  "Wrong numbers of side FEs");
208  }
209  }
210  CATCH_ERRORS;
211 
212  // finish work cleaning memory, getting statistics, etc.
214 
215  return 0;
216 }

Variable Documentation

◆ help

char help[] = "...\n\n"
static
Examples
simple_l2_only.cpp.

Definition at line 14 of file simple_l2_only.cpp.

◆ SPACE_DIM

constexpr int SPACE_DIM = 2
constexpr
Examples
simple_l2_only.cpp.

Definition at line 16 of file simple_l2_only.cpp.

NOSPACE
@ NOSPACE
Definition: definitions.h:83
MoFEM::UnknownInterface::getInterface
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Definition: UnknownInterface.hpp:93
MoFEM::EntitiesFieldData::EntData
Data on single entity (This is passed as argument to DataOperator::doWork)
Definition: EntitiesFieldData.hpp:128
MoFEM::CoreTmp< 0 >
Core (interface) class.
Definition: Core.hpp:82
MoFEM::DataOperator
base operator to do operations at Gauss Pt. level
Definition: DataOperators.hpp:24
MoFEM::PipelineManager::getOpSkeletonRhsPipeline
boost::ptr_deque< UserDataOperator > & getOpSkeletonRhsPipeline()
Get the Op Skeleton Rhs Pipeline object.
Definition: PipelineManager.hpp:944
NOBASE
@ NOBASE
Definition: definitions.h:59
BoundaryEleOp
BoundaryEle::UserDataOperator BoundaryEleOp
Definition: simple_l2_only.cpp:30
L2
@ L2
field with C-1 continuity
Definition: definitions.h:88
MoFEM::PipelineManager::loopFiniteElements
MoFEMErrorCode loopFiniteElements(SmartPetscObj< DM > dm=nullptr)
Iterate finite elements.
Definition: PipelineManager.cpp:63
help
static char help[]
Definition: simple_l2_only.cpp:14
MoFEM::Simple::loadFile
MoFEMErrorCode loadFile(const std::string options, const std::string mesh_file_name, LoadFileFunc loadFunc=defaultLoadFileFunc)
Load mesh file.
Definition: Simple.cpp:194
MoFEM::PipelineManager
PipelineManager interface.
Definition: PipelineManager.hpp:24
MoFEM::CoreTmp< 0 >::Finalize
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition: Core.cpp:112
MoFEM::Simple
Simple interface for fast problem set-up.
Definition: Simple.hpp:27
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
DomainEleOp
DomainEle::UserDataOperator DomainEleOp
Definition: simple_l2_only.cpp:28
MoFEM::Interface
DeprecatedCoreInterface Interface
Definition: Interface.hpp:2010
MoFEM::Simple::addMeshsetField
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:414
MoFEM::Simple::getOptions
MoFEMErrorCode getOptions()
get options
Definition: Simple.cpp:180
MoFEM::Simple::getAddSkeletonFE
bool & getAddSkeletonFE()
Get the addSkeletonFE.
Definition: Simple.hpp:487
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
MoFEM::CoreInterface::get_moab
virtual moab::Interface & get_moab()=0
BoundaryEleOp
convert.type
type
Definition: convert.py:64
MoFEM::Simple::getMeshsetFiniteElementEntities
auto & getMeshsetFiniteElementEntities()
Get the Domain Fields.
Definition: Simple.hpp:443
MoFEM::Simple::getAddBoundaryFE
bool & getAddBoundaryFE()
Get the addSkeletonFE.
Definition: Simple.hpp:498
MoFEM::DMRegister_MoFEM
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
Definition: DMMoFEM.cpp:43
MoFEM::Simple::getDomainFEName
const std::string getDomainFEName() const
Get the Domain FE Name.
Definition: Simple.hpp:387
MoFEM::Simple::setFieldOrder
MoFEMErrorCode setFieldOrder(const std::string field_name, const int order, const Range *ents=NULL)
Set field order.
Definition: Simple.cpp:599
MoFEM::PipelineManager::getOpMeshsetRhsPipeline
boost::ptr_deque< UserDataOperator > & getOpMeshsetRhsPipeline()
Get the Op Meshset Rhs Pipeline object.
Definition: PipelineManager.cpp:33
Range
DomainEleOp
MoFEM::CoreTmp< 0 >::Initialize
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
MOFEM_LOG
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308
CATCH_ERRORS
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:385
SPACE_DIM
constexpr int SPACE_DIM
Definition: simple_l2_only.cpp:16
MoFEM::Core
CoreTmp< 0 > Core
Definition: Core.hpp:1148
UserDataOperator
ForcesAndSourcesCore::UserDataOperator UserDataOperator
Definition: HookeElement.hpp:75
AINSWORTH_LEGENDRE_BASE
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Definition: definitions.h:60
MoFEM::PipelineManager::getOpBoundaryRhsPipeline
boost::ptr_deque< UserDataOperator > & getOpBoundaryRhsPipeline()
Get the Op Boundary Rhs Pipeline object.
Definition: PipelineManager.hpp:896
MOFEM_ATOM_TEST_INVALID
@ MOFEM_ATOM_TEST_INVALID
Definition: definitions.h:40
MoFEM::Simple::setUp
MoFEMErrorCode setUp(const PetscBool is_partitioned=PETSC_TRUE)
Setup problem.
Definition: Simple.cpp:765
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
MoFEM::Simple::addDomainField
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:264
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
NOFIELD
@ NOFIELD
scalar or vector of scalars describe (no true field)
Definition: definitions.h:84