v0.15.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Private Attributes | List of all members
MoFEM::ProblemsManager Struct Reference

Problem manager is used to build and partition problems. More...

#include "src/interfaces/ProblemsManager.hpp"

Inheritance diagram for MoFEM::ProblemsManager:
[legend]
Collaboration diagram for MoFEM::ProblemsManager:
[legend]

Public Types

enum  MarkOP { OR , AND }
 

Public Member Functions

MoFEMErrorCode query_interface (boost::typeindex::type_index type_index, UnknownInterface **iface) const
 
 ProblemsManager (const MoFEM::Core &core)
 
virtual ~ProblemsManager ()=default
 
MoFEMErrorCode getOptions ()
 Get command line options for ProblemsManager.
 
DEPRECATED MoFEMErrorCode partitionMesh (const Range &ents, const int dim, const int adj_dim, const int n_parts, Tag *th_vertex_weights=nullptr, Tag *th_edge_weights=nullptr, Tag *th_part_weights=nullptr, int verb=VERBOSE, const bool debug=false)
 Set partition tag to each finite element in the problem.
 
MoFEMErrorCode buildProblem (const std::string name, const bool square_matrix, int verb=VERBOSE)
 build problem data structures
 
MoFEMErrorCode buildProblem (Problem *problem_ptr, const bool square_matrix, int verb=VERBOSE)
 build problem data structures
 
MoFEMErrorCode buildProblemOnDistributedMesh (const std::string name, const bool square_matrix, int verb=VERBOSE)
 build problem data structures, assuming that mesh is distributed (collective)
 
MoFEMErrorCode buildProblemOnDistributedMesh (Problem *problem_ptr, const bool square_matrix=true, int verb=VERBOSE)
 build problem data structures, assuming that mesh is distributed (collective)
 
MoFEMErrorCode buildSubProblem (const std::string out_name, const std::vector< std::string > &fields_row, const std::vector< std::string > &fields_col, const std::string main_problem, const bool square_matrix=true, const map< std::string, boost::shared_ptr< Range > > *entityMapRow=nullptr, const map< std::string, boost::shared_ptr< Range > > *entityMapCol=nullptr, int verb=VERBOSE)
 build sub problem
 
MoFEMErrorCode buildComposedProblem (const std::string out_name, const std::vector< std::string > add_row_problems, const std::vector< std::string > add_col_problems, const bool square_matrix=true, int verb=1)
 build composite problem
 
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
 
MoFEMErrorCode partitionSimpleProblem (const std::string name, int verb=VERBOSE)
 partition problem dofs
 
MoFEMErrorCode partitionProblem (const std::string name, int verb=VERBOSE)
 partition problem dofs (collective)
 
MoFEMErrorCode printPartitionedProblem (const Problem *problem_ptr, int verb=VERBOSE)
 Print partition information for debugging.
 
MoFEMErrorCode debugPartitionedProblem (const Problem *problem_ptr, int verb=VERBOSE)
 Debug partition information.
 
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
 
MoFEMErrorCode partitionGhostDofs (const std::string name, int verb=VERBOSE)
 determine ghost nodes
 
MoFEMErrorCode partitionGhostDofsOnDistributedMesh (const std::string name, int verb=VERBOSE)
 determine ghost nodes on distributed meshes
 
MoFEMErrorCode getFEMeshset (const std::string prb_name, const std::string &fe_name, EntityHandle *meshset) const
 Create finite element meshset for the problem.
 
MoFEMErrorCode getProblemElementsLayout (const std::string name, const std::string &fe_name, PetscLayout *layout) const
 Get layout of elements in the problem.
 
MoFEMErrorCode removeDofsOnEntities (const std::string problem_name, const std::string field_name, const Range ents, const int lo_coeff=0, const int hi_coeff=MAX_DOFS_ON_ENTITY, const int lo_order=0, const int hi_order=100, int verb=VERBOSE, const bool debug=false)
 Remove DOFs from problem.
 
MoFEMErrorCode removeDofsOnEntitiesNotDistributed (const std::string problem_name, const std::string field_name, const Range ents, const int lo_coeff=0, const int hi_coeff=MAX_DOFS_ON_ENTITY, const int lo_order=0, const int hi_order=100, int verb=VERBOSE, const bool debug=false)
 Remove DOFs from problem.
 
MoFEMErrorCode removeDofsOnEntities (const std::string problem_name, const std::string field_name, const BitRefLevel bit_ref_level, const BitRefLevel bit_ref_mask, Range *ents_ptr=nullptr, const int lo_coeff=0, const int hi_coeff=MAX_DOFS_ON_ENTITY, const int lo_order=0, const int hi_order=100, int verb=VERBOSE, const bool debug=false)
 Remove DOFs from problem by bit ref level.
 
