v0.16.3
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 rebuildProblemOnDistributedMesh (const std::string &name, const BitRefLevel target_bit, const BitRefLevel target_mask, const bool square_matrix, int verb=VERBOSE, SmartPetscObj< IS > *old_row_indices=nullptr, SmartPetscObj< IS > *new_row_indices=nullptr)
 Rebuild a parent problem in place on a distributed mesh (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::Core & cOre
 
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/field_values_from_tags.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/tools/mesh_smoothing.cpp, mofem/tutorials/adv-3_level_set/level_set.cpp, mofem/tutorials/adv-5_poroelasticity/seepage.cpp, mofem/tutorials/clx-0_acoustics/helmholtz.cpp, mofem/tutorials/cor-12_cohesive_interface/arc_length_interface.cpp, mofem/tutorials/cor-9_reaction_diffusion/reaction_diffusion.cpp, mofem/tutorials/mix-0_mixed_poisson/mixed_poisson.cpp, mofem/tutorials/scl-9_heat_method/heat_method.cpp, mofem/tutorials/vec-5_free_surface/free_surface.cpp, mofem/tutorials/vec-6_dg_kirchhoff_plate/plate.cpp, mofem/tutorials/vec-7_shape_optimisation/adjoint.cpp, mofem/users_modules/basic_finite_elements/nonlinear_elasticity/nonlinear_dynamics.cpp, and mofem/users_modules/bone_remodelling/src/impl/Remodeling.cpp.

Definition at line 133 of file ProblemsManager.hpp.

Member Enumeration Documentation

◆ MarkOP

Enumerator
OR 
AND 

Definition at line 632 of file ProblemsManager.hpp.

Constructor & Destructor Documentation

◆ ProblemsManager()

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

Definition at line 116 of file ProblemsManager.cpp.

117 : cOre(const_cast<MoFEM::Core &>(core)),
118 buildProblemFromFields(PETSC_FALSE),
119 synchroniseProblemEntities(PETSC_FALSE) {
120 PetscLogEventRegister("ProblemsManager", 0, &MOFEM_EVENT_ProblemsManager);
121}
Core (interface) class.
Definition Core.hpp:83
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_acoustics/helmholtz.cpp.

Definition at line 3789 of file ProblemsManager.cpp.

3791 {
3792
3793 Interface &m_field = cOre;
3794 const Problem *problem_ptr;
3796 CHKERR m_field.get_problem(problem_name, &problem_ptr);
3797 boost::shared_ptr<NumeredDofEntity_multiIndex> dofs;
3798 switch (rc) {
3799 case ROW:
3800 dofs = problem_ptr->getNumeredRowDofsPtr();
3801 break;
3802 case COL:
3803 dofs = problem_ptr->getNumeredColDofsPtr();
3804 default:
3805 SETERRQ(PETSC_COMM_SELF, MOFEM_IMPOSSIBLE_CASE, "Should be row or column");
3806 }
3807 marker.resize(dofs->size(), 0);
3808 std::vector<unsigned char> marker_tmp;
3809
3810 switch (op) {
3811 case MarkOP::OR:
3812 for (auto p = ents.pair_begin(); p != ents.pair_end(); ++p) {
3813 auto lo = dofs->get<Ent_mi_tag>().lower_bound(p->first);
3814 auto hi = dofs->get<Ent_mi_tag>().upper_bound(p->second);
3815 for (; lo != hi; ++lo) {
3816 if ((*lo)->getPetscLocalDofIdx() < 0)
3817 continue;
3818 marker[(*lo)->getPetscLocalDofIdx()] |= 1;
3819 }
3820 }
3821 break;
3822 case MarkOP::AND:
3823 marker_tmp.resize(dofs->size(), 0);
3824 for (auto p = ents.pair_begin(); p != ents.pair_end(); ++p) {
3825 auto lo = dofs->get<Ent_mi_tag>().lower_bound(p->first);
3826 auto hi = dofs->get<Ent_mi_tag>().upper_bound(p->second);
3827 for (; lo != hi; ++lo) {
3828 if ((*lo)->getPetscLocalDofIdx() < 0)
3829 continue;
3830 marker_tmp[(*lo)->getPetscLocalDofIdx()] = 1;
3831 }
3832 }
3833 for (int i = 0; i != marker.size(); ++i) {
3834 marker[i] &= marker_tmp[i];
3835 }
3836 break;
3837 }
3838
3840}
#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:843

◆ 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 654 of file ProblemsManager.hpp.

655 {
656 return markDofs(problem_name, rc, MarkOP::OR, ents, marker);
657 }
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 110 of file ProblemsManager.cpp.

111 {
112 *iface = const_cast<ProblemsManager *>(this);
113 return 0;
114}
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 3761 of file ProblemsManager.cpp.

3765 {
3766 MoFEM::Interface &m_field = cOre;
3768
3769 auto bit_manager = m_field.getInterface<BitRefManager>();
3770
3771 Range ents;
3772 if (ents_ptr) {
3773 ents = *ents_ptr;
3774 CHKERR bit_manager->filterEntitiesByRefLevel(bit_ref_level, bit_ref_mask,
3775 ents, verb);
3776 } else {
3777 CHKERR bit_manager->getEntitiesByRefLevel(bit_ref_level, bit_ref_mask, ents,
3778 verb);
3779 }
3780
3782 lo_coeff, hi_coeff, lo_order,
3783 hi_order, verb, debug);
3784
3786}
#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 3457 of file ProblemsManager.cpp.

