v0.10.0
Classes | Functions | Variables
loop_entities.cpp File Reference
#include <MoFEM.hpp>

Go to the source code of this file.

Classes

struct  TestEntityMethod
 

Functions

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

Variables

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

Function Documentation

◆ main()

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

Definition at line 59 of file loop_entities.cpp.

59  {
60  // initialize petsc
61  MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
62 
63  try {
64 
65  // read mesh and create moab and mofem data structures
66  moab::Core mb_instance;
67  moab::Interface &moab = mb_instance;
68 
69  MoFEM::Core core(moab, PETSC_COMM_WORLD);
70  MoFEM::Interface &m_field = core;
71 
72  // Register DM Manager
73  DMType dm_name = "DMMOFEM";
74  CHKERR DMRegister_MoFEM(dm_name);
75 
76  EntityHandle root_set = moab.get_root_set();
77 
78  // Simple interface
79  Simple *simple_interface;
80  CHKERR m_field.getInterface(simple_interface);
81  {
82  // get options from command line
83  CHKERR simple_interface->getOptions();
84  // load mesh file
85  CHKERR simple_interface->loadFile();
86  // add fields
87  CHKERR simple_interface->addDomainField("FIELD1", H1,
89  // set fields order
90  CHKERR simple_interface->setFieldOrder("FIELD1", 4);
91  // setup problem
92  CHKERR simple_interface->setUp();
93 
94  Range all_ents;
95  CHKERR m_field.get_moab().get_entities_by_handle(root_set, all_ents);
96  all_ents = subtract(all_ents, all_ents.subset_by_type(MBENTITYSET));
97 
98  auto testingEntitiesInDatabase = [&]() {
100  TestEntityMethod method(all_ents);
101  CHKERR m_field.loop_entities("FIELD1", method);
103  };
104 
105  CHKERR testingEntitiesInDatabase();
106 
107  auto testingEntitiesInDatabaseSubRange = [&]() {
109  Range edges = all_ents.subset_by_type(MBEDGE);
110  TestEntityMethod method(edges);
111  CHKERR m_field.loop_entities("FIELD1", method, &edges);
113  };
114 
115  CHKERR testingEntitiesInDatabaseSubRange();
116 
117  auto dm = simple_interface->getDM();
118 
119  auto testingEntitiesInDM = [&]() {
121  TestEntityMethod method(all_ents);
122  const MoFEM::Problem *prb_ptr;
123  CHKERR DMMoFEMGetProblemPtr(dm, &prb_ptr);
124  CHKERR m_field.loop_entities(prb_ptr, "FIELD1", ROW, method, 0,
125  m_field.get_comm_size());
127  };
128 
129  CHKERR testingEntitiesInDM();
130 
131  }
132  }
133  CATCH_ERRORS;
134 
135  // finish work cleaning memory, getting statistics, ect.
137 
138  return 0;
139 }

Variable Documentation

◆ help

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

Definition at line 25 of file loop_entities.cpp.

MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:26
EntityHandle
MoFEM::Simple::setFieldOrder
MoFEMErrorCode setFieldOrder(const std::string field_name, const int order, const Range *ents=NULL)
Set field order.
Definition: Simple.cpp:482
H1
@ H1
continuous field
Definition: definitions.h:177
help
static char help[]
Definition: loop_entities.cpp:25
MoFEM::Simple::loadFile
MoFEMErrorCode loadFile(const std::string options, const std::string mesh_file_name)
Load mesh file.
Definition: Simple.cpp:212
MoFEM::CoreInterface::get_comm_size
virtual int get_comm_size() const =0
MoFEM::Simple
Simple interface for fast problem set-up.
Definition: Simple.hpp:36
MoFEM::Interface
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1943
MoFEM::CoreInterface::get_moab
virtual moab::Interface & get_moab()=0
ROW
@ ROW
Definition: definitions.h:192
MoFEM::Simple::getDM
MoFEMErrorCode getDM(DM *dm)
Get DM.
Definition: Simple.cpp:706
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:604
TestEntityMethod
Definition: loop_entities.cpp:27
MoFEM::Simple::getOptions
MoFEMErrorCode getOptions()
get options
Definition: Simple.cpp:198
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:269
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:60
MoFEM::DMRegister_MoFEM
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
Definition: DMMMoFEM.cpp:48
MoFEM::Simple::setUp
MoFEMErrorCode setUp(const PetscBool is_partitioned=PETSC_TRUE)
Setup problem.
Definition: Simple.cpp:672
MoFEM::CoreTmp< 0 >
Core (interface) class.
Definition: Core.hpp:77
MoFEM::CoreTmp< 0 >::Finalize
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition: Core.cpp:100
CATCH_ERRORS
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:441
AINSWORTH_LEGENDRE_BASE
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Definition: definitions.h:152
MoFEM::DMMoFEMGetProblemPtr
PetscErrorCode DMMoFEMGetProblemPtr(DM dm, const MoFEM::Problem **problem_ptr)
Get pointer to problem data structure.
Definition: DMMMoFEM.cpp:348
MoFEM::Problem
keeps basic data about problem
Definition: ProblemsMultiIndices.hpp:79
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
MoFEM::Core
CoreTmp< 0 > Core
Definition: Core.hpp:1129
MoFEM::UnknownInterface::getInterface
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
Definition: UnknownInterface.hpp:130
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415
MoFEM::CoreInterface::loop_entities
virtual MoFEMErrorCode loop_entities(const std::string field_name, EntityMethod &method, Range const *const ents=nullptr, int verb=DEFAULT_VERBOSITY)=0
Loop over field entities.