v0.16.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
/home/lk58p/mofem_install/vanilla_dev_release/mofem-cephas/mofem/users_modules/eshelbian_plasticity/src/impl/EshelbianPlasticity.cpp, 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/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-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, mofem/users_modules/bone_remodelling/src/impl/Remodeling.cpp, thermo_elastic.cpp, and thermoplastic.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: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 3581 of file ProblemsManager.cpp.

3583 {
3584
3585 Interface &m_field = cOre;
3586 const Problem *problem_ptr;
3588 CHKERR m_field.get_problem(problem_name, &problem_ptr);
3589 boost::shared_ptr<NumeredDofEntity_multiIndex> dofs;
3590 switch (rc) {
3591 case ROW:
3592 dofs = problem_ptr->getNumeredRowDofsPtr();
3593 break;
3594 case COL:
3595 dofs = problem_ptr->getNumeredColDofsPtr();
3596 default:
3597 SETERRQ(PETSC_COMM_SELF, MOFEM_IMPOSSIBLE_CASE, "Should be row or column");
3598 }
3599 marker.resize(dofs->size(), 0);
3600 std::vector<unsigned char> marker_tmp;
3601
3602 switch (op) {
3603 case MarkOP::OR:
3604 for (auto p = ents.pair_begin(); p != ents.pair_end(); ++p) {
3605 auto lo = dofs->get<Ent_mi_tag>().lower_bound(p->first);
3606 auto hi = dofs->get<Ent_mi_tag>().upper_bound(p->second);
3607 for (; lo != hi; ++lo) {
3608 if ((*lo)->getPetscLocalDofIdx() < 0)
3609 continue;
3610 marker[(*lo)->getPetscLocalDofIdx()] |= 1;
3611 }
3612 }
3613 break;
3614 case MarkOP::AND:
3615 marker_tmp.resize(dofs->size(), 0);
3616 for (auto p = ents.pair_begin(); p != ents.pair_end(); ++p) {
3617 auto lo = dofs->get<Ent_mi_tag>().lower_bound(p->first);
3618 auto hi = dofs->get<Ent_mi_tag>().upper_bound(p->second);
3619 for (; lo != hi; ++lo) {
3620 if ((*lo)->getPetscLocalDofIdx() < 0)
3621 continue;
3622 marker_tmp[(*lo)->getPetscLocalDofIdx()] = 1;
3623 }
3624 }
3625 for (int i = 0; i != marker.size(); ++i) {
3626 marker[i] &= marker_tmp[i];
3627 }
3628 break;
3629 }
3630
3632}
#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:831

◆ 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 3553 of file ProblemsManager.cpp.

3557 {
3558 MoFEM::Interface &m_field = cOre;
3560
3561 auto bit_manager = m_field.getInterface<BitRefManager>();
3562
3563 Range ents;
3564 if (ents_ptr) {
3565 ents = *ents_ptr;
3566 CHKERR bit_manager->filterEntitiesByRefLevel(bit_ref_level, bit_ref_mask,
3567 ents, verb);
3568 } else {
3569 CHKERR bit_manager->getEntitiesByRefLevel(bit_ref_level, bit_ref_mask, ents,
3570 verb);
3571 }
3572
3574 lo_coeff, hi_coeff, lo_order,
3575 hi_order, verb, debug);
3576
3578}
#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 3253 of file ProblemsManager.cpp.