MoFEMErrorCode removeDofsOnEntitiesNotDistributed (const std::string problem_name, const std::string field_name, const BitRefLevel bit_ref_level, const BitRefLevel bit_ref_mask, Range *ents_ptr=nullptr, const int lo_coeff=0, const int hi_coeff=MAX_DOFS_ON_ENTITY, const int lo_order=0, const int hi_order=100, int verb=VERBOSE, const bool debug=false)
 Remove DOFs from problem.
 
MoFEMErrorCode removeDofs (const std::string problem_name, RowColData rc, std::vector< boost::weak_ptr< NumeredDofEntity > > &vec_dof_view, int verb=VERBOSE, const bool debug=false)
 Remove DOFs from problem on broken space.
 
MoFEMErrorCode getSideDofsOnBrokenSpaceEntities (std::vector< boost::weak_ptr< NumeredDofEntity > > &vec_dof_view, const std::string problem_name, RowColData rc, const std::string field_name, const Range ents, int bridge_dim, const int lo_coeff=0, const int hi_coeff=MAX_DOFS_ON_ENTITY, const int lo_order=0, const int hi_order=100, int verb=VERBOSE, const bool debug=false) const
 Get DOFs on side entities for broken space.
 
MoFEMErrorCode markDofs (const std::string problem_name, RowColData rc, const enum MarkOP op, const Range ents, std::vector< unsigned char > &marker) const
 Create vector with marked indices.
 
DEPRECATED MoFEMErrorCode markDofs (const std::string problem_name, RowColData rc, const Range ents, std::vector< unsigned char > &marker) const
 
MoFEMErrorCode modifyMarkDofs (const std::string problem_name, RowColData rc, const std::string field_name, const int lo, const int hi, const enum MarkOP op, const unsigned char c, std::vector< unsigned char > &marker) const
 Modify DOF markers for specific field and coefficient range.
 
MoFEMErrorCode markDofs (const std::string problem_name, RowColData rc, std::vector< boost::weak_ptr< NumeredDofEntity > > &vec_dof_view, const enum MarkOP op, std::vector< unsigned char > &marker) const
 Create vector with marked DOF indices based on DOF view.
 
MoFEMErrorCode addFieldToEmptyFieldBlocks (const std::string problem_name, const std::string row_field, const std::string col_field) const
 Add empty field blocks to optimize matrix storage.
 
- Public Member Functions inherited from MoFEM::UnknownInterface
template<class IFACE >
MoFEMErrorCode registerInterface (bool error_if_registration_failed=true)
 Register interface.
 
template<class IFACE >
MoFEMErrorCode getInterface (IFACE *&iface) const
 Get interface reference to pointer of interface.
 
template<class IFACE >
MoFEMErrorCode getInterface (IFACE **const iface) const
 Get interface pointer to pointer of interface.
 
template<class IFACE , typename boost::enable_if< boost::is_pointer< IFACE >, int >::type = 0>
IFACE getInterface () const
 Get interface pointer to pointer of interface.
 
template<class IFACE , typename boost::enable_if< boost::is_reference< IFACE >, int >::type = 0>
IFACE getInterface () const
 Get reference to interface.
 
template<class IFACE >
IFACE * getInterface () const
 Function returning pointer to interface.
 
virtual ~UnknownInterface ()=default
 

Public Attributes

MoFEM::CorecOre
 
PetscBool buildProblemFromFields
 
PetscBool synchroniseProblemEntities
 DOFs in fields, not from DOFs on elements.
 

Private Attributes

PetscLogEvent MOFEM_EVENT_ProblemsManager
 

Additional Inherited Members

- Static Public Member Functions inherited from MoFEM::UnknownInterface
static MoFEMErrorCode getLibVersion (Version &version)
 Get library version.
 
static MoFEMErrorCode getFileVersion (moab::Interface &moab, Version &version)
 Get database major version.
 
static MoFEMErrorCode setFileVersion (moab::Interface &moab, Version version=Version(MoFEM_VERSION_MAJOR, MoFEM_VERSION_MINOR, MoFEM_VERSION_BUILD))
 Get database major version.
 
static MoFEMErrorCode getInterfaceVersion (Version &version)
 Get database major version.
 

Detailed Description

Problem manager is used to build and partition problems.

Overview

The ProblemsManager serves as the central interface for creating, configuring, and managing finite element problems within the MoFEM framework. It acts as a bridge between the Core interface (which manages the fundamental MoFEM data structures like fields, finite elements, and DOFs) and the PETSc Discrete Manager (DM) system for parallel computing.

