v0.10.0
Functions | Variables
build_problems.cpp File Reference

Atom test for building composite problem. More...

#include <MoFEM.hpp>

Go to the source code of this file.

Functions

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

Variables

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

Detailed Description

Atom test for building composite problem.

Bug:
Not verifying what if partitioned mesh is loaded.

Definition in file build_problems.cpp.

Function Documentation

◆ main()

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

Definition at line 28 of file build_problems.cpp.

28  {
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  CHKERR moab.load_file(mesh_file_name, 0, "");
56 
57  // Create MoFEM database
58  MoFEM::Core core(moab);
59  MoFEM::Interface &m_field = core;
60 
61  // set entities bit level
62  BitRefLevel bit_level0;
63  bit_level0.set(0);
64  CHKERR m_field.getInterface<BitRefManager>()->setBitRefLevelByDim(
65  0, 3, bit_level0);
66 
67  // Fields
68  CHKERR m_field.add_field("F1", L2, AINSWORTH_LEGENDRE_BASE, 1);
69  CHKERR m_field.add_field("F2", HDIV, AINSWORTH_LEGENDRE_BASE, 1);
70 
71  // meshset consisting all entities in mesh
72  EntityHandle root_set = moab.get_root_set();
73  // add entities to field
74  CHKERR m_field.add_ents_to_field_by_type(root_set, MBTET, "F1");
75  CHKERR m_field.add_ents_to_field_by_type(root_set, MBTET, "F2");
76 
77  // set app. order
78  // see Hierarchic Finite Element Bases on Unstructured Tetrahedral Meshes
79  // (Mark Ainsworth & Joe Coyle)
80  int order = 2;
81  CHKERR m_field.set_field_order(root_set, MBTET, "F1", order - 1);
82  CHKERR m_field.set_field_order(root_set, MBTET, "F2", order);
83  CHKERR m_field.set_field_order(root_set, MBTRI, "F2", order);
84 
85  CHKERR m_field.build_fields();
86 
87  // add elements
88  CHKERR m_field.add_finite_element("E1");
89  CHKERR m_field.add_finite_element("E2");
90  CHKERR m_field.add_finite_element("E3");
91 
92  CHKERR m_field.modify_finite_element_add_field_row("E1", "F1");
93  CHKERR m_field.modify_finite_element_add_field_col("E1", "F1");
94  CHKERR m_field.modify_finite_element_add_field_row("E2", "F2");
95  CHKERR m_field.modify_finite_element_add_field_col("E2", "F2");
96  // To build composite problem
97  CHKERR m_field.modify_finite_element_add_field_row("E3", "F1");
98  CHKERR m_field.modify_finite_element_add_field_col("E3", "F2");
99 
100  CHKERR m_field.add_ents_to_finite_element_by_type(root_set, MBTET, "E1");
101  CHKERR m_field.add_ents_to_finite_element_by_type(root_set, MBTET, "E2");
102  CHKERR m_field.add_ents_to_finite_element_by_type(root_set, MBTET, "E3");
103 
104  CHKERR m_field.build_finite_elements();
105  CHKERR m_field.build_adjacencies(bit_level0);
106 
107  // Problems
108  CHKERR m_field.add_problem("P1");
109  CHKERR m_field.add_problem("P2");
110 
111  // set refinement level for problem
112  CHKERR m_field.modify_problem_ref_level_add_bit("P1", bit_level0);
113  CHKERR m_field.modify_problem_ref_level_add_bit("P2", bit_level0);
114 
115  CHKERR m_field.modify_problem_add_finite_element("P1", "E1");
116  CHKERR m_field.modify_problem_add_finite_element("P2", "E2");
117 
118  // build problems
119  ProblemsManager *prb_mng_ptr;
120  CHKERR m_field.getInterface(prb_mng_ptr);
121  CHKERR prb_mng_ptr->buildProblem("P1", true);
122  CHKERR prb_mng_ptr->buildProblem("P2", true);
123  CHKERR prb_mng_ptr->partitionProblem("P1");
124  CHKERR prb_mng_ptr->partitionProblem("P2");
125 
126  CHKERR prb_mng_ptr->partitionFiniteElements("P1");
127  CHKERR prb_mng_ptr->partitionGhostDofs("P1");
129  ->checkMPIAIJWithArraysMatrixFillIn<PetscGlobalIdx_mi_tag>("P1", -1, -1,
130  0);
131  CHKERR prb_mng_ptr->partitionFiniteElements("P2");
132  CHKERR prb_mng_ptr->partitionGhostDofs("P2");
134  ->checkMPIAIJWithArraysMatrixFillIn<PetscGlobalIdx_mi_tag>("P2", -1, -1,
135  0);
136 
137  // compose problem
138  CHKERR m_field.add_problem("P3");
139  CHKERR m_field.modify_problem_ref_level_add_bit("P3", bit_level0);
140  CHKERR m_field.modify_problem_add_finite_element("P3", "E3");
141 
142  CHKERR prb_mng_ptr->buildProblem("P3", false);
143  CHKERR prb_mng_ptr->inheritPartition("P3", "P1", false, "P2", true);
144  CHKERR prb_mng_ptr->partitionFiniteElements("P3");
145  CHKERR prb_mng_ptr->partitionGhostDofs("P3");
147  ->checkMPIAIJWithArraysMatrixFillIn<PetscGlobalIdx_mi_tag>("P3", -1, -1,
148  0);
149  }
150  CATCH_ERRORS;
151 
152  // finish work cleaning memory, getting statistics, etc.
154 
155  return 0;
156 }

