v0.14.0
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 15 of file activate_deactivate_dofs.cpp.

15  {
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);
41  CHKERRG(rval);
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);
52  CHKERRG(rval);
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);
58  CHKERR m_field.add_field("F2", HDIV, 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 
81  CHKERR m_field.clear_inactive_dofs();
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 }

Variable Documentation

◆ help

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

Definition at line 13 of file activate_deactivate_dofs.cpp.

MoFEM::UnknownInterface::getInterface
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Definition: UnknownInterface.hpp:93
MoFEM::CoreTmp< 0 >
Core (interface) class.
Definition: Core.hpp:82
EntityHandle
L2
@ L2
field with C-1 continuity
Definition: definitions.h:88
help
static char help[]
Definition: activate_deactivate_dofs.cpp:13
MoFEM::CoreTmp< 0 >::Finalize
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition: Core.cpp:112
MoFEM::CoreInterface::add_ents_to_field_by_type
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.
order
constexpr int order
Definition: dg_projection.cpp:18
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
MoFEM::CoreInterface::get_dofs
virtual const DofEntity_multiIndex * get_dofs() const =0
Get the dofs object.
MoFEM::Interface
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1975
MoFEM::Exceptions::rval
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Exceptions.hpp:74
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:535
MoFEM::CoreInterface::add_field
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.
mesh_file_name
char mesh_file_name[255]
Definition: mesh_smoothing.cpp:23
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
CATCH_ERRORS
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:372
MoFEM::Core
CoreTmp< 0 > Core
Definition: Core.hpp:1102
MoFEM::CoreInterface::clear_inactive_dofs
virtual MoFEMErrorCode clear_inactive_dofs(int verb=DEFAULT_VERBOSITY)=0
AINSWORTH_LEGENDRE_BASE
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Definition: definitions.h:60
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
MoFEM::PetscOptionsGetString
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
Definition: DeprecatedPetsc.hpp:172
MoFEM::CoreInterface::build_fields
virtual MoFEMErrorCode build_fields(int verb=DEFAULT_VERBOSITY)=0
MoFEM::BitRefManager
Managing BitRefLevels.
Definition: BitRefManager.hpp:21
MoFEM::Types::BitRefLevel
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:40
MoFEM::CoreInterface::set_field_order
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.
HDIV
@ HDIV
field with continuous normal traction
Definition: definitions.h:87
CHKERRG
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:483