v0.16.3
Loading...
Searching...
No Matches
Problems

Adding and managing problems. More...

Collaboration diagram for Problems:

Make elements multishared

MoFEMErrorCode MoFEM::CommInterface::resolveSharedFiniteElements (const Problem *problem_ptr, const std::string &fe_name, int verb=DEFAULT_VERBOSITY)
 resolve shared entities for finite elements in the problem
 
MoFEMErrorCode MoFEM::CommInterface::resolveSharedFiniteElements (const std::string name, const std::string &fe_name, int verb=DEFAULT_VERBOSITY)
 resolve shared entities for finite elements in the problem
 

Problems

virtual MoFEMErrorCode MoFEM::CoreInterface::add_problem (const std::string &name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
 Add problem.
 
virtual MoFEMErrorCode MoFEM::CoreInterface::delete_problem (const std::string name)=0
 Delete problem.
 
virtual MoFEMErrorCode MoFEM::CoreInterface::modify_problem_add_finite_element (const std::string name_problem, const std::string &fe_name)=0
 add finite element to problem, this add entities assigned to finite element to a particular problem
 
virtual MoFEMErrorCode MoFEM::CoreInterface::modify_problem_unset_finite_element (const std::string name_problem, const std::string &fe_name)=0
 unset finite element from problem, this remove entities assigned to finite element to a particular problem
 
virtual MoFEMErrorCode MoFEM::CoreInterface::modify_problem_ref_level_add_bit (const std::string &name_problem, const BitRefLevel &bit)=0
 add ref level to problem
 
virtual MoFEMErrorCode MoFEM::CoreInterface::modify_problem_mask_ref_level_add_bit (const std::string &name_problem, const BitRefLevel &bit)=0
 set dof mask ref level for problem
 
virtual MoFEMErrorCode MoFEM::CoreInterface::modify_problem_ref_level_set_bit (const std::string &name_problem, const BitRefLevel &bit)=0
 set ref level for problem
 
virtual MoFEMErrorCode MoFEM::CoreInterface::modify_problem_mask_ref_level_set_bit (const std::string &name_problem, const BitRefLevel &bit)=0
 set dof mask ref level for problem
 
virtual MoFEMErrorCode MoFEM::CoreInterface::list_problem () const =0
 list problems
 
virtual MoFEMErrorCode MoFEM::CoreInterface::clear_problem (const std::string name, int verb=DEFAULT_VERBOSITY)=0
 clear problem
 
virtual MoFEMErrorCode MoFEM::CoreInterface::clear_problems (int verb=DEFAULT_VERBOSITY)=0
 clear problems
 
virtual MoFEMErrorCode MoFEM::CoreInterface::get_problem_finite_elements_entities (const std::string name, const std::string &fe_name, const EntityHandle meshset)=0
 add finite elements to the meshset
 
virtual bool MoFEM::CoreInterface::check_problem (const std::string name)=0
 check if problem exist
 

Detailed Description

Adding and managing problems.

Function Documentation

◆ add_problem()

virtual MoFEMErrorCode MoFEM::CoreInterface::add_problem ( const std::string &  name,
enum MoFEMTypes  bh = MF_EXCL,
int  verb = DEFAULT_VERBOSITY 
)
pure virtual

◆ check_problem()

virtual bool MoFEM::CoreInterface::check_problem ( const std::string  name)
pure virtual

#include <src/interfaces/Interface.hpp>

check if problem exist

Parameters
nameproblem name
Returns
true if problem is in database

Implemented in MoFEM::CoreTmp< 0 >.

Examples
mofem/atom_tests/rebuild_problem.cpp.

◆ clear_problem()

virtual MoFEMErrorCode MoFEM::CoreInterface::clear_problem ( const std::string  name,
int  verb = DEFAULT_VERBOSITY 
)
pure virtual

#include <src/interfaces/Interface.hpp>

clear problem

Implemented in MoFEM::CoreTmp< 0 >.

◆ clear_problems()

virtual MoFEMErrorCode MoFEM::CoreInterface::clear_problems ( int  verb = DEFAULT_VERBOSITY)
pure virtual

#include <src/interfaces/Interface.hpp>

clear problems

Implemented in MoFEM::CoreTmp< 0 >.

◆ delete_problem()

virtual MoFEMErrorCode MoFEM::CoreInterface::delete_problem ( const std::string  name)
pure virtual

#include <src/interfaces/Interface.hpp>

Delete problem.

Note
add_file is a collective, should be executed on all processors. Otherwise could lead to deadlock.

Implemented in MoFEM::CoreTmp< 0 >.

Examples
mofem/tools/remove_mofem_meshsets.cpp.

◆ get_problem_finite_elements_entities()

virtual MoFEMErrorCode MoFEM::CoreInterface::get_problem_finite_elements_entities ( const std::string  name,
const std::string &  fe_name,
const EntityHandle  meshset 
)
pure virtual

#include <src/interfaces/Interface.hpp>

add finite elements to the meshset

Parameters
nameis problem name
fe_name
meshset

Implemented in MoFEM::CoreTmp< 0 >.

◆ list_problem()

virtual MoFEMErrorCode MoFEM::CoreInterface::list_problem ( ) const
pure virtual

#include <src/interfaces/Interface.hpp>

list problems

Implemented in MoFEM::CoreTmp< 0 >.

◆ modify_problem_add_finite_element()

virtual MoFEMErrorCode MoFEM::CoreInterface::modify_problem_add_finite_element ( const std::string  name_problem,
const std::string &  fe_name 
)
pure virtual

◆ modify_problem_mask_ref_level_add_bit()

virtual MoFEMErrorCode MoFEM::CoreInterface::modify_problem_mask_ref_level_add_bit ( const std::string &  name_problem,
const BitRefLevel &  bit 
)
pure virtual

#include <src/interfaces/Interface.hpp>

set dof mask ref level for problem

Implemented in MoFEM::CoreTmp< 0 >.

◆ modify_problem_mask_ref_level_set_bit()

virtual MoFEMErrorCode MoFEM::CoreInterface::modify_problem_mask_ref_level_set_bit ( const std::string &  name_problem,
const BitRefLevel &  bit 
)
pure virtual

#include <src/interfaces/Interface.hpp>

set dof mask ref level for problem

Note
add_file is a collective, should be executed on all processors. Otherwise could lead to deadlock.

Implemented in MoFEM::CoreTmp< 0 >.

Examples
mofem/atom_tests/rebuild_problem.cpp.

◆ modify_problem_ref_level_add_bit()

virtual MoFEMErrorCode MoFEM::CoreInterface::modify_problem_ref_level_add_bit ( const std::string &  name_problem,
const BitRefLevel &  bit 
)
pure virtual

#include <src/interfaces/Interface.hpp>

add ref level to problem

Note
add_file is a collective, should be executed on all processors. Otherwise could lead to deadlock.

if same finite element is solved using different level of refinements, than the level of refinement has to be specificied to problem in query

Parameters
nameProblem name
BitRefLevelbitLevel Example:
mField.modify_problem_add_finite_element("BEAM_BENDING_ON_MESH_REF1","ELASTIC");
mField.modify_problem_add_finite_element("BEAM_BENDING_ON_MESH_REF2","ELASTIC");
mField.modify_problem_ref_level_add_bit("BEAM_BENDING_ON_MESH_REF1",bit_level1);
mField.modify_problem_ref_level_add_bit("BEAM_BENDING_ON_MESH_REF2",bit_level2);
MoFEM::Interface & mField
#define CHKERR
Inline error check.
virtual MoFEMErrorCode modify_problem_ref_level_add_bit(const std::string &name_problem, const BitRefLevel &bit)=0
add ref level to problem
virtual MoFEMErrorCode modify_problem_add_finite_element(const std::string name_problem, const std::string &fe_name)=0
add finite element to problem, this add entities assigned to finite element to a particular problem
Two Problems exist and solved independently, both are elastic, but solved using different mesh refinement

Implemented in MoFEM::CoreTmp< 0 >.

Examples
mofem/atom_tests/build_composite_problem.cpp, mofem/atom_tests/build_large_problem.cpp, mofem/atom_tests/build_problems.cpp, mofem/atom_tests/continuity_check_on_contact_prism_side_ele.cpp, mofem/atom_tests/continuity_check_on_skeleton_3d.cpp, mofem/atom_tests/field_values_from_tags.cpp, mofem/atom_tests/forces_and_sources_testing_edge_element.cpp, mofem/atom_tests/forces_and_sources_testing_flat_prism_element.cpp, mofem/atom_tests/forces_and_sources_testing_users_base.cpp, mofem/atom_tests/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, and mofem/users_modules/basic_finite_elements/nonlinear_elasticity/nonlinear_dynamics.cpp.

◆ modify_problem_ref_level_set_bit()

virtual MoFEMErrorCode MoFEM::CoreInterface::modify_problem_ref_level_set_bit ( const std::string &  name_problem,
const BitRefLevel &  bit 
)
pure virtual

#include <src/interfaces/Interface.hpp>

set ref level for problem

Note
add_file is a collective, should be executed on all processors. Otherwise could lead to deadlock.

if same finite element is solved using different level of refinements, than the level of refinement has to be specificied to problem in query

Parameters
nameProblem name
BitRefLevelbitLevel Example:
mField.modify_problem_add_finite_element("BEAM_BENDING_ON_MESH_REF1","ELASTIC");
mField.modify_problem_add_finite_element("BEAM_BENDING_ON_MESH_REF2","ELASTIC");
mField.modify_problem_ref_level_set_bit("BEAM_BENDING_ON_MESH_REF1",bit_level1);
mField.modify_problem_ref_level_set_bit("BEAM_BENDING_ON_MESH_REF2",bit_level2);
virtual MoFEMErrorCode modify_problem_ref_level_set_bit(const std::string &name_problem, const BitRefLevel &bit)=0
set ref level for problem
Two Problems exist and solved independently, both are elastic, but solved using different mesh refinement

Implemented in MoFEM::CoreTmp< 0 >.

Examples
mofem/atom_tests/rebuild_problem.cpp.

◆ modify_problem_unset_finite_element()

virtual MoFEMErrorCode MoFEM::CoreInterface::modify_problem_unset_finite_element ( const std::string  name_problem,
const std::string &  fe_name 
)
pure virtual

#include <src/interfaces/Interface.hpp>

unset finite element from problem, this remove entities assigned to finite element to a particular problem

Note: If problem is build, it need to be cleaned to make this effective

Note
add_file is a collective, should be executed on all processors. Otherwise could lead to deadlock.
Parameters
nameProblem name
nameFinite Element name

Implemented in MoFEM::CoreTmp< 0 >.

◆ resolveSharedFiniteElements() [1/2]

MoFEMErrorCode MoFEM::CommInterface::resolveSharedFiniteElements ( const Problem *  problem_ptr,
const std::string &  fe_name,
int  verb = DEFAULT_VERBOSITY 
)

#include <src/interfaces/CommInterface.hpp>

resolve shared entities for finite elements in the problem

Parameters
problem_ptrproblem pointer
fe_namefinite element name
verbverbosity level
Returns
error code

This allows for tag reduction or tag exchange, f.e.

CHKERR m_field.resolveSharedFiniteElements(problem_ptr,"SHELL_ELEMENT");
CHKERR mField.get_moab().tag_get_handle("ADAPT_ORDER",th);
CHKERR ParallelComm* pcomm =
ParallelComm::get_pcomm(&mField.get_moab(),MYPCOMM_INDEX);
CHKERR pcomm->exchange_tags(th,prisms);
#define MYPCOMM_INDEX
default communicator number PCOMM
virtual moab::Interface & get_moab()=0

Definition at line 1306 of file CommInterface.cpp.

1307 {
1308 MoFEM::Interface &m_field = cOre;
1310 ParallelComm *pcomm = ParallelComm::get_pcomm(
1311 &m_field.get_moab(), m_field.get_basic_entity_data_ptr()->pcommID);
1312 std::vector<int> shprocs(MAX_SHARING_PROCS, 0);
1313 std::vector<EntityHandle> shhandles(MAX_SHARING_PROCS, 0);
1314 Range ents;
1315 Tag th_gid = m_field.get_moab().globalId_tag();
1316 PetscLayout layout;
1317 CHKERR problem_ptr->getNumberOfElementsByNameAndPart(m_field.get_comm(),
1318 fe_name, &layout);
1319 int gid, last_gid;
1320 CHKERR PetscLayoutGetRange(layout, &gid, &last_gid);
1321 CHKERR PetscLayoutDestroy(&layout);
1322
1323 const FiniteElement_multiIndex *fes_ptr;
1324 CHKERR m_field.get_finite_elements(&fes_ptr);
1325
1326 auto fe_miit = fes_ptr->get<FiniteElement_name_mi_tag>().find(fe_name);
1327 if (fe_miit != fes_ptr->get<FiniteElement_name_mi_tag>().end()) {
1328 auto fit =
1329 problem_ptr->numeredFiniteElementsPtr->get<Unique_mi_tag>().lower_bound(
1331 0, (*fe_miit)->getFEUId()));
1332 auto hi_fe_it =
1333 problem_ptr->numeredFiniteElementsPtr->get<Unique_mi_tag>().upper_bound(
1335 get_id_for_max_type<MBENTITYSET>(), (*fe_miit)->getFEUId()));
1336 for (; fit != hi_fe_it; ++fit) {
1337
1338 auto ent = (*fit)->getEnt();
1339 auto part = (*fit)->getPart();
1340
1341 ents.insert(ent);
1342 CHKERR m_field.get_moab().tag_set_data(pcomm->part_tag(), &ent, 1, &part);
1343 if (part == pcomm->rank()) {
1344 CHKERR m_field.get_moab().tag_set_data(th_gid, &ent, 1, &gid);
1345 gid++;
1346 }
1347 shprocs.clear();
1348 shhandles.clear();
1349
1350 if (pcomm->size() > 1) {
1351
1352 unsigned char pstatus = 0;
1353 if (pcomm->rank() != part) {
1354 pstatus = PSTATUS_NOT_OWNED;
1355 pstatus |= PSTATUS_GHOST;
1356 }
1357
1358 if (pcomm->size() > 2) {
1359 pstatus |= PSTATUS_SHARED;
1360 pstatus |= PSTATUS_MULTISHARED;
1361 } else {
1362 pstatus |= PSTATUS_SHARED;
1363 }
1364
1365 size_t rrr = 0;
1366 for (size_t rr = 0; rr < pcomm->size(); ++rr) {
1367 if (rr != pcomm->rank()) {
1368 shhandles[rrr] = ent;
1369 shprocs[rrr] = rr;
1370 ++rrr;
1371 }
1372 }
1373 for (; rrr != pcomm->size(); ++rrr)
1374 shprocs[rrr] = -1;
1375
1376 if (pstatus & PSTATUS_SHARED) {
1377 CHKERR m_field.get_moab().tag_set_data(pcomm->sharedp_tag(), &ent, 1,
1378 &shprocs[0]);
1379 CHKERR m_field.get_moab().tag_set_data(pcomm->sharedh_tag(), &ent, 1,
1380 &shhandles[0]);
1381 }
1382
1383 if (pstatus & PSTATUS_MULTISHARED) {
1384 CHKERR m_field.get_moab().tag_set_data(pcomm->sharedps_tag(), &ent, 1,
1385 &shprocs[0]);
1386 CHKERR m_field.get_moab().tag_set_data(pcomm->sharedhs_tag(), &ent, 1,
1387 &shhandles[0]);
1388 }
1389 CHKERR m_field.get_moab().tag_set_data(pcomm->pstatus_tag(), &ent, 1,
1390 &pstatus);
1391 }
1392 }
1393 }
1394
1395 CHKERR pcomm->exchange_tags(th_gid, ents);
1397}
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
multi_index_container< boost::shared_ptr< FiniteElement >, indexed_by< hashed_unique< tag< FiniteElement_Meshset_mi_tag >, member< FiniteElement, EntityHandle, &FiniteElement::meshset > >, hashed_unique< tag< BitFEId_mi_tag >, const_mem_fun< FiniteElement, BitFEId, &FiniteElement::getId >, HashBit< BitFEId >, EqBit< BitFEId > >, ordered_unique< tag< FiniteElement_name_mi_tag >, const_mem_fun< FiniteElement, boost::string_ref, &FiniteElement::getNameRef > > > > FiniteElement_multiIndex
MultiIndex for entities for FiniteElement.
virtual const FiniteElement_multiIndex * get_finite_elements() const =0
Get the finite elements object.
virtual MPI_Comm & get_comm() const =0
virtual boost::shared_ptr< BasicEntityData > & get_basic_entity_data_ptr()=0
Get pointer to basic entity data.
Deprecated interface functions.
UId getLocalUniqueIdCalculate() const
Generate UId for finite element entity.