Variable Documentation

◆ help

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

Definition at line 26 of file build_problems.cpp.

MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:26
EntityHandle
MoFEM::CoreInterface::build_adjacencies
virtual MoFEMErrorCode build_adjacencies(const Range &ents, int verb=DEFAULT_VERBOSITY)=0
build adjacencies
MYPCOMM_INDEX
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:292
MoFEM::ProblemsManager::buildProblem
MoFEMErrorCode buildProblem(const std::string name, const bool square_matrix, int verb=VERBOSE)
build problem data structures
Definition: ProblemsManager.cpp:428
MoFEM::ProblemsManager::inheritPartition
MoFEMErrorCode inheritPartition(const std::string name, const std::string problem_for_rows, bool copy_rows, const std::string problem_for_cols, bool copy_cols, int verb=VERBOSE)
build indexing and partition problem inheriting indexing and partitioning from two other problems
Definition: ProblemsManager.cpp:2166
L2
@ L2
field with C-1 continuity
Definition: definitions.h:180
MoFEM::CoreInterface::modify_finite_element_add_field_col
virtual MoFEMErrorCode modify_finite_element_add_field_col(const std::string &fe_name, const std::string &name_row)=0
set field col which finite element use
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.
MoFEM::CoreInterface::modify_problem_add_finite_element
virtual MoFEMErrorCode modify_problem_add_finite_element(const std::string &name_problem, const std::string &fe_name)=0
add finite element to problem, this add entities assigned to finite element to a particular problem
MoFEM::Interface
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1943
MoFEM::PetscOptionsGetString
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
Definition: DeprecatedPetsc.hpp:183
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.
MoFEM::CoreInterface::add_ents_to_finite_element_by_type
virtual MoFEMErrorCode add_ents_to_finite_element_by_type(const EntityHandle entities, const EntityType type, const std::string &name, const bool recursive=true)=0
add entities to finite element
help
static char help[]
Definition: build_problems.cpp:26
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:604
MoFEM::CoreInterface::add_finite_element
virtual MoFEMErrorCode add_finite_element(const std::string &fe_name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
add finite element
MoFEM::CoreInterface::build_finite_elements
virtual MoFEMErrorCode build_finite_elements(int verb=DEFAULT_VERBOSITY)=0
Build finite elements.
MoFEM::CoreInterface::modify_finite_element_add_field_row
virtual MoFEMErrorCode modify_finite_element_add_field_row(const std::string &fe_name, const std::string &name_row)=0
set field row which finite element use
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
StdRDOperators::order
const int order
Definition: rd_stdOperators.hpp:28
MoFEM::ProblemsManager
Problem manager is used to build and partition problems.
Definition: ProblemsManager.hpp:34
MoFEM::Types::BitRefLevel
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:51
MoFEM::ProblemsManager::partitionFiniteElements
MoFEMErrorCode partitionFiniteElements(const std::string name, bool part_from_moab=false, int low_proc=-1, int hi_proc=-1, int verb=VERBOSE)
partition finite elements
Definition: ProblemsManager.cpp:2416
MoFEM::CoreInterface::modify_problem_ref_level_add_bit
virtual MoFEMErrorCode modify_problem_ref_level_add_bit(const std::string &name_problem, const BitRefLevel &bit)=0
add ref level to problem
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
mesh_file_name
char mesh_file_name[255]
Definition: mesh_smoothing.cpp:35
CATCH_ERRORS
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:441
MoFEM::BitRefManager
Managing BitRefLevels.
Definition: BitRefManager.hpp:34
AINSWORTH_LEGENDRE_BASE
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Definition: definitions.h:152
MoFEM::CoreInterface::build_fields
virtual MoFEMErrorCode build_fields(int verb=DEFAULT_VERBOSITY)=0
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.
MoFEM::MatrixManager
Matrix manager is used to build and partition problems.
Definition: MatrixManager.hpp:34
MoFEM::ProblemsManager::partitionGhostDofs
MoFEMErrorCode partitionGhostDofs(const std::string name, int verb=VERBOSE)
determine ghost nodes
Definition: ProblemsManager.cpp:2599
MoFEM::CoreInterface::add_problem
virtual MoFEMErrorCode add_problem(const std::string &name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
Add problem.
HDIV
@ HDIV
field with continuous normal traction
Definition: definitions.h:179
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
MoFEM::ProblemsManager::partitionProblem
MoFEMErrorCode partitionProblem(const std::string name, int verb=VERBOSE)
partition problem dofs (collective)
Definition: ProblemsManager.cpp:1954