Generate a sphere from a Python SDF, partition it, gradually stretch and twist its vertices, reconstruct Delaunay connectivity, and rebuild a hybrid problem at every checkpoint. Rank 0 retains the complete active mesh; workers retain their owned cells, a vertex-adjacent halo, cells incident to their preferred-owned faces and required parent topology. Extra cell copies are non-owned ghosts. Vertex global IDs survive every stage. Representative parents provide partition lineage; incident cells determine sharing. Field transfer is independent. Each stage writes a native MOAB H5M checkpoint.
Requires CGAL and Boost.Python/NumPy. From the installed tutorial directory:
The example keeps one MOAB/MoFEM database and all three DMs alive through all stages. Each checkpoint updates the parent with DMMoFEMRebuildProblem(), refreshes numbering in the SCHUR (HYBRID) and BLOCK (BROKEN and U) sub-DMs, rebuilds block and nested Schur structures in place, and creates new matrix objects, following atom_tests/rebuild_problem_hybrid.cpp. Field and finite-element registration is refreshed after topology or partition changes, with field DOF construction restricted to new memberships. It is retained at coordinate-only and sharing-verification stages.
Matrices, solver contexts and cached vectors are released before topology edits. Surviving entities retain their handles and field DOFs. Older source lineage is removed, sharing registrations are reset, and source/output refinement bits are assigned again before importing and pruning the next mesh. Parent/sub-DMs and block storage are retained. Sharing is already established before the 02 and 05 checkpoint builds; 03 and 06 verify the prepared layout and rebuild the algebra again. Checkpoints contain a FUN3_HYBRID_COUNTS summary checked independently against their saved topology.
Reconstruction gathers the complete vertex/source-topology description on one producer. Indexed mesh descriptions are temporarily broadcast in full before workers prune their resident topology and release transport buffers. This small example demonstrates correctness rather than distributed Delaunay scalability. The reconstructed mesh fills the convex hull of the moved vertices. The sphere script supplies values only; derivatives are unnecessary.
#include <iomanip>
}
<<
"Completed " <<
stretchSteps <<
" stretch/reconstruction steps";
}
private:
struct Mesh {
};
std::array<double, 3>
scale{2, 1, .75};
int error;
CHKERR MPI_Allreduce(&local_error, &error, 1, MPI_INT, MPI_MAX,
if (error)
"Mesh stage failed on an MPI rank");
}
char file[PETSC_MAX_PATH_LEN] =
"sphere.py";
sizeof(file), nullptr);
nullptr);
"hybrid_order must be positive");
"twist_degrees must be finite");
nullptr);
"stretch_steps must be positive");
for (
int d = 0;
d != 3; ++
d) {
const std::string option = std::string(
"-scale_") +
"xyz"[
d];
nullptr);
"Scaling must be positive");
}
}
auto *pc =
}
const int initial_owner = 0;
&initial_owner);
nullptr,
nullptr,
QUIET,
false,
true);
}
}
const double before =
static_cast<double>(step - 1) /
stretchSteps;
const double after =
static_cast<double>(step) /
stretchSteps;
std::array<double, 3> old_scale, new_scale;
for (
int d = 0;
d != 3; ++
d) {
old_scale[
d] = 1. + before * (
scale[
d] - 1.);
new_scale[
d] = 1. + after * (
scale[
d] - 1.);
}
const double angle_increment =
for (
auto vertex :
currentPtr->entities.subset_by_type(MBVERTEX)) {
std::array<double, 3> x;
CHKERR mb.get_coords(&vertex, 1, x.data());
for (
int d = 0;
d != 3; ++
d)
const double angle = angle_increment * x[0];
const std::array<double, 3> rotated{x[0],
c * x[1] -
s * x[2],
for (
int d = 0;
d != 3; ++
d)
x[
d] = new_scale[
d] * rotated[
d];
CHKERR mb.set_coords(&vertex, 1, x.data());
}
}
std::set<std::array<int, 4>> keys;
std::array<int, 4> ids;
for (
int d = 0;
d != 4; ++
d)
ids[
d] =
mesh.vertexIds[cell[
d]];
std::sort(ids.begin(), ids.end());
keys.insert(ids);
}
return keys;
}
std::map<std::array<int, 3>, int> incidence;
for (
int opposite = 0; opposite != 4; ++opposite) {
std::array<int, 3> face;
for (
int d = 0;
d != 4; ++
d)
face[
n++] =
mesh.vertexIds[cell[
d]];
std::sort(face.begin(), face.end());
++incidence[face];
}
std::set<std::array<int, 3>>
skin;
for (const auto &[face, count] : incidence)
if (count == 1)
}
->getTools()
auto changes = [](const auto &before, const auto &after) {
const auto retained =
std::count_if(before.begin(), before.end(),
[&](
const auto &
key) { return after.count(key); });
return std::make_pair(before.size() - retained,
after.size() - retained);
};
<<
"Step " << step <<
"/" <<
stretchSteps <<
": tetrahedra removed "
<<
"; skin triangles removed " <<
skin.first <<
", added "
}
}
}
CHKERR mb.get_entities_by_handle(0, geometry);
geometry = subtract(geometry, geometry.subset_by_type(MBENTITYSET));
CHKERR mb.tag_clear_data(
field.get_basic_entity_data_ptr()->th_RefBitLevel,
geometry, &no_bits);
const EntityHandle no_parent = 0;
&no_parent);
const unsigned char unshared = 0;
CHKERR mb.tag_clear_data(pc->pstatus_tag(), geometry, &unshared);
for (
auto tag : {pc->sharedp_tag(), pc->sharedps_tag(), pc->sharedh_tag(),
pc->sharedhs_tag()}) {
const auto error =
mb.tag_delete_data(
tag, geometry);
if (error != MB_SUCCESS && error != MB_TAG_NOT_FOUND)
}
Range sets = pc->interface_sets();
sets.merge(pc->partition_sets());
delete pc;
int id = -1;
pc =
new ParallelComm(&
mb,
field.get_comm(), &
id);
"Unexpected ParallelComm index after resetting sharing");
}
if (remove.empty())
CHKERR mb.get_entities_by_type(0, MBENTITYSET, sets);
for (auto set : sets)
for (int dim = 3; dim >= 0; --dim) {
const auto batch = remove.subset_by_dimension(dim);
if (!batch.empty())
}
}
auto trim_lineage = [&]() {
const auto parent_tag =
}
for (int dim = 2; dim >= 0; --dim) {
CHKERR mb.get_adjacencies(needed.subset_by_dimension(dim + 1), dim,
false,
closure, moab::Interface::UNION);
}
if (remove.empty())
};
}
if (!
mesh.sharingReady) {
auto retain = [&]() {
if (!
field.get_comm_rank())
const auto cells =
mesh.entities.subset_by_type(MBTET);
for (
auto cell :
cells) {
owned.insert(cell);
}
moab::Interface::UNION);
Range owned_faces, face_cells;
for (
auto face :
mesh.entities.subset_by_type(MBTRI)) {
owned_faces.insert(face);
}
CHKERR mb.get_adjacencies(owned_faces, 3,
false, face_cells,
moab::Interface::UNION);
halo.merge(face_cells);
halo = intersect(halo,
cells);
for (int dim : {0, 1, 2}) {
CHKERR mb.get_adjacencies(halo.subset_by_type(MBTET), dim,
false,
}
Range protected_entities = preserve;
protected_entities.merge(halo);
mesh.entities,
mesh.activeBit, protected_entities);
};
mesh.sharingReady =
true;
}
int owned = 0, invalid = 0;
for (
auto cell :
mesh.entities.subset_by_type(MBTET)) {
}
int global_owned, root_cells =
mesh.entities.num_of_type(MBTET);
CHKERR MPI_Allreduce(&owned, &global_owned, 1, MPI_INT, MPI_SUM,
CHKERR MPI_Bcast(&root_cells, 1, MPI_INT, 0,
field.get_comm());
CHKERR testing_ptr->checkValue<TestType::SCALAR>(
"root retains every owned cell", root_cells, global_owned, zero);
CHKERR testing_ptr->checkValue<TestType::SCALAR>(
"off-partition residents are ghost cells", invalid, 0, zero);
CHKERR pc->check_all_shared_handles();
}
std::vector<std::array<int, 3>> keys;
auto find_interior = [&]() {
if (
field.get_comm_rank())
const auto tets =
mesh.entities.subset_by_type(MBTET);
CHKERR mb.get_adjacencies(tets, 2,
true,
faces, moab::Interface::UNION);
const EntityHandle *conn;
std::array<int, 3> ids;
CHKERR mb.get_connectivity(face, conn,
n,
true);
CHKERR mb.tag_get_data(
mb.globalId_tag(), conn, 3, ids.data());
std::sort(ids.begin(), ids.end());
keys.push_back(ids);
}
if (keys.size() > static_cast<size_t>(INT_MAX) / 3)
"Skeleton exceeds MPI count range");
};
int count = keys.size();
CHKERR MPI_Bcast(&count, 1, MPI_INT, 0,
field.get_comm());
keys.resize(count);
CHKERR MPI_Bcast(keys.data(), 3 * count, MPI_INT, 0,
field.get_comm());
const std::set<std::array<int, 3>> interior(keys.begin(), keys.end());
auto select_skeleton = [&]() {
for (
auto face :
mesh.entities.subset_by_type(MBTRI)) {
const EntityHandle *conn;
std::array<int, 3> ids;
CHKERR mb.get_connectivity(face, conn,
n,
true);
CHKERR mb.tag_get_data(
mb.globalId_tag(), conn, 3, ids.data());
std::sort(ids.begin(), ids.end());
if (interior.count(ids))
skeleton.insert(face);
}
};
mesh.registrationChanged =
false;
}
PetscInt step = 0) {
auto &m_field =
mesh.field;
const auto &entities =
mesh.entities;
if (step)
name <<
"_" << std::setw(4) << std::setfill(
'0') << step;
auto write = [&]() {
if (!distributed && m_field.get_comm_rank())
auto &
mb = m_field.get_moab();
EntityHandle selection;
CHKERR mb.create_meshset(MESHSET_SET, selection);
CHKERR mb.add_entities(selection, entities);
CHKERR mb.tag_get_handle(
"FUN3_HYBRID_COUNTS", 5, MB_TYPE_DOUBLE,
summary_tag, MB_TAG_SPARSE | MB_TAG_CREAT);
CHKERR mb.tag_set_data(summary_tag, &selection, 1,
mesh.hybrid.summary.data());
auto tag = pc->part_tag();
CHKERR mb.get_entities_by_type_and_tag(0, MBENTITYSET, &
tag,
nullptr, 1,
parts);
CHKERR mb.add_entities(selection, parts);
distributed ? "PARALLEL=WRITE_PART" : "", &selection,
1);
CHKERR mb.delete_entities(&selection, 1);
};
}
};
int main(
int argc,
char *argv[]) {
&argc, &argv, nullptr,
"Sphere, partition, stretch, twist and reconstruct a mesh\n");
try {
CHKERR SDFPython::initialise();
{
}
}
return 0;
}
CGALInterfaceImpl & owner
std::vector< std::array< EntityHandle, 3 > > faces
Sorted keys.
bool angle
Radians between candidate face and target plane.
std::vector< int > vertices
std::vector< int > parent
bool closure
The face (f0, f1, w) closes a corner at f0 or f1.
std::vector< Cell > cells
Reusable hybrid algebra and graph validation for FUN-3.
#define CATCH_ERRORS
Catch errors.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#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_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
#define MOFEM_LOG(channel, severity)
Log.
const double c
speed of light (cm/ns)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
implementation of Data Operators for Forces and Sources
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
PetscErrorCode PetscOptionsGetReal(PetscOptions *, const char pre[], const char name[], PetscReal *dval, PetscBool *set)
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
Fun3::HybridProblem hybrid
std::unique_ptr< Mesh > currentPtr
TetMeshData reconstructed
MoFEMErrorCode rebuildHybrid(Mesh &mesh, const std::string &tag)
MoFEMErrorCode deleteGeometry(const Range &remove)
MoFEMErrorCode generateSphere()
CGALTools::ImplicitMeshSettings settings
MoFEMErrorCode distributeSphere()
MoFEMErrorCode reconstructOnRoot(PetscInt step)
static auto skinKeys(const TetMeshData &mesh)
MoFEMErrorCode reconstructMesh(PetscInt step)
MoFEMErrorCode saveStage(Mesh &mesh, const char *stage, bool distributed, PetscInt step=0)
static auto cellKeys(const TetMeshData &mesh)
MoFEMErrorCode readOptions()
MoFEMErrorCode synchroniseMesh()
MoFEMErrorCode resetMeshForImport()
MoFEMErrorCode deformMesh(PetscInt step)
MoFEMErrorCode partitionSphere()
MoFEMErrorCode agree(MoFEMErrorCode local_error)
MoFEMErrorCode prepareDistributed(Mesh &mesh, const Range &preserve={})
std::array< double, 3 > scale
Retain the parent/sub-DMs, field DOFs and block storage across mesh edits.
Tag get_th_RefParentHandle() const
virtual CGALTools & getTools()=0
virtual MoFEMErrorCode importMesh(const TetMeshData &data, BitRefLevel bit, Range &entities, EntityHandle &volume, EntityHandle &surface)=0
virtual MoFEMErrorCode reconstructDelaunay(const Range &source_entities, BitRefLevel output_bit, Range &entities, CGALTools::ReconstructionMethod method=CGALTools::ReconstructionMethod::PointDelaunay)=0
MoFEMErrorCode inheritPartitions(const Range &source_entities, const Range &child_entities)
MoFEMErrorCode gatherMesh(const Range &cells, TetMeshData &data, int root=0)
MoFEMErrorCode broadcastMesh(TetMeshData &data, int root=0)
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.
Mesh refinement interface.
MoFEMErrorCode setTopologicalParents(const Range &source_entities, const Range &child_entities, const BitRefLevel &output_bit, int verb=QUIET, const std::map< EntityHandle, EntityHandle > &moved_vertices={})
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
#ifndef FUN3_HYBRID_PROBLEM_HPP
#define FUN3_HYBRID_PROBLEM_HPP
#include <unordered_map>
const Range &tets, Mat matrix,
double &nonzeros) {
std::unordered_map<EntityHandle, std::vector<PetscInt>> face_dofs;
for (auto &dof : *problem_ptr->getNumeredColDofsPtr())
if (dof->getPetscGlobalDofIdx() >= 0)
face_dofs[dof->getEnt()].push_back(dof->getPetscGlobalDofIdx());
std::unordered_map<EntityHandle, std::vector<PetscInt>> neighbors;
for (auto tet : tets) {
std::vector<PetscInt> columns;
for (
auto face :
faces) {
auto it = face_dofs.find(face);
if (
it != face_dofs.end())
columns.insert(columns.end(),
it->second.begin(),
it->second.end());
}
if (face_dofs.count(face)) {
auto &adj = neighbors[face];
adj.insert(adj.end(), columns.begin(), columns.end());
}
}
PetscInt first_row, last_row;
CHKERR MatGetOwnershipRange(matrix, &first_row, &last_row);
MatInfo before;
CHKERR MatGetInfo(matrix, MAT_GLOBAL_SUM, &before);
CHKERR MatSetOption(matrix, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_TRUE);
double local_nnz = 0, root_nnz = 0;
for (auto &entry : neighbors) {
auto &columns = entry.second;
std::sort(columns.begin(), columns.end());
columns.erase(std::unique(columns.begin(), columns.end()), columns.end());
const PetscInt nb_cols = columns.size();
root_nnz +=
static_cast<double>(nb_cols) * face_dofs.at(entry.first).size();
const std::vector<PetscScalar>
values(nb_cols, 1.);
for (
auto row : face_dofs.at(entry.first))
if (
row >= first_row &&
row < last_row) {
local_nnz += nb_cols;
values.data(), INSERT_VALUES);
}
}
double expected_nnz;
CHKERR MPI_Allreduce(&local_nnz, &expected_nnz, 1, MPI_DOUBLE, MPI_SUM,
tag +
" distributed graph equals complete root graph", expected_nnz,
root_nnz, zero);
tag +
" hybrid allocation covers topology non-zeros",
before.nz_allocated >= expected_nnz ? 0 : 1, 0, zero);
tag +
" serial hybrid allocation is exact", before.nz_allocated,
expected_nnz, zero);
CHKERR MatAssemblyBegin(matrix, MAT_FINAL_ASSEMBLY);
CHKERR MatAssemblyEnd(matrix, MAT_FINAL_ASSEMBLY);
MatInfo after;
CHKERR MatGetInfo(matrix, MAT_GLOBAL_SUM, &after);
nonzeros = after.nz_used;
tag +
" hybrid filled non-zeros equal topology", nonzeros, expected_nnz,
zero);
tag +
" hybrid fill without reallocations", after.mallocs, before.mallocs,
zero);
PetscBool missing;
PetscInt missing_row;
CHKERR MatMissingDiagonal(matrix, &missing, &missing_row);
tag +
" hybrid diagonal exists in every row", missing ? 1 : 0, 0, zero);
}
struct HybridProblem {
std::array<PetscObjectId, 3>
dmIds{};
if (dm) {
CHKERR DMClearGlobalVectors(dm);
CHKERR DMClearLocalVectors(dm);
CHKERR DMClearNamedGlobalVectors(dm);
CHKERR DMClearNamedLocalVectors(dm);
}
}
for (
const auto &
name : {
"SCHUR",
"BLOCK"})
if (parent_dm_ptr) {
parent_dm_ptr.reset();
}
}
const std::vector<std::string> &fields,
const bool update =
bool(dm);
if (!update) {
for (
const auto &
field : fields) {
}
}
if (update)
else
}
return {
{{"BROKEN", "BROKEN"}, {"U", "U"}, {"BROKEN", "U"}, {"U", "BROKEN"}}},
{{"BROKEN", "HYBRID"}, {"HYBRID", "BROKEN"}}}};
}
bool refresh_registration) {
1);
}
if (!update || refresh_registration) {
Range new_field_entities;
for (
const auto &
name : {
"BROKEN",
"U",
"HYBRID"}) {
registered);
const auto &keep = std::string(
name) ==
"HYBRID" ? skeleton : entities;
const auto removed = subtract(registered, keep);
registered = intersect(registered, keep);
const int dim = std::string(
name) ==
"HYBRID" ? 2 : 3;
const auto added = subtract(keep.subset_by_dimension(dim), registered);
CHKERR comm_ptr->synchroniseFieldEntities(
name, 0);
current);
const auto new_entities =
update ? subtract(current, registered) : current;
if (!new_entities.empty())
new_field_entities.merge(new_entities);
}
for (
const auto &[
name, keep] :
continue;
const auto removed = subtract(registered, keep);
}
if (!update)
}
if (!update)
if (update) {
problems_ptr->buildProblemFromFields = PETSC_TRUE;
problems_ptr->buildProblemFromFields = from_fields;
} else
if (reuse)
else {
}
if (reuse)
else
{nullptr, nullptr}, true);
}
"Build the hybrid problem before validating it");
auto fresh_block_ptr =
{nullptr, nullptr}, true);
auto compare = [&](const std::string &what, auto rebuilt_ptr,
auto fresh_ptr) {
if (
r.nbBlocks !=
f.nbBlocks ||
r.nbElems !=
f.nbElems ||
r.indexHash !=
f.indexHash ||
r.blocksHash !=
f.blocksHash ||
r.elemsHash !=
f.elemsHash)
<< what <<
" digest: blocks " <<
r.nbBlocks <<
"/" <<
f.nbBlocks
<<
", elements " <<
r.nbElems <<
"/" <<
f.nbElems <<
", index "
<<
r.indexHash <<
"/" <<
f.indexHash <<
", layout "
<<
r.blocksHash <<
"/" <<
f.blocksHash <<
", element layout "
<<
r.elemsHash <<
"/" <<
f.elemsHash;
tag +
" rebuilt " + what +
" equals fresh structure",
r.nbBlocks ==
f.nbBlocks &&
r.nbElems ==
f.nbElems &&
r.indexHash ==
f.indexHash &&
r.blocksHash ==
f.blocksHash &&
r.elemsHash ==
f.elemsHash
? 0
: 1,
};
for (
int q = 0;
q != 4; ++
q)
CHKERR compare(
"quadrant " + std::to_string(
q),
std::get<1>(*fresh_nested_ptr)[
q]);
}
int dm_index = 0;
for (DM dm :
PetscObjectId id;
CHKERR PetscObjectGetId(
reinterpret_cast<PetscObject
>(dm), &
id);
CHKERR testing_ptr->checkValue<TestType::SCALAR>(
tag +
" DM " + std::to_string(dm_index) +
" identity retained",
id ==
dmIds[dm_index] ? 0 : 1, 0, zero);
++dm_index;
}
int field_index = 0;
for (
const auto &
name : {
"BROKEN",
"U",
"HYBRID"}) {
int identity_error = 0;
if (old_ptr) {
auto it = dofs.find(old_ptr->getLocalUniqueId());
(*it)->getFieldEntityPtr() == old_ptr->getFieldEntityPtr())
identity_error = *
it == old_ptr ? 0 : 1;
}
CHKERR testing_ptr->checkValue<TestType::SCALAR>(
tag +
" surviving " +
name +
" DOF identity retained", identity_error,
0, zero);
old_ptr =
it != dofs.end() && (*it)->getBitNumber() == bit_number
: nullptr;
}
int counts[2] = {static_cast<int>(entities.num_of_type(MBTET)),
static_cast<int>(skeleton.size())};
const double broken =
const double parent_rows = block_rows + schur_rows;
for (const auto &[dm, expected] :
CHKERR testing_ptr->checkValue<TestType::SCALAR>(
tag +
" DM DOFs match complete root topology",
CHKERR VecGetOwnershipRange(vector, &first, &last);
CHKERR testing_ptr->checkValue<TestType::SCALAR>(
tag +
" DM vector global size",
n, expected, zero);
CHKERR testing_ptr->checkValue<TestType::SCALAR>(
tag +
" DM vector local size", last - first,
}
for (const auto &[matrix, expected] :
CHKERR testing_ptr->checkValue<TestType::SCALAR>(
tag +
" matrix rows",
m,
expected, zero);
CHKERR testing_ptr->checkValue<TestType::SCALAR>(
tag +
" matrix columns",
}
double nnz;
summary = {
static_cast<double>(
order), parent_rows, block_rows, schur_rows,
nnz};
<<
"Hybrid rebuilt " <<
tag
<< ": parent " << parent_rows << ", BLOCK " << block_rows << ", SCHUR "
<< schur_rows << ", nonzeros " << nnz;
}
};
}
#endif
std::vector< int > removed
std::vector< FieldBitNumber > row
SmartPetscObj< Vec > values
@ L2
field with C-1 continuity
@ HDIV
field with continuous normal traction
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 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.
PetscErrorCode DMMoFEMSetSquareProblem(DM dm, PetscBool square_problem)
set squared problem
PetscErrorCode DMMoFEMGetProblemPtr(DM dm, const MoFEM::Problem **problem_ptr)
Get pointer to problem data structure.
PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, const char field_name[])
auto createDMVector(DM dm, RowColData rc=RowColData::COL)
Get smart vector from DM.
PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, const char field_name[])
PetscErrorCode DMSubDMSetUp_MoFEM(DM subdm)
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
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.
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
SchurBlockStructureDigest schurBlockStructureDigest(boost::shared_ptr< BlockStructure > data_ptr)
PetscErrorCode DMMoFEMSetDestroyProblem(DM dm, PetscBool destroy_problem)
std::pair< SmartPetscObj< Mat >, boost::shared_ptr< NestSchurData > > createSchurNestedMatrix(boost::shared_ptr< NestSchurData > schur_net_data_ptr)
Create a Mat Diag Blocks object.
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.
auto createDMHybridisedL2Matrix(DM dm)
Get smart hybridised L2 matrix from DM.
boost::shared_ptr< BlockStructure > createBlockMatStructure(DM dm, SchurFEOpsFEandFields schur_fe_op_vec)
Create block matrix structure.
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].
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.
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.
std::vector< std::pair< std::string, std::vector< SchurFieldPair > > > SchurFEOpsFEandFields
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.
FTensor::Index< 'm', 3 > m
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(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
PetscBool rebuildStructures
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
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
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.
Problem manager is used to build and partition problems.
PetscBool buildProblemFromFields
Simple interface for fast problem set-up.
MoFEMErrorCode buildProblem()
Build problem.
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.
bool & getAddBoundaryFE()
Get the addBoundaryFE flag.
MoFEMErrorCode defineFiniteElements()
Define finite elements.
EntityHandle & getMeshset()
Get the MeshSet object.
auto & getBitAdjParent()
Get bit ref level for parent.
MoFEMErrorCode buildFiniteElements()
Build finite elements.
const std::string getSkeletonFEName() const
Get the Skeleton FE Name.
EntityHandle & getSkeletonMeshSet()
Get the SkeletonMeshSet object.
void setDim(int dim)
Set the problem dimension.
MoFEMErrorCode getDM(DM *dm)
Get DM.
auto & getBitAdjEnt()
Get bit ref level for entities.
MoFEMErrorCode setFieldOrder(const std::string field_name, const int order, const Range *ents=NULL)
Set field order.
MoFEMErrorCode defineProblem(const PetscBool is_partitioned=PETSC_TRUE)
define problem
BitRefLevel & getBitRefLevelMask()
Get the BitRefLevelMask.
const std::string getDomainFEName() const
Get the Domain FE Name.
MoFEMErrorCode setSkeletonAdjacency(int dim=-1, std::string fe_name="")
Set the skeleton adjacency object.
MoFEMErrorCode deleteDM()
Delete dm.
BitRefLevel & getBitRefLevel()
Get the BitRefLevel.
MoFEMErrorCode deleteFiniteElements()
Delete finite elements.
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.
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.
intrusive_ptr for managing petsc objects