v0.14.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 ()
 
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, boost::shared_ptr< Range > > *entityMapRow=nullptr, const map< std::string, boost::shared_ptr< Range > > *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, free_surface.cpp, hanging_node_approx.cpp, hcurl_divergence_operator_2d.cpp, heat_method.cpp, helmholtz.cpp, level_set.cpp, mesh_insert_interface_atom.cpp, mixed_poisson.cpp, nonlinear_dynamics.cpp, photon_diffusion.cpp, plastic.cpp, plate.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_elastic.cpp.

Definition at line 21 of file ProblemsManager.hpp.

Member Enumeration Documentation

◆ MarkOP

Enumerator
OR 
AND 

Definition at line 365 of file ProblemsManager.hpp.

Constructor & Destructor Documentation

◆ ProblemsManager()

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

Definition at line 55 of file ProblemsManager.cpp.

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

◆ ~ProblemsManager()

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

Member Function Documentation

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

3294 {
3295
3296 Interface &m_field = cOre;
3298
3299 const auto problem_ptr = m_field.get_problem(problem_name);
3300 auto get_field_id = [&](const std::string field_name) {
3301 return m_field.get_field_structure(field_name)->getId();
3302 };
3303 const auto row_id = get_field_id(row_field);
3304 const auto col_id = get_field_id(col_field);
3305
3306 problem_ptr->addFieldToEmptyFieldBlocks(EmptyFieldBlocks(row_id, col_id));
3307
3309}
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
Problem::EmptyFieldBlocks EmptyFieldBlocks
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1975
constexpr auto field_name

◆ debugPartitionedProblem()

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

Definition at line 2084 of file ProblemsManager.cpp.

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

62 {
63 MoFEM::Interface &m_field = cOre;
65 CHKERR PetscOptionsBegin(m_field.get_comm(), "", "Problem manager", "none");
66 {
67 CHKERR PetscOptionsBool(
68 "-problem_build_from_fields",
69 "Add DOFs to problem directly from fields not through DOFs on elements",
71 }
72 ierr = PetscOptionsEnd();
75}
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:483
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
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 3196 of file ProblemsManager.cpp.

3198 {
3199
3200 Interface &m_field = cOre;
3201 const Problem *problem_ptr;
3203 CHKERR m_field.get_problem(problem_name, &problem_ptr);
3204 boost::shared_ptr<NumeredDofEntity_multiIndex> dofs;
3205 switch (rc) {
3206 case ROW:
3207 dofs = problem_ptr->getNumeredRowDofsPtr();
3208 break;
3209 case COL:
3210 dofs = problem_ptr->getNumeredColDofsPtr();
3211 default:
3212 SETERRQ(PETSC_COMM_SELF, MOFEM_IMPOSSIBLE_CASE, "Should be row or column");
3213 }
3214 marker.resize(dofs->size(), 0);
3215 std::vector<unsigned char> marker_tmp;
3216
3217 switch (op) {
3218 case MarkOP::OR:
3219 for (auto p = ents.pair_begin(); p != ents.pair_end(); ++p) {
3220 auto lo = dofs->get<Ent_mi_tag>().lower_bound(p->first);
3221 auto hi = dofs->get<Ent_mi_tag>().upper_bound(p->second);
3222 for (; lo != hi; ++lo)
3223 marker[(*lo)->getPetscLocalDofIdx()] |= 1;
3224 }
3225 break;
3226 case MarkOP::AND:
3227 marker_tmp.resize(dofs->size(), 0);
3228 for (auto p = ents.pair_begin(); p != ents.pair_end(); ++p) {
3229 auto lo = dofs->get<Ent_mi_tag>().lower_bound(p->first);
3230 auto hi = dofs->get<Ent_mi_tag>().upper_bound(p->second);
3231 for (; lo != hi; ++lo)
3232 marker_tmp[(*lo)->getPetscLocalDofIdx()] = 1;
3233 }
3234 for (int i = 0; i != marker.size(); ++i) {
3235 marker[i] &= marker_tmp[i];
3236 }
3237 break;
3238 }
3239
3241}
static Index< 'p', 3 > p
#define ProblemManagerFunctionBegin
@ COL
Definition: definitions.h:123
@ ROW
Definition: definitions.h:123
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
inline
Deprecated:
use function with MarkOP

Definition at line 387 of file ProblemsManager.hpp.

388 {
389 return markDofs(problem_name, rc, MarkOP::OR, ents, marker);
390 }
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 3243 of file ProblemsManager.cpp.

3246 {
3247
3248 Interface &m_field = cOre;
3249 const Problem *problem_ptr;
3251 CHKERR m_field.get_problem(problem_name, &problem_ptr);
3252 boost::shared_ptr<NumeredDofEntity_multiIndex> dofs;
3253 switch (rc) {
3254 case ROW:
3255 dofs = problem_ptr->getNumeredRowDofsPtr();
3256 break;
3257 case COL:
3258 dofs = problem_ptr->getNumeredColDofsPtr();
3259 default:
3260 SETERRQ(PETSC_COMM_SELF, MOFEM_IMPOSSIBLE_CASE, "Should be row or column");
3261 }
3262 marker.resize(dofs->size(), 0);
3263
3264 auto dof_lo = dofs->get<Unique_mi_tag>().lower_bound(
3265 FieldEntity::getLoBitNumberUId(m_field.get_field_bit_number(field_name)));
3266 auto dof_hi = dofs->get<Unique_mi_tag>().upper_bound(
3267 FieldEntity::getHiBitNumberUId(m_field.get_field_bit_number(field_name)));
3268
3269 auto marker_ref = [marker](auto &it) -> unsigned int & {
3270 return marker[(*it)->getPetscLocalDofIdx()];
3271 };
3272
3273 switch (op) {
3274 case MarkOP::OR:
3275 for (; dof_lo != dof_hi; ++dof_lo)
3276 if ((*dof_lo)->getDofCoeffIdx() >= lo &&
3277 (*dof_lo)->getDofCoeffIdx() <= hi)
3278 marker[(*dof_lo)->getPetscLocalDofIdx()] |= c;
3279 break;
3280 case MarkOP::AND:
3281 for (; dof_lo != dof_hi; ++dof_lo)
3282 if ((*dof_lo)->getDofCoeffIdx() >= lo &&
3283 (*dof_lo)->getDofCoeffIdx() <= hi)
3284 marker[(*dof_lo)->getPetscLocalDofIdx()] &= c;
3285 break;
3286 }
3287
3289}
const double c
speed of light (cm/ns)
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 2065 of file ProblemsManager.cpp.

2065 {
2066 MoFEM::Interface &m_field = cOre;
2068
2069 if (verb > QUIET) {
2070
2071 MOFEM_LOG("SYNC", Sev::inform)
2072 << problem_ptr->getName() << " Nb. local dof "
2073 << problem_ptr->getNbLocalDofsRow() << " by "
2074 << problem_ptr->getNbLocalDofsCol() << " nb global dofs "
2075 << problem_ptr->getNbDofsRow() << " by " << problem_ptr->getNbDofsCol();
2076
2078 }
2079
2081}
#define MOFEM_LOG_SYNCHRONISE(comm)
Synchronise "SYNC" channel.
Definition: LogManager.hpp:345
@ QUIET
Definition: definitions.h:208
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308

◆ 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 nondistributed meshes

Definition at line 3168 of file ProblemsManager.cpp.

3172 {
3173 MoFEM::Interface &m_field = cOre;
3175
3176 auto bit_manager = m_field.getInterface<BitRefManager>();
3177
3178 Range ents;
3179 if (ents_ptr) {
3180 ents = *ents_ptr;
3181 CHKERR bit_manager->filterEntitiesByRefLevel(bit_ref_level, bit_ref_mask,
3182 ents, verb);
3183 } else {
3184 CHKERR bit_manager->getEntitiesByRefLevel(bit_ref_level, bit_ref_mask, ents,
3185 verb);
3186 }
3187
3189 lo_coeff, hi_coeff, lo_order,
3190 hi_order, verb, debug);
3191
3193}
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 2876 of file ProblemsManager.cpp.

2879 {
2880
2881 MoFEM::Interface &m_field = cOre;
2883
2884 const Problem *prb_ptr;
2885 CHKERR m_field.get_problem(problem_name, &prb_ptr);
2886
2887 decltype(prb_ptr->numeredRowDofsPtr) numered_dofs[2] = {
2888 prb_ptr->numeredRowDofsPtr, nullptr};
2889 if (prb_ptr->numeredRowDofsPtr != prb_ptr->numeredColDofsPtr)
2890 numered_dofs[1] = prb_ptr->numeredColDofsPtr;
2891
2892 int *nbdof_ptr[] = {&prb_ptr->nbDofsRow, &prb_ptr->nbDofsCol};
2893 int *local_nbdof_ptr[] = {&prb_ptr->nbLocDofsRow, &prb_ptr->nbLocDofsCol};
2894 int *ghost_nbdof_ptr[] = {&prb_ptr->nbGhostDofsRow, &prb_ptr->nbGhostDofsCol};
2895
2896 const int nb_init_row_dofs = prb_ptr->getNbDofsRow();
2897 const int nb_init_col_dofs = prb_ptr->getNbDofsCol();
2898 const int nb_init_loc_row_dofs = prb_ptr->getNbLocalDofsRow();
2899 // const int nb_init_loc_col_dofs = prb_ptr->getNbLocalDofsCol();
2900 const int nb_init_ghost_row_dofs = prb_ptr->getNbGhostDofsRow();
2901 const int nb_init_ghost_col_dofs = prb_ptr->getNbGhostDofsCol();
2902
2903 const std::array<int, 2> nb_init_dofs = {nb_init_row_dofs, nb_init_col_dofs};
2904
2905 for (int s = 0; s != 2; ++s)
2906 if (numered_dofs[s]) {
2907
2908 typedef multi_index_container<
2909
2910 NumeredDofEntity_multiIndex::iterator, indexed_by<sequenced<>>
2911
2912 >
2913 NumeredDofEntity_it_view_multiIndex;
2914
2915 const auto bit_number = m_field.get_field_bit_number(field_name);
2916 NumeredDofEntity_it_view_multiIndex dofs_it_view;
2917
2918 // Set -1 to global and local dofs indices
2919 for (auto pit = ents.const_pair_begin(); pit != ents.const_pair_end();
2920 ++pit) {
2921 auto lo = numered_dofs[s]->get<Unique_mi_tag>().lower_bound(
2922 DofEntity::getLoFieldEntityUId(bit_number, pit->first));
2923 auto hi = numered_dofs[s]->get<Unique_mi_tag>().upper_bound(
2924 DofEntity::getHiFieldEntityUId(bit_number, pit->second));
2925
2926 for (; lo != hi; ++lo)
2927 if ((*lo)->getDofCoeffIdx() >= lo_coeff &&
2928 (*lo)->getDofCoeffIdx() <= hi_coeff &&
2929 (*lo)->getDofOrder() >= lo_order &&
2930 (*lo)->getDofOrder() <= hi_order)
2931 dofs_it_view.emplace_back(numered_dofs[s]->project<0>(lo));
2932 }
2933
2934 if (verb > QUIET) {
2935 for (auto &dof : dofs_it_view)
2936 MOFEM_LOG("SYNC", Sev::noisy) << **dof;
2937 }
2938
2939 // set negative index
2940 auto mod = NumeredDofEntity_part_and_all_indices_change(-1, -1, -1, -1);
2941 for (auto dit : dofs_it_view) {
2942 bool success = numered_dofs[s]->modify(dit, mod);
2943 if (!success)
2944 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
2945 "can not set negative indices");
2946 }
2947
2948 // create weak view
2949 std::vector<boost::weak_ptr<NumeredDofEntity>> dosf_weak_view;
2950 dosf_weak_view.reserve(dofs_it_view.size());
2951 for (auto dit : dofs_it_view)
2952 dosf_weak_view.push_back(*dit);
2953
2954 if (verb >= NOISY)
2955 MOFEM_LOG_C("SYNC", Sev::noisy,
2956 "Number of DOFs in multi-index %d and to delete %d\n",
2957 numered_dofs[s]->size(), dofs_it_view.size());
2958
2959 // erase dofs from problem
2960 for (auto weak_dit : dosf_weak_view)
2961 if (auto dit = weak_dit.lock()) {
2962 numered_dofs[s]->erase(dit->getLocalUniqueId());
2963 }
2964
2965 if (verb >= NOISY)
2966 MOFEM_LOG_C("SYNC", Sev::noisy,
2967 "Number of DOFs in multi-index after delete %d\n",
2968 numered_dofs[s]->size());
2969
2970 // get current number of ghost dofs
2971 int nb_global_dof = 0;
2972 int nb_local_dofs = 0;
2973 int nb_ghost_dofs = 0;
2974
2975 for (auto dit = numered_dofs[s]->begin(); dit != numered_dofs[s]->end();
2976 ++dit) {
2977
2978 if ((*dit)->getDofIdx() >= 0) {
2979
2980 if ((*dit)->getPetscLocalDofIdx() >= 0 &&
2981 (*dit)->getPetscLocalDofIdx() < *(local_nbdof_ptr[s]))
2982 ++nb_local_dofs;
2983 else if ((*dit)->getPetscLocalDofIdx() >= *(local_nbdof_ptr[s]))
2984 ++nb_ghost_dofs;
2985
2986 ++nb_global_dof;
2987 }
2988 }
2989
2990 if (debug) {
2991 MPI_Allreduce(&nb_local_dofs, nbdof_ptr[s], 1, MPI_INT, MPI_SUM,
2992 m_field.get_comm());
2993 if (*(nbdof_ptr[s]) != nb_global_dof)
2994 SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
2995 "Number of local DOFs do not add up %d != %d",
2996 *(nbdof_ptr[s]), nb_global_dof);
2997 }
2998
2999 *(nbdof_ptr[s]) = nb_global_dof;
3000 *(local_nbdof_ptr[s]) = nb_local_dofs;
3001 *(ghost_nbdof_ptr[s]) = nb_ghost_dofs;
3002
3003 // get indices
3004 auto get_indices_by_tag = [&](auto tag) {
3005 std::vector<int> indices;
3006 indices.resize(nb_init_dofs[s], -1);
3007 for (auto dit = numered_dofs[s]->get<Idx_mi_tag>().lower_bound(0);
3008 dit != numered_dofs[s]->get<Idx_mi_tag>().end(); ++dit) {
3009 indices[(*dit)->getDofIdx()] = decltype(tag)::get_index(dit);
3010 }
3011 return indices;
3012 };
3013
3014 auto renumber = [&](auto tag, auto &indices) {
3016 int idx = 0;
3017 for (auto dit = numered_dofs[s]->get<decltype(tag)>().lower_bound(0);
3018 dit != numered_dofs[s]->get<decltype(tag)>().end(); ++dit) {
3019 indices[(*dit)->getDofIdx()] = idx++;
3020 }
3022 };
3023
3024 auto get_sub_ao = [&](auto sub_data) {
3025 if (s == 0) {
3026 return sub_data->getSmartRowMap();
3027 } else {
3028 return sub_data->getSmartColMap();
3029 }
3030 };
3031
3032 auto set_sub_is_and_ao = [&s, &prb_ptr](auto sub_data, auto is, auto ao) {
3033 if (s == 0) {
3034 sub_data->rowIs = is;
3035 sub_data->rowMap = ao;
3036 } else {
3037 sub_data->colIs = is;
3038 sub_data->colMap = ao;
3039 }
3040 };
3041
3042 auto apply_symmetry = [&s, &prb_ptr](auto sub_data) {
3043 if (s == 0) {
3044 if (prb_ptr->numeredRowDofsPtr == prb_ptr->numeredColDofsPtr) {
3045 sub_data->colIs = sub_data->getSmartRowIs();
3046 sub_data->colMap = sub_data->getSmartRowMap();
3047 }
3048 }
3049 };
3050
3051 auto set_sub_data = [&](auto &indices) {
3053 if (auto sub_data = prb_ptr->getSubData()) {
3054 // create is and then map it to main problem of sub-problem
3055 auto sub_is = createISGeneral(m_field.get_comm(), indices.size(),
3056 &*indices.begin(), PETSC_COPY_VALUES);
3057 // get old app, i.e. oroginal befor sub indices, and ao, from
3058 // app, to petsc sub indices.
3059 auto sub_ao = get_sub_ao(sub_data);
3060 CHKERR AOPetscToApplicationIS(sub_ao, sub_is);
3061 sub_ao = createAOMappingIS(sub_is, PETSC_NULL);
3062 // set new sub ao
3063 set_sub_is_and_ao(sub_data, sub_is, sub_ao);
3064 apply_symmetry(sub_data);
3065 } else {
3066 prb_ptr->getSubData() = boost::make_shared<Problem::SubProblemData>();
3067 auto sub_is = createISGeneral(m_field.get_comm(), indices.size(),
3068 &*indices.begin(), PETSC_COPY_VALUES);
3069 auto sub_ao = createAOMappingIS(sub_is, PETSC_NULL);
3070 // set sub is ao
3071 set_sub_is_and_ao(prb_ptr->getSubData(), sub_is, sub_ao);
3072 apply_symmetry(prb_ptr->getSubData());
3073 }
3075 };
3076
3077 auto global_indices = get_indices_by_tag(PetscGlobalIdx_mi_tag());
3078 auto local_indices = get_indices_by_tag(PetscLocalIdx_mi_tag());
3079 CHKERR set_sub_data(global_indices);
3080 CHKERR renumber(PetscGlobalIdx_mi_tag(), global_indices);
3081 CHKERR renumber(PetscLocalIdx_mi_tag(), local_indices);
3082
3083 int i = 0;
3084 for (auto dit = numered_dofs[s]->begin(); dit != numered_dofs[s]->end();
3085 ++dit) {
3086 auto idx = (*dit)->getDofIdx();
3087 if (idx >= 0) {
3088 auto mod = NumeredDofEntity_part_and_all_indices_change(
3089 (*dit)->getPart(), i++, global_indices[idx], local_indices[idx]);
3090 bool success = numered_dofs[s]->modify(dit, mod);
3091 if (!success)
3092 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
3093 "can not set negative indices");
3094 } else {
3095 auto mod = NumeredDofEntity_part_and_all_indices_change(
3096 (*dit)->getPart(), -1, -1, -1);
3097 bool success = numered_dofs[s]->modify(dit, mod);
3098 if (!success)
3099 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
3100 "can not set negative indices");
3101 }
3102 };
3103
3104 if (debug) {
3105 for (auto dof : (*numered_dofs[s])) {
3106 if (dof->getDofIdx() >= 0 && dof->getPetscGlobalDofIdx() < 0) {
3107 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
3108 "Negative global idx");
3109 }
3110 }
3111 }
3112
3113 } else {
3114
3115 *(nbdof_ptr[1]) = *(nbdof_ptr[0]);
3116 *(local_nbdof_ptr[1]) = *(local_nbdof_ptr[0]);
3117 *(ghost_nbdof_ptr[1]) = *(ghost_nbdof_ptr[0]);
3118 }
3119
3120 if (verb >= NOISY)
3122
3123 if (verb > QUIET) {
3125 "WORLD", Sev::inform,
3126 "Removed DOFs from problem %s dofs [%d / %d (before %d / %d) global]",
3127 prb_ptr->getName().c_str(), prb_ptr->getNbDofsRow(),
3128 prb_ptr->getNbDofsCol(), nb_init_row_dofs, nb_init_col_dofs);
3129 MOFEM_LOG_C("SYNC", Sev::verbose,
3130 "Removed DOFs from problem %s dofs [ %d / %d "
3131 "(before %d / %d) local, %d / %d (before %d / %d)]",
3132 prb_ptr->getName().c_str(), prb_ptr->getNbLocalDofsRow(),
3133 prb_ptr->getNbLocalDofsCol(), nb_init_loc_row_dofs,
3134 nb_init_loc_row_dofs, prb_ptr->getNbGhostDofsRow(),
3135 prb_ptr->getNbGhostDofsCol(), nb_init_ghost_row_dofs,
3136 nb_init_ghost_col_dofs);
3138 }
3140}
#define MOFEM_LOG_C(channel, severity, format,...)
Definition: LogManager.hpp:311
@ NOISY
Definition: definitions.h:211
@ 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.
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.
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 30 of file ProblemsManager.hpp.

◆ cOre

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

Definition at line 26 of file ProblemsManager.hpp.

◆ MOFEM_EVENT_ProblemsManager

PetscLogEvent MoFEM::ProblemsManager::MOFEM_EVENT_ProblemsManager
private

Definition at line 427 of file ProblemsManager.hpp.

◆ synchroniseProblemEntities

PetscBool MoFEM::ProblemsManager::synchroniseProblemEntities

DOFs in fields, not from DOFs on elements.

Definition at line 33 of file ProblemsManager.hpp.


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