Connection to Core Interface

The ProblemsManager operates on top of the MoFEM::Core interface:

Integration with PETSc Discrete Manager (DM)

The ProblemsManager creates and configures PETSc DM objects:

Distributed vs Non-Distributed Meshes

Non-Distributed Meshes

Distributed Meshes <br>

Problem Types

Sub-Problems

Composite Problems

Broken DOFs (Discontinuous Spaces)

Broken DOFs support discontinuous finite element spaces:

DOF Removal Operations

DOF removal serves multiple purposes:

Boundary Condition Enforcement

Model Reduction

Numerical Efficiency

The removal process:

  1. Identification: Mark DOFs for removal based on criteria
  2. Dependency Check: Verify no essential DOFs depend on removed ones
  3. Index Renumbering: Compact DOF indices to eliminate gaps
  4. Matrix/Vector Update: Adjust PETSc data structures accordingly
  5. Solver Configuration: Update preconditioners and solver contexts

Typical Workflow

  1. Problem Definition: Define fields, finite elements, and DOFs via Core
  2. Problem Building: Use buildProblem*() to create Problem object
  3. Partitioning: Apply partition*() functions for parallel distribution
  4. Ghost Setup: Configure ghost DOFs for parallel assembly
  5. Constraint Application: Remove DOFs for boundary conditions
  6. DM Creation: Generate PETSc DM for solver integration
  7. Matrix Assembly: Use Problem for parallel finite element assembly
Examples
mofem/atom_tests/boundary_marker.cpp, mofem/atom_tests/build_composite_problem.cpp, mofem/atom_tests/build_large_problem.cpp, mofem/atom_tests/build_problems.cpp, mofem/atom_tests/child_and_parent.cpp, mofem/atom_tests/continuity_check_on_contact_prism_side_ele.cpp, mofem/atom_tests/continuity_check_on_skeleton_3d.cpp, mofem/atom_tests/forces_and_sources_testing_edge_element.cpp, mofem/atom_tests/forces_and_sources_testing_flat_prism_element.cpp, mofem/atom_tests/forces_and_sources_testing_users_base.cpp, mofem/atom_tests/hanging_node_approx.cpp, mofem/atom_tests/hcurl_divergence_operator_2d.cpp, mofem/atom_tests/mesh_insert_interface_atom.cpp, mofem/atom_tests/prism_elements_from_surface.cpp, mofem/atom_tests/prism_polynomial_approximation.cpp, mofem/atom_tests/quad_polynomial_approximation.cpp, mofem/atom_tests/remove_entities_from_problem.cpp, mofem/atom_tests/remove_entities_from_problem_not_partitioned.cpp, mofem/atom_tests/test_cache_on_entities.cpp, mofem/tutorials/adv-2/thermo_elastic.cpp, mofem/tutorials/adv-3/level_set.cpp, mofem/tutorials/adv-5/seepage.cpp, mofem/tutorials/clx-0/helmholtz.cpp, mofem/tutorials/cor-9/reaction_diffusion.cpp, mofem/tutorials/mix-0/mixed_poisson.cpp, mofem/tutorials/scl-10/initial_diffusion.cpp, mofem/tutorials/scl-10/photon_diffusion.cpp, mofem/tutorials/scl-9/heat_method.cpp, mofem/tutorials/vec-5/free_surface.cpp, mofem/tutorials/vec-6/plate.cpp, mofem/tutorials/vec-7/adjoint.cpp, mofem/users_modules/basic_finite_elements/nonlinear_elasticity/nonlinear_dynamics.cpp, mofem/users_modules/bone_remodelling/src/impl/Remodeling.cpp, and mofem/users_modules/eshelbian_plasticity/src/impl/EshelbianPlasticity.cpp.

Definition at line 133 of file ProblemsManager.hpp.

Member Enumeration Documentation

◆ MarkOP

Enumerator
OR 
AND 

Definition at line 598 of file ProblemsManager.hpp.

Constructor & Destructor Documentation

◆ ProblemsManager()

MoFEM::ProblemsManager::ProblemsManager ( const MoFEM::Core core)

Definition at line 55 of file ProblemsManager.cpp.

56 : cOre(const_cast<MoFEM::Core &>(core)),
57 buildProblemFromFields(PETSC_FALSE),
58 synchroniseProblemEntities(PETSC_FALSE) {
59 PetscLogEventRegister("ProblemsManager", 0, &MOFEM_EVENT_ProblemsManager);
60}
Core (interface) class.
Definition Core.hpp:82
PetscLogEvent MOFEM_EVENT_ProblemsManager
PetscBool synchroniseProblemEntities
DOFs in fields, not from DOFs on elements.

