v0.16.3
Loading...
Searching...
No Matches
HybridProblem.hpp
Go to the documentation of this file.
1/** \file HybridProblem.hpp
2 * \brief Reusable hybrid algebra and graph validation for FUN-3.
3 */
4#ifndef FUN3_HYBRID_PROBLEM_HPP
5#define FUN3_HYBRID_PROBLEM_HPP
6#include <unordered_map>
7
8namespace Fun3 {
9using namespace MoFEM;
10
12 const Range &tets, Mat matrix,
14 const std::string &tag,
15 double &nonzeros) {
17 const Problem *problem_ptr;
18 CHKERR DMMoFEMGetProblemPtr(dm, &problem_ptr);
19 std::unordered_map<EntityHandle, std::vector<PetscInt>> face_dofs;
20 for (auto &dof : *problem_ptr->getNumeredColDofsPtr())
21 if (dof->getPetscGlobalDofIdx() >= 0)
22 face_dofs[dof->getEnt()].push_back(dof->getPetscGlobalDofIdx());
23
24 // Every active cell couples all its skeleton faces, including each face
25 // with itself. Deduplication accounts for a face belonging to two cells.
26 std::unordered_map<EntityHandle, std::vector<PetscInt>> neighbors;
27 for (auto tet : tets) {
29 CHKERR m_field.get_moab().get_adjacencies(&tet, 1, 2, false, faces);
30 std::vector<PetscInt> columns;
31 for (auto face : faces) {
32 auto it = face_dofs.find(face);
33 if (it != face_dofs.end())
34 columns.insert(columns.end(), it->second.begin(), it->second.end());
35 }
36 for (auto face : faces)
37 if (face_dofs.count(face)) {
38 auto &adj = neighbors[face];
39 adj.insert(adj.end(), columns.begin(), columns.end());
40 }
41 }
42
43 PetscInt first_row, last_row;
44 CHKERR MatGetOwnershipRange(matrix, &first_row, &last_row);
45 MatInfo before;
46 CHKERR MatGetInfo(matrix, MAT_GLOBAL_SUM, &before);
47 CHKERR MatSetOption(matrix, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_TRUE);
48 double local_nnz = 0, root_nnz = 0;
49 for (auto &entry : neighbors) {
50 auto &columns = entry.second;
51 std::sort(columns.begin(), columns.end());
52 columns.erase(std::unique(columns.begin(), columns.end()), columns.end());
53 const PetscInt nb_cols = columns.size();
54 if (m_field.get_comm_rank() == 0)
55 root_nnz +=
56 static_cast<double>(nb_cols) * face_dofs.at(entry.first).size();
57 const std::vector<PetscScalar> values(nb_cols, 1.);
58 for (auto row : face_dofs.at(entry.first))
59 if (row >= first_row && row < last_row) {
60 local_nnz += nb_cols;
61 CHKERR MatSetValues(matrix, 1, &row, nb_cols, columns.data(),
62 values.data(), INSERT_VALUES);
63 }
64 }
65 double expected_nnz;
66 CHKERR MPI_Allreduce(&local_nnz, &expected_nnz, 1, MPI_DOUBLE, MPI_SUM,
67 m_field.get_comm());
68 CHKERR MPI_Bcast(&root_nnz, 1, MPI_DOUBLE, 0, m_field.get_comm());
69 const auto zero = TestingInterface::Tolerance{0, 0};
70 CHKERR testing.checkValue<TestType::SCALAR>(
71 tag + " distributed graph equals complete root graph", expected_nnz,
72 root_nnz, zero);
73 // MPI ghost contributions can overestimate preallocation. The used graph
74 // below must still be exact, and filling it must require no new allocation.
75 CHKERR testing.checkValue<TestType::SCALAR>(
76 tag + " hybrid allocation covers topology non-zeros",
77 before.nz_allocated >= expected_nnz ? 0 : 1, 0, zero);
78 if (m_field.get_comm_size() == 1)
79 CHKERR testing.checkValue<TestType::SCALAR>(
80 tag + " serial hybrid allocation is exact", before.nz_allocated,
81 expected_nnz, zero);
82 CHKERR MatAssemblyBegin(matrix, MAT_FINAL_ASSEMBLY);
83 CHKERR MatAssemblyEnd(matrix, MAT_FINAL_ASSEMBLY);
84 MatInfo after;
85 CHKERR MatGetInfo(matrix, MAT_GLOBAL_SUM, &after);
86 nonzeros = after.nz_used;
87 CHKERR testing.checkValue<TestType::SCALAR>(
88 tag + " hybrid filled non-zeros equal topology", nonzeros, expected_nnz,
89 zero);
90 CHKERR testing.checkValue<TestType::SCALAR>(
91 tag + " hybrid fill without reallocations", after.mallocs, before.mallocs,
92 zero);
93 PetscBool missing;
94 PetscInt missing_row;
95 CHKERR MatMissingDiagonal(matrix, &missing, &missing_row);
96 CHKERR testing.checkValue<TestType::SCALAR>(
97 tag + " hybrid diagonal exists in every row", missing ? 1 : 0, 0, zero);
99}
100
101/// Retain the parent/sub-DMs, field DOFs and block storage across mesh edits.
105 bool configured = false;
106 bool updatePrepared = false;
107 bool structuresReused = false;
108 PetscBool rebuildStructures = PETSC_TRUE,
110 std::array<double, 5> summary{};
111 std::array<PetscObjectId, 3> dmIds{};
112 std::array<boost::shared_ptr<DofEntity>, 3> retainedDofPtrs;
115 boost::shared_ptr<BlockStructure> blockDataPtr;
116 boost::shared_ptr<NestSchurData> nestedDataPtr;
117
119 : mField(m_field), simplePtr(m_field.getInterface<Simple>()) {}
120 HybridProblem(const HybridProblem &) = delete;
122 ~HybridProblem() { CHKERRABORT(mField.get_comm(), release()); }
123
124 /// Release numeric objects and cached vectors before topology edits.
127 if (updatePrepared)
129 hybridMatPtr.reset();
130 nestedMatPtr.reset();
131 blockMatPtr.reset();
132 for (DM dm : {simplePtr->getDM().get(), schurDMPtr.get(), blockDMPtr.get()})
133 if (dm) {
135 CHKERR DMClearGlobalVectors(dm);
136 CHKERR DMClearLocalVectors(dm);
137 CHKERR DMClearNamedGlobalVectors(dm);
138 CHKERR DMClearNamedLocalVectors(dm);
139 }
140 updatePrepared = true;
142 }
143
144 /// Final teardown, after all retained storage stops referencing sub-DMs.
148 nestedDataPtr.reset();
149 blockDataPtr.reset();
150 schurDMPtr.reset();
151 blockDMPtr.reset();
152 for (const auto &name : {"SCHUR", "BLOCK"})
155 auto parent_dm_ptr = simplePtr->getDM();
156 if (parent_dm_ptr) {
157 CHKERR DMMoFEMSetDestroyProblem(parent_dm_ptr, PETSC_TRUE);
159 parent_dm_ptr.reset();
161 }
163 }
164
165 /// Rebuild subproblem numbering while keeping its DM and field selection.
167 const std::vector<std::string> &fields,
168 SmartPetscObj<DM> &dm) {
170 const bool update = bool(dm);
171 if (!update) {
172 dm = createDM(mField.get_comm(), "DMMOFEM");
174 CHKERR DMMoFEMSetDestroyProblem(dm, PETSC_FALSE);
175 CHKERR DMMoFEMSetSquareProblem(dm, PETSC_TRUE);
178 for (const auto &field : fields) {
181 }
182 }
183 // Creation adds selector bits to an existing named problem. Rebuilding
184 // must replace them, otherwise inactive source cells enter preallocation.
185 const Problem *parent_ptr;
188 name, parent_ptr->getBitRefLevel());
190 name, parent_ptr->getBitRefLevelMask());
191 // DMSetUp() skips a DM already set up by PETSc. Invoke MoFEM's subproblem
192 // setup directly to refresh its numbering and partitions in this object.
193 if (update)
195 else
196 CHKERR DMSetUp(dm);
198 }
199
200 /// Couplings used by both construction and the optional fresh-build oracle.
202 return {
204 {{"BROKEN", "BROKEN"}, {"U", "U"}, {"BROKEN", "U"}, {"U", "BROKEN"}}},
206 {{"BROKEN", "HYBRID"}, {"HYBRID", "BROKEN"}}}};
207 }
208
209 /// Construct the DMs and matrices without running validation or test fills.
210 MoFEMErrorCode build(const Range &entities, const Range &skeleton,
211 const BitRefLevel &active_bit, int order,
212 bool refresh_registration) {
215 updatePrepared = false;
216 const bool update = bool(simplePtr->getDM());
217 auto &mb = mField.get_moab();
218 if (!configured) {
219 CHKERR PetscOptionsGetBool(nullptr, nullptr, "-rebuild_structures",
220 &rebuildStructures, nullptr);
221 CHKERR PetscOptionsGetBool(nullptr, nullptr, "-check_rebuilt_structures",
222 &checkRebuiltStructures, nullptr);
223 simplePtr->setDim(3);
224 simplePtr->getAddBoundaryFE() = false;
225 CHKERR mb.create_meshset(MESHSET_SET, simplePtr->getMeshset());
226 CHKERR mb.create_meshset(MESHSET_SET, simplePtr->getSkeletonMeshSet());
231 1);
234 CHKERR simplePtr->setFieldOrder("HYBRID", order - 1);
235 configured = true;
236 }
237 for (auto set : {simplePtr->getMeshset(), simplePtr->getSkeletonMeshSet()})
238 CHKERR mb.clear_meshset(&set, 1);
239 CHKERR mb.add_entities(simplePtr->getMeshset(), entities);
240 CHKERR mb.add_entities(simplePtr->getSkeletonMeshSet(), skeleton);
241 simplePtr->getBitRefLevel() = active_bit;
242 simplePtr->getBitAdjEnt() = active_bit;
243 simplePtr->getBitAdjParent().reset();
244 if (!update || refresh_registration) {
245 Range new_field_entities;
246 auto comm_ptr = mField.getInterface<CommInterface>();
247 // A face may leave the skeleton without being deleted (e.g. when it
248 // joins a crack). Do not retain its old trace DOFs or skeleton element.
249 for (const auto &name : {"BROKEN", "U", "HYBRID"}) {
250 Range registered;
251 CHKERR mb.get_entities_by_handle(mField.get_field_meshset(name),
252 registered);
253 const auto &keep = std::string(name) == "HYBRID" ? skeleton : entities;
254 const auto removed = subtract(registered, keep);
255 if (!removed.empty())
257 registered = intersect(registered, keep);
258 const int dim = std::string(name) == "HYBRID" ? 2 : 3;
259 const auto added = subtract(keep.subset_by_dimension(dim), registered);
261 CHKERR comm_ptr->synchroniseFieldEntities(name, 0);
262 Range current;
263 CHKERR mb.get_entities_by_handle(mField.get_field_meshset(name),
264 current);
265 // A loaded checkpoint can carry field memberships and an older order.
266 // Initialise all current members once, then update additions only.
267 const auto new_entities =
268 update ? subtract(current, registered) : current;
269 if (!new_entities.empty())
271 new_entities, name,
272 std::string(name) == "BROKEN" ? order : order - 1, QUIET);
273 new_field_entities.merge(new_entities);
274 }
275 for (const auto &[name, keep] :
276 std::vector<std::pair<std::string, Range>>{
277 {simplePtr->getDomainFEName(), entities},
278 {simplePtr->getSkeletonFEName(), skeleton}}) {
280 continue;
281 Range registered;
282 CHKERR mb.get_entities_by_handle(
284 const auto removed = subtract(registered, keep);
285 if (!removed.empty())
287 }
288 if (!update)
292 // The range overload preserves existing DOF objects. Rebuilding views
293 // still visits surviving faces whose adjacent cells may have changed.
294 CHKERR mField.build_fields(new_field_entities, QUIET);
296 }
297 if (!update)
298 CHKERR simplePtr->defineProblem(PETSC_TRUE);
299 if (update) {
302 auto problems_ptr = mField.getInterface<ProblemsManager>();
303 const auto from_fields = problems_ptr->buildProblemFromFields;
304 problems_ptr->buildProblemFromFields = PETSC_TRUE;
305 const auto ierr = DMMoFEMRebuildProblem(simplePtr->getDM(), active_bit,
307 problems_ptr->buildProblemFromFields = from_fields;
308 CHKERR ierr;
309 } else
311 CHKERR buildSubProblem("SCHUR", {"HYBRID"}, schurDMPtr);
312 CHKERR buildSubProblem("BLOCK", {"BROKEN", "U"}, blockDMPtr);
313 const auto ops = getBlockOperations();
314 const bool reuse = rebuildStructures && blockDataPtr && nestedDataPtr;
315 structuresReused = reuse;
316 if (reuse)
318 else {
319 nestedDataPtr.reset();
321 }
323 if (reuse)
326 else
328 {schurDMPtr, blockDMPtr}, blockDataPtr, {"BROKEN", "U"},
329 {nullptr, nullptr}, true);
333 }
334
335 /// Check the completed algebra; graph validation fills the hybrid matrix.
336 MoFEMErrorCode validate(const Range &entities, const Range &skeleton,
337 int order, const std::string &tag) {
339 if (!hybridMatPtr)
341 "Build the hybrid problem before validating it");
343 auto fresh_block_ptr =
345 auto fresh_nested_ptr = createSchurNestedMatrixStruture(
346 {schurDMPtr, blockDMPtr}, fresh_block_ptr, {"BROKEN", "U"},
347 {nullptr, nullptr}, true);
348 auto compare = [&](const std::string &what, auto rebuilt_ptr,
349 auto fresh_ptr) {
351 const auto r = schurBlockStructureDigest(rebuilt_ptr);
352 const auto f = schurBlockStructureDigest(fresh_ptr);
353 if (r.nbBlocks != f.nbBlocks || r.nbElems != f.nbElems ||
354 r.indexHash != f.indexHash || r.blocksHash != f.blocksHash ||
355 r.elemsHash != f.elemsHash)
356 MOFEM_LOG("WORLD", Sev::error)
357 << what << " digest: blocks " << r.nbBlocks << "/" << f.nbBlocks
358 << ", elements " << r.nbElems << "/" << f.nbElems << ", index "
359 << r.indexHash << "/" << f.indexHash << ", layout "
360 << r.blocksHash << "/" << f.blocksHash << ", element layout "
361 << r.elemsHash << "/" << f.elemsHash;
364 tag + " rebuilt " + what + " equals fresh structure",
365 r.nbBlocks == f.nbBlocks && r.nbElems == f.nbElems &&
366 r.indexHash == f.indexHash &&
367 r.blocksHash == f.blocksHash &&
368 r.elemsHash == f.elemsHash
369 ? 0
370 : 1,
373 };
374 CHKERR compare("block", blockDataPtr, fresh_block_ptr);
375 for (int q = 0; q != 4; ++q)
376 CHKERR compare("quadrant " + std::to_string(q),
377 std::get<1>(*nestedDataPtr)[q],
378 std::get<1>(*fresh_nested_ptr)[q]);
379 }
380 auto testing_ptr = mField.getInterface<TestingInterface>();
381 const auto zero = TestingInterface::Tolerance{0, 0};
382 int dm_index = 0;
383 for (DM dm :
384 {simplePtr->getDM().get(), blockDMPtr.get(), schurDMPtr.get()}) {
385 PetscObjectId id;
386 CHKERR PetscObjectGetId(reinterpret_cast<PetscObject>(dm), &id);
387 if (!dmIds[dm_index])
388 dmIds[dm_index] = id;
389 CHKERR testing_ptr->checkValue<TestType::SCALAR>(
390 tag + " DM " + std::to_string(dm_index) + " identity retained",
391 id == dmIds[dm_index] ? 0 : 1, 0, zero);
392 ++dm_index;
393 }
394 // Sample one DOF per field. Replaced entities may have new field objects;
395 // a surviving field entity must keep its existing DOF object as well.
396 const auto &dofs = mField.get_dofs()->get<Unique_mi_tag>();
397 int field_index = 0;
398 for (const auto &name : {"BROKEN", "U", "HYBRID"}) {
399 auto &old_ptr = retainedDofPtrs[field_index++];
400 int identity_error = 0;
401 if (old_ptr) {
402 auto it = dofs.find(old_ptr->getLocalUniqueId());
403 if (it != dofs.end() &&
404 (*it)->getFieldEntityPtr() == old_ptr->getFieldEntityPtr())
405 identity_error = *it == old_ptr ? 0 : 1;
406 }
407 CHKERR testing_ptr->checkValue<TestType::SCALAR>(
408 tag + " surviving " + name + " DOF identity retained", identity_error,
409 0, zero);
410 const auto bit_number = mField.get_field_bit_number(name);
411 auto it = dofs.lower_bound(FieldEntity::getLoBitNumberUId(bit_number));
412 old_ptr = it != dofs.end() && (*it)->getBitNumber() == bit_number
413 ? *it
414 : nullptr;
415 }
416 int counts[2] = {static_cast<int>(entities.num_of_type(MBTET)),
417 static_cast<int>(skeleton.size())};
418 CHKERR MPI_Bcast(counts, 2, MPI_INT, 0, mField.get_comm());
419 const double broken =
421 const double block_rows = counts[0] * (broken + NBVOLUMETET_L2(order - 1));
422 const double schur_rows = counts[1] * NBFACETRI_L2(order - 1);
423 const double parent_rows = block_rows + schur_rows;
424 for (const auto &[dm, expected] :
425 std::vector<std::pair<DM, double>>{{simplePtr->getDM(), parent_rows},
426 {blockDMPtr, block_rows},
427 {schurDMPtr, schur_rows}}) {
428 const Problem *problem_ptr;
429 CHKERR DMMoFEMGetProblemPtr(dm, &problem_ptr);
430 CHKERR testing_ptr->checkValue<TestType::SCALAR>(
431 tag + " DM DOFs match complete root topology",
432 problem_ptr->getNbDofsRow(), expected, zero);
433 auto vector = createDMVector(dm);
434 PetscInt n, first, last;
435 CHKERR VecGetSize(vector, &n);
436 CHKERR VecGetOwnershipRange(vector, &first, &last);
437 CHKERR testing_ptr->checkValue<TestType::SCALAR>(
438 tag + " DM vector global size", n, expected, zero);
439 CHKERR testing_ptr->checkValue<TestType::SCALAR>(
440 tag + " DM vector local size", last - first,
441 problem_ptr->nbLocDofsRow, zero);
442 }
443 for (const auto &[matrix, expected] :
444 std::vector<std::pair<Mat, double>>{{blockMatPtr, parent_rows},
445 {nestedMatPtr, parent_rows},
446 {hybridMatPtr, schur_rows}}) {
447 PetscInt m, n;
448 CHKERR MatGetSize(matrix, &m, &n);
449 CHKERR testing_ptr->checkValue<TestType::SCALAR>(tag + " matrix rows", m,
450 expected, zero);
451 CHKERR testing_ptr->checkValue<TestType::SCALAR>(tag + " matrix columns",
452 n, expected, zero);
453 }
454 double nnz;
456 entities.subset_by_type(MBTET), hybridMatPtr,
457 *testing_ptr, tag, nnz);
458 summary = {static_cast<double>(order), parent_rows, block_rows, schur_rows,
459 nnz};
460 MOFEM_LOG("WORLD", Sev::inform)
461 << "Hybrid rebuilt " << tag
462 << (structuresReused ? " [reused structures]" : " [fresh structures]")
463 << ": parent " << parent_rows << ", BLOCK " << block_rows << ", SCHUR "
464 << schur_rows << ", nonzeros " << nnz;
466 }
467};
468} // namespace Fun3
469#endif
std::vector< std::array< EntityHandle, 3 > > faces
Sorted keys.
std::vector< int > removed
moab::Interface & mb
Tag tag
ProjectedField & field
std::vector< FieldBitNumber > row
Definition Schur.cpp:2488
It it
Definition Schur.cpp:2568
SmartPetscObj< Vec > values
std::string name
@ QUIET
@ DEMKOWICZ_JACOBI_BASE
Definition definitions.h:66
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
@ L2
field with C-1 continuity
Definition definitions.h:88
@ HDIV
field with continuous normal traction
Definition definitions.h:87
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
constexpr int order
PetscErrorCode DMMoFEMCreateSubDM(DM subdm, DM dm, const char problem_name[])
Must be called by user to set Sub DM MoFEM data structures.
Definition DMMoFEM.cpp:244
PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name)
add element to dm
Definition DMMoFEM.cpp:574
PetscErrorCode DMMoFEMRebuildProblem(DM dm, const MoFEM::BitRefLevel target_bit, const MoFEM::BitRefLevel target_mask, IS *old_row_indices=PETSC_NULLPTR, IS *new_row_indices=PETSC_NULLPTR)
Rebuild the DM's parent problem in place on a new bit ref level.
Definition DMMoFEM.cpp:479
PetscErrorCode DMMoFEMSetSquareProblem(DM dm, PetscBool square_problem)
set squared problem
Definition DMMoFEM.cpp:536
PetscErrorCode DMMoFEMGetProblemPtr(DM dm, const MoFEM::Problem **problem_ptr)
Get pointer to problem data structure.
Definition DMMoFEM.cpp:451
PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, const char field_name[])
Definition DMMoFEM.cpp:267
auto createDMVector(DM dm, RowColData rc=RowColData::COL)
Get smart vector from DM.
Definition DMMoFEM.hpp:1279
PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, const char field_name[])
Definition DMMoFEM.cpp:309
PetscErrorCode DMSubDMSetUp_MoFEM(DM subdm)
Definition DMMoFEM.cpp:1431
virtual const DofEntity_multiIndex * get_dofs() const =0
Get the dofs object.
virtual EntityHandle get_finite_element_meshset(const std::string name) const =0
virtual MoFEMErrorCode build_fields(int verb=DEFAULT_VERBOSITY)=0
virtual MoFEMErrorCode add_ents_to_field_by_dim(const Range &ents, const int dim, const std::string &name, int verb=DEFAULT_VERBOSITY)=0
Add entities to field meshset.
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 remove_ents_from_field(const std::string name, const EntityHandle meshset, const EntityType type, int verb=DEFAULT_VERBOSITY)=0
remove entities from field
#define MOFEM_LOG(channel, severity)
Log.
virtual MoFEMErrorCode modify_problem_mask_ref_level_set_bit(const std::string &name_problem, const BitRefLevel &bit)=0
set dof mask ref level for problem
virtual MoFEMErrorCode delete_problem(const std::string name)=0
Delete problem.
virtual MoFEMErrorCode modify_problem_ref_level_set_bit(const std::string &name_problem, const BitRefLevel &bit)=0
set ref level for problem
virtual bool check_problem(const std::string name)=0
check if problem exist
#define NBFACETRI_L2(P)
Number of base functions on triangle for L2 space.
#define NBVOLUMETET_DEMKOWICZ_HDIV(P)
#define NBFACETRI_DEMKOWICZ_HDIV(P)
#define NBVOLUMETET_L2(P)
Number of base functions on tetrahedron for L2 space.
PetscBool testing
MoFEMErrorCode check_hybrid_matrix(MoFEM::Interface &m_field, DM dm, const Range &tets, Mat matrix, TestingInterface &testing, const std::string &tag, double &nonzeros)
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition Types.hpp:40
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
SchurBlockStructureDigest schurBlockStructureDigest(boost::shared_ptr< BlockStructure > data_ptr)
Definition Schur.cpp:4821
PetscErrorCode DMMoFEMSetDestroyProblem(DM dm, PetscBool destroy_problem)
Definition DMMoFEM.cpp:463
std::pair< SmartPetscObj< Mat >, boost::shared_ptr< NestSchurData > > createSchurNestedMatrix(boost::shared_ptr< NestSchurData > schur_net_data_ptr)
Create a Mat Diag Blocks object.
Definition Schur.cpp:4859
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
PetscErrorCode DMMoFEMClearDMCtx(DM dm)
Clear solver and Schur data owned by a MoFEM DM context.
Definition DMMoFEM.cpp:79
auto createDMHybridisedL2Matrix(DM dm)
Get smart hybridised L2 matrix from DM.
Definition DMMoFEM.hpp:1249
boost::shared_ptr< BlockStructure > createBlockMatStructure(DM dm, SchurFEOpsFEandFields schur_fe_op_vec)
Create block matrix structure.
Definition Schur.cpp:2819
boost::shared_ptr< NestSchurData > createSchurNestedMatrixStruture(std::pair< SmartPetscObj< DM >, SmartPetscObj< DM > > dms, boost::shared_ptr< BlockStructure > block_mat_data_ptr, std::vector< std::string > fields_names, std::vector< boost::shared_ptr< Range > > field_ents, bool add_preconditioner_block)
Create structure of nested matrix [A11 A10; A01 A00].
Definition Schur.cpp:4760
MoFEMErrorCode MatSetValues(Mat M, const EntitiesFieldData::EntData &row_data, const EntitiesFieldData::EntData &col_data, const double *ptr, InsertMode iora)
Assemble PETSc matrix.
MoFEMErrorCode rebuildSchurNestedMatrixStruture(std::pair< SmartPetscObj< DM >, SmartPetscObj< DM > > dms, boost::shared_ptr< NestSchurData > nest_data_ptr)
Rebuild a nested Schur structure after rebuildBlockMatStructure.
Definition Schur.cpp:4799
MoFEMErrorCode TestingInterface::checkValue< TestType::SCALAR >(const std::string &check_name, PetscReal actual, PetscReal expected, Tolerance tolerance, Sev error_severity, Sev success_severity) const
MoFEMErrorCode rebuildBlockMatStructure(DM dm, SchurFEOpsFEandFields schur_fe_op_vec, boost::shared_ptr< BlockStructure > data_ptr)
Rebuild a block matrix structure after its problem changed.
Definition Schur.cpp:2833
std::vector< std::pair< std::string, std::vector< SchurFieldPair > > > SchurFEOpsFEandFields
Definition Schur.hpp:83
auto createDM(MPI_Comm comm, const std::string dm_type_name)
Creates smart DM object.
SchurShellMatData createBlockMat(DM dm, boost::shared_ptr< BlockStructure > data)
Create a Schur Mat object.
Definition Schur.cpp:3615
double q
FTensor::Index< 'm', 3 > m
Retain the parent/sub-DMs, field DOFs and block storage across mesh edits.
MoFEMErrorCode buildSubProblem(const char *name, const std::vector< std::string > &fields, SmartPetscObj< DM > &dm)
Rebuild subproblem numbering while keeping its DM and field selection.
MoFEM::Interface & mField
boost::shared_ptr< NestSchurData > nestedDataPtr
MoFEMErrorCode build(const Range &entities, const Range &skeleton, const BitRefLevel &active_bit, int order, bool refresh_registration)
Construct the DMs and matrices without running validation or test fills.
std::array< double, 5 > summary
std::array< PetscObjectId, 3 > dmIds
HybridProblem(const HybridProblem &)=delete
HybridProblem(MoFEM::Interface &m_field)
std::array< boost::shared_ptr< DofEntity >, 3 > retainedDofPtrs
PetscBool checkRebuiltStructures
SmartPetscObj< Mat > blockMatPtr
SmartPetscObj< DM > blockDMPtr
HybridProblem & operator=(const HybridProblem &)=delete
MoFEMErrorCode release()
Final teardown, after all retained storage stops referencing sub-DMs.
MoFEMErrorCode prepareUpdate()
Release numeric objects and cached vectors before topology edits.
SmartPetscObj< Mat > nestedMatPtr
boost::shared_ptr< BlockStructure > blockDataPtr
MoFEMErrorCode validate(const Range &entities, const Range &skeleton, int order, const std::string &tag)
Check the completed algebra; graph validation fills the hybrid matrix.
SchurFEOpsFEandFields getBlockOperations() const
Couplings used by both construction and the optional fresh-build oracle.
SmartPetscObj< DM > schurDMPtr
SmartPetscObj< Mat > hybridMatPtr
Managing BitRefLevels.
virtual int get_comm_size() const =0
virtual FieldBitNumber get_field_bit_number(const std::string name) const =0
get field bit number
virtual moab::Interface & get_moab()=0
virtual EntityHandle get_field_meshset(const std::string name) const =0
get field meshset
virtual bool check_finite_element(const std::string &name) const =0
Check if finite element is in database.
virtual MoFEMErrorCode build_adjacencies(const Range &ents, int verb=DEFAULT_VERBOSITY)=0
build adjacencies
virtual MPI_Comm & get_comm() const =0
virtual MoFEMErrorCode remove_ents_from_finite_element(const std::string name, const EntityHandle meshset, const EntityType type, int verb=DEFAULT_VERBOSITY)=0
remove entities from given refinement level to finite element database
virtual int get_comm_rank() const =0
Deprecated interface functions.
static UId getLoBitNumberUId(const FieldBitNumber bit_number)
keeps basic data about problem
DofIdx getNbDofsRow() const
BitRefLevel getBitRefLevel() const
BitRefLevel getBitRefLevelMask() const
DofIdx nbLocDofsRow
Local number of DOFs in row.
auto & getNumeredColDofsPtr() const
get access to numeredColDofsPtr storing DOFs on cols
Problem manager is used to build and partition problems.
Simple interface for fast problem set-up.
Definition Simple.hpp:27
MoFEMErrorCode buildProblem()
Build problem.
Definition Simple.cpp:724
MoFEMErrorCode addDomainField(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_ZERO, int verb=-1)
Add field on domain.
Definition Simple.cpp:264
bool & getAddBoundaryFE()
Get the addBoundaryFE flag.
Definition Simple.hpp:546
MoFEMErrorCode defineFiniteElements()
Define finite elements.
Definition Simple.cpp:474
EntityHandle & getMeshset()
Get the MeshSet object.
Definition Simple.hpp:394
auto & getBitAdjParent()
Get bit ref level for parent.
Definition Simple.hpp:562
MoFEMErrorCode buildFiniteElements()
Build finite elements.
Definition Simple.cpp:662
const std::string getSkeletonFEName() const
Get the Skeleton FE Name.
Definition Simple.hpp:443
EntityHandle & getSkeletonMeshSet()
Get the SkeletonMeshSet object.
Definition Simple.hpp:408
void setDim(int dim)
Set the problem dimension.
Definition Simple.hpp:380
MoFEMErrorCode getDM(DM *dm)
Get DM.
Definition Simple.cpp:802
auto & getBitAdjEnt()
Get bit ref level for entities.
Definition Simple.hpp:576
MoFEMErrorCode setFieldOrder(const std::string field_name, const int order, const Range *ents=NULL)
Set field order.
Definition Simple.cpp:578
MoFEMErrorCode defineProblem(const PetscBool is_partitioned=PETSC_TRUE)
define problem
Definition Simple.cpp:554
BitRefLevel & getBitRefLevelMask()
Get the BitRefLevelMask.
Definition Simple.hpp:422
const std::string getDomainFEName() const
Get the Domain FE Name.
Definition Simple.hpp:429
MoFEMErrorCode setSkeletonAdjacency(int dim=-1, std::string fe_name="")
Set the skeleton adjacency object.
Definition Simple.cpp:143
MoFEMErrorCode deleteDM()
Delete dm.
Definition Simple.cpp:814
BitRefLevel & getBitRefLevel()
Get the BitRefLevel.
Definition Simple.hpp:415
MoFEMErrorCode deleteFiniteElements()
Delete finite elements.
Definition Simple.cpp:825
MoFEMErrorCode addDomainBrokenField(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_ZERO, int verb=-1)
Add broken field on domain.
Definition Simple.cpp:285
MoFEMErrorCode addSkeletonField(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_ZERO, int verb=-1)
Add field on skeleton.
Definition Simple.cpp:376
intrusive_ptr for managing petsc objects
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.