v0.13.1
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 ()
 
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. More...
 
MoFEMErrorCode buildProblem (const std::string name, const bool square_matrix, int verb=VERBOSE)
 build problem data structures More...
 
MoFEMErrorCode buildProblem (Problem *problem_ptr, const bool square_matrix, int verb=VERBOSE)
 build problem data structures More...
 
MoFEMErrorCode buildProblemOnDistributedMesh (const std::string name, const bool square_matrix, int verb=VERBOSE)
 build problem data structures, assuming that mesh is distributed (collective) More...
 
MoFEMErrorCode buildProblemOnDistributedMesh (Problem *problem_ptr, const bool square_matrix=true, int verb=VERBOSE)
 build problem data structures, assuming that mesh is distributed (collective) More...
 
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, std::pair< EntityType, EntityType > > *entityMapRow=nullptr, const map< std::string, std::pair< EntityType, EntityType > > *entityMapCol=nullptr, int verb=VERBOSE)
 build sub problem More...
 
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 More...
 
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 More...
 
MoFEMErrorCode partitionSimpleProblem (const std::string name, int verb=VERBOSE)
 partition problem dofs More...
 
MoFEMErrorCode partitionProblem (const std::string name, int verb=VERBOSE)
 partition problem dofs (collective) More...
 
MoFEMErrorCode printPartitionedProblem (const Problem *problem_ptr, int verb=VERBOSE)
 
MoFEMErrorCode debugPartitionedProblem (const Problem *problem_ptr, int verb=VERBOSE)
 
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 More...
 
MoFEMErrorCode partitionGhostDofs (const std::string name, int verb=VERBOSE)
 determine ghost nodes More...
 
MoFEMErrorCode partitionGhostDofsOnDistributedMesh (const std::string name, int verb=VERBOSE)
 determine ghost nodes on distributed meshes More...
 
MoFEMErrorCode getFEMeshset (const std::string prb_name, const std::string fe_name, EntityHandle *meshset) const
 create add entities of finite element in the problem More...
 
MoFEMErrorCode getProblemElementsLayout (const std::string name, const std::string fe_name, PetscLayout *layout) const
 Get layout of elements in the problem. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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
 Mark DOFs. More...
 
MoFEMErrorCode addFieldToEmptyFieldBlocks (const std::string problem_name, const std::string row_field, const std::string col_field) const
 add empty block to problem More...
 
- Public Member Functions inherited from MoFEM::UnknownInterface
virtual MoFEMErrorCode query_interface (boost::typeindex::type_index type_index, UnknownInterface **iface) const =0
 
template<class IFACE >
MoFEMErrorCode registerInterface (bool error_if_registration_failed=true)
 Register interface. More...
 
template<class IFACE >
MoFEMErrorCode getInterface (IFACE *&iface) const
 Get interface refernce to pointer of interface. More...
 
template<class IFACE >
MoFEMErrorCode getInterface (IFACE **const iface) const
 Get interface pointer to pointer of interface. More...
 
template<class IFACE , typename boost::enable_if< boost::is_pointer< IFACE >, int >::type = 0>
IFACE getInterface () const
 Get interface pointer to pointer of interface. More...
 
template<class IFACE , typename boost::enable_if< boost::is_reference< IFACE >, int >::type = 0>
IFACE getInterface () const
 Get reference to interface. More...
 
template<class IFACE >
IFACE * getInterface () const
 Function returning pointer to interface. More...
 
virtual ~UnknownInterface ()=default
 

Public Attributes

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

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. More...
 
static MoFEMErrorCode getFileVersion (moab::Interface &moab, Version &version)
 Get database major version. More...
 
static MoFEMErrorCode setFileVersion (moab::Interface &moab, Version version=Version(MoFEM_VERSION_MAJOR, MoFEM_VERSION_MINOR, MoFEM_VERSION_BUILD))
 Get database major version. More...
 
static MoFEMErrorCode getInterfaceVersion (Version &version)
 Get database major version. More...
 

Detailed Description

Problem manager is used to build and partition problems.