◆ ~ProblemsManager()

virtual MoFEM::ProblemsManager::~ProblemsManager ( )
virtualdefault

Member Function Documentation

◆ markDofs() [1/2]

MoFEMErrorCode MoFEM::ProblemsManager::markDofs ( const std::string  problem_name,
RowColData  rc,
const enum MarkOP  op,
const Range  ents,
std::vector< unsigned char > &  marker 
) const

Create vector with marked indices.

Vector with local DOFs marked by entities

Parameters
problem_name
row
ents
marker
Returns
MoFEMErrorCode
Examples
mofem/atom_tests/boundary_marker.cpp, mofem/atom_tests/test_cache_on_entities.cpp, and mofem/tutorials/clx-0/helmholtz.cpp.

Definition at line 3553 of file ProblemsManager.cpp.

3555 {
3556
3557 Interface &m_field = cOre;
3558 const Problem *problem_ptr;
3560 CHKERR m_field.get_problem(problem_name, &problem_ptr);
3561 boost::shared_ptr<NumeredDofEntity_multiIndex> dofs;
3562 switch (rc) {
3563 case ROW:
3564 dofs = problem_ptr->getNumeredRowDofsPtr();
3565 break;
3566 case COL:
3567 dofs = problem_ptr->getNumeredColDofsPtr();
3568 default:
3569 SETERRQ(PETSC_COMM_SELF, MOFEM_IMPOSSIBLE_CASE, "Should be row or column");
3570 }
3571 marker.resize(dofs->size(), 0);
3572 std::vector<unsigned char> marker_tmp;
3573
3574 switch (op) {
3575 case MarkOP::OR:
3576 for (auto p = ents.pair_begin(); p != ents.pair_end(); ++p) {
3577 auto lo = dofs->get<Ent_mi_tag>().lower_bound(p->first);
3578 auto hi = dofs->get<Ent_mi_tag>().upper_bound(p->second);
3579 for (; lo != hi; ++lo) {
3580 if ((*lo)->getPetscLocalDofIdx() < 0)
3581 continue;
3582 marker[(*lo)->getPetscLocalDofIdx()] |= 1;
3583 }
3584 }
3585 break;
3586 case MarkOP::AND:
3587 marker_tmp.resize(dofs->size(), 0);
3588 for (auto p = ents.pair_begin(); p != ents.pair_end(); ++p) {
3589 auto lo = dofs->get<Ent_mi_tag>().lower_bound(p->first);
3590 auto hi = dofs->get<Ent_mi_tag>().upper_bound(p->second);
3591 for (; lo != hi; ++lo) {
3592 if ((*lo)->getPetscLocalDofIdx() < 0)
3593 continue;
3594 marker_tmp[(*lo)->getPetscLocalDofIdx()] = 1;
3595 }
3596 }
3597 for (int i = 0; i != marker.size(); ++i) {
3598 marker[i] &= marker_tmp[i];
3599 }
3600 break;
3601 }
3602
3604}
#define ProblemManagerFunctionBegin
@ COL
@ ROW
@ MOFEM_IMPOSSIBLE_CASE
Definition definitions.h:35
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
auto marker
set bit to marker
FTensor::Index< 'i', SPACE_DIM > i
DeprecatedCoreInterface Interface
MoFEMErrorCode get_problem(const std::string &problem_name, const Problem **problem_ptr) const
Get problem database (data structure)
Definition Core.cpp:822

◆ markDofs() [2/2]

DEPRECATED MoFEMErrorCode MoFEM::ProblemsManager::markDofs ( const std::string  problem_name,
RowColData  rc,
const Range  ents,
std::vector< unsigned char > &  marker 
) const
inline
Deprecated:
use function with MarkOP

Definition at line 620 of file ProblemsManager.hpp.

621 {
622 return markDofs(problem_name, rc, MarkOP::OR, ents, marker);
623 }
MoFEMErrorCode markDofs(const std::string problem_name, RowColData rc, const enum MarkOP op, const Range ents, std::vector< unsigned char > &marker) const
Create vector with marked indices.

◆ query_interface()

MoFEMErrorCode MoFEM::ProblemsManager::query_interface ( boost::typeindex::type_index  type_index,
UnknownInterface **  iface 
) const
virtual

Implements MoFEM::UnknownInterface.

Definition at line 49 of file ProblemsManager.cpp.

50 {
51 *iface = const_cast<ProblemsManager *>(this);
52 return 0;
53}
ProblemsManager(const MoFEM::Core &core)

