v0.8.15
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  ParallelComm *pcomm = ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
53  if (pcomm == NULL)
54  pcomm = new ParallelComm(&moab, PETSC_COMM_WORLD);
55 
56  const char *option;
57  option = ""; //"PARALLEL=BCAST;";//;DEBUG_IO";
58  CHKERR moab.load_file(mesh_file_name, 0, option);
59  CHKERRG(rval);
60 
61  // Create MoFEM (Joseph) database
62  MoFEM::Core core(moab);
63  MoFEM::Interface &m_field = core;
64 
65  // set entitities bit level
66  BitRefLevel bit_level0;
67  bit_level0.set(0);
68  EntityHandle meshset_level0;
69  CHKERR moab.create_meshset(MESHSET_SET, meshset_level0);
70  CHKERRG(rval);
71  CHKERR m_field.getInterface<BitRefManager>()->setBitRefLevelByDim(
72  0, 3, bit_level0);
73 
74  // Fields
75  CHKERR m_field.add_field("F1", L2, AINSWORTH_LEGENDRE_BASE, 1);
76  CHKERR m_field.add_field("F2", HDIV, AINSWORTH_LEGENDRE_BASE, 1);
77 
78  // meshset consisting all entities in mesh
79  EntityHandle root_set = moab.get_root_set();
80  // add entities to field
81  CHKERR m_field.add_ents_to_field_by_type(root_set, MBTET, "F1");
82  CHKERR m_field.add_ents_to_field_by_type(root_set, MBTET, "F2");
83 
84  // set app. order
85  // see Hierarchic Finite Element Bases on Unstructured Tetrahedral Meshes
86  // (Mark Ainsworth & Joe Coyle)
87  int order = 4;
88  CHKERR m_field.set_field_order(root_set, MBTET, "F1", order - 1, 2);
89  CHKERR m_field.set_field_order(root_set, MBTET, "F2", order, 2);
90  CHKERR m_field.set_field_order(root_set, MBTRI, "F2", order, 2);
91 
92  CHKERR m_field.build_fields();
93 
94  order = 2;
95  CHKERR m_field.set_field_order(root_set, MBTET, "F1", order - 1, 2);
96  CHKERR m_field.set_field_order(root_set, MBTET, "F2", order, 2);
97  CHKERR m_field.set_field_order(root_set, MBTRI, "F2", order, 2);
98 
99  CHKERR m_field.clear_inactive_dofs();
100  CHKERR m_field.build_fields();
101 
102  const DofEntity_multiIndex *dofs_ptr;
103  CHKERR m_field.get_dofs(&dofs_ptr);
104  const unsigned int expected_size = 300;
105  if (dofs_ptr->size() != expected_size) {
106  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
107  "Data inconsistency, should %d dofs but is %d", expected_size,
108  dofs_ptr->size());
109  }
110  }
111  CATCH_ERRORS;
112 
113  // finish work cleaning memory, getting statistics, ect.
115 
116  return 0;
117 }
field with continuous normal traction
Definition: definitions.h:170
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:526
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.
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.
Core (interface) class.
Definition: Core.hpp:50
char mesh_file_name[255]
virtual MoFEMErrorCode get_dofs(const DofEntity_multiIndex **dofs_ptr) const =0
Get dofs multi index.
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition: Core.cpp:51
multi_index_container< boost::shared_ptr< DofEntity >, indexed_by< ordered_unique< tag< Unique_mi_tag >, const_mem_fun< DofEntity, UId, &DofEntity::getGlobalUniqueId > >, ordered_non_unique< tag< Composite_Ent_and_ShortId_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt >, const_mem_fun< DofEntity, ShortId, &DofEntity::getNonNonuniqueShortId > > >, ordered_non_unique< tag< Composite_Name_And_Ent_And_EntDofIdx_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt >, const_mem_fun< DofEntity, DofIdx, &DofEntity::getEntDofIdx > > >, ordered_non_unique< tag< Unique_Ent_mi_tag >, const_mem_fun< DofEntity, UId, &DofEntity::getEntGlobalUniqueId > >, ordered_non_unique< tag< FieldName_mi_tag >, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt > >, ordered_non_unique< tag< Composite_Name_And_Ent_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt > > >, ordered_non_unique< tag< Composite_Name_And_Type_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity::interface_type_RefEntity, EntityType, &DofEntity::getEntType > > >, ordered_non_unique< tag< Composite_Name_Ent_Order_And_CoeffIdx_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt >, const_mem_fun< DofEntity, ApproximationOrder, &DofEntity::getDofOrder >, const_mem_fun< DofEntity, FieldCoefficientsNumber, &DofEntity::getDofCoeffIdx > > > > > DofEntity_multiIndex
MultiIndex container keeps DofEntity.
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Common.hpp:147
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Common.hpp:78
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.
Managing BitRefLevels.
Ainsworth Cole (Legendre) approx. base .
Definition: definitions.h:142
#define CHKERR
Inline error check.
Definition: definitions.h:578
static char help[]
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:282
virtual MoFEMErrorCode build_fields(int verb=DEFAULT_VERBOSITY)=0
virtual MoFEMErrorCode clear_inactive_dofs(int verb=DEFAULT_VERBOSITY)=0
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:429
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition: Core.cpp:61
field with C-1 continuity
Definition: definitions.h:171

Variable Documentation

◆ help

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

Definition at line 27 of file activate_deactivate_dofs.cpp.