◆ resolveSharedFiniteElements() [2/2]

MoFEMErrorCode MoFEM::CommInterface::resolveSharedFiniteElements ( const std::string  name,
const std::string &  fe_name,
int  verb = DEFAULT_VERBOSITY 
)

#include <src/interfaces/CommInterface.hpp>

resolve shared entities for finite elements in the problem

Parameters
nameproblem name
fe_namefinite element name
verbverbosity level
Returns
error code

This allows for tag reduction or tag exchange, f.e.

CHKERR m_field.resolveSharedFiniteElements(problem_ptr,"SHELL_ELEMENT");
CHKERR mField.get_moab().tag_get_handle("ADAPT_ORDER",th);
ParallelComm* pcomm =
ParallelComm::get_pcomm(&mField.get_moab(),MYPCOMM_INDEX);
// CHKERR pcomm->reduce_tags(th,MPI_SUM,prisms);
CHKERR pcomm->exchange_tags(th,prisms);

Definition at line 1399 of file CommInterface.cpp.

1400 {
1401 MoFEM::Interface &m_field = cOre;
1403 const Problem *problem_ptr;
1404 CHKERR m_field.get_problem(name, &problem_ptr);
1405 CHKERR resolveSharedFiniteElements(problem_ptr, fe_name, verb);
1407}
std::string name
virtual const Problem * get_problem(const std::string problem_name) const =0
Get the problem object.
MoFEMErrorCode resolveSharedFiniteElements(const Problem *problem_ptr, const std::string &fe_name, int verb=DEFAULT_VERBOSITY)
resolve shared entities for finite elements in the problem