◆ removeDofsOnEntitiesNotDistributed() [1/2]

MoFEMErrorCode MoFEM::ProblemsManager::removeDofsOnEntitiesNotDistributed ( const std::string  problem_name,
const std::string  field_name,
const BitRefLevel  bit_ref_level,
const BitRefLevel  bit_ref_mask,
Range ents_ptr = nullptr,
const int  lo_coeff = 0,
const int  hi_coeff = MAX_DOFS_ON_ENTITY,
const int  lo_order = 0,
const int  hi_order = 100,
int  verb = VERBOSE,
const bool  debug = false 
)

Remove DOFs from problem.

Remove DOFs from problem which are on entities on the given range and given field name. On the finite element level, DOFs can be still accessed however local PETSc indices and global PETSc indices are marked with the index -1.

Note
If the index is marked -1 it is not assembled and dropped by VecSetValues and MatSetValues.
Todo:
Not yet implemented update for AO maps and IS ranges if removed entities in composite problem or sub-problem
Parameters
problem_namename of the problem
field_namename of the field
entsentities on which DOFs are removed
lo_coefflow dof coefficient (rank)
hi_coeffhigh dof coefficient (rank)
verbverbosity level
debugto debug and seek for inconsistencies set to true
Returns
MoFEMErrorCode
Note
Use this function for non distributed meshes

Definition at line 3525 of file ProblemsManager.cpp.

3529 {
3530 MoFEM::Interface &m_field = cOre;
3532
3533 auto bit_manager = m_field.getInterface<BitRefManager>();
3534
3535 Range ents;
3536 if (ents_ptr) {
3537 ents = *ents_ptr;
3538 CHKERR bit_manager->filterEntitiesByRefLevel(bit_ref_level, bit_ref_mask,
3539 ents, verb);
3540 } else {
3541 CHKERR bit_manager->getEntitiesByRefLevel(bit_ref_level, bit_ref_mask, ents,
3542 verb);
3543 }
3544
3546 lo_coeff, hi_coeff, lo_order,
3547 hi_order, verb, debug);
3548
3550}
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
static const bool debug
constexpr auto field_name
Deprecated interface functions.
MoFEMErrorCode removeDofsOnEntitiesNotDistributed(const std::string problem_name, const std::string field_name, const Range ents, const int lo_coeff=0, const int hi_coeff=MAX_DOFS_ON_ENTITY, const int lo_order=0, const int hi_order=100, int verb=VERBOSE, const bool debug=false)
Remove DOFs from problem.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.

◆ removeDofsOnEntitiesNotDistributed() [2/2]

MoFEMErrorCode MoFEM::ProblemsManager::removeDofsOnEntitiesNotDistributed ( const std::string  problem_name,
const std::string  field_name,
const Range  ents,
const int  lo_coeff = 0,
const int  hi_coeff = MAX_DOFS_ON_ENTITY,
const int  lo_order = 0,
const int  hi_order = 100,
int  verb = VERBOSE,
const bool  debug = false 
)

Remove DOFs from problem.

Remove DOFs from problem which are on entities on the given range and given field name. On the finite element level, DOFs can be still accessed however local PETSc indices and global PETSc indices are marked with the index -1.

Note
If the index is marked -1 it is not assembled and dropped by VecSetValues and MatSetValues.
Todo:
Not yet implemented update for AO maps and IS ranges if removed entities in composite problem or sub-problem
Parameters
problem_namename of the problem
field_namename of the field
entsentities on which DOFs are removed
lo_coefflow dof coefficient (rank)
hi_coeffhigh dof coefficient (rank)
verbverbosity level
debugto debug and seek for inconsistencies set to true
Returns
MoFEMErrorCode
Note
Use this function for non-distributed meshes
Examples
mofem/atom_tests/remove_entities_from_problem_not_partitioned.cpp.

Definition at line 3231 of file ProblemsManager.cpp.

