14 {
15
16
18
19 try {
20
21 PetscBool flg = PETSC_TRUE;
23#if PETSC_VERSION_GE(3, 6, 4)
25 255, &flg);
26#else
29#endif
30 if (flg != PETSC_TRUE) {
31 SETERRQ(PETSC_COMM_SELF, 1, "*** ERROR -my_file (MESH FILE NEEDED)");
32 }
33
34
35 DMType dm_name = "DMMOFEM";
37 DMType dm_name_sub = "DMSUB";
39
40
41 DM dm;
42 CHKERR DMCreate(PETSC_COMM_WORLD, &dm);
43 CHKERR DMSetType(dm, dm_name);
44
45 DM subdm0, subdm1;
46 CHKERR DMCreate(PETSC_COMM_WORLD, &subdm0);
47 CHKERR DMSetType(subdm0, dm_name_sub);
48 CHKERR DMCreate(PETSC_COMM_WORLD, &subdm1);
49 CHKERR DMSetType(subdm1, dm_name_sub);
50
51
52 moab::Core mb_instance;
53 moab::Interface &moab = mb_instance;
54 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
55 auto moab_comm_wrap =
56 boost::make_shared<WrapMPIComm>(PETSC_COMM_WORLD, false);
57 if (pcomm == NULL)
58 pcomm = new ParallelComm(&moab, moab_comm_wrap->get_comm());
59
60 const char *option;
61 option = "PARALLEL=BCAST_DELETE;PARALLEL_RESOLVE_SHARED_ENTS;PARTITION="
62 "PARALLEL_PARTITION;";
64
67
69
71 bit_level0.set(0);
73 root_set, 3, bit_level0);
74
75 const int field_rank = 1;
77
79
82
84
87
88
90
91
93
97
99
100
102
106
108
109
111
116
118
119
121
123
124
126 CHKERR DMSetFromOptions(dm);
132 ->checkMPIAIJWithArraysMatrixFillIn<PetscGlobalIdx_mi_tag>(
133 "MAIN_PROBLEM", -1, -1, 1);
134
135 int nf;
136 char **field_names;
137 IS *fields;
138 CHKERR DMCreateFieldIS(dm, &nf, &field_names, &fields);
139 for (
int f = 0;
f != nf;
f++) {
140 PetscPrintf(PETSC_COMM_WORLD, "%d field %s\n", f, field_names[f]);
141 CHKERR PetscFree(field_names[f]);
142 CHKERR ISDestroy(&(fields[f]));
143 }
144 CHKERR PetscFree(field_names);
146
150
151 auto verts_ptr = boost::make_shared<Range>();
152 CHKERR moab.get_entities_by_type(0, MBVERTEX, *verts_ptr,
true);
153
158 ->checkMPIAIJWithArraysMatrixFillIn<PetscGlobalIdx_mi_tag>("SUB0", -1,
159 -1, 1);
162 CHKERR DMCreateMatrix(subdm0, &A);
163 MatView(A, PETSC_VIEWER_DRAW_WORLD);
164 std::string wait;
165 std::cin >> wait;
167 }
168
176 ->checkMPIAIJWithArraysMatrixFillIn<PetscGlobalIdx_mi_tag>("SUB1", -1,
177 -1, 1);
178
181 CHKERR DMCreateMatrix(subdm1, &
B);
182 MatView(
B, PETSC_VIEWER_DRAW_WORLD);
183 std::string wait;
184 std::cin >> wait;
186 }
187
188
190 CHKERR DMDestroy(&subdm0);
191 CHKERR DMDestroy(&subdm1);
192 }
194
195
197
198 return 0;
199}
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
#define MYPCOMM_INDEX
default communicator number PCOMM
#define CHKERR
Inline error check.
PetscErrorCode DMMoFEMCreateSubDM(DM subdm, DM dm, const char problem_name[])
Must be called by user to set Sub DM MoFEM data structures.
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 DMMoFEMAddSubFieldRow(DM dm, const char field_name[])
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, const char field_name[])
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.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
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 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.
Matrix manager is used to build and partition problems.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.