v0.16.0
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes | List of all members
MoFEM::MeshsetsManager Struct Reference

Interface for managing meshsets containing materials and boundary conditions. More...

#include "src/interfaces/MeshsetsManager.hpp"

Inheritance diagram for MoFEM::MeshsetsManager:
[legend]
Collaboration diagram for MoFEM::MeshsetsManager:
[legend]

Public Member Functions

MoFEMErrorCode query_interface (boost::typeindex::type_index type_index, UnknownInterface **iface) const
 Query interface for MeshsetsManager.
 
 MeshsetsManager (const MoFEM::Core &core)
 Constructor for MeshsetsManager.
 
virtual ~MeshsetsManager ()=default
 
MoFEMErrorCode getTags (int verb=-1)
 Get tag handles used on meshsets.
 
Tag get_nsTag () const
 get tag handle used to store "id" of NODESET
 
Tag get_ssTag () const
 get tag handle used to store "id" of SIDESET
 
Tag get_nsTag_data () const
 get tag handle used to store boundary data on NODESET
 
Tag get_ssTag_data () const
 get tag handle used to store boundary data on SIDESET
 
Tag get_bhTag () const
 get tag handle used to store "id" of BLOCKSET
 
Tag get_bhTag_header () const
 get tag handle used to store of block set header (Used by Cubit)
 
MeshsetsManagerget_meshsets_manager_ptr ()
 return pointer to meshset manager
 
const MeshsetsManagerget_meshsets_manager_ptr () const
 return pointer to meshset manager
 
MoFEMErrorCode clearMap ()
 Clear the multi-index container.
 
MoFEMErrorCode discardBlocksetConfiguration (std::size_t *cleared_names=nullptr, std::size_t *cleared_attributes=nullptr, const bool clear_names=true, const bool clear_attributes=true)
 Remove imported BLOCKSET names and/or attributes from the mesh.
 
MoFEMErrorCode initialiseDatabaseFromMesh (int verb=DEFAULT_VERBOSITY)
 Initialize container from mesh data.
 
MoFEMErrorCode readMeshsets (int verb=DEFAULT_VERBOSITY)
 Read meshsets from mesh database.
 
MoFEMErrorCode broadcastMeshsets (int verb=DEFAULT_VERBOSITY)
 Broadcast meshsets across MPI processes.
 
template<class CUBIT_BC_DATA_TYPE >
MoFEMErrorCode printBcSet (CUBIT_BC_DATA_TYPE &data, unsigned long int type) const
 
MoFEMErrorCode printDisplacementSet () const
 Print meshsets with displacement boundary conditions.
 
MoFEMErrorCode printPressureSet () const
 Print meshsets with pressure boundary conditions.
 
MoFEMErrorCode printForceSet () const
 Print meshsets with force boundary conditions.
 
MoFEMErrorCode printTemperatureSet () const
 Print meshsets with temperature boundary conditions.
 
MoFEMErrorCode printHeatFluxSet () const
 Print meshsets with heat flux boundary conditions.
 
MoFEMErrorCode printMaterialsSet () const
 Print meshsets with material properties.
 
CubitMeshSet_multiIndexgetMeshsetsMultindex ()
 