3256 {
3257
3258 MoFEM::Interface &m_field = cOre;
3260
3261 const Problem *prb_ptr;
3262 CHKERR m_field.get_problem(problem_name, &prb_ptr);
3263
3264 decltype(prb_ptr->numeredRowDofsPtr) numered_dofs[2] = {
3265 prb_ptr->numeredRowDofsPtr, nullptr};
3266 if (prb_ptr->numeredRowDofsPtr != prb_ptr->numeredColDofsPtr)
3267 numered_dofs[1] = prb_ptr->numeredColDofsPtr;
3268
3269 int *nbdof_ptr[] = {&prb_ptr->nbDofsRow, &prb_ptr->nbDofsCol};
3270 int *local_nbdof_ptr[] = {&prb_ptr->nbLocDofsRow, &prb_ptr->nbLocDofsCol};
3271 int *ghost_nbdof_ptr[] = {&prb_ptr->nbGhostDofsRow, &prb_ptr->nbGhostDofsCol};
3272
3273 const int nb_init_row_dofs = prb_ptr->getNbDofsRow();
3274 const int nb_init_col_dofs = prb_ptr->getNbDofsCol();
3275 const int nb_init_loc_row_dofs = prb_ptr->getNbLocalDofsRow();
3276 // const int nb_init_loc_col_dofs = prb_ptr->getNbLocalDofsCol();
3277 const int nb_init_ghost_row_dofs = prb_ptr->getNbGhostDofsRow();
3278 const int nb_init_ghost_col_dofs = prb_ptr->getNbGhostDofsCol();
3279
3280 const std::array<int, 2> nb_init_dofs = {nb_init_row_dofs, nb_init_col_dofs};
3281
3282 for (int s = 0; s != 2; ++s)
3283 if (numered_dofs[s]) {
3284
3285 typedef multi_index_container<
3286
3287 NumeredDofEntity_multiIndex::iterator, indexed_by<sequenced<>>
3288
3289 >
3290 NumeredDofEntity_it_view_multiIndex;
3291
3292 const auto bit_number = m_field.get_field_bit_number(field_name);
3293 NumeredDofEntity_it_view_multiIndex dofs_it_view;
3294
3295 // Set -1 to global and local dofs indices
3296 for (auto pit = ents.const_pair_begin(); pit != ents.const_pair_end();
3297 ++pit) {
3298 auto lo = numered_dofs[s]->get<Unique_mi_tag>().lower_bound(
3299 DofEntity::getLoFieldEntityUId(bit_number, pit->first));
3300 auto hi = numered_dofs[s]->get<Unique_mi_tag>().upper_bound(
3301 DofEntity::getHiFieldEntityUId(bit_number, pit->second));
3302
3303 for (; lo != hi; ++lo)
3304 if ((*lo)->getDofCoeffIdx() >= lo_coeff &&
3305 (*lo)->getDofCoeffIdx() <= hi_coeff &&
3306 (*lo)->getDofOrder() >= lo_order &&
3307 (*lo)->getDofOrder() <= hi_order)
3308 dofs_it_view.emplace_back(numered_dofs[s]->project<0>(lo));
3309 }
3310
3311 if (verb > QUIET) {
3312 for (auto &dof : dofs_it_view)
3313 MOFEM_LOG("SYNC", Sev::noisy) << **dof;
3314 }
3315
3316 // set negative index
3317 auto mod = NumeredDofEntity_part_and_all_indices_change(-1, -1, -1, -1);
3318 for (auto dit : dofs_it_view) {
3319 bool success = numered_dofs[s]->modify(dit, mod);
3320 if (!success)
3321 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
3322 "can not set negative indices");
3323 }
3324
3325 // create weak view
3326 std::vector<boost::weak_ptr<NumeredDofEntity>> dosf_weak_view;
3327 dosf_weak_view.reserve(dofs_it_view.size());
3328 for (auto dit : dofs_it_view)
3329 dosf_weak_view.push_back(*dit);
3330
3331 if (verb >= NOISY)
3332 MOFEM_LOG_C("SYNC", Sev::noisy,
3333 "Number of DOFs in multi-index %zu and to delete %zu\n",
3334 numered_dofs[s]->size(), dofs_it_view.size());
3335
3336 // erase dofs from problem
3337 for (auto weak_dit : dosf_weak_view)
3338 if (auto dit = weak_dit.lock()) {
3339 numered_dofs[s]->erase(dit->getLocalUniqueId());
3340 }
3341
3342 if (verb >= NOISY)
3343 MOFEM_LOG_C("SYNC", Sev::noisy,
3344 "Number of DOFs in multi-index after delete %zu\n",
3345 numered_dofs[s]->size());
3346
3347 // get current number of ghost dofs
3348 int nb_global_dof = 0;
3349 int nb_local_dofs = 0;
3350 int nb_ghost_dofs = 0;
3351
3352 for (auto dit = numered_dofs[s]->begin(); dit != numered_dofs[s]->end();
3353 ++dit) {
3354
3355 if ((*dit)->getDofIdx() >= 0) {
3356
3357 if ((*dit)->getPetscLocalDofIdx() >= 0 &&
3358 (*dit)->getPetscLocalDofIdx() < *(local_nbdof_ptr[s]))
3359 ++nb_local_dofs;
3360 else if ((*dit)->getPetscLocalDofIdx() >= *(local_nbdof_ptr[s]))
3361 ++nb_ghost_dofs;
3362
3363 ++nb_global_dof;
3364 }
3365 }
3366
3367 if (debug) {
3368 MPI_Allreduce(&nb_local_dofs, nbdof_ptr[s], 1, MPI_INT, MPI_SUM,
3369 m_field.get_comm());
3370 if (*(nbdof_ptr[s]) != nb_global_dof)
3371 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
3372 "Number of local DOFs do not add up %d != %d",
3373 *(nbdof_ptr[s]), nb_global_dof);
3374 }
3375
3376 *(nbdof_ptr[s]) = nb_global_dof;
3377 *(local_nbdof_ptr[s]) = nb_local_dofs;
3378 *(ghost_nbdof_ptr[s]) = nb_ghost_dofs;
3379
3380 // get indices
3381 auto get_indices_by_tag = [&](auto tag) {
3382 std::vector<int> indices;
3383 indices.resize(nb_init_dofs[s], -1);
3384 for (auto dit = numered_dofs[s]->get<Idx_mi_tag>().lower_bound(0);
3385 dit != numered_dofs[s]->get<Idx_mi_tag>().end(); ++dit) {
3386 indices[(*dit)->getDofIdx()] = decltype(tag)::get_index(dit);
3387 }
3388 return indices;
3389 };
3390
3391 auto renumber = [&](auto tag, auto &indices) {
3393 int idx = 0;
3394 for (auto dit = numered_dofs[s]->get<decltype(tag)>().lower_bound(0);
3395 dit != numered_dofs[s]->get<decltype(tag)>().end(); ++dit) {
3396 indices[(*dit)->getDofIdx()] = idx++;
3397 }
3399 };
3400
3401 auto get_sub_ao = [&](auto sub_data) {
3402 if (s == 0) {
3403 return sub_data->getSmartRowMap();
3404 } else {
3405 return sub_data->getSmartColMap();
3406 }
3407 };
3408
3409 auto set_sub_is_and_ao = [&s, &prb_ptr](auto sub_data, auto is, auto ao) {
3410 if (s == 0) {
3411 sub_data->rowIs = is;
3412 sub_data->rowMap = ao;
3413 if (prb_ptr->numeredRowDofsPtr == prb_ptr->numeredColDofsPtr) {
3414 sub_data->colIs = is;
3415 sub_data->colMap = ao;
3416 }
3417 } else {
3418 sub_data->colIs = is;
3419 sub_data->colMap = ao;
3420 }
3421 };
3422
3423 auto apply_symmetry = [&s, &prb_ptr](auto sub_data) {
3424 if (s == 0) {
3425 if (prb_ptr->numeredRowDofsPtr == prb_ptr->numeredColDofsPtr) {
3426 sub_data->colIs = sub_data->getSmartRowIs();
3427 sub_data->colMap = sub_data->getSmartRowMap();
3428 }
3429 }
3430 };
3431
3432 auto set_sub_data = [&](auto &indices) {
3434 auto indices_ptr = [](auto &indices) {
3435 return indices.empty() ? nullptr : indices.data();
3436 };
3437 if (auto sub_data = prb_ptr->getSubData()) {
3438 // create is and then map it to main problem of sub-problem
3439 auto sub_is = createISGeneral(m_field.get_comm(), indices.size(),
3440 indices_ptr(indices), PETSC_COPY_VALUES);
3441 // get old app, i.e. oroginal befor sub indices, and ao, from
3442 // app, to petsc sub indices.
3443 auto sub_ao = get_sub_ao(sub_data);
3444 if (sub_ao.get())
3445 CHKERR AOPetscToApplicationIS(sub_ao, sub_is);
3446 sub_ao = createAOMappingIS(sub_is, PETSC_NULLPTR);
3447 // set new sub ao
3448 set_sub_is_and_ao(sub_data, sub_is, sub_ao);
3449 apply_symmetry(sub_data);
3450 } else {
3451 prb_ptr->getSubData() = boost::make_shared<Problem::SubProblemData>();
3452 auto sub_is = createISGeneral(m_field.get_comm(), indices.size(),
3453 indices_ptr(indices), PETSC_COPY_VALUES);
3454 auto sub_ao = createAOMappingIS(sub_is, PETSC_NULLPTR);
3455 // set sub is ao
3456 set_sub_is_and_ao(prb_ptr->getSubData(), sub_is, sub_ao);
3457 apply_symmetry(prb_ptr->getSubData());
3458 }
3460 };
3461
3462 auto global_indices = get_indices_by_tag(PetscGlobalIdx_mi_tag());
3463 auto local_indices = get_indices_by_tag(PetscLocalIdx_mi_tag());
3464 CHKERR set_sub_data(global_indices);
3465 CHKERR renumber(PetscGlobalIdx_mi_tag(), global_indices);
3466 CHKERR renumber(PetscLocalIdx_mi_tag(), local_indices);
3467
3468 int i = 0;
3469 for (auto dit = numered_dofs[s]->begin(); dit != numered_dofs[s]->end();
3470 ++dit) {
3471 auto idx = (*dit)->getDofIdx();
3472 if (idx >= 0) {
3473 auto mod = NumeredDofEntity_part_and_all_indices_change(
3474 (*dit)->getPart(), i++, global_indices[idx], local_indices[idx]);
3475 bool success = numered_dofs[s]->modify(dit, mod);
3476 if (!success)
3477 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
3478 "can not set negative indices");
3479 } else {
3480 auto mod = NumeredDofEntity_part_and_all_indices_change(
3481 (*dit)->getPart(), -1, -1, -1);
3482 bool success = numered_dofs[s]->modify(dit, mod);
3483 if (!success)
3484 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
3485 "can not set negative indices");
3486 }
3487 };
3488
3489 if (debug) {
3490 for (auto dof : (*numered_dofs[s])) {
3491 if (dof->getDofIdx() >= 0 && dof->getPetscGlobalDofIdx() < 0) {
3492 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
3493 "Negative global idx");
3494 }
3495 }
3496 }
3497
3498 } else {
3499
3500 *(nbdof_ptr[1]) = *(nbdof_ptr[0]);
3501 *(local_nbdof_ptr[1]) = *(local_nbdof_ptr[0]);
3502 *(ghost_nbdof_ptr[1]) = *(ghost_nbdof_ptr[0]);
3503 }
3504
3505 if (verb >= NOISY)
3507
3508 if (verb > QUIET) {
3510 "WORLD", Sev::inform,
3511 "Removed DOFs from problem %s dofs [%d / %d (before %d / %d) global]",
3512 prb_ptr->getName().c_str(), prb_ptr->getNbDofsRow(),
3513 prb_ptr->getNbDofsCol(), nb_init_row_dofs, nb_init_col_dofs);
3514 MOFEM_LOG_C("SYNC", Sev::verbose,
3515 "Removed DOFs from problem %s dofs [ %d / %d "
3516 "(before %d / %d) local, %d / %d (before %d / %d)]",
3517 prb_ptr->getName().c_str(), prb_ptr->getNbLocalDofsRow(),
3518 prb_ptr->getNbLocalDofsCol(), nb_init_loc_row_dofs,
3519 nb_init_loc_row_dofs, prb_ptr->getNbGhostDofsRow(),
3520 prb_ptr->getNbGhostDofsCol(), nb_init_ghost_row_dofs,
3521 nb_init_ghost_col_dofs);
3523 }
3525}
#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: