v0.12.1
Functions | Variables
activate_deactivate_dofs.cpp File Reference
#include <MoFEM.hpp>

Go to the source code of this file.

Functions

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

Variables

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

Function Documentation

◆ main()

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

Definition at line 29 of file activate_deactivate_dofs.cpp.

29  {
30  MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
31 
32  try {
33 
34  moab::Core mb_instance;
35  moab::Interface &moab = mb_instance;
36  int rank;
37  MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
38 
39  PetscBool flg = PETSC_TRUE;
40  char mesh_file_name[255];
41 #if PETSC_VERSION_GE(3, 6, 4)
42  CHKERR PetscOptionsGetString(PETSC_NULL, "", "-my_file", mesh_file_name,
43  255, &flg);
44 #else
45  CHKERR PetscOptionsGetString(PETSC_NULL, PETSC_NULL, "-my_file",
46  mesh_file_name, 255, &flg);
47 #endif
48  if (flg != PETSC_TRUE) {
49  SETERRQ(PETSC_COMM_SELF, 1, "*** ERROR -my_file (MESH FILE NEEDED)");
50  }
51 
52  const char *option;
53  option = "";
54  CHKERR moab.load_file(mesh_file_name, 0, option);
55  CHKERRG(rval);
56 
57  // Create MoFEM (Joseph) database
58  MoFEM::Core core(moab);
59  MoFEM::Interface &m_field = core;
60 
61  // set entitities bit level
62  BitRefLevel bit_level0;
63  bit_level0.set(0);
64  EntityHandle meshset_level0;
65  CHKERR moab.create_meshset(MESHSET_SET, meshset_level0);
66  CHKERRG(rval);
67  CHKERR m_field.getInterface<BitRefManager>()->setBitRefLevelByDim(
68  0, 3, bit_level0);
69 
70  // Fields
71  CHKERR m_field.add_field("F1", L2, AINSWORTH_LEGENDRE_BASE, 1);
72  CHKERR m_field.add_field("F2", HDIV, AINSWORTH_LEGENDRE_BASE, 1);
73 
74  // meshset consisting all entities in mesh
75  EntityHandle root_set = moab.get_root_set();
76  // add entities to field
77  CHKERR m_field.add_ents_to_field_by_type(root_set, MBTET, "F1");
78  CHKERR m_field.add_ents_to_field_by_type(root_set, MBTET, "F2");
79 
80  // set app. order
81  // see Hierarchic Finite Element Bases on Unstructured Tetrahedral Meshes
82  // (Mark Ainsworth & Joe Coyle)
83  int order = 4;
84  CHKERR m_field.set_field_order(root_set, MBTET, "F1", order - 1, 2);
85  CHKERR m_field.set_field_order(root_set, MBTET, "F2", order, 2);
86  CHKERR m_field.set_field_order(root_set, MBTRI, "F2", order, 2);
87 
88  CHKERR m_field.build_fields();
89 
90  order = 2;
91  CHKERR m_field.set_field_order(root_set, MBTET, "F1", order - 1, 2);
92  CHKERR m_field.set_field_order(root_set, MBTET, "F2", order, 2);
93  CHKERR m_field.set_field_order(root_set, MBTRI, "F2", order, 2);
94 
95  CHKERR m_field.clear_inactive_dofs();
96  CHKERR m_field.build_fields();
97 
98  auto dofs_ptr = m_field.get_dofs();
99  const unsigned int expected_size = 300;
100  if (dofs_ptr->size() != expected_size) {
101  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
102  "Data inconsistency, should %d dofs but is %d", expected_size,
103  dofs_ptr->size());
104  }
105  }
106  CATCH_ERRORS;
107 
108  // finish work cleaning memory, getting statistics, ect.
110 
111  return 0;
112 }
static char help[]
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:385
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Definition: definitions.h:73
@ L2
field with C-1 continuity
Definition: definitions.h:101
@ HDIV
field with continuous normal traction
Definition: definitions.h:100
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:496
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:44
#define CHKERR
Inline error check.
Definition: definitions.h:548
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:85
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:51
CoreTmp< 0 > Core
Definition: Core.hpp:1095
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1949
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:92
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition: Core.cpp:85
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition: Core.cpp:125
Deprecated interface functions.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.

Variable Documentation

◆ help

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

Definition at line 27 of file activate_deactivate_dofs.cpp.