CubitMeshSet_multiIndex::iterator getBegin () const
 get begin iterator of cubit meshset of given type (instead you can use IT_CUBITMESHSETS_TYPE_FOR_LOOP(MFIELD,CUBITBCTYPE,IT)
 
CubitMeshSet_multiIndex::iterator getEnd () const
 get begin iterator of cubit meshset of given type (instead you can use IT_CUBITMESHSETS_TYPE_FOR_LOOP(MFIELD,CUBITBCTYPE,IT)
 
CubitMeshsetByType::iterator getBegin (const unsigned int cubit_bc_type) const
 get begin iterator of cubit meshset of given type (instead you can use IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP(MFIELD,CUBITBCTYPE,IT)
 
CubitMeshsetByType::iterator getEnd (const unsigned int cubit_bc_type) const
 get begin iterator of cubit meshset of given type (instead you can use IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP(MFIELD,CUBITBCTYPE,IT)
 
CubitMeshsetByMask::iterator getBySetTypeBegin (const unsigned int cubit_bc_type) const
 get end iterator of cubit meshset of given type (instead you can use IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP(MFIELD,CUBITBCTYPE,IT)
 
CubitMeshsetByMask::iterator getBySetTypeEnd (const unsigned int cubit_bc_type) const
 get end iterator of cubit meshset of given type (instead you can use IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP(MFIELD,CUBITBCTYPE,IT)
 
CubitMeshsetByName::iterator getBegin (const std::string &name) const
 get begin iterator of cubit meshset of given type (instead you can use IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP(MFIELD,CUBITBCTYPE,IT)
 
CubitMeshsetByName::iterator getEnd (const std::string &name) const
 get begin iterator of cubit meshset of given type (instead you can use IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP(MFIELD,CUBITBCTYPE,IT)
 
bool checkMeshset (const int ms_id, const CubitBCType cubit_bc_type) const
 Check for CUBIT meshset by ID and type.
 
bool checkMeshset (const string name, int *const number_of_meshsets_ptr=NULL) const
 Check if meshset with given name exists.
 
MoFEMErrorCode addMeshset (const CubitBCType cubit_bc_type, const int ms_id, const std::string name="")
 Add CUBIT meshset to manager.
 
MoFEMErrorCode addBitToMeshsetType (const CubitBCType cubit_bc_type, const int ms_id, const CubitBCType type_bit)
 
MoFEMErrorCode addEntitiesToMeshset (const CubitBCType cubit_bc_type, const int ms_id, const Range &ents)
 Add entities to CUBIT meshset.
 
MoFEMErrorCode addEntitiesToMeshset (const CubitBCType cubit_bc_type, const int ms_id, const EntityHandle *ents, const int nb_ents)
 Add entities to CUBIT meshset (array version)
 
MoFEMErrorCode setAttributes (const CubitBCType cubit_bc_type, const int ms_id, const std::vector< double > &attributes, const std::string name="")
 Set attributes for CUBIT meshset.
 
MoFEMErrorCode setName (const CubitBCType cubit_bc_type, const int ms_id, const std::string &name)
 
DEPRECATED auto setAtributes (const CubitBCType cubit_bc_type, const int ms_id, const std::vector< double > &attributes, const std::string name="")
 
MoFEMErrorCode setAttributesByDataStructure (const CubitBCType cubit_bc_type, const int ms_id, const GenericAttributeData &data, const std::string name="")
 Set attributes using data structure.
 
DEPRECATED auto setAtributesByDataStructure (const CubitBCType cubit_bc_type, const int ms_id, const GenericAttributeData &data, const std::string name="")
 
MoFEMErrorCode setBcData (const CubitBCType cubit_bc_type, const int ms_id, const GenericCubitBcData &data)
 Set boundary condition data for meshset.
 
MoFEMErrorCode deleteMeshset (const CubitBCType cubit_bc_type, const int ms_id, const MoFEMTypes bh=MF_EXIST)
 delete cubit meshset
 
MoFEMErrorCode getCubitMeshsetPtr (const int ms_id, const CubitBCType cubit_bc_type, const CubitMeshSets **cubit_meshset_ptr) const
 get cubit meshset
 
const CubitMeshSetsgetCubitMeshsetPtr (const int ms_id, const CubitBCType cubit_bc_type) const
 get cubit meshset
 
MoFEMErrorCode getCubitMeshsetPtr (const CubitBCType cubit_bc_type, std::vector< const CubitMeshSets * > &vec_ptr) const
 Get vector of pointer by bc type.
 
std::vector< const CubitMeshSets * > getCubitMeshsetPtr (const CubitBCType cubit_bc_type) const
 Get vector of pointer by bc type.
 
MoFEMErrorCode getCubitMeshsetPtr (const string name, const CubitMeshSets **cubit_meshset_ptr) const
 get cubit meshset
 
MoFEMErrorCode getCubitMeshsetPtr (const std::regex reg_exp_name, std::vector< const CubitMeshSets * > &vec_ptr) const
 Get vector of pointer to blocksets with name satisfying regular expression.
 
std::vector< const CubitMeshSets * > getCubitMeshsetPtr (const std::regex reg_exp_name) const
 Get vector of pointer to blocksets with name satisfying regular expression.
 
MoFEMErrorCode getEntitiesByDimension (const int ms_id, const unsigned int cubit_bc_type, const int dimension, Range &entities, const bool recursive=true) const
 get entities from CUBIT/meshset of a particular entity dimension
 
MoFEMErrorCode getEntitiesByDimension (const int ms_id, const unsigned int cubit_bc_type, Range &entities, const bool recursive=true) const
 get entities related to CUBIT/meshset,
 
MoFEMErrorCode getMeshset (const int ms_id, const unsigned int cubit_bc_type, EntityHandle &meshset) const
 get meshset from CUBIT Id and CUBIT type
 
bool checkIfMeshsetContainsEntities (const int ms_id, const unsigned int cubit_bc_type, const EntityHandle *entities, int num_entities, const int operation_type=moab::Interface::INTERSECT)
 Check if meshset constains entities.
 
MoFEMErrorCode getMeshsetsByType (const unsigned int cubit_bc_type, Range &meshsets) const
 get all CUBIT meshsets by CUBIT type
 
MoFEMErrorCode setMeshsetFromFile (const string file_name, const bool clean_file_options=true)
 add blocksets reading config file
 
MoFEMErrorCode setMeshsetFromFile ()
 Load meshset configuration from command line specified file.
 
MoFEMErrorCode saveMeshsetToFile (const int ms_id, const unsigned int cubit_bc_type, const std::string file_name="out_meshset.vtk", const std::string file_type="VTK", const std::string options="") const
 save cubit meshset entities on the moab mesh
 
MoFEMErrorCode saveMeshsetToFile (const int ms_id, const unsigned int cubit_bc_type, const int dim, const std::string file_name="out_meshset.vtk", const bool recursive=false, const std::string file_type="VTK", const std::string options="") const
 save cubit meshset entities on the moab mesh
 
boost::shared_ptr< boost::program_options::options_description > & getConfigFileOptionsPtr ()
 Get config file options, use with care.
 
MoFEMErrorCode updateAllMeshsetsByEntitiesChildren (const BitRefLevel &bit)
 Update all blocksets, sidesets and node sets.
 
- 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
 

Static Public Member Functions

static MoFEMErrorCode getTags (moab::Interface &moab, Tag &nsTag, Tag &ssTag, Tag &nsTag_data, Tag &ssTag_data, Tag &bhTag, Tag &bhTag_header, int verb=-1)
 Static version of getTags for external MOAB interface.
 
static void sortMeshsets (std::vector< const CubitMeshSets * > &vec_ptr)
 
- 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.
 

Public Attributes

MoFEM::CorecOre
 Reference to MoFEM Core interface.
 

Static Public Attributes

static bool broadcastMeshsetsOn = true
 

Protected Attributes

Tag nsTag
 
Tag ssTag
 
Tag nsTag_data
 
Tag ssTag_data
 
Tag bhTag
 
Tag bhTag_header
 
CubitMeshSet_multiIndex cubitMeshsets
 cubit meshsets
 
boost::shared_ptr< boost::program_options::options_description > configFileOptionsPtr
 config file options
 

Detailed Description

Interface for managing meshsets containing materials and boundary conditions.

The MeshsetsManager provides comprehensive functionality for creating, managing, and querying mesh sets (materials, boundary conditions, and blocks) within the MoFEM framework. It serves as the foundation for higher-level boundary condition management and integrates seamlessly with various meshing software formats.

Connection to BcManager

The MeshsetsManager acts as the data layer for the BcManager interface:

MOAB Meshset Integration

MeshsetsManager leverages MOAB's native meshset capabilities:

CUBIT/Coreform Meshset Types

NODESET

SIDESET <br>

BLOCKSET

Generic Multi-Format Support

The MeshsetsManager approach is not restricted to CUBIT and supports multiple meshing formats:

Gmsh Integration

Salome/MED Format Support

Other Format Support

Typical Multi-Format Workflow

  1. Mesh Import: Load mesh with native format-specific group definitions
  2. Tag Discovery: MeshsetsManager discovers and categorizes existing tags
  3. Meshset Creation: Convert format-specific groups to unified meshset representation
  4. Data Association: Attach material properties and boundary condition data
  5. Validation: Verify meshset consistency and completeness
  6. Problem Setup: Use meshsets for finite element problem definition

Key Capabilities

Examples
/home/lk58p/mofem_install/vanilla_dev_release/mofem-cephas/mofem/users_modules/eshelbian_plasticity/src/impl/EshelbianPlasticity.cpp, ep.cpp, mofem/atom_tests/add_blockset.cpp, mofem/atom_tests/add_cubit_meshsets.cpp, mofem/atom_tests/cubit_bc_test.cpp, mofem/atom_tests/prism_elements_from_surface.cpp, mofem/tools/mesh_cut.cpp, mofem/tools/mesh_smoothing.cpp, mofem/tools/meshset_to_vtk.cpp, mofem/tools/split_sideset.cpp, mofem/tutorials/adv-0_plasticity/plastic.cpp, mofem/tutorials/adv-4_dynamic_first_order_con_law/dynamic_first_order_con_law.cpp, mofem/tutorials/adv-5_poroelasticity/seepage.cpp, mofem/tutorials/cor-0to1_unsaturated_transport/unsaturated_transport.cpp, mofem/tutorials/cor-7_elasticity_mixed_formulation/elasticity_mixed_formulation.cpp, mofem/tutorials/cor-9_reaction_diffusion/reaction_diffusion.cpp, mofem/tutorials/scl-1_poisson_2d_homogeneous/poisson_2d_homogeneous.cpp, mofem/tutorials/scl-6_heat_equation/heat_equation.cpp, mofem/tutorials/vec-3_nonlinear_dynamics/nonlinear_dynamic_elastic.cpp, mofem/tutorials/vec-5_free_surface/free_surface.cpp, mofem/tutorials/vec-7_shape_optimisation/adjoint.cpp, mofem/users_modules/adolc-plasticity/adolc_plasticity.cpp, mofem/users_modules/basic_finite_elements/elasticity/elasticity.cpp, mofem/users_modules/eshelbian_plasticity/ep.cpp, plastic.cpp, thermo_elastic.cpp, and thermoplastic.cpp.

Definition at line 208 of file MeshsetsManager.hpp.

Constructor & Destructor Documentation

◆ MeshsetsManager()

MoFEM::MeshsetsManager::MeshsetsManager ( const MoFEM::Core core)

Constructor for MeshsetsManager.

Parameters
corereference to MoFEM Core interface for accessing mesh and field data

Definition at line 34 of file MeshsetsManager.cpp.

35 : cOre(const_cast<Core &>(core)) {
36
37 if (!LogManager::checkIfChannelExist("MeshsetMngWorld")) {
38 auto core_log = logging::core::get();
39
40 core_log->add_sink(
42 core_log->add_sink(
44 core_log->add_sink(
46
47 LogManager::setLog("MeshsetMngWorld");
48 LogManager::setLog("MeshsetMngSync");
49 LogManager::setLog("MeshsetMngSelf");
50
51 MOFEM_LOG_TAG("MeshsetMngWorld", "MeshsetMng");
52 MOFEM_LOG_TAG("MeshsetMngSync", "MeshsetMng");
53 MOFEM_LOG_TAG("MeshsetMngSelf", "MeshsetMng");
54 }
55
56 MOFEM_LOG("MeshsetMngWorld", Sev::noisy) << "Mashset manager created";
57}
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
CoreTmp< 0 > Core
Definition Core.hpp:1154
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
static boost::shared_ptr< std::ostream > getStrmSync()
Get the strm sync object.
static bool checkIfChannelExist(const std::string channel)
Check if channel exist.
static boost::shared_ptr< std::ostream > getStrmSelf()
Get the strm self object.
MoFEM::Core & cOre
Reference to MoFEM Core interface.

◆ ~MeshsetsManager()

virtual MoFEM::MeshsetsManager::~MeshsetsManager ( )
virtualdefault

Member Function Documentation

◆ addBitToMeshsetType()

MoFEMErrorCode MoFEM::MeshsetsManager::addBitToMeshsetType ( const CubitBCType  cubit_bc_type,
const int  ms_id,
const CubitBCType  type_bit 
)

Adds an extra classification bit to an existing meshset type. Example: promote a plain BLOCKSET to BLOCKSET|MAT_THERMALSET.

Definition at line 538 of file MeshsetsManager.cpp.

540 {
541 Interface &m_field = cOre;
543 // Update the meshset classification in-place without changing its entities.
544 auto cit =
545 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().find(
546 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
547 if (cit ==
548 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().end()) {
549 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
550 "Cannot find Cubit meshset with id: %d", ms_id);
551 }
552 const bool success = cubitMeshsets.modify(
553 cubitMeshsets.project<0>(cit),
554 CubitMeshSets_change_add_bit_to_cubit_bc_type(type_bit));
555 if (!success) {
556 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
557 "modification unsuccessful");
558 }
560}
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_OPERATION_UNSUCCESSFUL
Definition definitions.h:34
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
DeprecatedCoreInterface Interface
CubitMeshSet_multiIndex cubitMeshsets
cubit meshsets

◆ checkIfMeshsetContainsEntities()

bool MoFEM::MeshsetsManager::checkIfMeshsetContainsEntities ( const int  ms_id,
const unsigned int  cubit_bc_type,
const EntityHandle entities,
int  num_entities,
const int  operation_type = moab::Interface::INTERSECT 
)

Check if meshset constains entities.

Parameters
ms_id
cubit_bc_type
entities
num_entities
operation_type
Returns
true
false

Definition at line 893 of file MeshsetsManager.cpp.

895 {
896 auto miit =
897 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().find(
898 boost::make_tuple(ms_id, cubit_bc_type));
899 if (miit !=
900 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().end()) {
901 Interface &m_field = cOre;
902 return m_field.get_moab().contains_entities(miit->meshset, entities,
903 num_entities, operation_type);
904 } else
905 return false;
906}
moab::Interface & get_moab()
Definition Core.hpp:327

◆ get_bhTag()

Tag MoFEM::MeshsetsManager::get_bhTag ( ) const
inline

get tag handle used to store "id" of BLOCKSET

Definition at line 284 of file MeshsetsManager.hpp.

◆ get_bhTag_header()

Tag MoFEM::MeshsetsManager::get_bhTag_header ( ) const
inline

get tag handle used to store of block set header (Used by Cubit)

Definition at line 289 of file MeshsetsManager.hpp.

◆ get_meshsets_manager_ptr() [1/2]

MeshsetsManager * MoFEM::MeshsetsManager::get_meshsets_manager_ptr ( )
inline

return pointer to meshset manager

Definition at line 294 of file MeshsetsManager.hpp.

294{ return this; }

◆ get_meshsets_manager_ptr() [2/2]

const MeshsetsManager * MoFEM::MeshsetsManager::get_meshsets_manager_ptr ( ) const
inline

return pointer to meshset manager

Definition at line 299 of file MeshsetsManager.hpp.

299{ return this; }

◆ get_nsTag()

Tag MoFEM::MeshsetsManager::get_nsTag ( ) const
inline

get tag handle used to store "id" of NODESET

Definition at line 264 of file MeshsetsManager.hpp.

◆ get_nsTag_data()

Tag MoFEM::MeshsetsManager::get_nsTag_data ( ) const
inline

get tag handle used to store boundary data on NODESET

Definition at line 274 of file MeshsetsManager.hpp.

◆ get_ssTag()

Tag MoFEM::MeshsetsManager::get_ssTag ( ) const
inline

get tag handle used to store "id" of SIDESET

Definition at line 269 of file MeshsetsManager.hpp.

◆ get_ssTag_data()

Tag MoFEM::MeshsetsManager::get_ssTag_data ( ) const
inline

get tag handle used to store boundary data on SIDESET

Definition at line 279 of file MeshsetsManager.hpp.

◆ getConfigFileOptionsPtr()

boost::shared_ptr< boost::program_options::options_description > & MoFEM::MeshsetsManager::getConfigFileOptionsPtr ( )
inline

Get config file options, use with care.

Returns
error code

Definition at line 1154 of file MeshsetsManager.hpp.

1154 {
1155 return configFileOptionsPtr;
1156 }
boost::shared_ptr< boost::program_options::options_description > configFileOptionsPtr
config file options

◆ getMeshsetsMultindex()

CubitMeshSet_multiIndex & MoFEM::MeshsetsManager::getMeshsetsMultindex ( )
inline

◆ printBcSet()

template<class CUBIT_BC_DATA_TYPE >
MoFEMErrorCode MoFEM::MeshsetsManager::printBcSet ( CUBIT_BC_DATA_TYPE &  data,
unsigned long int  type 
) const

Definition at line 1187 of file MeshsetsManager.hpp.

1188 {
1190 const MoFEM::Interface &m_field = cOre;
1191 const moab::Interface &moab = m_field.get_moab();
1192 for (auto it : getCubitMeshsetPtr(type)) {
1193 CHKERR it->getBcDataStructure(data);
1194 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << *it;
1195 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << data;
1196 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << "name " << it->getName();
1197 for (EntityType t = MBVERTEX; t != MBENTITYSET; ++t) {
1198 int nb;
1199 CHKERR moab.get_number_entities_by_type(it->meshset, t, nb, true);
1200 if (nb > 0) {
1201 MOFEM_LOG("MeshsetMngSync", Sev::inform)
1202 << "msId " << it->getMeshsetId() << " number of "
1203 << moab::CN::EntityTypeName(t) << " " << nb;
1204 }
1205 }
1206 MOFEM_LOG_SEVERITY_SYNC(m_field.get_comm(), Sev::inform);
1207 }
1209}
std::string type
#define MOFEM_LOG_SEVERITY_SYNC(comm, severity)
Synchronise "SYNC" on curtain severity level.
#define CHKERR
Inline error check.
MoFEMErrorCode getCubitMeshsetPtr(const int ms_id, const CubitBCType cubit_bc_type, const CubitMeshSets **cubit_meshset_ptr) const
get cubit meshset
constexpr double t
plate stiffness
Definition plate.cpp:58
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
Deprecated interface functions.

◆ query_interface()

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

Query interface for MeshsetsManager.

Parameters
type_indextype index for the interface to query
ifacepointer to store the interface
Returns
MoFEMErrorCode Error code indicating success or failure

Implements MoFEM::UnknownInterface.

Definition at line 28 of file MeshsetsManager.cpp.

29 {
30 *iface = const_cast<MeshsetsManager *>(this);
31 return 0;
32}
MeshsetsManager(const MoFEM::Core &core)
Constructor for MeshsetsManager.

◆ saveMeshsetToFile() [1/2]

MoFEMErrorCode MoFEM::MeshsetsManager::saveMeshsetToFile ( const int  ms_id,
const unsigned int  cubit_bc_type,
const int  dim,
const std::string  file_name = "out_meshset.vtk",
const bool  recursive = false,
const std::string  file_type = "VTK",
const std::string  options = "" 
) const

save cubit meshset entities on the moab mesh

Parameters
ms_idid of the cubit meshset
cubit_bc_typetype of a cubit mesheset (NODESET SIDESET BLOCKSET)
dimdimension of the entities
file_nameoptional name for the file
file_typeoptional file type for moab (VTK MOAB)
optionsoptional parameters for moab writer (PARALLEL=WRITE_PART)
Returns
MoFEMErrorCode

Definition at line 1696 of file MeshsetsManager.cpp.

1699 {
1700
1702 MoFEM::Interface &m_field = cOre;
1703 moab::Interface &moab = m_field.get_moab();
1704 Range entities;
1705 CHKERR getEntitiesByDimension(ms_id, cubit_bc_type, dim, entities, recursive);
1706 EntityHandle meshset;
1707 CHKERR moab.create_meshset(MESHSET_SET, meshset);
1708 CHKERR moab.add_entities(meshset, entities);
1709 CHKERR moab.write_file(file_name.c_str(), file_type.c_str(), options.c_str(),
1710 &meshset, 1);
1711 CHKERR moab.delete_entities(&meshset, 1);
1713}
MoFEMErrorCode getEntitiesByDimension(const int ms_id, const unsigned int cubit_bc_type, const int dimension, Range &entities, const bool recursive=true) const
get entities from CUBIT/meshset of a particular entity dimension

◆ saveMeshsetToFile() [2/2]

MoFEMErrorCode MoFEM::MeshsetsManager::saveMeshsetToFile ( const int  ms_id,
const unsigned int  cubit_bc_type,
const std::string  file_name = "out_meshset.vtk",
const std::string  file_type = "VTK",
const std::string  options = "" 
) const

save cubit meshset entities on the moab mesh

Parameters
ms_idid of the cubit meshset (NODESET SIDESET BLOCKSET)
cubit_bc_typetype of a cubit mesheset
file_nameoptional name for the file
file_typeoptional file type for moab (VTK MOAB)
optionsoptional parameters for moab writer (PARALLEL=WRITE_PART)
Returns
MoFEMErrorCode
Examples
mofem/tools/meshset_to_vtk.cpp.

Definition at line 1681 of file MeshsetsManager.cpp.

1684 {
1685
1687 MoFEM::Interface &m_field = cOre;
1688 const CubitMeshSets *cubit_meshset_ptr;
1689 CHKERR getCubitMeshsetPtr(ms_id, cubit_bc_type, &cubit_meshset_ptr);
1690 EntityHandle meshset = cubit_meshset_ptr->getMeshset();
1691 CHKERR m_field.get_moab().write_file(file_name.c_str(), file_type.c_str(),
1692 options.c_str(), &meshset, 1);
1694}

◆ setAtributes()

DEPRECATED auto MoFEM::MeshsetsManager::setAtributes ( const CubitBCType  cubit_bc_type,
const int  ms_id,
const std::vector< double > &  attributes,
const std::string  name = "" 
)
inline

Definition at line 691 of file MeshsetsManager.hpp.

694 {
695 return setAttributes(cubit_bc_type, ms_id,
696 std::vector<double>(attributes), name);
697 }
MoFEMErrorCode setAttributes(const CubitBCType cubit_bc_type, const int ms_id, const std::vector< double > &attributes, const std::string name="")
Set attributes for CUBIT meshset.

◆ setAtributesByDataStructure()

DEPRECATED auto MoFEM::MeshsetsManager::setAtributesByDataStructure ( const CubitBCType  cubit_bc_type,
const int  ms_id,
const GenericAttributeData data,
const std::string  name = "" 
)
inline

Definition at line 718 of file MeshsetsManager.hpp.

720 {
721 return setAttributesByDataStructure(cubit_bc_type, ms_id, data, name);
722 }
MoFEMErrorCode setAttributesByDataStructure(const CubitBCType cubit_bc_type, const int ms_id, const GenericAttributeData &data, const std::string name="")
Set attributes using data structure.

◆ setMeshsetFromFile()

MoFEMErrorCode MoFEM::MeshsetsManager::setMeshsetFromFile ( const string  file_name,
const bool  clean_file_options = true 
)

add blocksets reading config file

Example of config file

[block_1001]
# Example applying attributes to blockset
id=2001
user1=1.0 # attribute value 1
user2=2.0 # legacy form supports user1 up to user10
user3=3.0
# alternatively, for any number of attributes:
# user_array=1.0, 2.0, 3.0, 4.0
[block_1002]
# Example applying material block (isotropic elastic material)
id=2002
name=MAT_ELASTIC
young=10
poisson=0.25
thermalexpansion=0
[block_1003]
# Example applying displacement constrains
id=2003
# Each flag means that boundary consition on displacements is set.
disp_flag1=1 # Setting constrains in x- direction
disp_flag2=1 # Setting constrains in y- direction
disp_flag3=1 # Setting constrains in z- direction
disp_flag4=1 # Setting constrains on rotation over x- axis
disp_flag5=1 # Setting constrains on rotation over y- axis
disp_flag6=1 # Setting constrains on rotation over z-axis
disp_ux=1 # value of disp in x- direction
disp_uy=2
disp_uz=3
disp_rx=4 # value of rotation in y-direction
disp_ry=5
disp_rz=6
# Note above values could be interpreted differently if needed.
[block_1004]
# Example applying force boundary conditions
id=2004
force_magnitude=1
moment_magnitude=1
force_fx=1
force_fy=1
force_fz=1
moment_mx=1
moment_my=1
moment_mz=1
[block_1005]
# Example applying pressure boundary conditions
id=2005
pressure_flag2=1 # 0: Pressure is interpreted as pure pressure 1:
pressure is interpreted as total force
pressure_magnitude=1
# Example applying temperature boundary conditions
[block_1006]
id=2006
temperature_flag1=1 # 0: N/A, 1: temperature value applied
temperature_t=1
[block_1007]
id=2007
heatflux_flag1=1 # 0: N/A, 1: heat flux applied
heatflux_magnitude=1
[block_1008]
# Example applying material block (isotropic thermal material)
id=2008
name=MAT_THERMAL # Hast to be set for Thermal Mat
conductivity=1
capacity=1
[block_1009]
# Example applying interface
id=2009
interface_type=1
[block_1010]
# Example applying material block for interface element
id=2010
name=MAT_INTERF
interface_alpha = 1
interface_beta = 0
interface_ft = 1
interface_Gf = 1
[block_1009]
# Example applying material block (isotropic trans iso material)
id=2011
name=MAT_ELASTIC_TRANS_ISO
Youngp=1
Youngz=2
Poissonp=3
Poissonpz=4
Shearzp=5
[SET_ATTR_FOO]
# Example set atttributes to block name "FOO"
number_of_attributes=3
user1=1
user2=2
user3=3
# alternatively, number_of_attributes is inferred from:
# user_array=1, 2, 3
@ NODESET
@ SIDESET
@ BLOCKSET
constexpr AssemblyType A
const int N
Definition speed_test.cpp:3
Parameters
file_namepath to configuration file containing meshset definitions
clean_file_optionswhether to clean existing file options before loading
Returns
MoFEMErrorCode Error code indicating success or failure
Examples
mofem/atom_tests/add_cubit_meshsets.cpp, mofem/tools/meshset_to_vtk.cpp, and mofem/tutorials/cor-0to1_unsaturated_transport/unsaturated_transport.cpp.

Definition at line 958 of file MeshsetsManager.cpp.

959 {
960 Interface &m_field = cOre;
962 std::ifstream ini_file(file_name.c_str(), std::ifstream::in);
963 po::variables_map vm;
964 if (clean_file_options) {
966 boost::shared_ptr<boost::program_options::options_description>(
967 new po::options_description());
968 }
969
970 auto add_block_attributes = [&](auto prefix, auto &block_lists, auto &it) {
971 // remove spacec from blockset name
972 configFileOptionsPtr->add_options()(
973 (prefix + ".number_of_attributes").c_str(),
974 po::value<int>(&block_lists[it->getMeshsetId()].numberOfAttributes)
975 ->default_value(-1),
976 "Number of blockset attributes")(
977 (prefix + ".user_array").c_str(), po::value<string>(),
978 "Add block attributes as comma separated list");
979 for (int ii = 1; ii <= 10; ii++) {
980 std::string surfix = ".user" + boost::lexical_cast<std::string>(ii);
981 configFileOptionsPtr->add_options()(
982 (prefix + surfix).c_str(),
983 po::value<double>(&block_lists[it->getMeshsetId()].aTtr[ii - 1])
984 ->default_value(0.0),
985 "Add block attribute");
986 }
987 };
988
989 // Add blocks
990 map<int, BlockData> block_lists;
992 const auto id = it->getMeshsetId();
993 block_lists[id].cubitMeshset = it->getMeshset();
994 std::string prefix =
995 "block_" + boost::lexical_cast<std::string>(id);
996 configFileOptionsPtr->add_options()(
997 (prefix + ".add").c_str(),
998 po::value<string>(&block_lists[it->getMeshsetId()].addType)
999 ->default_value("UNKNOWNSET"),
1000 "Add block set")(
1001 (prefix + ".id").c_str(),
1002 po::value<int>(&block_lists[it->getMeshsetId()].iD)->default_value(-1),
1003 "Id of meshset")(
1004 (prefix + ".name").c_str(),
1005 po::value<string>(&block_lists[it->getMeshsetId()].nAme)
1006 ->default_value(""),
1007 "Name of the meshset");
1008
1009 // Block attributes
1010 add_block_attributes(prefix, block_lists, it);
1011
1012 // Mat elastic
1013 {
1014 // double Young; ///< Young's modulus
1015 // double Poisson; ///< Poisson's ratio
1016 // double ThermalExpansion; ///< Thermal expansion
1017 configFileOptionsPtr->add_options()(
1018 (prefix + ".young").c_str(),
1019 po::value<double>()->default_value(-1)->notifier(
1020 [&block_lists, id](double v) {
1021 block_lists[id].matElastic.data.Young = v;
1022 }),
1023 "Young modulus")(
1024 (prefix + ".poisson").c_str(),
1025 po::value<double>()->default_value(-2)->notifier(
1026 [&block_lists, id](double v) {
1027 block_lists[id].matElastic.data.Poisson = v;
1028 }),
1029 "Poisson ratio")(
1030 (prefix + ".thermalexpansion").c_str(),
1031 po::value<double>()->default_value(-1)->notifier(
1032 [&block_lists, id](double v) {
1033 block_lists[id].matElastic.data.ThermalExpansion = v;
1034 }),
1035 "Thermal expansion");
1036 // TODO Add users parameters
1037 }
1038 // Mat Trans Iso
1039 {
1040 // Young's modulus in xy plane (Ep)
1041 // Young's modulus in z-direction (Ez)
1042 // Poisson's ratio in xy plane (vp)
1043 // Poisson's ratio in z-direction (vpz)
1044 // Shear modulus in z-direction (Gzp)
1045 configFileOptionsPtr->add_options()(
1046 (prefix + ".Youngp").c_str(),
1047 po::value<double>()->default_value(-1)->notifier(
1048 [&block_lists, id](double v) {
1049 block_lists[id].matTransIso.data.Youngp = v;
1050 }),
1051 "Youngp")(
1052 (prefix + ".Youngz").c_str(),
1053 po::value<double>()->default_value(-1)->notifier(
1054 [&block_lists, id](double v) {
1055 block_lists[id].matTransIso.data.Youngz = v;
1056 }),
1057 "Youngz")(
1058 (prefix + ".Poissonp").c_str(),
1059 po::value<double>()->default_value(0)->notifier(
1060 [&block_lists, id](double v) {
1061 block_lists[id].matTransIso.data.Poissonp = v;
1062 }),
1063 "Poissonp")(
1064 (prefix + ".Poissonpz").c_str(),
1065 po::value<double>()->default_value(0)->notifier(
1066 [&block_lists, id](double v) {
1067 block_lists[id].matTransIso.data.Poissonpz = v;
1068 }),
1069 "Poissonpz")(
1070 (prefix + ".Shearzp").c_str(),
1071 po::value<double>()->default_value(-1)->notifier(
1072 [&block_lists, id](double v) {
1073 block_lists[id].matTransIso.data.Shearzp = v;
1074 }),
1075 "Shearzp");
1076 // TODO Add users parameters
1077 }
1078 // Mat thermal
1079 {
1080 // double Conductivity; ///< Thermal conductivity
1081 // double HeatCapacity; ///< Heat Capacity
1082 configFileOptionsPtr->add_options()(
1083 (prefix + ".conductivity").c_str(),
1084 po::value<double>()->default_value(-1)->notifier(
1085 [&block_lists, id](double v) {
1086 block_lists[id].matThermal.data.Conductivity = v;
1087 }),
1088 "Conductivity")(
1089 (prefix + ".capacity").c_str(),
1090 po::value<double>()->default_value(-1)->notifier(
1091 [&block_lists, id](double v) {
1092 block_lists[id].matThermal.data.HeatCapacity = v;
1093 }),
1094 "Capacity");
1095 // TODO Add users parameters
1096 }
1097 // Mat interface
1098 {
1099 // double alpha; ///< Elastic modulus multiplier
1100 // double beta; ///< Damage Coupling multiplier between normal and
1101 // shear (g=sqrt(gn^2 + beta(gt1^2 + gt2^2))) double ft; ///< Maximum
1102 // stress of crack double Gf; ///< Fracture Energy
1103 configFileOptionsPtr->add_options()(
1104 (prefix + ".interface_alpha").c_str(),
1105 po::value<double>()->default_value(-1)->notifier(
1106 [&block_lists, id](double v) {
1107 block_lists[id].matInterf.data.alpha = v;
1108 }),
1109 "alpha")((prefix + ".interface_beta").c_str(),
1110 po::value<double>()->default_value(-1)->notifier(
1111 [&block_lists, id](double v) {
1112 block_lists[id].matInterf.data.beta = v;
1113 }),
1114 "beta")(
1115 (prefix + ".interface_ft").c_str(),
1116 po::value<double>()->default_value(-1)->notifier(
1117 [&block_lists, id](double v) {
1118 block_lists[id].matInterf.data.ft = v;
1119 }),
1120 "ft")(
1121 (prefix + ".interface_Gf").c_str(),
1122 po::value<double>()->default_value(-1)->notifier(
1123 [&block_lists, id](double v) {
1124 block_lists[id].matInterf.data.Gf = v;
1125 }),
1126 "Gf");
1127 // TODO Add users parameters
1128 }
1129
1130 // Displacement bc
1131 {
1132 // char flag1; //< Flag for X-Translation (0: N/A, 1: specified)
1133 // char flag2; //< Flag for Y-Translation (0: N/A, 1: specified)
1134 // char flag3; //< Flag for Z-Translation (0: N/A, 1: specified)
1135 // char flag4; //< Flag for X-Rotation (0: N/A, 1: specified)
1136 // char flag5; //< Flag for Y-Rotation (0: N/A, 1: specified)
1137 // char flag6; //< Flag for Z-Rotation (0: N/A, 1: specified)
1138 // double value1; //< Value for X-Translation
1139 // double value2; //< Value for Y-Translation
1140 // double value3; //< Value for Z-Translation
1141 // double value4; //< Value for X-Rotation
1142 // double value5; //< Value for Y-Rotation
1143 // double value6; //< Value for Z-Rotation
1144 configFileOptionsPtr->add_options()(
1145 (prefix + ".disp_flag1").c_str(),
1146 po::value<char>()->default_value(0)->notifier(
1147 [&block_lists, id](char v) {
1148 block_lists[id].dispBc.data.flag1 = v;
1149 }),
1150 "flag1")(
1151 (prefix + ".disp_flag2").c_str(),
1152 po::value<char>()->default_value(0)->notifier(
1153 [&block_lists, id](char v) {
1154 block_lists[id].dispBc.data.flag2 = v;
1155 }),
1156 "flag2")(
1157 (prefix + ".disp_flag3").c_str(),
1158 po::value<char>()->default_value(0)->notifier(
1159 [&block_lists, id](char v) {
1160 block_lists[id].dispBc.data.flag3 = v;
1161 }),
1162 "flag3")(
1163 (prefix + ".disp_flag4").c_str(),
1164 po::value<char>()->default_value(0)->notifier(
1165 [&block_lists, id](char v) {
1166 block_lists[id].dispBc.data.flag4 = v;
1167 }),
1168 "flag4")(
1169 (prefix + ".disp_flag5").c_str(),
1170 po::value<char>()->default_value(0)->notifier(
1171 [&block_lists, id](char v) {
1172 block_lists[id].dispBc.data.flag5 = v;
1173 }),
1174 "flag5")(
1175 (prefix + ".disp_flag6").c_str(),
1176 po::value<char>()->default_value(0)->notifier(
1177 [&block_lists, id](char v) {
1178 block_lists[id].dispBc.data.flag6 = v;
1179 }),
1180 "flag6")(
1181 (prefix + ".disp_ux").c_str(),
1182 po::value<double>()->default_value(0)->notifier(
1183 [&block_lists, id](double v) {
1184 block_lists[id].dispBc.data.value1 = v;
1185 }),
1186 "value1")(
1187 (prefix + ".disp_uy").c_str(),
1188 po::value<double>()->default_value(0)->notifier(
1189 [&block_lists, id](double v) {
1190 block_lists[id].dispBc.data.value2 = v;
1191 }),
1192 "value2")(
1193 (prefix + ".disp_uz").c_str(),
1194 po::value<double>()->default_value(0)->notifier(
1195 [&block_lists, id](double v) {
1196 block_lists[id].dispBc.data.value3 = v;
1197 }),
1198 "value3")(
1199 (prefix + ".disp_rx").c_str(),
1200 po::value<double>()->default_value(0)->notifier(
1201 [&block_lists, id](double v) {
1202 block_lists[id].dispBc.data.value4 = v;
1203 }),
1204 "value4")(
1205 (prefix + ".disp_ry").c_str(),
1206 po::value<double>()->default_value(0)->notifier(
1207 [&block_lists, id](double v) {
1208 block_lists[id].dispBc.data.value5 = v;
1209 }),
1210 "value5")(
1211 (prefix + ".disp_rz").c_str(),
1212 po::value<double>()->default_value(0)->notifier(
1213 [&block_lists, id](double v) {
1214 block_lists[id].dispBc.data.value6 = v;
1215 }),
1216 "value6");
1217 }
1218 // Force BC data
1219 {
1220 // char zero[3]; //< 3 zeros
1221 // double value1; //< Force magnitude
1222 // double value2; //< Moment magnitude
1223 // double value3; //< X-component of force direction vector
1224 // double value4; //< Y-component of force direction vector
1225 // double value5; //< Z-component of force direction vector
1226 // double value6; //< X-component of moment direction vector
1227 // double value7; //< Y-component of moment direction vector
1228 // double value8; //< Z-component of moment direction vector
1229 // char zero2; // 0
1230 configFileOptionsPtr->add_options()(
1231 (prefix + ".force_magnitude").c_str(),
1232 po::value<double>()->default_value(0)->notifier(
1233 [&block_lists, id](double v) {
1234 block_lists[id].forceBc.data.value1 = v;
1235 }),
1236 "value1")((prefix + ".moment_magnitude").c_str(),
1237 po::value<double>()->default_value(0)->notifier(
1238 [&block_lists, id](double v) {
1239 block_lists[id].forceBc.data.value2 = v;
1240 }),
1241 "value2")(
1242 (prefix + ".force_fx").c_str(),
1243 po::value<double>()->default_value(0)->notifier(
1244 [&block_lists, id](double v) {
1245 block_lists[id].forceBc.data.value3 = v;
1246 }),
1247 "value3")((prefix + ".force_fy").c_str(),
1248 po::value<double>()->default_value(0)->notifier(
1249 [&block_lists, id](double v) {
1250 block_lists[id].forceBc.data.value4 = v;
1251 }),
1252 "value4")(
1253 (prefix + ".force_fz").c_str(),
1254 po::value<double>()->default_value(0)->notifier(
1255 [&block_lists, id](double v) {
1256 block_lists[id].forceBc.data.value5 = v;
1257 }),
1258 "value5")((prefix + ".moment_mx").c_str(),
1259 po::value<double>()->default_value(0)->notifier(
1260 [&block_lists, id](double v) {
1261 block_lists[id].forceBc.data.value6 = v;
1262 }),
1263 "value6")(
1264 (prefix + ".moment_my").c_str(),
1265 po::value<double>()->default_value(0)->notifier(
1266 [&block_lists, id](double v) {
1267 block_lists[id].forceBc.data.value7 = v;
1268 }),
1269 "value7")((prefix + ".moment_mz").c_str(),
1270 po::value<double>()->default_value(0)->notifier(
1271 [&block_lists, id](double v) {
1272 block_lists[id].forceBc.data.value8 = v;
1273 }),
1274 "value8");
1275 }
1276 {
1277 // char name[11]; //< 11 characters for "Temperature"
1278 // char pre1; //< This is always zero
1279 // char pre2; //< 0: temperature is not applied on thin shells
1280 // (default); 1: temperature is applied on thin shells char flag1; //<
1281 // 0: N/A, 1: temperature value applied (not on thin shells) char flag2;
1282 // //< 0: N/A, 1: temperature applied on thin shell middle char flag3;
1283 // //< 0: N/A, 1: thin shell temperature gradient specified char flag4;
1284 // //< 0: N/A, 1: top thin shell temperature char flag5; //< 0: N/A, 1:
1285 // bottom thin shell temperature char flag6; //< This is always zero
1286 // double value1; //< Temperature (default case - no thin shells)
1287 // double value2; //< Temperature for middle of thin shells
1288 // double value3; //< Temperature gradient for thin shells
1289 // double value4; //< Temperature for top of thin shells
1290 // double value5; //< Temperature for bottom of thin shells
1291 // double value6; //< This is always zero, i.e. ignore
1292 configFileOptionsPtr->add_options()(
1293 (prefix + ".temperature_flag1").c_str(),
1294 po::value<char>()->default_value(0)->notifier(
1295 [&block_lists, id](char v) {
1296 block_lists[id].temperatureBc.data.flag1 = v;
1297 }),
1298 "flag1")(
1299 (prefix + ".temperature_t").c_str(),
1300 po::value<double>()->default_value(0)->notifier(
1301 [&block_lists, id](double v) {
1302 block_lists[id].temperatureBc.data.value1 = v;
1303 }),
1304 "value1");
1305 // TODO: Add more cases, see above
1306 }
1307 // Sideset
1308 {
1309 // char name[8]; //< 8 characters for "Pressure"
1310 // char zero; //< This is always zero
1311 // char flag2; //< 0: Pressure is interpreted as pure pressure 1:
1312 // pressure is interpreted as total force double value1; //< Pressure
1313 // value
1314 configFileOptionsPtr->add_options()(
1315 (prefix + ".pressure_flag2").c_str(),
1316 po::value<char>()->default_value(0)->notifier(
1317 [&block_lists, id](char v) {
1318 block_lists[id].pressureBc.data.flag2 = v;
1319 }),
1320 "flag2")((prefix + ".pressure_magnitude").c_str(),
1321 po::value<double>()->default_value(0)->notifier(
1322 [&block_lists, id](double v) {
1323 block_lists[id].pressureBc.data.value1 = v;
1324 }),
1325 "value1");
1326 }
1327 {
1328 // char name[8]; //< 8 characters for "HeatFlux" (no space)
1329 // char pre1; //< This is always zero
1330 // char pre2; //< 0: heat flux is not applied on thin shells (default);
1331 // 1: heat flux is applied on thin shells char flag1; //< 0: N/A, 1:
1332 // normal heat flux case (i.e. single value, case without thin shells)
1333 // char flag2; //< 0: N/A, 1: Thin shell top heat flux specified
1334 // char flag3; //< 0: N/A, 1: Thin shell bottom heat flux specidied
1335 // double value1; //< Heat flux value for default case (no thin shells)
1336 // double value2; //< Heat flux (thin shell top)
1337 // double value3; //< Heat flux (thin shell bottom)
1338 configFileOptionsPtr->add_options()(
1339 (prefix + ".heatflux_flag1").c_str(),
1340 po::value<char>()->default_value(0)->notifier(
1341 [&block_lists, id](char v) {
1342 block_lists[id].heatFluxBc.data.flag1 = v;
1343 }),
1344 "flag1")((prefix + ".heatflux_magnitude").c_str(),
1345 po::value<double>()->default_value(0)->notifier(
1346 [&block_lists, id](double v) {
1347 block_lists[id].heatFluxBc.data.value1 = v;
1348 }),
1349 "value1");
1350 }
1351 // Interface set
1352 {
1353 configFileOptionsPtr->add_options()(
1354 (prefix + ".interface_type").c_str(),
1355 po::value<char>()->default_value(0)->notifier(
1356 [&block_lists, id](char v) {
1357 block_lists[id].cfgBc.data.type = v;
1358 }),
1359 "type");
1360 }
1361 }
1362
1363 map<int, BlockData> block_set_attributes;
1365 block_set_attributes[it->getMeshsetId()].cubitMeshset = it->getMeshset();
1366 block_set_attributes[it->getMeshsetId()].iD = it->getMeshsetId();
1367 block_set_attributes[it->getMeshsetId()].bcType = BLOCKSET;
1368 std::string block_name = it->getName();
1369 block_name.erase(
1370 std::remove_if(block_name.begin(), block_name.end(), ::isspace),
1371 block_name.end());
1372 block_set_attributes[it->getMeshsetId()].nAme = block_name;
1373 // Only blocks which have name
1374 if (block_name.compare("NoNameSet") != 0) {
1375 std::string prefix = "SET_ATTR_" + block_name;
1376 // Block attributes
1377 add_block_attributes(prefix, block_set_attributes, it);
1378 }
1379 }
1380
1381 po::parsed_options parsed =
1382 parse_config_file(ini_file, *configFileOptionsPtr, true);
1383 store(parsed, vm);
1384 po::notify(vm);
1385
1386 auto parse_attributes_array = [&](const std::string &option_name,
1387 const std::string &values,
1388 std::vector<double> &attributes) {
1389 attributes.clear();
1390 std::string normalized = values;
1391 for (auto &c : normalized) {
1392 if (c == ',' || c == '[' || c == ']')
1393 c = ' ';
1394 }
1395
1396 std::stringstream ss(normalized);
1397 double value;
1398 while (ss >> value) {
1399 attributes.push_back(value);
1400 }
1401 if (!ss.eof()) {
1402 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1403 "Invalid value for %s: %s", option_name.c_str(),
1404 values.c_str());
1405 }
1406 return 0;
1407 };
1408
1409 auto apply_attributes_array = [&](const std::string &prefix,
1410 BlockData &block_data) {
1411 const auto option_name = prefix + ".user_array";
1412 if (vm.count(option_name)) {
1413 CHKERR parse_attributes_array(option_name, vm[option_name].as<string>(),
1414 block_data.aTtr);
1415 block_data.numberOfAttributes = static_cast<int>(block_data.aTtr.size());
1416 } else if (block_data.numberOfAttributes > -1) {
1417 block_data.aTtr.resize(block_data.numberOfAttributes, 0);
1418 }
1419 return 0;
1420 };
1421
1422 for (auto &block : block_lists) {
1423 const std::string prefix =
1424 "block_" + boost::lexical_cast<std::string>(block.first);
1425 CHKERR apply_attributes_array(prefix, block.second);
1426 }
1427 for (auto &set_attr : block_set_attributes) {
1428 if (set_attr.second.nAme.compare("NoNameSet") != 0) {
1429 const std::string prefix = "SET_ATTR_" + set_attr.second.nAme;
1430 CHKERR apply_attributes_array(prefix, set_attr.second);
1431 }
1432 }
1433
1434 // Set type from name
1436
1437 CubitBCType bc_type;
1438 unsigned jj = 0;
1439 while (1 << jj != LASTSET_BC) {
1440 if (string(CubitBCNames[jj + 1]) ==
1441 block_lists[it->getMeshsetId()].addType) {
1442 bc_type = 1 << jj;
1443 }
1444 ++jj;
1445 }
1446 if (bc_type.none()) {
1447 block_lists[it->getMeshsetId()].bcType = UNKNOWNSET;
1448 // Skip the bockset nothing is defined for it
1449 continue;
1450 }
1451
1452 if (bc_type.to_ulong() == BLOCKSET)
1453 block_lists[it->getMeshsetId()].bcType = BLOCKSET;
1454 else if (bc_type.to_ulong() == NODESET)
1455 block_lists[it->getMeshsetId()].bcType = NODESET;
1456 else if (bc_type.to_ulong() == SIDESET)
1457 block_lists[it->getMeshsetId()].bcType = SIDESET;
1458 else {
1459 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1460 "Not yet implemented type %s\n",
1461 block_lists[it->getMeshsetId()].addType.c_str());
1462 }
1463 if (block_lists[it->getMeshsetId()].iD == -1) {
1464 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1465 "Unset iD number %d\n", block_lists[it->getMeshsetId()].iD);
1466 }
1467 }
1468
1469 std::vector<std::string> additional_parameters;
1470 additional_parameters =
1471 collect_unrecognized(parsed.options, po::include_positional);
1472 for (std::vector<std::string>::iterator vit = additional_parameters.begin();
1473 vit != additional_parameters.end(); vit++) {
1474 MOFEM_LOG_C("MeshsetMngSelf", Sev::warning, "Unrecognized option %s",
1475 vit->c_str());
1476 }
1477 for (map<int, BlockData>::iterator mit = block_lists.begin();
1478 mit != block_lists.end(); mit++) {
1479 CubitMeshSet_multiIndex::iterator cubit_meshset_it =
1480 cubitMeshsets.find(mit->second.cubitMeshset);
1481 if (cubit_meshset_it == cubitMeshsets.end()) {
1482 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1483 "Data inconsistency\n");
1484 }
1485 switch (mit->second.bcType) {
1486 case UNKNOWNSET:
1487 break;
1488 case BLOCKSET: {
1489 if ((CubitBCType(mit->second.bcType) & cubit_meshset_it->getBcType())
1490 .any() &&
1491 mit->second.iD == cubit_meshset_it->getMeshsetId()) {
1492 // Meshset is the same, only modification
1493 } else {
1494 CHKERR addMeshset(mit->second.bcType, mit->second.iD, mit->second.nAme);
1495 EntityHandle meshset = cubit_meshset_it->getMeshset();
1496 CHKERR addEntitiesToMeshset(mit->second.bcType, mit->second.iD,
1497 &meshset, 1);
1498 }
1499 // Add attributes
1500 CHKERR setAttributes(mit->second.bcType, mit->second.iD, mit->second.aTtr);
1501 // Add material elastic data if value are physical (i.e. Young > 0,
1502 // Poisson in (-1.0.5) and ThermalExpansion>0)
1503 if (mit->second.matElastic.data.Young != -1) {
1504 CHKERR setAttributesByDataStructure(mit->second.bcType, mit->second.iD,
1505 mit->second.matElastic);
1506 }
1507 if (mit->second.matTransIso.data.Youngp != -1) {
1508 CHKERR setAttributesByDataStructure(mit->second.bcType, mit->second.iD,
1509 mit->second.matTransIso);
1510 }
1511 if (mit->second.matThermal.data.Conductivity != -1) {
1512 CHKERR setAttributesByDataStructure(mit->second.bcType, mit->second.iD,
1513 mit->second.matThermal);
1514 }
1515 if (mit->second.matInterf.data.ft != -1) {
1516 CHKERR setAttributesByDataStructure(mit->second.bcType, mit->second.iD,
1517 mit->second.matInterf);
1518 }
1519 } break;
1520 case NODESET: {
1521 if ((CubitBCType(mit->second.bcType) & cubit_meshset_it->getBcType())
1522 .any() &&
1523 mit->second.iD == cubit_meshset_it->getMeshsetId()) {
1524 // Meshset is the same, only modification
1525 } else {
1526 CHKERR addMeshset(mit->second.bcType, mit->second.iD);
1527 EntityHandle meshset = cubit_meshset_it->getMeshset();
1528 CHKERR addEntitiesToMeshset(mit->second.bcType, mit->second.iD,
1529 &meshset, 1);
1530 }
1531 // Add displacement bc
1532 if (mit->second.dispBc.data.flag1 || mit->second.dispBc.data.flag2 ||
1533 mit->second.dispBc.data.flag3 || mit->second.dispBc.data.flag4 ||
1534 mit->second.dispBc.data.flag5 || mit->second.dispBc.data.flag6) {
1535 if (mit->second.dispBc.data.flag1 == '0')
1536 mit->second.dispBc.data.flag1 = 0;
1537 if (mit->second.dispBc.data.flag1 == 'N')
1538 mit->second.dispBc.data.flag1 = 0;
1539 if (mit->second.dispBc.data.flag1)
1540 mit->second.dispBc.data.flag1 = 1;
1541 if (mit->second.dispBc.data.flag2 == '0')
1542 mit->second.dispBc.data.flag2 = 0;
1543 if (mit->second.dispBc.data.flag2 == 'N')
1544 mit->second.dispBc.data.flag2 = 0;
1545 if (mit->second.dispBc.data.flag2)
1546 mit->second.dispBc.data.flag2 = 1;
1547 if (mit->second.dispBc.data.flag3 == '0')
1548 mit->second.dispBc.data.flag3 = 0;
1549 if (mit->second.dispBc.data.flag3 == 'N')
1550 mit->second.dispBc.data.flag3 = 0;
1551 if (mit->second.dispBc.data.flag3)
1552 mit->second.dispBc.data.flag3 = 1;
1553 if (mit->second.dispBc.data.flag4 == '0')
1554 mit->second.dispBc.data.flag4 = 0;
1555 if (mit->second.dispBc.data.flag4 == 'N')
1556 mit->second.dispBc.data.flag4 = 0;
1557 if (mit->second.dispBc.data.flag4)
1558 mit->second.dispBc.data.flag4 = 1;
1559 if (mit->second.dispBc.data.flag5 == '0')
1560 mit->second.dispBc.data.flag5 = 0;
1561 if (mit->second.dispBc.data.flag5 == 'N')
1562 mit->second.dispBc.data.flag5 = 0;
1563 if (mit->second.dispBc.data.flag5)
1564 mit->second.dispBc.data.flag5 = 1;
1565 if (mit->second.dispBc.data.flag6 == '0')
1566 mit->second.dispBc.data.flag6 = 0;
1567 if (mit->second.dispBc.data.flag6 == 'N')
1568 mit->second.dispBc.data.flag6 = 0;
1569 if (mit->second.dispBc.data.flag6)
1570 mit->second.dispBc.data.flag6 = 1;
1571 CHKERR setBcData(mit->second.bcType, mit->second.iD,
1572 mit->second.dispBc);
1573 }
1574 if (mit->second.forceBc.data.value1 != 0 ||
1575 mit->second.forceBc.data.value2 != 0) {
1576 CHKERR setBcData(mit->second.bcType, mit->second.iD,
1577 mit->second.forceBc);
1578 }
1579 // Add temperature boundary condition
1580 if (mit->second.temperatureBc.data.flag1) {
1581 if (mit->second.temperatureBc.data.flag1 == '0')
1582 mit->second.temperatureBc.data.flag1 = 0;
1583 if (mit->second.temperatureBc.data.flag1 == 'N')
1584 mit->second.temperatureBc.data.flag1 = 0;
1585 if (mit->second.temperatureBc.data.flag1)
1586 mit->second.temperatureBc.data.flag1 = 1;
1587 CHKERR setBcData(mit->second.bcType, mit->second.iD,
1588 mit->second.temperatureBc);
1589 }
1590 } break;
1591 case SIDESET: {
1592 if ((CubitBCType(mit->second.bcType) & cubit_meshset_it->getBcType())
1593 .any() &&
1594 mit->second.iD == cubit_meshset_it->getMeshsetId()) {
1595 // Meshset is the same, only modification
1596 } else {
1597 CHKERR addMeshset(mit->second.bcType, mit->second.iD);
1598 EntityHandle meshset = cubit_meshset_it->getMeshset();
1599 CHKERR addEntitiesToMeshset(mit->second.bcType, mit->second.iD,
1600 &meshset, 1);
1601 }
1602 // Add pressure
1603 if (mit->second.pressureBc.data.value1 != 0) {
1604 if (mit->second.pressureBc.data.flag2 == '0')
1605 mit->second.pressureBc.data.flag2 = 0;
1606 if (mit->second.pressureBc.data.flag2 == 'N')
1607 mit->second.pressureBc.data.flag2 = 0;
1608 if (mit->second.pressureBc.data.flag2)
1609 mit->second.pressureBc.data.flag2 = 1;
1610 CHKERR setBcData(mit->second.bcType, mit->second.iD,
1611 mit->second.pressureBc);
1612 }
1613 // Add heat flux
1614 if (mit->second.heatFluxBc.data.value1 != 0) {
1615 if (mit->second.heatFluxBc.data.flag1 == '0')
1616 mit->second.heatFluxBc.data.flag1 = 0;
1617 if (mit->second.heatFluxBc.data.flag1 == 'N')
1618 mit->second.heatFluxBc.data.flag1 = 0;
1619 if (mit->second.heatFluxBc.data.flag1)
1620 mit->second.heatFluxBc.data.flag1 = 1;
1621 CHKERR setBcData(mit->second.bcType, mit->second.iD,
1622 mit->second.heatFluxBc);
1623 }
1624 // Add Interface
1625 if (mit->second.cfgBc.data.type != 0) {
1626 CHKERR setBcData(mit->second.bcType, mit->second.iD, mit->second.cfgBc);
1627 }
1628 } break;
1629 default:
1630 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1631 "Not yet implemented type\n");
1632 }
1633 }
1634
1635 for (auto set_attr : block_set_attributes) {
1636 // Add attributes
1637 if (set_attr.second.numberOfAttributes > 0) {
1638 MOFEM_LOG("MeshsetMngSelf", Sev::verbose)
1639 << "Set attributes to blockset " << set_attr.second.nAme;
1640 set_attr.second.aTtr.resize(set_attr.second.numberOfAttributes);
1641 CHKERR setAttributes(set_attr.second.bcType, set_attr.second.iD,
1642 set_attr.second.aTtr);
1643 }
1644 }
1645
1647}
#define MOFEM_LOG_C(channel, severity, format,...)
@ LASTSET_BC
@ UNKNOWNSET
static const char *const CubitBCNames[]
Names of types of sets and boundary conditions.
MoFEMErrorCode setBcData(const CubitBCType cubit_bc_type, const int ms_id, const GenericCubitBcData &data)
Set boundary condition data for meshset.
MoFEMErrorCode addEntitiesToMeshset(const CubitBCType cubit_bc_type, const int ms_id, const Range &ents)
Add entities to CUBIT meshset.
MoFEMErrorCode addMeshset(const CubitBCType cubit_bc_type, const int ms_id, const std::string name="")
Add CUBIT meshset to manager.
#define _IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet having a particular BC meshset in a moFEM field.
const double c
speed of light (cm/ns)
const double v
phase velocity of light in medium (cm/ns)
std::bitset< 32 > CubitBCType
Definition Types.hpp:52

◆ setName()

MoFEMErrorCode MoFEM::MeshsetsManager::setName ( const CubitBCType  cubit_bc_type,
const int  ms_id,
const std::string &  name 
)

Definition at line 644 of file MeshsetsManager.cpp.

646 {
647 Interface &m_field = cOre;
648 moab::Interface &moab = m_field.get_moab();
650 auto cit =
651 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().find(
652 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
653 if (cit ==
654 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().end()) {
655 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
656 "Cannot find Cubit meshset with id: %d", ms_id);
657 }
658 const bool success = cubitMeshsets.modify(cubitMeshsets.project<0>(cit),
659 CubitMeshSets_change_name(moab, name));
660 if (!success)
661 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
662 "name to cubit meshset can not be set");
664}

◆ sortMeshsets()

void MoFEM::MeshsetsManager::sortMeshsets ( std::vector< const CubitMeshSets * > &  vec_ptr)
static

Definition at line 12 of file MeshsetsManager.cpp.

13 {
14 std::sort(vec_ptr.begin(), vec_ptr.end(),
15 [](const CubitMeshSets *a, const CubitMeshSets *b) {
16 if (a->getBcType().to_ullong() < b->getBcType().to_ullong())
17 return true;
18 if (a->getBcType().to_ullong() > b->getBcType().to_ullong())
19 return false;
20 else
21 return a->getMeshsetId() < b->getMeshsetId();
22 });
23}
constexpr double a

◆ updateAllMeshsetsByEntitiesChildren()

MoFEMErrorCode MoFEM::MeshsetsManager::updateAllMeshsetsByEntitiesChildren ( const BitRefLevel bit)

Update all blocksets, sidesets and node sets.

Parameters
bit
Returns
MoFEMErrorCode
Examples
thermoplastic.cpp.

Definition at line 1716 of file MeshsetsManager.cpp.

1716 {
1718 BitRefManager *bit_mng = cOre.getInterface<BitRefManager>();
1719 for (_IT_CUBITMESHSETS_FOR_LOOP_((*this), iit)) {
1720 EntityHandle meshset = iit->getMeshset();
1721 for (EntityType t = MBVERTEX; t != MBENTITYSET; ++t)
1722 CHKERR bit_mng->updateMeshsetByEntitiesChildren(meshset, bit, meshset, t,
1723 true);
1724 }
1726}
#define _IT_CUBITMESHSETS_FOR_LOOP_(MESHSET_MANAGER, IT)
Iterator that loops over all the Cubit MeshSets in a moFEM field.
auto bit
set bit
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.

Member Data Documentation

◆ bhTag

Tag MoFEM::MeshsetsManager::bhTag
protected

Definition at line 1176 of file MeshsetsManager.hpp.

◆ bhTag_header

Tag MoFEM::MeshsetsManager::bhTag_header
protected

Definition at line 1177 of file MeshsetsManager.hpp.

◆ broadcastMeshsetsOn

bool MoFEM::MeshsetsManager::broadcastMeshsetsOn = true
static

if true meshsets are synchronised between processors

Definition at line 1166 of file MeshsetsManager.hpp.

◆ configFileOptionsPtr

boost::shared_ptr<boost::program_options::options_description> MoFEM::MeshsetsManager::configFileOptionsPtr
protected

config file options

Definition at line 1182 of file MeshsetsManager.hpp.

◆ cOre

MoFEM::Core& MoFEM::MeshsetsManager::cOre

Reference to MoFEM Core interface.

Definition at line 220 of file MeshsetsManager.hpp.

◆ cubitMeshsets

CubitMeshSet_multiIndex MoFEM::MeshsetsManager::cubitMeshsets
protected

cubit meshsets

Definition at line 1180 of file MeshsetsManager.hpp.

◆ nsTag

Tag MoFEM::MeshsetsManager::nsTag
protected

Definition at line 1172 of file MeshsetsManager.hpp.

◆ nsTag_data

Tag MoFEM::MeshsetsManager::nsTag_data
protected

Definition at line 1174 of file MeshsetsManager.hpp.

◆ ssTag

Tag MoFEM::MeshsetsManager::ssTag
protected

Definition at line 1173 of file MeshsetsManager.hpp.

◆ ssTag_data

Tag MoFEM::MeshsetsManager::ssTag_data
protected

Definition at line 1175 of file MeshsetsManager.hpp.


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