3460 {
3461
3462 MoFEM::Interface &m_field = cOre;
3464
3465 const Problem *prb_ptr;
3466 CHKERR m_field.get_problem(problem_name, &prb_ptr);
3467
3468 decltype(prb_ptr->numeredRowDofsPtr) numered_dofs[2] = {
3469 prb_ptr->numeredRowDofsPtr, nullptr};
3470 if (prb_ptr->numeredRowDofsPtr != prb_ptr->numeredColDofsPtr)
3471 numered_dofs[1] = prb_ptr->numeredColDofsPtr;
3472
3473 int *nbdof_ptr[] = {&prb_ptr->nbDofsRow, &prb_ptr->nbDofsCol};
3474 int *local_nbdof_ptr[] = {&prb_ptr->nbLocDofsRow, &prb_ptr->nbLocDofsCol};
3475 int *ghost_nbdof_ptr[] = {&prb_ptr->nbGhostDofsRow, &prb_ptr->nbGhostDofsCol};
3476
3477 const int nb_init_row_dofs = prb_ptr->getNbDofsRow();
3478 const int nb_init_col_dofs = prb_ptr->getNbDofsCol();
3479 const int nb_init_loc_row_dofs = prb_ptr->getNbLocalDofsRow();
3480 // const int nb_init_loc_col_dofs = prb_ptr->getNbLocalDofsCol();
3481 const int nb_init_ghost_row_dofs = prb_ptr->getNbGhostDofsRow();
3482 const int nb_init_ghost_col_dofs = prb_ptr->getNbGhostDofsCol();
3483
3484 const std::array<int, 2> nb_init_dofs = {nb_init_row_dofs, nb_init_col_dofs};
3485
3486 for (int s = 0; s != 2; ++s)
3487 if (numered_dofs[s]) {
3488
3489 typedef multi_index_container<
3490
3491 NumeredDofEntity_multiIndex::iterator, indexed_by<sequenced<>>
3492
3493 >
3494 NumeredDofEntity_it_view_multiIndex;
3495
3496 const auto bit_number = m_field.get_field_bit_number(field_name);
3497 NumeredDofEntity_it_view_multiIndex dofs_it_view;
3498
3499 // Set -1 to global and local dofs indices
3500 for (auto pit = ents.const_pair_begin(); pit != ents.const_pair_end();
3501 ++pit) {
3502 auto lo = numered_dofs[s]->get<Unique_mi_tag>().lower_bound(
3503 DofEntity::getLoFieldEntityUId(bit_number, pit->first));
3504 auto hi = numered_dofs[s]->get<Unique_mi_tag>().upper_bound(
3505 DofEntity::getHiFieldEntityUId(bit_number, pit->second));
3506
3507 for (; lo != hi; ++lo)
3508 if ((*lo)->getDofCoeffIdx() >= lo_coeff &&
3509 (*lo)->getDofCoeffIdx() <= hi_coeff &&
3510 (*lo)->getDofOrder() >= lo_order &&
3511 (*lo)->getDofOrder() <= hi_order)
3512 dofs_it_view.emplace_back(numered_dofs[s]->project<0>(lo));
3513 }
3514
3515 if (verb > QUIET) {
3516 for (auto &dof : dofs_it_view)
3517 MOFEM_LOG("SYNC", Sev::noisy) << **dof;
3518 }
3519
3520 // set negative index
3521 auto mod = NumeredDofEntity_part_and_indices_change(-1, -1, -1);
3522 for (auto dit : dofs_it_view) {
3523 bool success = numered_dofs[s]->modify(dit, mod);
3524 if (!success)
3525 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
3526 "can not set negative indices");
3527 }
3528
3529 // create weak view
3530 std::vector<boost::weak_ptr<NumeredDofEntity>> dosf_weak_view;
3531 dosf_weak_view.reserve(dofs_it_view.size());
3532 for (auto dit : dofs_it_view)
3533 dosf_weak_view.push_back(*dit);
3534
3535 if (verb >= NOISY)
3536 MOFEM_LOG_C("SYNC", Sev::noisy,
3537 "Number of DOFs in multi-index %zu and to delete %zu\n",
3538 numered_dofs[s]->size(), dofs_it_view.size());
3539
3540 // erase dofs from problem
3541 for (auto weak_dit : dosf_weak_view)
3542 if (auto dit = weak_dit.lock()) {
3543 numered_dofs[s]->erase(dit->getLocalUniqueId());
3544 }
3545
3546 if (verb >= NOISY)
3547 MOFEM_LOG_C("SYNC", Sev::noisy,
3548 "Number of DOFs in multi-index after delete %zu\n",
3549 numered_dofs[s]->size());
3550
3551 // get current number of ghost dofs
3552 int nb_global_dof = 0;
3553 int nb_local_dofs = 0;
3554 int nb_ghost_dofs = 0;
3555
3556 for (auto dit = numered_dofs[s]->begin(); dit != numered_dofs[s]->end();
3557 ++dit) {
3558
3559 if ((*dit)->getPetscGlobalDofIdx() >= 0) {
3560
3561 if ((*dit)->getPetscLocalDofIdx() >= 0 &&
3562 (*dit)->getPetscLocalDofIdx() < *(local_nbdof_ptr[s]))
3563 ++nb_local_dofs;
3564 else if ((*dit)->getPetscLocalDofIdx() >= *(local_nbdof_ptr[s]))
3565 ++nb_ghost_dofs;
3566
3567 ++nb_global_dof;
3568 }
3569 }
3570
3571 if (debug) {
3572 MPI_Allreduce(&nb_local_dofs, nbdof_ptr[s], 1, MPI_INT, MPI_SUM,
3573 m_field.get_comm());
3574 if (*(nbdof_ptr[s]) != nb_global_dof)
3575 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
3576 "Number of local DOFs do not add up %d != %d",
3577 *(nbdof_ptr[s]), nb_global_dof);
3578 }
3579
3580 *(nbdof_ptr[s]) = nb_global_dof;
3581 *(local_nbdof_ptr[s]) = nb_local_dofs;
3582 *(ghost_nbdof_ptr[s]) = nb_ghost_dofs;
3583
3584 // Indices in slots of the global index before renumbering. The slots
3585 // are sized by the global count: on a replicated mesh DOFs of other
3586 // parts have a global index but no local index.
3587 auto get_indices_by_tag = [&](auto tag) {
3588 std::vector<int> indices;
3589 indices.resize(nb_init_dofs[s], -1);
3590 for (auto dit =
3591 numered_dofs[s]->get<PetscGlobalIdx_mi_tag>().lower_bound(0);
3592 dit != numered_dofs[s]->get<PetscGlobalIdx_mi_tag>().end();
3593 ++dit) {
3594 indices[(*dit)->getPetscGlobalDofIdx()] =
3595 decltype(tag)::get_index(dit);
3596 }
3597 return indices;
3598 };
3599
3600 auto renumber = [&](auto tag, auto &indices) {
3602 int idx = 0;
3603 for (auto dit = numered_dofs[s]->get<decltype(tag)>().lower_bound(0);
3604 dit != numered_dofs[s]->get<decltype(tag)>().end(); ++dit) {
3605 indices[(*dit)->getPetscGlobalDofIdx()] = idx++;
3606 }
3608 };
3609
3610 auto get_sub_ao = [&](auto sub_data) {
3611 if (s == 0) {
3612 return sub_data->getSmartRowMap();
3613 } else {
3614 return sub_data->getSmartColMap();
3615 }
3616 };
3617
3618 auto set_sub_is_and_ao = [&s, &prb_ptr](auto sub_data, auto is, auto ao) {
3619 if (s == 0) {
3620 sub_data->rowIs = is;
3621 sub_data->rowMap = ao;
3622 if (prb_ptr->numeredRowDofsPtr == prb_ptr->numeredColDofsPtr) {
3623 sub_data->colIs = is;
3624 sub_data->colMap = ao;
3625 }
3626 } else {
3627 sub_data->colIs = is;
3628 sub_data->colMap = ao;
3629 }
3630 };
3631
3632 auto apply_symmetry = [&s, &prb_ptr](auto sub_data) {
3633 if (s == 0) {
3634 if (prb_ptr->numeredRowDofsPtr == prb_ptr->numeredColDofsPtr) {
3635 sub_data->colIs = sub_data->getSmartRowIs();
3636 sub_data->colMap = sub_data->getSmartRowMap();
3637 }
3638 }
3639 };
3640
3641 auto set_sub_data = [&](auto &indices) {
3643 auto indices_ptr = [](auto &indices) {
3644 return indices.empty() ? nullptr : indices.data();
3645 };
3646 if (auto sub_data = prb_ptr->getSubData()) {
3647 // create is and then map it to main problem of sub-problem
3648 auto sub_is = createISGeneral(m_field.get_comm(), indices.size(),
3649 indices_ptr(indices), PETSC_COPY_VALUES);
3650 // get old app, i.e. oroginal befor sub indices, and ao, from
3651 // app, to petsc sub indices.
3652 auto sub_ao = get_sub_ao(sub_data);
3653 if (sub_ao.get())
3654 CHKERR AOPetscToApplicationIS(sub_ao, sub_is);
3655 sub_ao = createAOMappingIS(sub_is, PETSC_NULLPTR);
3656 // set new sub ao
3657 set_sub_is_and_ao(sub_data, sub_is, sub_ao);
3658 apply_symmetry(sub_data);
3659 } else {
3660 prb_ptr->getSubData() = boost::make_shared<Problem::SubProblemData>();
3661 auto sub_is = createISGeneral(m_field.get_comm(), indices.size(),
3662 indices_ptr(indices), PETSC_COPY_VALUES);
3663 auto sub_ao = createAOMappingIS(sub_is, PETSC_NULLPTR);
3664 // set sub is ao
3665 set_sub_is_and_ao(prb_ptr->getSubData(), sub_is, sub_ao);
3666 apply_symmetry(prb_ptr->getSubData());
3667 }
3669 };
3670
3671 auto global_indices = get_indices_by_tag(PetscGlobalIdx_mi_tag());
3672 auto local_indices = get_indices_by_tag(PetscLocalIdx_mi_tag());
3673 CHKERR set_sub_data(global_indices);
3674 CHKERR renumber(PetscGlobalIdx_mi_tag(), global_indices);
3675 CHKERR renumber(PetscLocalIdx_mi_tag(), local_indices);
3676
3677 for (auto dit = numered_dofs[s]->begin(); dit != numered_dofs[s]->end();
3678 ++dit) {
3679 const auto idx = (*dit)->getPetscGlobalDofIdx();
3680 if (idx >= 0) {
3681 auto mod = NumeredDofEntity_part_and_indices_change(
3682 (*dit)->getPart(), global_indices[idx], local_indices[idx]);
3683 bool success = numered_dofs[s]->modify(dit, mod);
3684 if (!success)
3685 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
3686 "can not set negative indices");
3687 } else {
3688 auto mod = NumeredDofEntity_part_and_indices_change(
3689 (*dit)->getPart(), -1, -1);
3690 bool success = numered_dofs[s]->modify(dit, mod);
3691 if (!success)
3692 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
3693 "can not set negative indices");
3694 }
3695 };
3696
3697 if (debug) {
3698 for (auto dof : (*numered_dofs[s])) {
3699 if (dof->getPetscGlobalDofIdx() >= *(nbdof_ptr[s])) {
3700 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
3701 "Global idx out of range");
3702 }
3703 }
3704 }
3705
3706 } else {
3707
3708 *(nbdof_ptr[1]) = *(nbdof_ptr[0]);
3709 *(local_nbdof_ptr[1]) = *(local_nbdof_ptr[0]);
3710 *(ghost_nbdof_ptr[1]) = *(ghost_nbdof_ptr[0]);
3711 }
3712
3713 if (verb >= NOISY)
3715
3716 if (verb > QUIET) {
3718 "WORLD", Sev::inform,
3719 "Removed DOFs from problem %s dofs [%d / %d (before %d / %d) global]",
3720 prb_ptr->getName().c_str(), prb_ptr->getNbDofsRow(),
3721 prb_ptr->getNbDofsCol(), nb_init_row_dofs, nb_init_col_dofs);
3722 MOFEM_LOG_C("SYNC", Sev::verbose,
3723 "Removed DOFs from problem %s dofs [ %d / %d "
3724 "(before %d / %d) local, %d / %d (before %d / %d)]",
3725 prb_ptr->getName().c_str(), prb_ptr->getNbLocalDofsRow(),
3726 prb_ptr->getNbLocalDofsCol(), nb_init_loc_row_dofs,
3727 nb_init_loc_row_dofs, prb_ptr->getNbGhostDofsRow(),
3728 prb_ptr->getNbGhostDofsCol(), nb_init_ghost_row_dofs,
3729 nb_init_ghost_col_dofs);
3731 }
3733}
std::vector< int > size
Tag tag
#define MOFEM_LOG_SYNCHRONISE(comm)
Synchronise "SYNC" channel.
#define MOFEM_LOG_C(channel, severity, format,...)
It end
Definition Schur.cpp:2568
@ 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 722 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: