v0.13.2
Loading...
Searching...
No Matches
activate_deactivate_dofs.cpp
Go to the documentation of this file.
1/** \file build_problems.cpp
2
3 \brief Atom test for building composite problem
4
5 \bug Not verifying what if partitioned mesh is loaded.
6
7*/
8
9#include <MoFEM.hpp>
10
11using namespace MoFEM;
12
13static char help[] = "...\n\n";
14
15int main(int argc, char *argv[]) {
16 MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
17
18 try {
19
20 moab::Core mb_instance;
21 moab::Interface &moab = mb_instance;
22 int rank;
23 MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
24
25 PetscBool flg = PETSC_TRUE;
26 char mesh_file_name[255];
27#if PETSC_VERSION_GE(3, 6, 4)
28 CHKERR PetscOptionsGetString(PETSC_NULL, "", "-my_file", mesh_file_name,
29 255, &flg);
30#else
31 CHKERR PetscOptionsGetString(PETSC_NULL, PETSC_NULL, "-my_file",
32 mesh_file_name, 255, &flg);
33#endif
34 if (flg != PETSC_TRUE) {
35 SETERRQ(PETSC_COMM_SELF, 1, "*** ERROR -my_file (MESH FILE NEEDED)");
36 }
37
38 const char *option;
39 option = "";
40 CHKERR moab.load_file(mesh_file_name, 0, option);
42
43 // Create MoFEM (Joseph) database
44 MoFEM::Core core(moab);
45 MoFEM::Interface &m_field = core;
46
47 // set entitities bit level
48 BitRefLevel bit_level0;
49 bit_level0.set(0);
50 EntityHandle meshset_level0;
51 CHKERR moab.create_meshset(MESHSET_SET, meshset_level0);
53 CHKERR m_field.getInterface<BitRefManager>()->setBitRefLevelByDim(
54 0, 3, bit_level0);
55
56 // Fields
57 CHKERR m_field.add_field("F1", L2, AINSWORTH_LEGENDRE_BASE, 1);
59
60 // meshset consisting all entities in mesh
61 EntityHandle root_set = moab.get_root_set();
62 // add entities to field
63 CHKERR m_field.add_ents_to_field_by_type(root_set, MBTET, "F1");
64 CHKERR m_field.add_ents_to_field_by_type(root_set, MBTET, "F2");
65
66 // set app. order
67 // see Hierarchic Finite Element Bases on Unstructured Tetrahedral Meshes
68 // (Mark Ainsworth & Joe Coyle)
69 int order = 4;
70 CHKERR m_field.set_field_order(root_set, MBTET, "F1", order - 1, 2);
71 CHKERR m_field.set_field_order(root_set, MBTET, "F2", order, 2);
72 CHKERR m_field.set_field_order(root_set, MBTRI, "F2", order, 2);
73
74 CHKERR m_field.build_fields();
75
76 order = 2;
77 CHKERR m_field.set_field_order(root_set, MBTET, "F1", order - 1, 2);
78 CHKERR m_field.set_field_order(root_set, MBTET, "F2", order, 2);
79 CHKERR m_field.set_field_order(root_set, MBTRI, "F2", order, 2);
80
82 CHKERR m_field.build_fields();
83
84 auto dofs_ptr = m_field.get_dofs();
85 const unsigned int expected_size = 300;
86 if (dofs_ptr->size() != expected_size) {
87 SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
88 "Data inconsistency, should %d dofs but is %d", expected_size,
89 dofs_ptr->size());
90 }
91 }
93
94 // finish work cleaning memory, getting statistics, ect.
96
97 return 0;
98}
static char help[]
int main()
Definition: adol-c_atom.cpp:46
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:372
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Definition: definitions.h:60
@ L2
field with C-1 continuity
Definition: definitions.h:88
@ HDIV
field with continuous normal traction
Definition: definitions.h:87
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:483
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
#define CHKERR
Inline error check.
Definition: definitions.h:535
virtual const DofEntity_multiIndex * get_dofs() const =0
Get the dofs object.
virtual MoFEMErrorCode build_fields(int verb=DEFAULT_VERBOSITY)=0
virtual MoFEMErrorCode set_field_order(const EntityHandle meshset, const EntityType type, const std::string &name, const ApproximationOrder order, int verb=DEFAULT_VERBOSITY)=0
Set order approximation of the entities in the field.
virtual MoFEMErrorCode add_ents_to_field_by_type(const Range &ents, const EntityType type, const std::string &name, int verb=DEFAULT_VERBOSITY)=0
Add entities to field meshset.
virtual MoFEMErrorCode clear_inactive_dofs(int verb=DEFAULT_VERBOSITY)=0
char mesh_file_name[255]
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Exceptions.hpp:74
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:40
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
Managing BitRefLevels.
virtual MoFEMErrorCode add_field(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_EXCL, int verb=DEFAULT_VERBOSITY)=0
Add field.
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:112
Deprecated interface functions.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.