41 {
42
44
45 try {
46
47 PetscBool flg = PETSC_TRUE;
49#if PETSC_VERSION_GE(3, 6, 4)
51 255, &flg);
52#else
55#endif
56 if (flg != PETSC_TRUE) {
57 SETERRQ(PETSC_COMM_SELF, 1, "*** ERROR -my_file (MESH FILE NEEDED)");
58 }
59
60
61 DMType dm_name = "DMMOFEM";
63
64
65 DM dm;
66 CHKERR DMCreate(PETSC_COMM_WORLD, &dm);
67 CHKERR DMSetType(dm, dm_name);
68
69
70 moab::Core mb_instance;
71 moab::Interface &moab = mb_instance;
72
73 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
74 auto moab_comm_wrap =
75 boost::make_shared<WrapMPIComm>(PETSC_COMM_WORLD, false);
76 if (pcomm == NULL)
77 pcomm = new ParallelComm(&moab, moab_comm_wrap->get_comm());
78
79 const char *option;
80 option = "PARALLEL=BCAST_DELETE;PARALLEL_RESOLVE_SHARED_ENTS;PARTITION="
81 "PARALLEL_PARTITION;";
83
86
88
90 bit_level0.set(0);
92 root_set, 3, bit_level0);
93
94 int field_rank = 3;
95#if PETSC_VERSION_GE(3, 6, 4)
97 &flg);
98#else
100 &field_rank, &flg);
101#endif
104
105
108
109
116
117
119
120
122
129
132 "FIELD1");
134 "FIELD2");
135
138 "FE_ONLY_DATA");
139
141
143
144
148 dm, PETSC_FALSE);
149
150 CHKERR DMSetFromOptions(dm);
154
155
158
160 ->checkMPIAIJWithArraysMatrixFillIn<PetscGlobalIdx_mi_tag>(
161 "TEST_PROBLEM", -1, -1, 1);
162
164 ->checkMPIAIJMatrixFillIn<PetscGlobalIdx_mi_tag>("TEST_PROBLEM", -1, -1,
165 1);
166
167 std::vector<std::string> fields_list;
168 fields_list.push_back("FIELD1");
169
170
171 PetscSection section;
173 §ion);
174 CHKERR PetscSectionView(section, PETSC_VIEWER_STDOUT_WORLD);
175 CHKERR DMSetSection(dm, section);
176 CHKERR PetscSectionDestroy(§ion);
177
178 PetscBool save_file = PETSC_TRUE;
179#if PETSC_VERSION_GE(3, 6, 4)
181 &flg);
182#else
184 &save_file, &flg);
185#endif
186 if (save_file) {
187 PetscViewer viewer;
188 CHKERR PetscViewerASCIIOpen(PETSC_COMM_WORLD,
189 "dm_build_partitioned_mesh.txt", &viewer);
190 CHKERR PetscViewerPushFormat(viewer, PETSC_VIEWER_ASCII_INFO);
192 CHKERR PetscViewerDestroy(&viewer);
193 }
194
195 int count = 0;
197 boost::make_shared<CountUp>(count));
199 boost::make_shared<CountDown>(count));
200 if (count)
202 count);
203
204 auto check_consistency_of_uids = [&]() {
207 for (auto &fe : *field_ents_ptr) {
208 if (fe->getOwnerProc() !=
212 << "UId owner proc "
215 << "Entity owner proc " << fe->getOwnerProc();
217 "UId and entity handle inconsistency");
218 }
219 if (fe->getEnt() !=
223 << "UId handle "
225 MOFEM_LOG(
"SELF", Sev::error) <<
"Entity handle " << fe->getEnt();
227 "UId and entity handle inconsistency");
228 }
229 const auto field_bit_number_from_uid =
231 if (fe->getBitNumber() != field_bit_number_from_uid) {
234 << "UId field bit " << field_bit_number_from_uid;
236 << "Entity owner proc " << fe->getBitNumber();
238 "UId and entity handle inconsistency");
239 }
241 field_bit_number_from_uid - 1))) {
244 << "UId field bit "
246 BitFieldId().set(field_bit_number_from_uid - 1));
248 << "Entity owner proc " << fe->getName();
250 "UId and entity handle inconsistency");
251 }
252 }
253
255 };
256
257 CHKERR check_consistency_of_uids();
258
259
261 }
263
264
266
267 return 0;
268}
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
@ L2
field with C-1 continuity
#define MYPCOMM_INDEX
default communicator number PCOMM
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_ATOM_TEST_INVALID
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
FTensor::Index< 'm', SPACE_DIM > m
PetscErrorCode DMMoFEMSetIsPartitioned(DM dm, PetscBool is_partitioned)
PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name)
add element to dm
PetscErrorCode DMMoFEMSetSquareProblem(DM dm, PetscBool square_problem)
set squared problem
PetscErrorCode DMMoFEMCreateMoFEM(DM dm, MoFEM::Interface *m_field_ptr, const char problem_name[], const MoFEM::BitRefLevel bit_level, const MoFEM::BitRefLevel bit_mask=MoFEM::BitRefLevel().set())
Must be called by user to set MoFEM data structures.
PetscErrorCode DMCreateMatrix_MoFEM(DM dm, Mat *M)
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
virtual const FieldEntity_multiIndex * get_field_ents() const =0
Get the field ents object.
virtual MoFEMErrorCode add_finite_element(const std::string &fe_name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
add finite element
virtual MoFEMErrorCode build_finite_elements(int verb=DEFAULT_VERBOSITY)=0
Build finite elements.
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
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
virtual MoFEMErrorCode modify_finite_element_add_field_data(const std::string &fe_name, const std::string name_filed)=0
set finite element field data
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
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.
#define MOFEM_LOG(channel, severity)
Log.
std::bitset< BITFIELDID_SIZE > BitFieldId
Field Id.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
virtual MoFEMErrorCode build_adjacencies(const Range &ents, int verb=DEFAULT_VERBOSITY)=0
build adjacencies
virtual std::string get_field_name(const BitFieldId id) const =0
get field name from id
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.
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Deprecated interface functions.
static auto getHandleFromUniqueId(const UId uid)
Get the Handle From Unique Id.
static auto getFieldBitNumberFromUniqueId(const UId uid)
Get the Field Bit Number From Unique Id.
static auto getOwnerFromUniqueId(const UId uid)
Section manager is used to create indexes and sections.
Matrix manager is used to build and partition problems.
intrusive_ptr for managing petsc objects
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.