Examples
EshelbianPlasticity.cpp, Remodeling.cpp, boundary_marker.cpp, build_large_problem.cpp, build_problems.cpp, child_and_parent.cpp, continuity_check_on_contact_prism_side_ele.cpp, continuity_check_on_skeleton_3d.cpp, forces_and_sources_testing_edge_element.cpp, forces_and_sources_testing_flat_prism_element.cpp, forces_and_sources_testing_users_base.cpp, hanging_node_approx.cpp, hcurl_divergence_operator_2d.cpp, heat_method.cpp, helmholtz.cpp, mesh_insert_interface_atom.cpp, mixed_poisson.cpp, nonlinear_dynamics.cpp, plastic.cpp, plate.cpp, poisson_2d_homogeneous.cpp, prism_elements_from_surface.cpp, prism_polynomial_approximation.cpp, quad_polynomial_approximation.cpp, reaction_diffusion.cpp, remove_entities_from_problem.cpp, remove_entities_from_problem_not_partitioned.cpp, test_cache_on_entities.cpp, and thermo_plastic.cpp.

Definition at line 31 of file ProblemsManager.hpp.

Member Enumeration Documentation

◆ MarkOP

Enumerator
OR 
AND 

Definition at line 377 of file ProblemsManager.hpp.

Constructor & Destructor Documentation

◆ ProblemsManager()

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

Definition at line 69 of file ProblemsManager.cpp.

70 : cOre(const_cast<MoFEM::Core &>(core)),
71 buildProblemFromFields(PETSC_FALSE),
72 synchroniseProblemEntities(PETSC_FALSE) {
73 PetscLogEventRegister("ProblemsManager", 0, &MOFEM_EVENT_ProblemsManager);
74}
Core (interface) class.
Definition: Core.hpp:92
PetscLogEvent MOFEM_EVENT_ProblemsManager
PetscBool synchroniseProblemEntities
DOFs in fields, not from DOFs on elements.

◆ ~ProblemsManager()

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

Member Function Documentation

◆ addFieldToEmptyFieldBlocks()

MoFEMErrorCode MoFEM::ProblemsManager::addFieldToEmptyFieldBlocks ( const std::string  problem_name,
const std::string  row_field,
const std::string  col_field 
) const

add empty block to problem

MatrixManager assumes that all blocks, i.e. all fields combinations are non zero. This is not always the case, to optimise code and reduce memory usage user can specifi which blocks are empty.

Parameters
problem_nameproblem name
row_fieldrow filed name
col_fieldcol field name
Returns
MoFEMErrorCode

Definition at line 3175 of file ProblemsManager.cpp.

3177 {
3178
3179 Interface &m_field = cOre;
3181
3182 const auto problem_ptr = m_field.get_problem(problem_name);
3183 auto get_field_id = [&](const std::string field_name) {
3184 return m_field.get_field_structure(field_name)->getId();
3185 };
3186 const auto row_id = get_field_id(row_field);
3187 const auto col_id = get_field_id(col_field);
3188
3189 problem_ptr->addFieldToEmptyFieldBlocks(EmptyFieldBlocks(row_id, col_id));
3190
3192}
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
Problem::EmptyFieldBlocks EmptyFieldBlocks
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1965
constexpr auto field_name

◆ debugPartitionedProblem()

MoFEMErrorCode MoFEM::ProblemsManager::debugPartitionedProblem ( const Problem problem_ptr,
int  verb = VERBOSE 
)

Definition at line 2088 of file ProblemsManager.cpp.

2088 {
2089 MoFEM::Interface &m_field = cOre;
2091
2092 auto save_ent = [](moab::Interface &moab, const std::string name,
2093 const EntityHandle ent) {
2095 EntityHandle out_meshset;
2096 CHKERR moab.create_meshset(MESHSET_SET, out_meshset);
2097 CHKERR moab.add_entities(out_meshset, &ent, 1);
2098 CHKERR moab.write_file(name.c_str(), "VTK", "", &out_meshset, 1);
2099 CHKERR moab.delete_entities(&out_meshset, 1);
2101 };
2102
2103 if (debug > 0) {
2104
2106 NumeredDofEntitysByIdx;
2107 NumeredDofEntitysByIdx::iterator dit, hi_dit;
2108 const NumeredDofEntitysByIdx *numered_dofs_ptr[] = {
2109 &(problem_ptr->numeredRowDofsPtr->get<Idx_mi_tag>()),
2110 &(problem_ptr->numeredColDofsPtr->get<Idx_mi_tag>())};
2111
2112 int *nbdof_ptr[] = {&problem_ptr->nbDofsRow, &problem_ptr->nbDofsCol};
2113 int *local_nbdof_ptr[] = {&problem_ptr->nbLocDofsRow,
2114 &problem_ptr->nbLocDofsCol};
2115
2116 for (int ss = 0; ss < 2; ss++) {
2117
2118 dit = numered_dofs_ptr[ss]->begin();
2119 hi_dit = numered_dofs_ptr[ss]->end();
2120 for (; dit != hi_dit; dit++) {
2121 if ((*dit)->getPart() == (unsigned int)m_field.get_comm_rank()) {
2122 if ((*dit)->getPetscLocalDofIdx() < 0) {
2123 std::ostringstream zz;
2124 zz << "rank " << m_field.get_comm_rank() << " " << **dit;
2125 SETERRQ2(PETSC_COMM_SELF, MOFEM_IMPOSIBLE_CASE,
2126 "local dof index for %d (0-row, 1-col) not set, i.e. has "
2127 "negative value\n %s",
2128 ss, zz.str().c_str());
2129 }
2130 if ((*dit)->getPetscLocalDofIdx() >= *local_nbdof_ptr[ss]) {
2131 std::ostringstream zz;
2132 zz << "rank " << m_field.get_comm_rank() << " " << **dit;
2133 SETERRQ2(PETSC_COMM_SELF, MOFEM_IMPOSIBLE_CASE,
2134 "local dofs for %d (0-row, 1-col) out of range\n %s", ss,
2135 zz.str().c_str());
2136 }
2137 } else {
2138 if ((*dit)->getPetscGlobalDofIdx() < 0) {
2139
2140 const EntityHandle ent = (*dit)->getEnt();
2141 CHKERR save_ent(
2142 m_field.get_moab(),
2143 "debug_part" +
2144 boost::lexical_cast<std::string>(m_field.get_comm_rank()) +
2145 "_negative_global_index.vtk",
2146 ent);
2147
2148 std::ostringstream zz;
2149 zz << "rank " << m_field.get_comm_rank() << " "
2150 << dit->get()->getBitRefLevel() << " " << **dit;
2151 SETERRQ2(PETSC_COMM_SELF, MOFEM_IMPOSIBLE_CASE,
2152 "global dof index for %d (0-row, 1-col) row not set, i.e. "
2153 "has negative value\n %s",
2154 ss, zz.str().c_str());
2155 }
2156 if ((*dit)->getPetscGlobalDofIdx() >= *nbdof_ptr[ss]) {
2157 std::ostringstream zz;
2158 zz << "rank " << m_field.get_comm_rank() << " nb_dofs "
2159 << *nbdof_ptr[ss] << " " << **dit;
2160 SETERRQ2(PETSC_COMM_SELF, MOFEM_IMPOSIBLE_CASE,
2161 "global dofs for %d (0-row, 1-col) out of range\n %s", ss,
2162 zz.str().c_str());
2163 }
2164 }
2165 }
2166 }
2167 }
2169}
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:460
@ MOFEM_IMPOSIBLE_CASE
Definition: definitions.h:48
#define CHKERR
Inline error check.
Definition: definitions.h:548
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:453
static const bool debug
virtual moab::Interface & get_moab()=0
virtual int get_comm_rank() const =0
Deprecated interface functions.

◆ getOptions()

MoFEMErrorCode MoFEM::ProblemsManager::getOptions ( )

Definition at line 76 of file ProblemsManager.cpp.

76 {
77 MoFEM::Interface &m_field = cOre;
79 CHKERR PetscOptionsBegin(m_field.get_comm(), "", "Problem manager", "none");
80 {
81 CHKERR PetscOptionsBool(
82 "-problem_build_from_fields",
83 "Add DOFs to problem directly from fields not through DOFs on elements",
85 }
86 ierr = PetscOptionsEnd();
89}
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:496
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:87
virtual MPI_Comm & get_comm() const =0

◆ 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
helmholtz.cpp, and test_cache_on_entities.cpp.

Definition at line 3079 of file ProblemsManager.cpp.

3081 {
3082
3083 Interface &m_field = cOre;
3084 const Problem *problem_ptr;
3086 CHKERR m_field.get_problem(problem_name, &problem_ptr);
3087 boost::shared_ptr<NumeredDofEntity_multiIndex> dofs;
3088 switch (rc) {
3089 case ROW:
3090 dofs = problem_ptr->getNumeredRowDofsPtr();
3091 break;
3092 case COL:
3093 dofs = problem_ptr->getNumeredColDofsPtr();
3094 default:
3095 SETERRQ(PETSC_COMM_SELF, MOFEM_IMPOSIBLE_CASE, "Should be row or column");
3096 }
3097 marker.resize(dofs->size(), 0);
3098 std::vector<unsigned char> marker_tmp;
3099
3100 switch (op) {
3101 case MarkOP::OR:
3102 for (auto p = ents.pair_begin(); p != ents.pair_end(); ++p) {
3103 auto lo = dofs->get<Ent_mi_tag>().lower_bound(p->first);
3104 auto hi = dofs->get<Ent_mi_tag>().upper_bound(p->second);
3105 for (; lo != hi; ++lo)
3106 marker[(*lo)->getPetscLocalDofIdx()] |= 1;
3107 }
3108 break;
3109 case MarkOP::AND:
3110 marker_tmp.resize(dofs->size(), 0);
3111 for (auto p = ents.pair_begin(); p != ents.pair_end(); ++p) {
3112 auto lo = dofs->get<Ent_mi_tag>().lower_bound(p->first);
3113 auto hi = dofs->get<Ent_mi_tag>().upper_bound(p->second);
3114 for (; lo != hi; ++lo)
3115 marker_tmp[(*lo)->getPetscLocalDofIdx()] = 1;
3116 }
3117 for (int i = 0; i != marker.size(); ++i) {
3118 marker[i] &= marker_tmp[i];
3119 }
3120 break;
3121 }
3122
3124}
static Index< 'p', 3 > p
#define ProblemManagerFunctionBegin
@ COL
Definition: definitions.h:136
@ ROW
Definition: definitions.h:136
auto marker
set bit to marker
FTensor::Index< 'i', SPACE_DIM > i

◆ markDofs() [2/2]

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

Definition at line 399 of file ProblemsManager.hpp.

400 {
401 return markDofs(problem_name, rc, MarkOP::OR, ents, marker);
402 }
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.

◆ modifyMarkDofs()

MoFEMErrorCode MoFEM::ProblemsManager::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

Mark DOFs.

Parameters
problem_name
rc
field_name
lo
hi
op
marker
Returns
MoFEMErrorCode

Definition at line 3126 of file ProblemsManager.cpp.

3129 {
3130
3131 Interface &m_field = cOre;
3132 const Problem *problem_ptr;
3134 CHKERR m_field.get_problem(problem_name, &problem_ptr);
3135 boost::shared_ptr<NumeredDofEntity_multiIndex> dofs;
3136 switch (rc) {
3137 case ROW:
3138 dofs = problem_ptr->getNumeredRowDofsPtr();
3139 break;
3140 case COL:
3141 dofs = problem_ptr->getNumeredColDofsPtr();
3142 default:
3143 SETERRQ(PETSC_COMM_SELF, MOFEM_IMPOSIBLE_CASE, "Should be row or column");
3144 }
3145 marker.resize(dofs->size(), 0);
3146
3147 auto dof_lo = dofs->get<Unique_mi_tag>().lower_bound(
3148 FieldEntity::getLoBitNumberUId(m_field.get_field_bit_number(field_name)));
3149 auto dof_hi = dofs->get<Unique_mi_tag>().upper_bound(
3150 FieldEntity::getHiBitNumberUId(m_field.get_field_bit_number(field_name)));
3151
3152 auto marker_ref = [marker](auto &it) -> unsigned int & {
3153 return marker[(*it)->getPetscLocalDofIdx()];
3154 };
3155
3156 switch (op) {
3157 case MarkOP::OR:
3158 for (; dof_lo != dof_hi; ++dof_lo)
3159 if ((*dof_lo)->getDofCoeffIdx() >= lo &&
3160 (*dof_lo)->getDofCoeffIdx() <= hi)
3161 marker[(*dof_lo)->getPetscLocalDofIdx()] |= c;
3162 break;
3163 case MarkOP::AND:
3164 for (; dof_lo != dof_hi; ++dof_lo)
3165 if ((*dof_lo)->getDofCoeffIdx() >= lo &&
3166 (*dof_lo)->getDofCoeffIdx() <= hi)
3167 marker[(*dof_lo)->getPetscLocalDofIdx()] &= c;
3168 break;
3169 }
3170
3172}
static UId getHiBitNumberUId(const FieldBitNumber bit_number)
static UId getLoBitNumberUId(const FieldBitNumber bit_number)

◆ printPartitionedProblem()

MoFEMErrorCode MoFEM::ProblemsManager::printPartitionedProblem ( const Problem problem_ptr,
int  verb = VERBOSE 
)

Definition at line 2069 of file ProblemsManager.cpp.

2069 {
2070 MoFEM::Interface &m_field = cOre;
2072
2073 if (verb > QUIET) {
2074
2075 MOFEM_LOG("SYNC", Sev::inform)
2076 << problem_ptr->getName() << " Nb. local dof "
2077 << problem_ptr->getNbLocalDofsRow() << " by "
2078 << problem_ptr->getNbLocalDofsCol() << " nb global dofs "
2079 << problem_ptr->getNbDofsRow() << " by " << problem_ptr->getNbDofsCol();
2080
2082 }
2083
2085}
#define MOFEM_LOG_SYNCHRONISE(comm)
Synchronise "SYNC" channel.
Definition: LogManager.hpp:348
@ QUIET
Definition: definitions.h:221
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:311

◆ query_interface()

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

Implements MoFEM::UnknownInterface.

Definition at line 63 of file ProblemsManager.cpp.

64 {
65 *iface = const_cast<ProblemsManager *>(this);
66 return 0;
67}
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 nondistributed meshes

Definition at line 3051 of file ProblemsManager.cpp.

3055 {
3056 MoFEM::Interface &m_field = cOre;
3058
3059 auto bit_manager = m_field.getInterface<BitRefManager>();
3060
3061 Range ents;
3062 if (ents_ptr) {
3063 ents = *ents_ptr;
3064 CHKERR bit_manager->filterEntitiesByRefLevel(bit_ref_level, bit_ref_mask,
3065 ents, verb);
3066 } else {
3067 CHKERR bit_manager->getEntitiesByRefLevel(bit_ref_level, bit_ref_mask, ents,
3068 verb);
3069 }
3070
3072 lo_coeff, hi_coeff, lo_order,
3073 hi_order, verb, debug);
3074
3076}
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 refernce 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 nondistributed meshes
Examples
remove_entities_from_problem_not_partitioned.cpp.

Definition at line 2825 of file ProblemsManager.cpp.

2828 {
2829
2830 MoFEM::Interface &m_field = cOre;
2832
2833 const Problem *prb_ptr;
2834 CHKERR m_field.get_problem(problem_name, &prb_ptr);
2835
2836 decltype(prb_ptr->numeredRowDofsPtr) numered_dofs[2] = {
2837 prb_ptr->numeredRowDofsPtr, nullptr};
2838 if (prb_ptr->numeredRowDofsPtr != prb_ptr->numeredColDofsPtr)
2839 numered_dofs[1] = prb_ptr->numeredColDofsPtr;
2840
2841 int *nbdof_ptr[] = {&prb_ptr->nbDofsRow, &prb_ptr->nbDofsCol};
2842 int *local_nbdof_ptr[] = {&prb_ptr->nbLocDofsRow, &prb_ptr->nbLocDofsCol};
2843 int *ghost_nbdof_ptr[] = {&prb_ptr->nbGhostDofsRow, &prb_ptr->nbGhostDofsCol};
2844
2845 const int nb_init_row_dofs = prb_ptr->getNbDofsRow();
2846 const int nb_init_col_dofs = prb_ptr->getNbDofsCol();
2847 const int nb_init_loc_row_dofs = prb_ptr->getNbLocalDofsRow();
2848 const int nb_init_loc_col_dofs = prb_ptr->getNbLocalDofsCol();
2849 const int nb_init_ghost_row_dofs = prb_ptr->getNbGhostDofsRow();
2850 const int nb_init_ghost_col_dofs = prb_ptr->getNbGhostDofsCol();
2851
2852 for (int s = 0; s != 2; ++s)
2853 if (numered_dofs[s]) {
2854
2855 typedef multi_index_container<
2856
2857 NumeredDofEntity_multiIndex::iterator, indexed_by<sequenced<>>
2858
2859 >
2860 NumeredDofEntity_it_view_multiIndex;
2861
2862 const auto bit_number = m_field.get_field_bit_number(field_name);
2863 NumeredDofEntity_it_view_multiIndex dofs_it_view;
2864
2865 // Set -1 to global and local dofs indices
2866 for (auto pit = ents.const_pair_begin(); pit != ents.const_pair_end();
2867 ++pit) {
2868 auto lo = numered_dofs[s]->get<Unique_mi_tag>().lower_bound(
2869 DofEntity::getLoFieldEntityUId(bit_number, pit->first));
2870 auto hi = numered_dofs[s]->get<Unique_mi_tag>().upper_bound(
2871 DofEntity::getHiFieldEntityUId(bit_number, pit->second));
2872
2873 for (; lo != hi; ++lo)
2874 if ((*lo)->getDofCoeffIdx() >= lo_coeff &&
2875 (*lo)->getDofCoeffIdx() <= hi_coeff &&
2876 (*lo)->getDofOrder() >= lo_order &&
2877 (*lo)->getDofOrder() <= hi_order)
2878 dofs_it_view.emplace_back(numered_dofs[s]->project<0>(lo));
2879 }
2880
2881 if (verb > QUIET) {
2882 for (auto &dof : dofs_it_view)
2883 MOFEM_LOG("SYNC", Sev::noisy) << **dof;
2884 }
2885
2886 // set negative index
2887 auto mod = NumeredDofEntity_part_and_all_indices_change(-1, -1, -1, -1);
2888 for (auto dit : dofs_it_view) {
2889 bool success = numered_dofs[s]->modify(dit, mod);
2890 if (!success)
2891 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
2892 "can not set negative indices");
2893 }
2894
2895 // create weak view
2896 std::vector<boost::weak_ptr<NumeredDofEntity>> dosf_weak_view;
2897 dosf_weak_view.reserve(dofs_it_view.size());
2898 for (auto dit : dofs_it_view)
2899 dosf_weak_view.push_back(*dit);
2900
2901 if (verb >= NOISY)
2902 MOFEM_LOG_C("SYNC", Sev::noisy,
2903 "Number of DOFs in multi-index %d and to delete %d\n",
2904 numered_dofs[s]->size(), dofs_it_view.size());
2905
2906 // erase dofs from problem
2907 for (auto weak_dit : dosf_weak_view)
2908 if (auto dit = weak_dit.lock()) {
2909 numered_dofs[s]->erase(dit->getLocalUniqueId());
2910 }
2911
2912 if (verb >= NOISY)
2913 MOFEM_LOG_C("SYNC", Sev::noisy,
2914 "Number of DOFs in multi-index after delete %d\n",
2915 numered_dofs[s]->size());
2916
2917 // get current number of ghost dofs
2918 int nb_global_dof = 0;
2919 int nb_local_dofs = 0;
2920 int nb_ghost_dofs = 0;
2921
2922 for (auto dit = numered_dofs[s]->begin(); dit != numered_dofs[s]->end();
2923 ++dit) {
2924
2925 if ((*dit)->getDofIdx() >= 0) {
2926
2927 if ((*dit)->getPetscLocalDofIdx() >= 0 &&
2928 (*dit)->getPetscLocalDofIdx() < *(local_nbdof_ptr[s]))
2929 ++nb_local_dofs;
2930 else if ((*dit)->getPetscLocalDofIdx() >= *(local_nbdof_ptr[s]))
2931 ++nb_ghost_dofs;
2932
2933 ++nb_global_dof;
2934 }
2935 }
2936
2937 if (debug) {
2938 MPI_Allreduce(&nb_local_dofs, nbdof_ptr[s], 1, MPI_INT, MPI_SUM,
2939 m_field.get_comm());
2940 if (*(nbdof_ptr[s]) != nb_global_dof)
2941 SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
2942 "Number of local DOFs do not add up %d != %d",
2943 *(nbdof_ptr[s]), nb_global_dof);
2944 }
2945
2946 *(nbdof_ptr[s]) = nb_global_dof;
2947 *(local_nbdof_ptr[s]) = nb_local_dofs;
2948 *(ghost_nbdof_ptr[s]) = nb_ghost_dofs;
2949
2950 // get indices
2951 auto get_indices_by_tag = [&](auto tag) {
2952 std::vector<int> indices;
2953 const int nb_dofs = numered_dofs[s]->size();
2954 indices.resize(nb_dofs, -1);
2955 int i = 0;
2956 for (auto dit = numered_dofs[s]->get<decltype(tag)>().begin();
2957 dit != numered_dofs[s]->get<decltype(tag)>().end(); ++dit) {
2958 int idx = std::distance(numered_dofs[s]->begin(),
2959 numered_dofs[s]->project<0>(dit));
2960 int current_idx = decltype(tag)::get_index(dit);
2961 if (current_idx >= 0)
2962 indices[idx] = i++;
2963 }
2964 return indices;
2965 };
2966
2967 auto global_indices = get_indices_by_tag(PetscGlobalIdx_mi_tag());
2968 auto local_indices = get_indices_by_tag(PetscLocalIdx_mi_tag());
2969
2970 int idx = 0;
2971 for (auto dit = numered_dofs[s]->begin(); dit != numered_dofs[s]->end();
2972 ++dit, ++idx) {
2973
2974 auto mod = NumeredDofEntity_part_and_all_indices_change(
2975 (*dit)->getPart(), (*dit)->getDofIdx(), global_indices[idx],
2976 local_indices[idx]);
2977 bool success = numered_dofs[s]->modify(dit, mod);
2978 if (!success)
2979 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
2980 "can not set negative indices");
2981 };
2982
2983 if (debug)
2984 for (auto dof : (*numered_dofs[s])) {
2985 if (dof->getDofIdx() >= 0 && dof->getPetscGlobalDofIdx() < 0) {
2986 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
2987 "Negative global idx");
2988 }
2989 }
2990 } else {
2991
2992 *(nbdof_ptr[1]) = *(nbdof_ptr[0]);
2993 *(local_nbdof_ptr[1]) = *(local_nbdof_ptr[0]);
2994 *(ghost_nbdof_ptr[1]) = *(ghost_nbdof_ptr[0]);
2995 }
2996
2997 if (verb >= NOISY)
2999
3000 if (verb > QUIET) {
3001 auto log = [&](auto str, auto level) {
3002 MOFEM_LOG_C(str, level,
3003 "removed ents on rank %d from problem %s dofs [ %d / %d "
3004 "(before %d / "
3005 "%d) local, %d / %d (before %d / %d) "
3006 "ghost, %d / %d (before %d / %d) global]",
3007 m_field.get_comm_rank(), prb_ptr->getName().c_str(),
3008 prb_ptr->getNbLocalDofsRow(), prb_ptr->getNbLocalDofsCol(),
3009 nb_init_row_dofs, nb_init_col_dofs,
3010 prb_ptr->getNbGhostDofsRow(), prb_ptr->getNbGhostDofsCol(),
3011 nb_init_ghost_row_dofs, nb_init_ghost_col_dofs,
3012 prb_ptr->getNbDofsRow(), prb_ptr->getNbDofsCol(),
3013 nb_init_loc_row_dofs, nb_init_loc_col_dofs);
3014 };
3015
3016 log("WORLD", Sev::verbose);
3017 if (m_field.get_comm_rank() > 0)
3018 log("SYNC", Sev::noisy);
3019
3021 }
3023}
#define MOFEM_LOG_C(channel, severity, format,...)
Definition: LogManager.hpp:314
@ NOISY
Definition: definitions.h:224
@ MOFEM_OPERATION_UNSUCCESSFUL
Definition: definitions.h:47
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:44
virtual const Problem * get_problem(const std::string problem_name) const =0
Get the problem object.
virtual FieldBitNumber get_field_bit_number(const std::string name) const =0
get field bit number
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 40 of file ProblemsManager.hpp.

◆ cOre

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

Definition at line 36 of file ProblemsManager.hpp.

◆ MOFEM_EVENT_ProblemsManager

PetscLogEvent MoFEM::ProblemsManager::MOFEM_EVENT_ProblemsManager
private

Definition at line 439 of file ProblemsManager.hpp.

◆ synchroniseProblemEntities

PetscBool MoFEM::ProblemsManager::synchroniseProblemEntities

DOFs in fields, not from DOFs on elements.

Definition at line 43 of file ProblemsManager.hpp.


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