3234 {
3235
3236 MoFEM::Interface &m_field = cOre;
3238
3239 const Problem *prb_ptr;
3240 CHKERR m_field.get_problem(problem_name, &prb_ptr);
3241
3242 decltype(prb_ptr->numeredRowDofsPtr) numered_dofs[2] = {
3243 prb_ptr->numeredRowDofsPtr, nullptr};
3244 if (prb_ptr->numeredRowDofsPtr != prb_ptr->numeredColDofsPtr)
3245 numered_dofs[1] = prb_ptr->numeredColDofsPtr;
3246
3247 int *nbdof_ptr[] = {&prb_ptr->nbDofsRow, &prb_ptr->nbDofsCol};
3248 int *local_nbdof_ptr[] = {&prb_ptr->nbLocDofsRow, &prb_ptr->nbLocDofsCol};
3249 int *ghost_nbdof_ptr[] = {&prb_ptr->nbGhostDofsRow, &prb_ptr->nbGhostDofsCol};
3250
3251 const int nb_init_row_dofs = prb_ptr->getNbDofsRow();
3252 const int nb_init_col_dofs = prb_ptr->getNbDofsCol();
3253 const int nb_init_loc_row_dofs = prb_ptr->getNbLocalDofsRow();
3254 // const int nb_init_loc_col_dofs = prb_ptr->getNbLocalDofsCol();
3255 const int nb_init_ghost_row_dofs = prb_ptr->getNbGhostDofsRow();
3256 const int nb_init_ghost_col_dofs = prb_ptr->getNbGhostDofsCol();
3257
3258 const std::array<int, 2> nb_init_dofs = {nb_init_row_dofs, nb_init_col_dofs};
3259
3260 for (int s = 0; s != 2; ++s)
3261 if (numered_dofs[s]) {
3262
3263 typedef multi_index_container<
3264
3265 NumeredDofEntity_multiIndex::iterator, indexed_by<sequenced<>>
3266
3267 >
3268 NumeredDofEntity_it_view_multiIndex;
3269
3270 const auto bit_number = m_field.get_field_bit_number(field_name);
3271 NumeredDofEntity_it_view_multiIndex dofs_it_view;
3272
3273 // Set -1 to global and local dofs indices
3274 for (auto pit = ents.const_pair_begin(); pit != ents.const_pair_end();
3275 ++pit) {
3276 auto lo = numered_dofs[s]->get<Unique_mi_tag>().lower_bound(
3277 DofEntity::getLoFieldEntityUId(bit_number, pit->first));
3278 auto hi = numered_dofs[s]->get<Unique_mi_tag>().upper_bound(
3279 DofEntity::getHiFieldEntityUId(bit_number, pit->second));
3280
3281 for (; lo != hi; ++lo)
3282 if ((*lo)->getDofCoeffIdx() >= lo_coeff &&
3283 (*lo)->getDofCoeffIdx() <= hi_coeff &&
3284 (*lo)->getDofOrder() >= lo_order &&
3285 (*lo)->getDofOrder() <= hi_order)
3286 dofs_it_view.emplace_back(numered_dofs[s]->project<0>(lo));
3287 }
3288
3289 if (verb > QUIET) {
3290 for (auto &dof : dofs_it_view)
3291 MOFEM_LOG("SYNC", Sev::noisy) << **dof;
3292 }
3293
3294 // set negative index
3295 auto mod = NumeredDofEntity_part_and_all_indices_change(-1, -1, -1, -1);
3296 for (auto dit : dofs_it_view) {
3297 bool success = numered_dofs[s]->modify(dit, mod);
3298 if (!success)
3299 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
3300 "can not set negative indices");
3301 }
3302
3303 // create weak view
3304 std::vector<boost::weak_ptr<NumeredDofEntity>> dosf_weak_view;
3305 dosf_weak_view.reserve(dofs_it_view.size());
3306 for (auto dit : dofs_it_view)
3307 dosf_weak_view.push_back(*dit);
3308
3309 if (verb >= NOISY)
3310 MOFEM_LOG_C("SYNC", Sev::noisy,
3311 "Number of DOFs in multi-index %d and to delete %d\n",
3312 numered_dofs[s]->size(), dofs_it_view.size());
3313
3314 // erase dofs from problem
3315 for (auto weak_dit : dosf_weak_view)
3316 if (auto dit = weak_dit.lock()) {
3317 numered_dofs[s]->erase(dit->getLocalUniqueId());
3318 }
3319
3320 if (verb >= NOISY)
3321 MOFEM_LOG_C("SYNC", Sev::noisy,
3322 "Number of DOFs in multi-index after delete %d\n",
3323 numered_dofs[s]->size());
3324
3325 // get current number of ghost dofs
3326 int nb_global_dof = 0;
3327 int nb_local_dofs = 0;
3328 int nb_ghost_dofs = 0;
3329
3330 for (auto dit = numered_dofs[s]->begin(); dit != numered_dofs[s]->end();
3331 ++dit) {
3332
3333 if ((*dit)->getDofIdx() >= 0) {
3334
3335 if ((*dit)->getPetscLocalDofIdx() >= 0 &&
3336 (*dit)->getPetscLocalDofIdx() < *(local_nbdof_ptr[s]))
3337 ++nb_local_dofs;
3338 else if ((*dit)->getPetscLocalDofIdx() >= *(local_nbdof_ptr[s]))
3339 ++nb_ghost_dofs;
3340
3341 ++nb_global_dof;
3342 }
3343 }
3344
3345 if (debug) {
3346 MPI_Allreduce(&nb_local_dofs, nbdof_ptr[s], 1, MPI_INT, MPI_SUM,
3347 m_field.get_comm());
3348 if (*(nbdof_ptr[s]) != nb_global_dof)
3349 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
3350 "Number of local DOFs do not add up %d != %d",
3351 *(nbdof_ptr[s]), nb_global_dof);
3352 }
3353
3354 *(nbdof_ptr[s]) = nb_global_dof;
3355 *(local_nbdof_ptr[s]) = nb_local_dofs;
3356 *(ghost_nbdof_ptr[s]) = nb_ghost_dofs;
3357
3358 // get indices
3359 auto get_indices_by_tag = [&](auto tag) {
3360 std::vector<int> indices;
3361 indices.resize(nb_init_dofs[s], -1);
3362 for (auto dit = numered_dofs[s]->get<Idx_mi_tag>().lower_bound(0);
3363 dit != numered_dofs[s]->get<Idx_mi_tag>().end(); ++dit) {
3364 indices[(*dit)->getDofIdx()] = decltype(tag)::get_index(dit);
3365 }
3366 return indices;
3367 };
3368
3369 auto renumber = [&](auto tag, auto &indices) {
3371 int idx = 0;
3372 for (auto dit = numered_dofs[s]->get<decltype(tag)>().lower_bound(0);
3373 dit != numered_dofs[s]->get<decltype(tag)>().end(); ++dit) {
3374 indices[(*dit)->getDofIdx()] = idx++;
3375 }
3377 };
3378
3379 auto get_sub_ao = [&](auto sub_data) {
3380 if (s == 0) {
3381 return sub_data->getSmartRowMap();
3382 } else {
3383 return sub_data->getSmartColMap();
3384 }
3385 };
3386
3387 auto set_sub_is_and_ao = [&s, &prb_ptr](auto sub_data, auto is, auto ao) {
3388 if (s == 0) {
3389 sub_data->rowIs = is;
3390 sub_data->rowMap = ao;
3391 sub_data->colIs = is;
3392 sub_data->colMap = ao;
3393 } else {
3394 sub_data->colIs = is;
3395 sub_data->colMap = ao;
3396 }
3397 };
3398
3399 auto apply_symmetry = [&s, &prb_ptr](auto sub_data) {
3400 if (s == 0) {
3401 if (prb_ptr->numeredRowDofsPtr == prb_ptr->numeredColDofsPtr) {
3402 sub_data->colIs = sub_data->getSmartRowIs();
3403 sub_data->colMap = sub_data->getSmartRowMap();
3404 }
3405 }
3406 };
3407
3408 auto set_sub_data = [&](auto &indices) {
3410 if (auto sub_data = prb_ptr->getSubData()) {
3411 // create is and then map it to main problem of sub-problem
3412 auto sub_is = createISGeneral(m_field.get_comm(), indices.size(),
3413 &*indices.begin(), PETSC_COPY_VALUES);
3414 // get old app, i.e. oroginal befor sub indices, and ao, from
3415 // app, to petsc sub indices.
3416 auto sub_ao = get_sub_ao(sub_data);
3417 CHKERR AOPetscToApplicationIS(sub_ao, sub_is);
3418 sub_ao = createAOMappingIS(sub_is, PETSC_NULLPTR);
3419 // set new sub ao
3420 set_sub_is_and_ao(sub_data, sub_is, sub_ao);
3421 apply_symmetry(sub_data);
3422 } else {
3423 prb_ptr->getSubData() = boost::make_shared<Problem::SubProblemData>();
3424 auto sub_is = createISGeneral(m_field.get_comm(), indices.size(),
3425 &*indices.begin(), PETSC_COPY_VALUES);
3426 auto sub_ao = createAOMappingIS(sub_is, PETSC_NULLPTR);
3427 // set sub is ao
3428 set_sub_is_and_ao(prb_ptr->getSubData(), sub_is, sub_ao);
3429 apply_symmetry(prb_ptr->getSubData());
3430 }
3432 };
3433
3434 auto global_indices = get_indices_by_tag(PetscGlobalIdx_mi_tag());
3435 auto local_indices = get_indices_by_tag(PetscLocalIdx_mi_tag());
3436 CHKERR set_sub_data(global_indices);
3437 CHKERR renumber(PetscGlobalIdx_mi_tag(), global_indices);
3438 CHKERR renumber(PetscLocalIdx_mi_tag(), local_indices);
3439
3440 int i = 0;
3441 for (auto dit = numered_dofs[s]->begin(); dit != numered_dofs[s]->end();
3442 ++dit) {
3443 auto idx = (*dit)->getDofIdx();
3444 if (idx >= 0) {
3445 auto mod = NumeredDofEntity_part_and_all_indices_change(
3446 (*dit)->getPart(), i++, global_indices[idx], local_indices[idx]);
3447 bool success = numered_dofs[s]->modify(dit, mod);
3448 if (!success)
3449 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
3450 "can not set negative indices");
3451 } else {
3452 auto mod = NumeredDofEntity_part_and_all_indices_change(
3453 (*dit)->getPart(), -1, -1, -1);
3454 bool success = numered_dofs[s]->modify(dit, mod);
3455 if (!success)
3456 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
3457 "can not set negative indices");
3458 }
3459 };
3460
3461 if (debug) {
3462 for (auto dof : (*numered_dofs[s])) {
3463 if (dof->getDofIdx() >= 0 && dof->getPetscGlobalDofIdx() < 0) {
3464 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
3465 "Negative global idx");
3466 }
3467 }
3468 }
3469
3470 } else {
3471
3472 *(nbdof_ptr[1]) = *(nbdof_ptr[0]);
3473 *(local_nbdof_ptr[1]) = *(local_nbdof_ptr[0]);
3474 *(ghost_nbdof_ptr[1]) = *(ghost_nbdof_ptr[0]);
3475 }
3476
3477 if (verb >= NOISY)
3479
3480 if (verb > QUIET) {
3482 "WORLD", Sev::inform,
3483 "Removed DOFs from problem %s dofs [%d / %d (before %d / %d) global]",
3484 prb_ptr->getName().c_str(), prb_ptr->getNbDofsRow(),
3485 prb_ptr->getNbDofsCol(), nb_init_row_dofs, nb_init_col_dofs);
3486 MOFEM_LOG_C("SYNC", Sev::verbose,
3487 "Removed DOFs from problem %s dofs [ %d / %d "
3488 "(before %d / %d) local, %d / %d (before %d / %d)]",
3489 prb_ptr->getName().c_str(), prb_ptr->getNbLocalDofsRow(),
3490 prb_ptr->getNbLocalDofsCol(), nb_init_loc_row_dofs,
3491 nb_init_loc_row_dofs, prb_ptr->getNbGhostDofsRow(),
3492 prb_ptr->getNbGhostDofsCol(), nb_init_ghost_row_dofs,
3493 nb_init_ghost_col_dofs);
3495 }
3497}
#define MOFEM_LOG_SYNCHRONISE(comm)
Synchronise "SYNC" channel.
#define MOFEM_LOG_C(channel, severity, format,...)
@ QUIET
@ NOISY
@ MOFEM_OPERATION_UNSUCCESSFUL
Definition definitions.h:34
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
virtual const Problem * get_problem(const std::string problem_name) const =0
Get the problem object.
#define MOFEM_LOG(channel, severity)
Log.
auto createISGeneral(MPI_Comm comm, PetscInt n, const PetscInt idx[], PetscCopyMode mode)
Creates a data structure for an index set containing a list of integers.
auto createAOMappingIS(IS isapp, IS ispetsc)
Creates an application mapping using two index sets.
MoFEM::LogManager::SeverityLevel Sev
virtual FieldBitNumber get_field_bit_number(const std::string name) const =0
get field bit number
virtual MPI_Comm & get_comm() const =0
static UId getLoFieldEntityUId(const FieldBitNumber bit, const EntityHandle ent)
static UId getHiFieldEntityUId(const FieldBitNumber bit, const EntityHandle ent)
boost::shared_ptr< NumeredDofEntity_multiIndex > numeredRowDofsPtr
store DOFs on rows for this problem

Member Data Documentation

◆ buildProblemFromFields

PetscBool MoFEM::ProblemsManager::buildProblemFromFields

If set to true, problem is build from

Definition at line 142 of file ProblemsManager.hpp.

◆ cOre

MoFEM::Core& MoFEM::ProblemsManager::cOre

Definition at line 138 of file ProblemsManager.hpp.

◆ MOFEM_EVENT_ProblemsManager

PetscLogEvent MoFEM::ProblemsManager::MOFEM_EVENT_ProblemsManager
private

Definition at line 688 of file ProblemsManager.hpp.

◆ synchroniseProblemEntities

PetscBool MoFEM::ProblemsManager::synchroniseProblemEntities

DOFs in fields, not from DOFs on elements.

Definition at line 145 of file ProblemsManager.hpp.


The documentation for this struct was generated from the following files: