v0.16.0
Loading...
Searching...
No Matches
Files | Classes | Macros | Functions
MeshsetsManager

Interface for meshsets with entities with data and boundary conditions. More...

Collaboration diagram for MeshsetsManager:

Files

file  MeshsetsManager.hpp
 Interface for managing mesh sets containing materials and boundary conditions.
 

Classes

struct  MoFEM::MeshsetsManager
 Interface for managing meshsets containing materials and boundary conditions. More...
 

Macros

#define _IT_CUBITMESHSETS_FOR_LOOP_(MESHSET_MANAGER, IT)
 Iterator that loops over all the Cubit MeshSets in a moFEM field.
 
#define _IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
 Iterator that loops over a specific Cubit MeshSet in a moFEM field.
 
#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.
 
#define _IT_CUBITMESHSETS_BY_NAME_FOR_LOOP_(MESHSET_MANAGER, NAME, IT)
 Iterator that loops over Cubit BlockSet having a particular name.
 

Functions

MoFEMErrorCode MoFEM::MeshsetsManager::getTags (int verb=-1)
 Get tag handles used on meshsets.
 
static MoFEMErrorCode MoFEM::MeshsetsManager::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.
 
MoFEMErrorCode MoFEM::MeshsetsManager::clearMap ()
 Clear the multi-index container.
 
MoFEMErrorCode MoFEM::MeshsetsManager::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 MoFEM::MeshsetsManager::initialiseDatabaseFromMesh (int verb=DEFAULT_VERBOSITY)
 Initialize container from mesh data.
 
MoFEMErrorCode MoFEM::MeshsetsManager::readMeshsets (int verb=DEFAULT_VERBOSITY)
 Read meshsets from mesh database.
 
MoFEMErrorCode MoFEM::MeshsetsManager::broadcastMeshsets (int verb=DEFAULT_VERBOSITY)
 Broadcast meshsets across MPI processes.
 
MoFEMErrorCode MoFEM::MeshsetsManager::printDisplacementSet () const
 Print meshsets with displacement boundary conditions.
 
MoFEMErrorCode MoFEM::MeshsetsManager::printPressureSet () const
 Print meshsets with pressure boundary conditions.
 
MoFEMErrorCode MoFEM::MeshsetsManager::printForceSet () const
 Print meshsets with force boundary conditions.
 
MoFEMErrorCode MoFEM::MeshsetsManager::printTemperatureSet () const
 Print meshsets with temperature boundary conditions.
 
MoFEMErrorCode MoFEM::MeshsetsManager::printHeatFluxSet () const
 Print meshsets with heat flux boundary conditions.
 
MoFEMErrorCode MoFEM::MeshsetsManager::printMaterialsSet () const
 Print meshsets with material properties.
 
CubitMeshSet_multiIndex::iterator MoFEM::MeshsetsManager::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 MoFEM::MeshsetsManager::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 MoFEM::MeshsetsManager::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 MoFEM::MeshsetsManager::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 MoFEM::MeshsetsManager::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 MoFEM::MeshsetsManager::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 MoFEM::MeshsetsManager::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 MoFEM::MeshsetsManager::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 MoFEM::MeshsetsManager::checkMeshset (const int ms_id, const CubitBCType cubit_bc_type) const
 Check for CUBIT meshset by ID and type.
 
bool MoFEM::MeshsetsManager::checkMeshset (const string name, int *const number_of_meshsets_ptr=NULL) const
 Check if meshset with given name exists.
 
MoFEMErrorCode MoFEM::MeshsetsManager::addMeshset (const CubitBCType cubit_bc_type, const int ms_id, const std::string name="")
 Add CUBIT meshset to manager.
 
MoFEMErrorCode MoFEM::MeshsetsManager::addEntitiesToMeshset (const CubitBCType cubit_bc_type, const int ms_id, const Range &ents)
 Add entities to CUBIT meshset.
 
MoFEMErrorCode MoFEM::MeshsetsManager::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 MoFEM::MeshsetsManager::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 MoFEM::MeshsetsManager::setAttributesByDataStructure (const CubitBCType cubit_bc_type, const int ms_id, const GenericAttributeData &data, const std::string name="")
 Set attributes using data structure.
 
MoFEMErrorCode MoFEM::MeshsetsManager::setBcData (const CubitBCType cubit_bc_type, const int ms_id, const GenericCubitBcData &data)
 Set boundary condition data for meshset.
 
MoFEMErrorCode MoFEM::MeshsetsManager::getCubitMeshsetPtr (const int ms_id, const CubitBCType cubit_bc_type, const CubitMeshSets **cubit_meshset_ptr) const
 get cubit meshset
 
const CubitMeshSetsMoFEM::MeshsetsManager::getCubitMeshsetPtr (const int ms_id, const CubitBCType cubit_bc_type) const
 get cubit meshset
 
MoFEMErrorCode MoFEM::MeshsetsManager::getCubitMeshsetPtr (const CubitBCType cubit_bc_type, std::vector< const CubitMeshSets * > &vec_ptr) const
 Get vector of pointer by bc type.
 
std::vector< const CubitMeshSets * > MoFEM::MeshsetsManager::getCubitMeshsetPtr (const CubitBCType cubit_bc_type) const
 Get vector of pointer by bc type.
 
MoFEMErrorCode MoFEM::MeshsetsManager::getCubitMeshsetPtr (const string name, const CubitMeshSets **cubit_meshset_ptr) const
 get cubit meshset
 
MoFEMErrorCode MoFEM::MeshsetsManager::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 * > MoFEM::MeshsetsManager::getCubitMeshsetPtr (const std::regex reg_exp_name) const
 Get vector of pointer to blocksets with name satisfying regular expression.
 
MoFEMErrorCode MoFEM::MeshsetsManager::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 MoFEM::MeshsetsManager::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 MoFEM::MeshsetsManager::getMeshset (const int ms_id, const unsigned int cubit_bc_type, EntityHandle &meshset) const
 get meshset from CUBIT Id and CUBIT type
 
MoFEMErrorCode MoFEM::MeshsetsManager::getMeshsetsByType (const unsigned int cubit_bc_type, Range &meshsets) const
 get all CUBIT meshsets by CUBIT type
 
MoFEMErrorCode MoFEM::MeshsetsManager::setMeshsetFromFile ()
 Load meshset configuration from command line specified file.
 

Detailed Description

Interface for meshsets with entities with data and boundary conditions.

Macro Definition Documentation

◆ _IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_

#define _IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_ (   MESHSET_MANAGER,
  CUBITBCTYPE,
  IT 
)

#include <src/interfaces/MeshsetsManager.hpp>

Value:
CubitMeshsetByType::iterator IT = \
MESHSET_MANAGER.get_meshsets_manager_ptr()->getBegin(CUBITBCTYPE); \
IT != MESHSET_MANAGER.get_meshsets_manager_ptr()->getEnd(CUBITBCTYPE); \
IT++
constexpr IntegrationType IT

Iterator that loops over a specific Cubit MeshSet in a moFEM field.

Parameters
mFieldmoFEM Field
seeCubitBC (NODESET, SIDESET or BLOCKSET and more)
iterator
Examples
mofem/atom_tests/add_cubit_meshsets.cpp, mofem/atom_tests/field_blas.cpp, mofem/atom_tests/field_blas_axpy.cpp, mofem/tutorials/cor-6_simple_elasticity/simple_elasticity.cpp, mofem/tutorials/cor-7_elasticity_mixed_formulation/src/ElasticityMixedFormulation.hpp, mofem/users_modules/basic_finite_elements/elasticity/elasticity.cpp, mofem/users_modules/basic_finite_elements/nonlinear_elasticity/nonlinear_dynamics.cpp, mofem/users_modules/basic_finite_elements/src/impl/HookeElement.cpp, and mofem/users_modules/bone_remodelling/bone_adaptation.cpp.

Definition at line 72 of file MeshsetsManager.hpp.

207 : public UnknownInterface {
208
209 /**
210 * \brief Query interface for MeshsetsManager
211 *
212 * @param type_index type index for the interface to query
213 * @param iface pointer to store the interface
214 * @return MoFEMErrorCode Error code indicating success or failure
215 */
216 MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
217 UnknownInterface **iface) const;
218
219 MoFEM::Core &cOre; ///< Reference to MoFEM Core interface
220
221 /**
222 * \brief Constructor for MeshsetsManager
223 *
224 * @param core reference to MoFEM Core interface for accessing mesh and field data
225 */
226 MeshsetsManager(const MoFEM::Core &core);
227 virtual ~MeshsetsManager() = default;
228
229 /**
230 * \brief Get tag handles used on meshsets
231 * \ingroup mofem_meshset_mng
232 *
233 * Retrieves MOAB tag handles for meshset identification and data storage.
234 * These tags follow CUBIT/MOAB conventions for nodesets, sidesets, and blocksets.
235 * The function initializes internal tag handles for subsequent meshset operations.
236 *
237 * @param verb verbosity level for output (-1 = default, higher values = more verbose)
238 * @return MoFEMErrorCode Error code indicating success or failure
239 */
240 MoFEMErrorCode getTags(int verb = -1);
241
242 /**
243 * \brief Static version of getTags for external MOAB interface
244 * \ingroup mofem_meshset_mng
245 *
246 * @param moab reference to MOAB interface
247 * @param nsTag reference to store nodeset tag handle
248 * @param ssTag reference to store sideset tag handle
249 * @param nsTag_data reference to store nodeset data tag handle
250 * @param ssTag_data reference to store sideset data tag handle
251 * @param bhTag reference to store blockset tag handle
252 * @param bhTag_header reference to store blockset header tag handle
253 * @param verb verbosity level for output
254 * @return MoFEMErrorCode Error code indicating success or failure
255 */
256 static MoFEMErrorCode getTags(moab::Interface &moab, Tag &nsTag, Tag &ssTag,
257 Tag &nsTag_data, Tag &ssTag_data, Tag &bhTag,
258 Tag &bhTag_header, int verb = -1);
259
260 /**
261 * \brief get tag handle used to store "id" of NODESET
262 */
263 inline Tag get_nsTag() const { return nsTag; }
264
265 /**
266 * \brief get tag handle used to store "id" of SIDESET
267 */
268 inline Tag get_ssTag() const { return ssTag; }
269
270 /**
271 * \brief get tag handle used to store boundary data on NODESET
272 */
273 inline Tag get_nsTag_data() const { return nsTag_data; }
274
275 /**
276 * \brief get tag handle used to store boundary data on SIDESET
277 */
278 inline Tag get_ssTag_data() const { return ssTag_data; }
279
280 /**
281 * \brief get tag handle used to store "id" of BLOCKSET
282 */
283 inline Tag get_bhTag() const { return bhTag; }
284
285 /**
286 * \brief get tag handle used to store of block set header (Used by Cubit)
287 */
288 inline Tag get_bhTag_header() const { return bhTag_header; }
289
290 /**
291 * \brief return pointer to meshset manager
292 */
293 MeshsetsManager *get_meshsets_manager_ptr() { return this; }
294
295 /**
296 * \brief return pointer to meshset manager
297 */
298 const MeshsetsManager *get_meshsets_manager_ptr() const { return this; }
299
300 /**
301 * \brief Clear the multi-index container
302 * \ingroup mofem_meshset_mng
303 *
304 * Removes all stored meshset data from the internal container.
305 * Useful for reinitialization or memory cleanup.
306 *
307 * @return MoFEMErrorCode Error code indicating success or failure
308 */
309 MoFEMErrorCode clearMap();
310
311 /**
312 * \brief Remove imported BLOCKSET names and/or attributes from the mesh.
313 * \ingroup mofem_meshset_mng
314 *
315 * This is used by the JSON config path to control how much embedded block
316 * metadata is preserved from the mesh file before JSON data is applied.
317 *
318 * @param cleared_names optional pointer storing how many block names were removed
319 * @param cleared_attributes optional pointer storing how many block attribute tags were removed
320 * @param clear_names when true remove imported BLOCKSET names
321 * @param clear_attributes when true remove imported BLOCKSET attributes
322 * @return MoFEMErrorCode Error code indicating success or failure
323 */
324 MoFEMErrorCode discardBlocksetConfiguration(
325 std::size_t *cleared_names = nullptr,
326 std::size_t *cleared_attributes = nullptr,
327 const bool clear_names = true,
328 const bool clear_attributes = true);
329
330 /**
331 * \brief Initialize container from mesh data
332 * \ingroup mofem_meshset_mng
333 *
334 * Reads meshset information from the mesh database and populates the
335 * internal multi-index container. This includes discovering nodesets,
336 * sidesets, and blocksets with their associated tags and data.
337 *
338 * @param verb verbosity level for output
339 * @return MoFEMErrorCode Error code indicating success or failure
340 */
341 MoFEMErrorCode initialiseDatabaseFromMesh(int verb = DEFAULT_VERBOSITY);
342
343 /**
344 * @brief Read meshsets from mesh database
345 * \ingroup mofem_meshset_mng
346 *
347 * Scans the mesh for existing meshsets and populates the manager's
348 * internal data structures. This is typically called after mesh loading
349 * to discover all available nodesets, sidesets, and blocksets.
350 *
351 * @param verb verbosity level for output
352 * @return MoFEMErrorCode Error code indicating success or failure
353 */
354 MoFEMErrorCode readMeshsets(int verb = DEFAULT_VERBOSITY);
355
356 /**
357 * @brief Broadcast meshsets across MPI processes
358 * \ingroup mofem_meshset_mng
359 *
360 * Synchronizes meshset information across all MPI processes to ensure
361 * consistent meshset data in parallel computations. Typically called
362 * after meshset modifications on specific processes.
363 *
364 * @param verb verbosity level for output
365 * @return MoFEMErrorCode Error code indicating success or failure
366 */
367 MoFEMErrorCode broadcastMeshsets(int verb = DEFAULT_VERBOSITY);
368
369 template <class CUBIT_BC_DATA_TYPE>
370 MoFEMErrorCode printBcSet(CUBIT_BC_DATA_TYPE &data,
371 unsigned long int type) const;
372
373 /**
374 * \brief Print meshsets with displacement boundary conditions
375 * \ingroup mofem_meshset_mng
376 *
377 * Outputs information about all meshsets containing displacement boundary
378 * condition data, including constraint flags and prescribed values.
379 *
380 * @return MoFEMErrorCode Error code indicating success or failure
381 */
382 MoFEMErrorCode printDisplacementSet() const;
383
384 /**
385 * \brief Print meshsets with pressure boundary conditions
386 * \ingroup mofem_meshset_mng
387 *
388 * Outputs information about all meshsets containing pressure boundary
389 * condition data, including pressure magnitudes and application flags.
390 *
391 * @return MoFEMErrorCode Error code indicating success or failure
392 */
393 MoFEMErrorCode printPressureSet() const;
394
395 /**
396 * \brief Print meshsets with force boundary conditions
397 * \ingroup mofem_meshset_mng
398 *
399 * Outputs information about all meshsets containing force boundary
400 * condition data, including force and moment components.
401 *
402 * @return MoFEMErrorCode Error code indicating success or failure
403 */
404 MoFEMErrorCode printForceSet() const;
405
406 /**
407 * \brief Print meshsets with temperature boundary conditions
408 * \ingroup mofem_meshset_mng
409 *
410 * Outputs information about all meshsets containing temperature boundary
411 * condition data, including prescribed temperature values.
412 *
413 * @return MoFEMErrorCode Error code indicating success or failure
414 */
415 MoFEMErrorCode printTemperatureSet() const;
416
417 /**
418 * \brief Print meshsets with heat flux boundary conditions
419 * \ingroup mofem_meshset_mng
420 *
421 * Outputs information about all meshsets containing heat flux boundary
422 * condition data, including flux magnitudes and directions.
423 *
424 * @return MoFEMErrorCode Error code indicating success or failure
425 */
426 MoFEMErrorCode printHeatFluxSet() const;
427
428 /**
429 * \brief Print meshsets with material properties
430 * \ingroup mofem_meshset_mng
431 *
432 * Outputs information about all meshsets containing material data,
433 * including material parameters and constitutive model information.
434 *
435 * @return MoFEMErrorCode Error code indicating success or failure
436 */
437 MoFEMErrorCode printMaterialsSet() const;
438
439 inline CubitMeshSet_multiIndex &getMeshsetsMultindex() {
440 return cubitMeshsets;
441 }
442
443 /**
444 * \ingroup mofem_meshset_mng
445 * \brief get begin iterator of cubit meshset of given type (instead you can
446 * use _IT_CUBITMESHSETS_TYPE_FOR_LOOP_(MFIELD,CUBITBCTYPE,IT)
447 *
448 * for(_IT_CUBITMESHSETS_FOR_LOOP_(mField,it) {
449 * ...
450 * }
451 *
452 */
453 inline CubitMeshSet_multiIndex::iterator getBegin() const {
454 return cubitMeshsets.begin();
455 }
456
457 /**
458 * \ingroup mofem_meshset_mng
459 * \brief get begin iterator of cubit meshset of given type (instead you can
460 * use _IT_CUBITMESHSETS_TYPE_FOR_LOOP_(MFIELD,CUBITBCTYPE,IT)
461 *
462 * for(_IT_CUBITMESHSETS_FOR_LOOP_(mField,it) {
463 * ...
464 * }
465 *
466 */
467 CubitMeshSet_multiIndex::iterator getEnd() const {
468 return cubitMeshsets.end();
469 }
470
471 /**
472 * \brief get begin iterator of cubit meshset of given type (instead you can
473 use _IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_(MFIELD,CUBITBCTYPE,IT)
474 * \ingroup mofem_meshset_mng
475
476 *
477 *
478 for(_IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_(mField,NODESET|DISPLACEMENTSET,it)
479 {
480 * ...
481 * }
482 *
483 * \param type of meshset (NODESET, SIDESET or BLOCKSET and more)
484 */
485 inline CubitMeshsetByType::iterator
486 getBegin(const unsigned int cubit_bc_type) const {
487 return cubitMeshsets.get<CubitMeshsetType_mi_tag>().lower_bound(
488 cubit_bc_type);
489 }
490
491 /**
492 * \brief get begin iterator of cubit meshset of given type (instead you can
493 use _IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_(MFIELD,CUBITBCTYPE,IT)
494 * \ingroup mofem_meshset_mng
495
496 *
497 *
498 for(_IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_(mField,NODESET|DISPLACEMENTSET,it)
499 {
500 * ...
501 * }
502 *
503 * \param type of meshset (NODESET, SIDESET or BLOCKSET and more)
504 */
505 inline CubitMeshsetByType::iterator
506 getEnd(const unsigned int cubit_bc_type) const {
507 return cubitMeshsets.get<CubitMeshsetType_mi_tag>().upper_bound(
508 cubit_bc_type);
509 }
510
511 /**
512 * \brief get end iterator of cubit meshset of given type (instead you can
513 use _IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_(MFIELD,CUBITBCTYPE,IT)
514 * \ingroup mofem_meshset_mng
515
516 *
517 * for(_IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_(mField,NODESET,it) {
518 * ...
519 * }
520 *
521 * \param type of meshset (NODESET, SIDESET or BLOCKSET and more)
522 */
523 inline CubitMeshsetByMask::iterator
524 getBySetTypeBegin(const unsigned int cubit_bc_type) const {
525 return cubitMeshsets.get<CubitMeshsetMaskedType_mi_tag>().lower_bound(
526 cubit_bc_type);
527 }
528
529 /**
530 * \brief get end iterator of cubit meshset of given type (instead you can
531 use _IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_(MFIELD,CUBITBCTYPE,IT)
532 * \ingroup mofem_meshset_mng
533
534 *
535 * for(_IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_(mField,NODESET,it) {
536 * ...
537 * }
538 *
539 * \param type of meshset (NODESET, SIDESET or BLOCKSET and more)
540 */
541 inline CubitMeshsetByMask::iterator
542 getBySetTypeEnd(const unsigned int cubit_bc_type) const {
543 return cubitMeshsets.get<CubitMeshsetMaskedType_mi_tag>().upper_bound(
544 cubit_bc_type);
545 }
546
547 /**
548 * \brief get begin iterator of cubit meshset of given type (instead you can
549 use _IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_(MFIELD,CUBITBCTYPE,IT)
550 * \ingroup mofem_meshset_mng
551
552 *
553 *
554 for(_IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_(mField,NODESET|DISPLACEMENTSET,it)
555 {
556 * ...
557 * }
558 *
559 * \param type of meshset (NODESET, SIDESET or BLOCKSET and more)
560 */
561 inline CubitMeshsetByName::iterator getBegin(const std::string &name) const {
562 return cubitMeshsets.get<CubitMeshsets_name>().lower_bound(name);
563 }
564
565 /**
566 * \brief get begin iterator of cubit meshset of given type (instead you can
567 use _IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_(MFIELD,CUBITBCTYPE,IT)
568 * \ingroup mofem_meshset_mng
569
570 *
571 *
572 for(_IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_(mField,NODESET|DISPLACEMENTSET,it)
573 {
574 * ...
575 * }
576 *
577 * \param type of meshset (NODESET, SIDESET or BLOCKSET and more)
578 */
579 inline CubitMeshsetByName::iterator getEnd(const std::string &name) const {
580 return cubitMeshsets.get<CubitMeshsets_name>().upper_bound(name);
581 }
582
583 /**
584 * \brief Check for CUBIT meshset by ID and type
585 * \ingroup mofem_meshset_mng
586 *
587 * Verifies if a meshset with the specified CUBIT ID and type exists
588 * in the manager's database. Useful for validation before accessing
589 * meshset properties or entities.
590 *
591 * \todo All cubit interface functions should be outsourced to dedicated
592 * interface
593 *
594 * @param ms_id CUBIT ID of the meshset (BLOCKSET/SIDESET/NODESET)
595 * @param cubit_bc_type type of meshset (NODESET, SIDESET, BLOCKSET, etc.)
596 * @return bool true if meshset exists, false otherwise
597 */
598 bool checkMeshset(const int ms_id, const CubitBCType cubit_bc_type) const;
599
600 /**
601 * \brief Check if meshset with given name exists
602 * \ingroup mofem_meshset_mng
603 *
604 * Searches for meshsets by name and optionally returns the count of
605 * matching meshsets. Multiple meshsets can have the same name.
606 *
607 * @param name name of the meshset to search for
608 * @param number_of_meshsets_ptr optional pointer to store count of matching meshsets
609 * @return bool true if at least one meshset with the name exists, false otherwise
610 */
611 bool checkMeshset(const string name,
612 int *const number_of_meshsets_ptr = NULL) const;
613
614 /**
615 * \brief Add CUBIT meshset to manager
616 * \ingroup mofem_meshset_mng
617 *
618 * Creates a new meshset entry in the manager's database with the specified
619 * CUBIT type and ID. The meshset can be given an optional name for easier
620 * identification and access.
621 *
622 * @param cubit_bc_type type of meshset (NODESET, SIDESET, BLOCKSET, etc.)
623 * @param ms_id CUBIT ID for the meshset
624 * @param name optional name for the meshset (empty string if not specified)
625 * @return MoFEMErrorCode Error code indicating success or failure
626 */
627 MoFEMErrorCode addMeshset(const CubitBCType cubit_bc_type, const int ms_id,
628 const std::string name = "");
629
630 /// Adds an extra classification bit to an existing meshset type.
631 /// Example: promote a plain BLOCKSET to BLOCKSET|MAT_THERMALSET.
632 MoFEMErrorCode addBitToMeshsetType(const CubitBCType cubit_bc_type,
633 const int ms_id,
634 const CubitBCType type_bit);
635
636 /**
637 * \brief Add entities to CUBIT meshset
638 * \ingroup mofem_meshset_mng
639 *
640 * Adds a range of mesh entities to an existing meshset. The entities
641 * become part of the meshset for subsequent operations like applying
642 * boundary conditions or material properties.
643 *
644 * @param cubit_bc_type type of meshset (NODESET, SIDESET, BLOCKSET, etc.)
645 * @param ms_id CUBIT ID of the target meshset
646 * @param ents range of entities to add to the meshset
647 * @return MoFEMErrorCode Error code indicating success or failure
648 */
649 MoFEMErrorCode addEntitiesToMeshset(const CubitBCType cubit_bc_type,
650 const int ms_id, const Range &ents);
651
652 /**
653 * \brief Add entities to CUBIT meshset (array version)
654 * \ingroup mofem_meshset_mng
655 *
656 * Adds an array of mesh entities to an existing meshset. This version
657 * accepts entities as a C-style array with explicit count.
658 *
659 * @param cubit_bc_type type of meshset (NODESET, SIDESET, BLOCKSET, etc.)
660 * @param ms_id CUBIT ID of the target meshset
661 * @param ents pointer to array of entity handles
662 * @param nb_ents number of entities in the array
663 * @return MoFEMErrorCode Error code indicating success or failure
664 */
665 MoFEMErrorCode addEntitiesToMeshset(const CubitBCType cubit_bc_type,
666 const int ms_id, const EntityHandle *ents,
667 const int nb_ents);
668
669 /**
670 * \brief Set attributes for CUBIT meshset
671 * \ingroup mofem_meshset_mng
672 *
673 * Assigns attribute values to a meshset. Attributes are typically used
674 * for material properties or other numerical parameters associated with
675 * the meshset entities.
676 *
677 * @param cubit_bc_type type of meshset (BLOCKSET, NODESET, SIDESET, etc.)
678 * @param ms_id CUBIT ID of the target meshset
679 * @param attributes vector of attribute values to assign
680 * @param name optional name to assign to the meshset
681 * @return MoFEMErrorCode Error code indicating success or failure
682 */
683 MoFEMErrorCode setAttributes(const CubitBCType cubit_bc_type, const int ms_id,
684 const std::vector<double> &attributes,
685 const std::string name = "");
686
687 MoFEMErrorCode setName(const CubitBCType cubit_bc_type, const int ms_id,
688 const std::string &name);
689
690 DEPRECATED inline auto setAtributes(const CubitBCType cubit_bc_type,
691 const int ms_id,
692 const std::vector<double> &attributes,
693 const std::string name = "") {
694 return setAttributes(cubit_bc_type, ms_id,
695 std::vector<double>(attributes), name);
696 }
697
698 /**
699 * \brief Set attributes using data structure
700 * \ingroup mofem_meshset_mng
701 *
702 * Assigns material or other attributes to a meshset using a structured
703 * data object. This provides a more organized way to handle complex
704 * attribute data with proper typing and validation.
705 *
706 * @param cubit_bc_type type of meshset (BLOCKSET, NODESET, SIDESET, etc.)
707 * @param ms_id CUBIT ID of the target meshset
708 * @param data structured data containing attribute information
709 * @param name optional name to assign to the meshset
710 * @return MoFEMErrorCode Error code indicating success or failure
711 */
712 MoFEMErrorCode setAttributesByDataStructure(const CubitBCType cubit_bc_type,
713 const int ms_id,
714 const GenericAttributeData &data,
715 const std::string name = "");
716
717 DEPRECATED inline auto setAtributesByDataStructure(
718 const CubitBCType cubit_bc_type, const int ms_id,
719 const GenericAttributeData &data, const std::string name = "") {
720 return setAttributesByDataStructure(cubit_bc_type, ms_id, data, name);
721 }
722
723
724 /**
725 * \brief Set boundary condition data for meshset
726 * \ingroup mofem_meshset_mng
727 *
728 * Assigns boundary condition data to a meshset. This includes constraint
729 * information, prescribed values, and application flags for various
730 * boundary condition types (displacement, force, pressure, etc.).
731 *
732 * @param cubit_bc_type type of meshset (BLOCKSET, NODESET, SIDESET, etc.)
733 * @param ms_id CUBIT ID of the target meshset
734 * @param data boundary condition data structure
735 * @return MoFEMErrorCode Error code indicating success or failure
736 */
737 MoFEMErrorCode setBcData(const CubitBCType cubit_bc_type, const int ms_id,
738 const GenericCubitBcData &data);
739
740 /**
741 * \brief delete cubit meshset
742 * \ingroup mofem_bc
743
744 *
745 * \param see CubitBC (NODESET, SIDESET or BLOCKSET and more)
746 * \param ms_id id of the BLOCKSET/SIDESET/BLOCKSET: from CUBIT
747 *
748 */
749 MoFEMErrorCode deleteMeshset(const CubitBCType cubit_bc_type, const int ms_id,
750 const MoFEMTypes bh = MF_EXIST);
751
752 /**
753 * \brief get cubit meshset
754 * \ingroup mofem_meshset_mng
755 *
756 *
757 */
759 getCubitMeshsetPtr(const int ms_id, const CubitBCType cubit_bc_type,
760 const CubitMeshSets **cubit_meshset_ptr) const;
761
762 /**
763 * \brief get cubit meshset
764 * \ingroup mofem_meshset_mng
765 *
766 *
767 */
768 const CubitMeshSets *
769 getCubitMeshsetPtr(const int ms_id, const CubitBCType cubit_bc_type) const;
770
771 /**
772 * @brief Get vector of pointer by bc type
773 *
774 * \ingroup mofem_meshset_mng
775 *
776 * @param std::vector<const CubitMeshSets *>
777 * @return MoFEMErrorCode
778 */
780 getCubitMeshsetPtr(const CubitBCType cubit_bc_type,
781 std::vector<const CubitMeshSets *> &vec_ptr) const;
782
783/**
784 * @brief Get vector of pointer by bc type
785 *
786 * \ingroup mofem_meshset_mng
787 *
788 * @return MoFEMErrorCode
789 */
790 std::vector<const CubitMeshSets *>
791 getCubitMeshsetPtr(const CubitBCType cubit_bc_type) const;
792
793 /**
794 * \brief get cubit meshset
795 *
796 * \ingroup mofem_meshset_mng
797 */
799 getCubitMeshsetPtr(const string name,
800 const CubitMeshSets **cubit_meshset_ptr) const;
801
802 /**
803 * @brief Get vector of pointer to blocksets with name satisfying regular
804 * expression.
805 *
806 * \ingroup mofem_meshset_mng
807 *
808 * @param reg_exp_name
809 * @param std::vector<const CubitMeshSets *>
810 * @return MoFEMErrorCode
811 */
813 getCubitMeshsetPtr(const std::regex reg_exp_name,
814 std::vector<const CubitMeshSets *> &vec_ptr) const;
815
816 /**
817 * @brief Get vector of pointer to blocksets with name satisfying regular
818 * expression.
819 *
820 * \ingroup mofem_meshset_mng
821 *
822 * \code
823 for (auto m :
824 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(std::regex(
825
826 (boost::format("%s(.*)") % block_name).str()
827
828 ))
829
830 ) {
831 MOFEM_LOG("WORLD", Sev::inform) << m->getName();
832
833 Range ents;
834 m_field.get_moab().get_entities_by_dimension(
835 m->getMeshset(), 0, ents, false);
836
837 auto print_ents = [](boost::shared_ptr<FieldEntity> ent_ptr) {
838 MoFEMFunctionBegin;
839 if(!(ent_ptr->getPStatus() & PSTATUS_NOT_OWNED)) {
840 MOFEM_LOG("SYNC", Sev::inform) << ent_ptr->getName() << ": " <<
841 ent_ptr->getEntFieldData();
842 }
843 MoFEMFunctionReturn(0);
844 };
845
846 CHKERR m_field.getInterface<FieldBlas>()->fieldLambdaOnEntities(
847 print_ents, "VELOCITIES", &ents);
848 CHKERR m_field.getInterface<FieldBlas>()->fieldLambdaOnEntities(
849 print_ents, "DISPLACEMENTS", &ents);
850 MOFEM_LOG_SEVERITY_SYNC(m_field.get_comm(), Sev::ifrom);
851 }
852 * \endcode
853 *
854 * @param reg_exp_name
855 * @return std::vector<const CubitMeshSets *>
856 */
857 std::vector<const CubitMeshSets *>
858 getCubitMeshsetPtr(const std::regex reg_exp_name) const;
859
860 /**
861 * \brief get entities from CUBIT/meshset of a particular entity dimension
862 * \ingroup mofem_meshset_mng
863
864 * Nodeset can contain nodes, edges, triangles and tets. This applies to
865 other meshsets too.
866 * The nodeset's meshset contain the nodes in the MIDDLE of the surface or
867 volume which is done by default in Cubit,
868 * Hence if all nodes on a particular nodeset are required,
869 * one should get all triangles or tetrahedrons for which the nodeset was
870 create in Cubit,
871 * and get all the connectivities of tris/tets.
872
873 * \param ms_id id of the BLOCKSET/SIDESET/BLOCKSET: from CUBIT
874 * \param see CubitBC (NODESET, SIDESET or BLOCKSET and more)
875 * \param dimensions (0 - Nodes, 1 - Edges, 2 - Faces, 3 -
876 Volume(tetrahedral))
877 * \param Range containing the retrieved entities
878 * \param recursive If true, meshsets containing meshsets are queried
879 recursively. Returns the contents of meshsets, but not the meshsets
880 themselves if true.
881 */
882 MoFEMErrorCode getEntitiesByDimension(const int ms_id,
883 const unsigned int cubit_bc_type,
884 const int dimension, Range &entities,
885 const bool recursive = true) const;
886
887 /**
888 * \brief get entities related to CUBIT/meshset,
889 * \ingroup mofem_meshset_mng
890
891 * NODESET will get Vertices only, even if the NODESET contains edges, tris
892 and tets
893 * SIDESET will get Tris, BLOCKSET will get Tets, DISPLACEMENTSET and
894 FORCESET are stored in NODESET, PRESSURESET is stored in Sideset.
895
896 * \param ms_id id of the BLOCKSET/SIDESET/BLOCKSET: from CUBIT
897 * \param see CubitBC (NODESET, SIDESET or BLOCKSET and more)
898 * \param Range containing the retrieved entities related to the
899 * \param recursive If true, meshsets containing meshsets are queried
900 recursively. Returns the contents of meshsets, but not the meshsets
901 themselves if true.
902 */
903 MoFEMErrorCode getEntitiesByDimension(const int ms_id,
904 const unsigned int cubit_bc_type,
905 Range &entities,
906 const bool recursive = true) const;
907
908 /**
909 * \ingroup mofem_meshset_mng
910 * \brief get meshset from CUBIT Id and CUBIT type
911 *
912 * \param ms_id id of the BLOCKSET/SIDESET/BLOCKSET: from CUBIT
913 * \param see CubitBC (NODESET, SIDESET or BLOCKSET and more)
914 * \param meshset where to store the retrieved entities
915 */
916 MoFEMErrorCode getMeshset(const int ms_id, const unsigned int cubit_bc_type,
917 EntityHandle &meshset) const;
918
919 /**
920 * @brief Check if meshset constains entities
921 *
922 * @param ms_id
923 * @param cubit_bc_type
924 * @param entities
925 * @param num_entities
926 * @param operation_type
927 * @return true
928 * @return false
929 */
930 bool checkIfMeshsetContainsEntities(
931 const int ms_id, const unsigned int cubit_bc_type,
932 const EntityHandle *entities, int num_entities,
933 const int operation_type = moab::Interface::INTERSECT);
934
935 /**
936 * \ingroup mofem_meshset_mng
937 * \brief get all CUBIT meshsets by CUBIT type
938 *
939 * \param see CubitBC (NODESET, SIDESET or BLOCKSET and more).
940 * \param meshsets is range of meshsets
941 */
942 MoFEMErrorCode getMeshsetsByType(const unsigned int cubit_bc_type,
943 Range &meshsets) const;
944
945 /**
946 * \brief add blocksets reading config file
947
948 Example of config file
949 \code
950
951 [block_1001]
952
953 # Example applying attributes to blockset
954
955 id=2001
956 add=BLOCKSET
957 user1=1.0 # attribute value 1
958 user2=2.0 # legacy form supports user1 up to user10
959 user3=3.0
960 # alternatively, for any number of attributes:
961 # user_array=1.0, 2.0, 3.0, 4.0
962
963 [block_1002]
964
965 # Example applying material block (isotropic elastic material)
966
967 id=2002
968 add=BLOCKSET
969 name=MAT_ELASTIC
970 young=10
971 poisson=0.25
972 thermalexpansion=0
973
974 [block_1003]
975
976 # Example applying displacement constrains
977
978 id=2003
979 add=NODESET
980
981 # Each flag means that boundary consition on displacements is set.
982 disp_flag1=1 # Setting constrains in x- direction
983 disp_flag2=1 # Setting constrains in y- direction
984 disp_flag3=1 # Setting constrains in z- direction
985 disp_flag4=1 # Setting constrains on rotation over x- axis
986 disp_flag5=1 # Setting constrains on rotation over y- axis
987 disp_flag6=1 # Setting constrains on rotation over z-axis
988 disp_ux=1 # value of disp in x- direction
989 disp_uy=2
990 disp_uz=3
991 disp_rx=4 # value of rotation in y-direction
992 disp_ry=5
993 disp_rz=6
994
995 # Note above values could be interpreted differently if needed.
996
997 [block_1004]
998
999 # Example applying force boundary conditions
1000
1001 id=2004
1002 add=NODESET
1003 force_magnitude=1
1004 moment_magnitude=1
1005 force_fx=1
1006 force_fy=1
1007 force_fz=1
1008 moment_mx=1
1009 moment_my=1
1010 moment_mz=1
1011
1012 [block_1005]
1013
1014 # Example applying pressure boundary conditions
1015
1016 id=2005
1017 add=SIDESET
1018 pressure_flag2=1 # 0: Pressure is interpreted as pure pressure 1:
1019 pressure is interpreted as total force
1020 pressure_magnitude=1
1021
1022 # Example applying temperature boundary conditions
1023
1024 [block_1006]
1025
1026 id=2006
1027 add=NODESET
1028 temperature_flag1=1 # 0: N/A, 1: temperature value applied
1029 temperature_t=1
1030
1031 [block_1007]
1032
1033 id=2007
1034 add=SIDESET
1035 heatflux_flag1=1 # 0: N/A, 1: heat flux applied
1036 heatflux_magnitude=1
1037
1038 [block_1008]
1039
1040 # Example applying material block (isotropic thermal material)
1041
1042 id=2008
1043 add=BLOCKSET
1044 name=MAT_THERMAL # Hast to be set for Thermal Mat
1045 conductivity=1
1046 capacity=1
1047
1048 [block_1009]
1049
1050 # Example applying interface
1051 id=2009
1052 add=SIDESET
1053 interface_type=1
1054
1055 [block_1010]
1056
1057 # Example applying material block for interface element
1058
1059 id=2010
1060 add=BLOCKSET
1061 name=MAT_INTERF
1062 interface_alpha = 1
1063 interface_beta = 0
1064 interface_ft = 1
1065 interface_Gf = 1
1066
1067
1068 [block_1009]
1069
1070 # Example applying material block (isotropic trans iso material)
1071
1072 id=2011
1073 add=BLOCKSET
1074 name=MAT_ELASTIC_TRANS_ISO
1075 Youngp=1
1076 Youngz=2
1077 Poissonp=3
1078 Poissonpz=4
1079 Shearzp=5
1080
1081 [SET_ATTR_FOO]
1082
1083 # Example set atttributes to block name "FOO"
1084 number_of_attributes=3
1085 user1=1
1086 user2=2
1087 user3=3
1088 # alternatively, number_of_attributes is inferred from:
1089 # user_array=1, 2, 3
1090
1091 \endcode
1092
1093 * @param file_name path to configuration file containing meshset definitions
1094 * @param clean_file_options whether to clean existing file options before loading
1095 * @return MoFEMErrorCode Error code indicating success or failure
1096 */
1097 MoFEMErrorCode setMeshsetFromFile(const string file_name,
1098 const bool clean_file_options = true);
1099
1100 /**
1101 * \brief Load meshset configuration from command line specified file
1102 * \ingroup mofem_meshset_mng
1103 *
1104 * Reads the configuration file name from the command line option
1105 * '-meshsets_config' and loads meshset definitions from that file.
1106 * This provides a convenient way to specify meshset configurations
1107 * at runtime without hardcoding file paths.
1108 *
1109 * Command line usage: -meshsets_config filename.cfg
1110 *
1111 * @return MoFEMErrorCode Error code indicating success or failure
1112 */
1113 MoFEMErrorCode setMeshsetFromFile();
1114
1115 /**
1116 * @brief save cubit meshset entities on the moab mesh
1117 *
1118 * @param ms_id id of the cubit meshset (NODESET SIDESET BLOCKSET)
1119 * @param cubit_bc_type type of a cubit mesheset
1120 * @param file_name optional name for the file
1121 * @param file_type optional file type for moab (VTK MOAB)
1122 * @param options optional parameters for moab writer (PARALLEL=WRITE_PART)
1123 * @return MoFEMErrorCode
1124 */
1126 saveMeshsetToFile(const int ms_id, const unsigned int cubit_bc_type,
1127 const std::string file_name = "out_meshset.vtk",
1128 const std::string file_type = "VTK",
1129 const std::string options = "") const;
1130
1131 /**
1132 * @brief save cubit meshset entities on the moab mesh
1133 *
1134 * @param ms_id id of the cubit meshset
1135 * @param cubit_bc_type type of a cubit mesheset (NODESET SIDESET BLOCKSET)
1136 * @param dim dimension of the entities
1137 * @param file_name optional name for the file
1138 * @param file_type optional file type for moab (VTK MOAB)
1139 * @param options optional parameters for moab writer (PARALLEL=WRITE_PART)
1140 * @return MoFEMErrorCode
1141 */
1142 MoFEMErrorCode saveMeshsetToFile(
1143 const int ms_id, const unsigned int cubit_bc_type, const int dim,
1144 const std::string file_name = "out_meshset.vtk",
1145 const bool recursive = false, const std::string file_type = "VTK",
1146 const std::string options = "") const;
1147
1148 /**
1149 * \brief Get config file options, use with care
1150 * @return error code
1151 */
1152 inline boost::shared_ptr<boost::program_options::options_description> &
1153 getConfigFileOptionsPtr() {
1154 return configFileOptionsPtr;
1155 }
1156
1157 /**
1158 * @brief Update all blocksets, sidesets and node sets
1159 *
1160 * @param bit
1161 * @return MoFEMErrorCode
1162 */
1163 MoFEMErrorCode updateAllMeshsetsByEntitiesChildren(const BitRefLevel &bit);
1164
1165 static bool broadcastMeshsetsOn; ///< if true meshsets are synchronised
1166 ///< between processors
1167
1168 static void sortMeshsets(std::vector<const CubitMeshSets *> &vec_ptr);
1169
1170protected:
1171 Tag nsTag;
1172 Tag ssTag;
1173 Tag nsTag_data;
1174 Tag ssTag_data;
1175 Tag bhTag;
1176 Tag bhTag_header;
1177
1178 // cubit
1179 CubitMeshSet_multiIndex cubitMeshsets; ///< cubit meshsets
1180 boost::shared_ptr<boost::program_options::options_description>
1181 configFileOptionsPtr; ///< config file options
1182
1183};
1184
1185template <class CUBIT_BC_DATA_TYPE>
1186MoFEMErrorCode MeshsetsManager::printBcSet(CUBIT_BC_DATA_TYPE &data,
1187 unsigned long int type) const {
1189 const MoFEM::Interface &m_field = cOre;
1190 const moab::Interface &moab = m_field.get_moab();
1191 for (auto it : getCubitMeshsetPtr(type)) {
1192 CHKERR it->getBcDataStructure(data);
1193 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << *it;
1194 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << data;
1195 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << "name " << it->getName();
1196 for (EntityType t = MBVERTEX; t != MBENTITYSET; ++t) {
1197 int nb;
1198 CHKERR moab.get_number_entities_by_type(it->meshset, t, nb, true);
1199 if (nb > 0) {
1200 MOFEM_LOG("MeshsetMngSync", Sev::inform)
1201 << "msId " << it->getMeshsetId() << " number of "
1202 << moab::CN::EntityTypeName(t) << " " << nb;
1203 }
1204 }
1205 MOFEM_LOG_SEVERITY_SYNC(m_field.get_comm(), Sev::inform);
1206 }
1208}
1209
1210} // namespace MoFEM
1211
1212#endif //__MESHSETSMANAGER_HPP__
1213
1214/**
1215 * \defgroup mofem_meshset_mng MeshsetsManager
1216 * \brief Interface for meshsets with entities with data and boundary conditions
1217 *
1218 * \ingroup mofem
1219 **/
std::string type
#define MOFEM_LOG_SEVERITY_SYNC(comm, severity)
Synchronise "SYNC" on curtain severity level.
@ DEFAULT_VERBOSITY
MoFEMTypes
Those types control how functions respond on arguments, f.e. error handling.
@ MF_EXIST
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define DEPRECATED
Definition definitions.h:17
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MOFEM_LOG(channel, severity)
Log.
auto bit
set bit
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
multi_index_container< CubitMeshSets, indexed_by< hashed_unique< tag< Meshset_mi_tag >, member< CubitMeshSets, EntityHandle, &CubitMeshSets::meshset > >, ordered_non_unique< tag< CubitMeshsetType_mi_tag >, const_mem_fun< CubitMeshSets, unsigned long int, &CubitMeshSets::getBcTypeULong > >, ordered_non_unique< tag< CubitMeshsetMaskedType_mi_tag >, const_mem_fun< CubitMeshSets, unsigned long int, &CubitMeshSets::getMaskedBcTypeULong > >, ordered_non_unique< tag< CubitMeshsets_name >, const_mem_fun< CubitMeshSets, std::string, &CubitMeshSets::getName > >, hashed_unique< tag< Composite_Cubit_msId_And_MeshsetType_mi_tag >, composite_key< CubitMeshSets, const_mem_fun< CubitMeshSets, int, &CubitMeshSets::getMeshsetId >, const_mem_fun< CubitMeshSets, unsigned long int, &CubitMeshSets::getMaskedBcTypeULong > > > > > CubitMeshSet_multiIndex
Stores data about meshsets (see CubitMeshSets) storing data about boundary conditions,...
constexpr double t
plate stiffness
Definition plate.cpp:58
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
Core (interface) class.
Definition Core.hpp:83
Deprecated interface functions.

◆ _IT_CUBITMESHSETS_BY_NAME_FOR_LOOP_

#define _IT_CUBITMESHSETS_BY_NAME_FOR_LOOP_ (   MESHSET_MANAGER,
  NAME,
  IT 
)

#include <src/interfaces/MeshsetsManager.hpp>

Value:
CubitMeshsetByName::iterator IT = \
MESHSET_MANAGER.get_meshsets_manager_ptr()->getBegin(NAME); \
IT != MESHSET_MANAGER.get_meshsets_manager_ptr()->getEnd(NAME); \
IT++

Iterator that loops over Cubit BlockSet having a particular name.

Parameters
MESHSET_MANAGERmeshset manager (works as well with Interface)
NAMEname
ITiterator

Example:

for(_IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_(mField,"SOME_BLOCK_NAME",it) {
...
}
#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.

Definition at line 117 of file MeshsetsManager.hpp.

◆ _IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_

#define _IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_ (   MESHSET_MANAGER,
  CUBITBCTYPE,
  IT 
)

#include <src/interfaces/MeshsetsManager.hpp>

Value:
CubitMeshsetByMask::iterator IT = \
MESHSET_MANAGER.get_meshsets_manager_ptr()->getBySetTypeBegin( \
CUBITBCTYPE); \
IT != MESHSET_MANAGER.get_meshsets_manager_ptr()->getBySetTypeEnd( \
CUBITBCTYPE); \
IT++

Iterator that loops over a specific Cubit MeshSet having a particular BC meshset in a moFEM field.

Parameters
MESHSET_MANAGERmeshset manager (works as well with Interface)
seeCubitBC (NODESET, SIDESET or BLOCKSET and more)
iterator

Example:

Examples
mofem/atom_tests/add_cubit_meshsets.cpp, mofem/atom_tests/continuity_check_on_contact_prism_side_ele.cpp, mofem/atom_tests/cubit_bc_test.cpp, mofem/atom_tests/forces_and_sources_testing_flat_prism_element.cpp, mofem/atom_tests/mesh_insert_interface_atom.cpp, mofem/tools/extrude_prisms.cpp, mofem/tools/mesh_cut.cpp, mofem/tutorials/clx-0_acoustics/helmholtz.cpp, mofem/tutorials/cor-0to1_unsaturated_transport/src/UnsaturatedFlow.hpp, mofem/tutorials/cor-0to1_unsaturated_transport/unsaturated_transport.cpp, mofem/tutorials/cor-10_navier_stokes/navier_stokes.cpp, mofem/tutorials/max-0_magnetostatics/src/MagneticElement.hpp, mofem/tutorials/scl-12_electrostatics/electrostatics.cpp, mofem/users_modules/basic_finite_elements/elasticity/elasticity.cpp, and mofem/users_modules/bone_remodelling/src/impl/Remodeling.cpp.

Definition at line 94 of file MeshsetsManager.hpp.

◆ _IT_CUBITMESHSETS_FOR_LOOP_

#define _IT_CUBITMESHSETS_FOR_LOOP_ (   MESHSET_MANAGER,
  IT 
)

#include <src/interfaces/MeshsetsManager.hpp>

Value:
CubitMeshSet_multiIndex::iterator IT = \
MESHSET_MANAGER.get_meshsets_manager_ptr()->getBegin(); \
IT != MESHSET_MANAGER.get_meshsets_manager_ptr()->getEnd(); \
IT++

Iterator that loops over all the Cubit MeshSets in a moFEM field.

Parameters
MESHSET_MANAGERmeshset manager (works as well with Interface)
iterator
Examples
mofem/atom_tests/add_cubit_meshsets.cpp, mofem/atom_tests/continuity_check_on_contact_prism_side_ele.cpp, mofem/atom_tests/forces_and_sources_testing_flat_prism_element.cpp, mofem/atom_tests/mesh_insert_interface_atom.cpp, mofem/tools/split_sideset.cpp, mofem/tutorials/cor-0to1_unsaturated_transport/unsaturated_transport.cpp, and mofem/users_modules/bone_remodelling/bone_adaptation.cpp.

Definition at line 57 of file MeshsetsManager.hpp.

Function Documentation

◆ addEntitiesToMeshset() [1/2]

MoFEMErrorCode MoFEM::MeshsetsManager::addEntitiesToMeshset ( const CubitBCType  cubit_bc_type,
const int  ms_id,
const EntityHandle ents,
const int  nb_ents 
)

#include <src/interfaces/MeshsetsManager.hpp>

Add entities to CUBIT meshset (array version)

Adds an array of mesh entities to an existing meshset. This version accepts entities as a C-style array with explicit count.

Parameters
cubit_bc_typetype of meshset (NODESET, SIDESET, BLOCKSET, etc.)
ms_idCUBIT ID of the target meshset
entspointer to array of entity handles
nb_entsnumber of entities in the array
Returns
MoFEMErrorCode Error code indicating success or failure

Definition at line 583 of file MeshsetsManager.cpp.

585 {
586 Interface &m_field = cOre;
587 moab::Interface &moab = m_field.get_moab();
589 auto cit =
590 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().find(
591 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
592 if (cit ==
593 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().end()) {
594 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
595 "Cannot find Cubit meshset with id: %d", ms_id);
596 }
597 EntityHandle meshset = cit->getMeshset();
598 CHKERR moab.add_entities(meshset, ents, nb_ents);
599
601}
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
DeprecatedCoreInterface Interface
moab::Interface & get_moab()
Definition Core.hpp:327
CubitMeshSet_multiIndex cubitMeshsets
cubit meshsets
MoFEM::Core & cOre
Reference to MoFEM Core interface.

◆ addEntitiesToMeshset() [2/2]

MoFEMErrorCode MoFEM::MeshsetsManager::addEntitiesToMeshset ( const CubitBCType  cubit_bc_type,
const int  ms_id,
const Range ents 
)

#include <src/interfaces/MeshsetsManager.hpp>

Add entities to CUBIT meshset.

Adds a range of mesh entities to an existing meshset. The entities become part of the meshset for subsequent operations like applying boundary conditions or material properties.

Parameters
cubit_bc_typetype of meshset (NODESET, SIDESET, BLOCKSET, etc.)
ms_idCUBIT ID of the target meshset
entsrange of entities to add to the meshset
Returns
MoFEMErrorCode Error code indicating success or failure
Examples
mofem/tools/mesh_cut.cpp.

Definition at line 563 of file MeshsetsManager.cpp.

564 {
565 Interface &m_field = cOre;
566 moab::Interface &moab = m_field.get_moab();
568 auto cit =
569 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().find(
570 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
571 if (cit ==
572 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().end()) {
573 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
574 "Cannot find Cubit meshset with id: %d", ms_id);
575 }
576 EntityHandle meshset = cit->getMeshset();
577 CHKERR moab.add_entities(meshset, ents);
578
580}

◆ addMeshset()

MoFEMErrorCode MoFEM::MeshsetsManager::addMeshset ( const CubitBCType  cubit_bc_type,
const int  ms_id,
const std::string  name = "" 
)

#include <src/interfaces/MeshsetsManager.hpp>

Add CUBIT meshset to manager.

Creates a new meshset entry in the manager's database with the specified CUBIT type and ID. The meshset can be given an optional name for easier identification and access.

Parameters
cubit_bc_typetype of meshset (NODESET, SIDESET, BLOCKSET, etc.)
ms_idCUBIT ID for the meshset
nameoptional name for the meshset (empty string if not specified)
Returns
MoFEMErrorCode Error code indicating success or failure
Examples
mofem/atom_tests/add_cubit_meshsets.cpp, and mofem/tools/mesh_cut.cpp.

Definition at line 506 of file MeshsetsManager.cpp.

508 {
509 Interface &m_field = cOre;
510 moab::Interface &moab = m_field.get_moab();
512 if (checkMeshset(ms_id, cubit_bc_type)) {
513 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
514 "such cubit meshset is already there id = %d", ms_id);
515 }
516
517 CubitMeshSets cmeshset(moab, cubit_bc_type, ms_id);
518 if ((cmeshset.cubitBcType & CubitBCType(NODESET | SIDESET | BLOCKSET))
519 .any()) {
520 auto p = cubitMeshsets.insert(cmeshset);
521 if (!p.second) {
522 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
523 "meshset not inserted");
524 }
525 if (name.size() > 0) {
526 bool success =
527 cubitMeshsets.modify(p.first, CubitMeshSets_change_name(moab, name));
528 if (!success) {
529 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
530 "name to cubit meshset can not be set");
531 }
532 }
533 }
534
536}
@ SIDESET
@ BLOCKSET
@ MOFEM_OPERATION_UNSUCCESSFUL
Definition definitions.h:34
bool checkMeshset(const int ms_id, const CubitBCType cubit_bc_type) const
Check for CUBIT meshset by ID and type.
std::bitset< 32 > CubitBCType
Definition Types.hpp:52

◆ broadcastMeshsets()

MoFEMErrorCode MoFEM::MeshsetsManager::broadcastMeshsets ( int  verb = DEFAULT_VERBOSITY)

#include <src/interfaces/MeshsetsManager.hpp>

Broadcast meshsets across MPI processes.

Synchronizes meshset information across all MPI processes to ensure consistent meshset data in parallel computations. Typically called after meshset modifications on specific processes.

Parameters
verbverbosity level for output
Returns
MoFEMErrorCode Error code indicating success or failure

Definition at line 184 of file MeshsetsManager.cpp.

184 {
185 Interface &m_field = cOre;
186 moab::Interface &moab = m_field.get_moab();
188
189 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
190 if (pcomm == NULL)
191 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
192 "MOAB communicator not set");
193
194 auto all_to_all = [&](Range &verts, std::vector<Range> &recv_verts) {
196 int success;
197 int buff_size;
198 ParallelComm::Buffer buff_send(ParallelComm::INITIAL_BUFF_SIZE);
199 buff_send.reset_ptr(sizeof(int));
200 CHKERR pcomm->pack_buffer(verts, false, true, false, -1, &buff_send);
201 buff_send.set_stored_size();
202 buff_size = buff_send.buff_ptr - buff_send.mem_ptr;
203
204 std::vector<int> recv_buff_sizes(pcomm->size(), 0);
205 success =
206 MPI_Allgather(&buff_size, 1, MPI_INT, recv_buff_sizes.data(), 1,
207 MPI_INT,
208 pcomm->comm());
209 if (success != MPI_SUCCESS)
210 SETERRQ(pcomm->comm(), MOFEM_DATA_INCONSISTENCY,
211 "MPI_Allgather failed");
212
213 std::vector<int> recv_buff_displs(
214 recv_buff_sizes.size(),
215 0); // that is relative (position) displacements in recv buffer
216 int recv_buff_size = 0;
217 for (std::size_t proc = 0; proc != recv_buff_sizes.size(); ++proc) {
218 recv_buff_displs[proc] = recv_buff_size;
219 recv_buff_size += recv_buff_sizes[proc];
220 }
221
222 std::vector<unsigned char> recv_buff(recv_buff_size);
223 success = MPI_Allgatherv(
224 buff_send.mem_ptr, buff_size, MPI_UNSIGNED_CHAR, recv_buff.data(),
225 recv_buff_sizes.data(), recv_buff_displs.data(), MPI_UNSIGNED_CHAR,
226 pcomm->comm());
227 if (success != MPI_SUCCESS)
228 SETERRQ(pcomm->comm(), MOFEM_DATA_INCONSISTENCY,
229 "MPI_Allgatherv failed");
230
231 recv_verts.clear();
232 recv_verts.resize(pcomm->size());
233 for (int from_proc = 0; from_proc < pcomm->size(); ++from_proc) {
234 if (from_proc == pcomm->rank())
235 continue;
236 if (recv_buff_sizes[from_proc] < static_cast<int>(sizeof(int)))
237 SETERRQ(pcomm->comm(), MOFEM_DATA_INCONSISTENCY,
238 "Received meshset buffer is too small");
239
240 std::vector<std::vector<EntityHandle>> L1hloc, L1hrem;
241 std::vector<std::vector<int>> L1p;
242 std::vector<EntityHandle> L2hloc, L2hrem, recv_ents;
243 std::vector<unsigned int> L2p;
244 auto *recv_ptr =
245 recv_buff.data() + recv_buff_displs[from_proc] + sizeof(int);
246 CHKERR pcomm->unpack_buffer(recv_ptr, false, from_proc, -1, L1hloc,
247 L1hrem, L1p, L2hloc, L2hrem, L2p, recv_ents);
248 recv_verts[from_proc].insert_list(recv_ents.begin(), recv_ents.end());
249 }
250
252 };
253
254 const double coords[] = {0, 0, 0};
255
256 auto set_tags_dummy_node = [&](const EntityHandle dummy_node,
257 const EntityHandle meshset) {
259 std::vector<Tag> tag_handles;
260 CHKERR moab.tag_get_tags_on_entity(meshset, tag_handles);
261 for (auto th : tag_handles) {
262 void *data[1];
263 int tag_size;
264 CHKERR moab.tag_get_by_ptr(th, &meshset, 1, (const void **)data,
265 &tag_size);
266 if (tag_size > 0)
267 CHKERR moab.tag_set_by_ptr(th, &dummy_node, 1, data, &tag_size);
268 }
270 };
271
272 for (auto t : {NODESET, SIDESET, BLOCKSET}) {
273 std::vector<const CubitMeshSets *> vec_ptr;
274 for (auto &m : cubitMeshsets) {
275 if ((m.getBcType() & CubitBCType(t)).any()) {
276 vec_ptr.push_back(&m);
277 }
278 }
279 sortMeshsets(vec_ptr);
280
281 std::vector<EntityHandle> vec_meshsets;
282 vec_meshsets.reserve(vec_ptr.size());
283 for (auto m_ptr : vec_ptr) {
284 vec_meshsets.push_back(m_ptr->getMeshset());
285 }
286
287 switch (t) {
288 case NODESET:
289 MOFEM_LOG("MeshsetMngSync", Sev::verbose)
290 << "broadcast NODESET " << vec_meshsets.size();
291 break;
292 case SIDESET:
293 MOFEM_LOG("MeshsetMngSync", Sev::verbose)
294 << "broadcast SIDESET " << vec_meshsets.size();
295 break;
296 case BLOCKSET:
297 MOFEM_LOG("MeshsetMngSync", Sev::verbose)
298 << "broadcast BLOCKSET " << vec_meshsets.size();
299 break;
300 default:
301 MOFEM_LOG("MeshsetMngSync", Sev::verbose)
302 << "broadcast Unknown " << vec_meshsets.size();
303 }
304
305 Range r_dummy_nodes;
306 std::vector<EntityHandle> dummy_nodes(vec_meshsets.size(), 0);
307 int i = 0;
308 for (auto m : vec_meshsets) {
309 CHKERR moab.create_vertex(coords, dummy_nodes[i]);
310 CHKERR set_tags_dummy_node(dummy_nodes[i], m);
311 ++i;
312 }
313 r_dummy_nodes.insert_list(dummy_nodes.begin(), dummy_nodes.end());
314
315 std::vector<Range> recv_dummy_nodes;
316 CHKERR all_to_all(r_dummy_nodes, recv_dummy_nodes);
317
318 for (int from_proc = 0; from_proc < pcomm->size(); ++from_proc) {
319 if (from_proc != pcomm->rank()) {
320 for (auto dummy_node : recv_dummy_nodes[from_proc]) {
321 CubitMeshSets broadcast_block(moab, dummy_node);
322 auto id = broadcast_block.getMeshsetId();
323 if (id != -1) {
324 auto mit =
325 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>()
326 .find(boost::make_tuple(
327 id, broadcast_block.getMaskedBcTypeULong()));
328 if (mit ==
329 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>()
330 .end()) {
332 CHKERR moab.create_meshset(MESHSET_SET, m);
333 CHKERR set_tags_dummy_node(m, dummy_node);
334 auto hint = cubitMeshsets.end();
335 /*auto p = */ cubitMeshsets.emplace_hint(hint, moab, m);
336 }
337 } else {
338 MOFEM_LOG("MeshsetMngSync", Sev::warning)
339 << "broadcasted vertex " << dummy_node << " has negative id";
340 }
341 }
342 } else {
343 MOFEM_LOG("MeshsetMngSync", Sev::verbose)
344 << "broadcast send from " << from_proc;
345 }
346 CHKERR moab.delete_entities(recv_dummy_nodes[from_proc]);
347 }
348
349 CHKERR moab.delete_entities(r_dummy_nodes);
350
351 MOFEM_LOG_SEVERITY_SYNC(m_field.get_comm(), Sev::verbose);
352 }
353
355}
#define MYPCOMM_INDEX
default communicator number PCOMM
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'm', 3 > m
static void sortMeshsets(std::vector< const CubitMeshSets * > &vec_ptr)

◆ checkMeshset() [1/2]

bool MoFEM::MeshsetsManager::checkMeshset ( const int  ms_id,
const CubitBCType  cubit_bc_type 
) const

#include <src/interfaces/MeshsetsManager.hpp>

Check for CUBIT meshset by ID and type.

Verifies if a meshset with the specified CUBIT ID and type exists in the manager's database. Useful for validation before accessing meshset properties or entities.

Todo:
All cubit interface functions should be outsourced to dedicated interface
Parameters
ms_idCUBIT ID of the meshset (BLOCKSET/SIDESET/NODESET)
cubit_bc_typetype of meshset (NODESET, SIDESET, BLOCKSET, etc.)
Returns
bool true if meshset exists, false otherwise
Examples
mofem/tools/mesh_cut.cpp, mofem/tools/mesh_smoothing.cpp, mofem/tutorials/cor-9_reaction_diffusion/reaction_diffusion.cpp, and mofem/tutorials/scl-6_heat_equation/heat_equation.cpp.

Definition at line 481 of file MeshsetsManager.cpp.

482 {
483 auto miit =
484 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().find(
485 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
486 if (miit !=
487 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().end()) {
488 return true;
489 }
490 return false;
491}

◆ checkMeshset() [2/2]

bool MoFEM::MeshsetsManager::checkMeshset ( const string  name,
int *const  number_of_meshsets_ptr = NULL 
) const

#include <src/interfaces/MeshsetsManager.hpp>

Check if meshset with given name exists.

Searches for meshsets by name and optionally returns the count of matching meshsets. Multiple meshsets can have the same name.

Parameters
namename of the meshset to search for
number_of_meshsets_ptroptional pointer to store count of matching meshsets
Returns
bool true if at least one meshset with the name exists, false otherwise

Definition at line 493 of file MeshsetsManager.cpp.

494 {
495 auto miit = cubitMeshsets.get<CubitMeshsets_name>().lower_bound(name);
496 auto hi_miit = cubitMeshsets.get<CubitMeshsets_name>().upper_bound(name);
497 if (std::distance(miit, hi_miit) == 0) {
498 return false;
499 }
500 if (number_of_meshsets_ptr) {
501 *number_of_meshsets_ptr = std::distance(miit, hi_miit);
502 }
503 return true;
504}

◆ clearMap()

MoFEMErrorCode MoFEM::MeshsetsManager::clearMap ( )

#include <src/interfaces/MeshsetsManager.hpp>

Clear the multi-index container.

Removes all stored meshset data from the internal container. Useful for reinitialization or memory cleanup.

Returns
MoFEMErrorCode Error code indicating success or failure

Definition at line 59 of file MeshsetsManager.cpp.

59 {
61 cubitMeshsets.clear();
63}
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...

◆ discardBlocksetConfiguration()

MoFEMErrorCode MoFEM::MeshsetsManager::discardBlocksetConfiguration ( std::size_t *  cleared_names = nullptr,
std::size_t *  cleared_attributes = nullptr,
const bool  clear_names = true,
const bool  clear_attributes = true 
)

#include <src/interfaces/MeshsetsManager.hpp>

Remove imported BLOCKSET names and/or attributes from the mesh.

This is used by the JSON config path to control how much embedded block metadata is preserved from the mesh file before JSON data is applied.

Parameters
cleared_namesoptional pointer storing how many block names were removed
cleared_attributesoptional pointer storing how many block attribute tags were removed
clear_nameswhen true remove imported BLOCKSET names
clear_attributeswhen true remove imported BLOCKSET attributes
Returns
MoFEMErrorCode Error code indicating success or failure

Definition at line 65 of file MeshsetsManager.cpp.

67 {
68 Interface &m_field = cOre;
69 moab::Interface &moab = m_field.get_moab();
71
72 Tag block_attributes;
73 CHKERR moab.tag_get_handle(BLOCK_ATTRIBUTES, block_attributes);
74
75 Tag entity_name_tag;
76 CHKERR moab.tag_get_handle(NAME_TAG_NAME, entity_name_tag);
77
78 std::vector<EntityHandle> block_meshsets;
79 block_meshsets.reserve(cubitMeshsets.size());
80 for (const auto &meshset : cubitMeshsets) {
81 if ((meshset.getBcType() & CubitBCType(BLOCKSET)).any()) {
82 block_meshsets.push_back(meshset.getMeshset());
83 }
84 }
85
86 std::sort(block_meshsets.begin(), block_meshsets.end());
87 block_meshsets.erase(
88 std::unique(block_meshsets.begin(), block_meshsets.end()),
89 block_meshsets.end());
90
91 std::size_t local_cleared_names = 0;
92 std::size_t local_cleared_attributes = 0;
93 for (const auto meshset : block_meshsets) {
94 std::vector<Tag> tag_handles;
95 CHKERR moab.tag_get_tags_on_entity(meshset, tag_handles);
96 if (clear_names &&
97 std::find(tag_handles.begin(), tag_handles.end(), entity_name_tag) !=
98 tag_handles.end()) {
99 CHKERR moab.tag_delete_data(entity_name_tag, &meshset, 1);
100 ++local_cleared_names;
101 }
102 if (clear_attributes &&
103 std::find(tag_handles.begin(), tag_handles.end(), block_attributes) !=
104 tag_handles.end()) {
105 CHKERR moab.tag_delete_data(block_attributes, &meshset, 1);
106 ++local_cleared_attributes;
107 }
108 }
109
110 if (cleared_names) {
111 *cleared_names = local_cleared_names;
112 }
113 if (cleared_attributes) {
114 *cleared_attributes = local_cleared_attributes;
115 }
116
118}

◆ getBegin() [1/3]

CubitMeshSet_multiIndex::iterator MoFEM::MeshsetsManager::getBegin ( ) const
inline

#include <src/interfaces/MeshsetsManager.hpp>

get begin iterator of cubit meshset of given type (instead you can use IT_CUBITMESHSETS_TYPE_FOR_LOOP(MFIELD,CUBITBCTYPE,IT)

for(IT_CUBITMESHSETS_FOR_LOOP(mField,it) { ... }

Definition at line 454 of file MeshsetsManager.hpp.

454 {
455 return cubitMeshsets.begin();
456 }

◆ getBegin() [2/3]

CubitMeshsetByName::iterator MoFEM::MeshsetsManager::getBegin ( const std::string &  name) const
inline

#include <src/interfaces/MeshsetsManager.hpp>

get begin iterator of cubit meshset of given type (instead you can use IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP(MFIELD,CUBITBCTYPE,IT)

for(IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP(mField,NODESET|DISPLACEMENTSET,it) { ... }

Parameters
typeof meshset (NODESET, SIDESET or BLOCKSET and more)

Definition at line 562 of file MeshsetsManager.hpp.

562 {
563 return cubitMeshsets.get<CubitMeshsets_name>().lower_bound(name);
564 }

◆ getBegin() [3/3]

CubitMeshsetByType::iterator MoFEM::MeshsetsManager::getBegin ( const unsigned int  cubit_bc_type) const
inline

#include <src/interfaces/MeshsetsManager.hpp>

get begin iterator of cubit meshset of given type (instead you can use IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP(MFIELD,CUBITBCTYPE,IT)

for(IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP(mField,NODESET|DISPLACEMENTSET,it) { ... }

Parameters
typeof meshset (NODESET, SIDESET or BLOCKSET and more)

Definition at line 487 of file MeshsetsManager.hpp.

487 {
488 return cubitMeshsets.get<CubitMeshsetType_mi_tag>().lower_bound(
489 cubit_bc_type);
490 }

◆ getBySetTypeBegin()

CubitMeshsetByMask::iterator MoFEM::MeshsetsManager::getBySetTypeBegin ( const unsigned int  cubit_bc_type) const
inline

#include <src/interfaces/MeshsetsManager.hpp>

get end iterator of cubit meshset of given type (instead you can use IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP(MFIELD,CUBITBCTYPE,IT)

for(IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP(mField,NODESET,it) { ... }

Parameters
typeof meshset (NODESET, SIDESET or BLOCKSET and more)

Definition at line 525 of file MeshsetsManager.hpp.

525 {
526 return cubitMeshsets.get<CubitMeshsetMaskedType_mi_tag>().lower_bound(
527 cubit_bc_type);
528 }

◆ getBySetTypeEnd()

CubitMeshsetByMask::iterator MoFEM::MeshsetsManager::getBySetTypeEnd ( const unsigned int  cubit_bc_type) const
inline

#include <src/interfaces/MeshsetsManager.hpp>

get end iterator of cubit meshset of given type (instead you can use IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP(MFIELD,CUBITBCTYPE,IT)

for(IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP(mField,NODESET,it) { ... }

Parameters
typeof meshset (NODESET, SIDESET or BLOCKSET and more)

Definition at line 543 of file MeshsetsManager.hpp.

543 {
544 return cubitMeshsets.get<CubitMeshsetMaskedType_mi_tag>().upper_bound(
545 cubit_bc_type);
546 }

◆ getCubitMeshsetPtr() [1/7]

std::vector< const CubitMeshSets * > MoFEM::MeshsetsManager::getCubitMeshsetPtr ( const CubitBCType  cubit_bc_type) const

#include <src/interfaces/MeshsetsManager.hpp>

Get vector of pointer by bc type.

Returns
MoFEMErrorCode

Definition at line 805 of file MeshsetsManager.cpp.

805 {
806 std::vector<const CubitMeshSets *> vec_ptr;
807 CHK_MOAB_THROW(getCubitMeshsetPtr(cubit_bc_type, vec_ptr),
808 "Error in getting meshsets by name");
809 return vec_ptr;
810}
#define CHK_MOAB_THROW(err, msg)
Check error code of MoAB function and throw MoFEM exception.
MoFEMErrorCode getCubitMeshsetPtr(const int ms_id, const CubitBCType cubit_bc_type, const CubitMeshSets **cubit_meshset_ptr) const
get cubit meshset

◆ getCubitMeshsetPtr() [2/7]

MoFEMErrorCode MoFEM::MeshsetsManager::getCubitMeshsetPtr ( const CubitBCType  cubit_bc_type,
std::vector< const CubitMeshSets * > &  vec_ptr 
) const

#include <src/interfaces/MeshsetsManager.hpp>

Get vector of pointer by bc type.

Parameters
std::vector<constCubitMeshSets *>
Returns
MoFEMErrorCode

Definition at line 791 of file MeshsetsManager.cpp.

793 {
795 auto r = cubitMeshsets.get<CubitMeshsetType_mi_tag>().equal_range(
796 cubit_bc_type.to_ulong());
797 for (auto it = r.first; it != r.second; ++it) {
798 vec_ptr.push_back(&*it);
799 }
800 sortMeshsets(vec_ptr);
802}
int r
Definition sdf.py:205

◆ getCubitMeshsetPtr() [3/7]

const CubitMeshSets * MoFEM::MeshsetsManager::getCubitMeshsetPtr ( const int  ms_id,
const CubitBCType  cubit_bc_type 
) const

#include <src/interfaces/MeshsetsManager.hpp>

get cubit meshset

Definition at line 764 of file MeshsetsManager.cpp.

765 {
766 const CubitMeshSets *cubit_meshset_ptr;
768 getCubitMeshsetPtr(ms_id, cubit_bc_type, &cubit_meshset_ptr),
769 "Get not get meshset");
770 return cubit_meshset_ptr;
771}
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.

◆ getCubitMeshsetPtr() [4/7]

MoFEMErrorCode MoFEM::MeshsetsManager::getCubitMeshsetPtr ( const int  ms_id,
const CubitBCType  cubit_bc_type,
const CubitMeshSets **  cubit_meshset_ptr 
) const

#include <src/interfaces/MeshsetsManager.hpp>

get cubit meshset

Examples
/home/lk58p/mofem_install/vanilla_dev_release/mofem-cephas/mofem/users_modules/eshelbian_plasticity/src/impl/EshelbianPlasticity.cpp, mofem/tutorials/adv-5_poroelasticity/seepage.cpp, mofem/tutorials/vec-3_nonlinear_dynamics/nonlinear_dynamic_elastic.cpp, mofem/tutorials/vec-7_shape_optimisation/adjoint.cpp, thermo_elastic.cpp, and thermoplastic.cpp.

Definition at line 745 of file MeshsetsManager.cpp.

747 {
748 Interface &m_field = cOre;
750 auto miit =
751 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().find(
752 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
753 if (miit !=
754 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().end()) {
755 *cubit_meshset_ptr = &*miit;
756 } else {
757 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
758 "msId = %d is not there", ms_id);
759 }
761}

◆ getCubitMeshsetPtr() [5/7]

std::vector< const CubitMeshSets * > MoFEM::MeshsetsManager::getCubitMeshsetPtr ( const std::regex  reg_exp_name) const

#include <src/interfaces/MeshsetsManager.hpp>

Get vector of pointer to blocksets with name satisfying regular expression.

for (auto m :
(boost::format("%s(.*)") % block_name).str()
))
) {
MOFEM_LOG("WORLD", Sev::inform) << m->getName();
Range ents;
m_field.get_moab().get_entities_by_dimension(
m->getMeshset(), 0, ents, false);
auto print_ents = [](boost::shared_ptr<FieldEntity> ent_ptr) {
if(!(ent_ptr->getPStatus() & PSTATUS_NOT_OWNED)) {
MOFEM_LOG("SYNC", Sev::inform) << ent_ptr->getName() << ": " <<
ent_ptr->getEntFieldData();
}
};
CHKERR m_field.getInterface<FieldBlas>()->fieldLambdaOnEntities(
print_ents, "VELOCITIES", &ents);
CHKERR m_field.getInterface<FieldBlas>()->fieldLambdaOnEntities(
print_ents, "DISPLACEMENTS", &ents);
MOFEM_LOG_SEVERITY_SYNC(m_field.get_comm(), Sev::ifrom);
}
Interface for managing meshsets containing materials and boundary conditions.
IFACE getInterface() const
Get interface pointer to pointer of interface.
Parameters
reg_exp_name
Returns
std::vector<const CubitMeshSets *>

Definition at line 829 of file MeshsetsManager.cpp.

829 {
830 std::vector<const CubitMeshSets *> vec_ptr;
831 CHK_MOAB_THROW(getCubitMeshsetPtr(reg_exp_name, vec_ptr),
832 "Error in getting meshsets by name");
833 return vec_ptr;
834}

◆ getCubitMeshsetPtr() [6/7]

MoFEMErrorCode MoFEM::MeshsetsManager::getCubitMeshsetPtr ( const std::regex  reg_exp_name,
std::vector< const CubitMeshSets * > &  vec_ptr 
) const

#include <src/interfaces/MeshsetsManager.hpp>

Get vector of pointer to blocksets with name satisfying regular expression.

Parameters
reg_exp_name
std::vector<constCubitMeshSets *>
Returns
MoFEMErrorCode

Definition at line 812 of file MeshsetsManager.cpp.

814 {
816 auto r =
817 cubitMeshsets.get<CubitMeshsetMaskedType_mi_tag>().equal_range(BLOCKSET);
818 for (; r.first != r.second; ++r.first) {
819 const auto name = r.first->getName();
820 if (std::regex_match(name, reg_exp_name)) {
821 vec_ptr.push_back(&*r.first);
822 }
823 }
824 sortMeshsets(vec_ptr);
826}

◆ getCubitMeshsetPtr() [7/7]

MoFEMErrorCode MoFEM::MeshsetsManager::getCubitMeshsetPtr ( const string  name,
const CubitMeshSets **  cubit_meshset_ptr 
) const

#include <src/interfaces/MeshsetsManager.hpp>

get cubit meshset

Definition at line 773 of file MeshsetsManager.cpp.

774 {
775 Interface &m_field = cOre;
777 auto miit = cubitMeshsets.get<CubitMeshsets_name>().lower_bound(name);
778 auto hi_miit = cubitMeshsets.get<CubitMeshsets_name>().upper_bound(name);
779 if (std::distance(miit, hi_miit) == 0) {
780 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
781 "meshset name <%s> is not there", name.c_str());
782 }
783 if (std::distance(miit, hi_miit) > 1) {
784 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
785 "more that one meshser of that name <%s>", name.c_str());
786 }
787 *cubit_meshset_ptr = &*miit;
789}

◆ getEnd() [1/3]

CubitMeshSet_multiIndex::iterator MoFEM::MeshsetsManager::getEnd ( ) const
inline

#include <src/interfaces/MeshsetsManager.hpp>

get begin iterator of cubit meshset of given type (instead you can use IT_CUBITMESHSETS_TYPE_FOR_LOOP(MFIELD,CUBITBCTYPE,IT)

for(IT_CUBITMESHSETS_FOR_LOOP(mField,it) { ... }

Definition at line 468 of file MeshsetsManager.hpp.

468 {
469 return cubitMeshsets.end();
470 }

◆ getEnd() [2/3]

CubitMeshsetByName::iterator MoFEM::MeshsetsManager::getEnd ( const std::string &  name) const
inline

#include <src/interfaces/MeshsetsManager.hpp>

get begin iterator of cubit meshset of given type (instead you can use IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP(MFIELD,CUBITBCTYPE,IT)

for(IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP(mField,NODESET|DISPLACEMENTSET,it) { ... }

Parameters
typeof meshset (NODESET, SIDESET or BLOCKSET and more)

Definition at line 580 of file MeshsetsManager.hpp.

580 {
581 return cubitMeshsets.get<CubitMeshsets_name>().upper_bound(name);
582 }

◆ getEnd() [3/3]

CubitMeshsetByType::iterator MoFEM::MeshsetsManager::getEnd ( const unsigned int  cubit_bc_type) const
inline

#include <src/interfaces/MeshsetsManager.hpp>

get begin iterator of cubit meshset of given type (instead you can use IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP(MFIELD,CUBITBCTYPE,IT)

for(IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP(mField,NODESET|DISPLACEMENTSET,it) { ... }

Parameters
typeof meshset (NODESET, SIDESET or BLOCKSET and more)

Definition at line 507 of file MeshsetsManager.hpp.

507 {
508 return cubitMeshsets.get<CubitMeshsetType_mi_tag>().upper_bound(
509 cubit_bc_type);
510 }

◆ getEntitiesByDimension() [1/2]

MoFEMErrorCode MoFEM::MeshsetsManager::getEntitiesByDimension ( const int  ms_id,
const unsigned int  cubit_bc_type,
const int  dimension,
Range entities,
const bool  recursive = true 
) const

#include <src/interfaces/MeshsetsManager.hpp>

get entities from CUBIT/meshset of a particular entity dimension

Nodeset can contain nodes, edges, triangles and tets. This applies to other meshsets too. The nodeset's meshset contain the nodes in the MIDDLE of the surface or volume which is done by default in Cubit, Hence if all nodes on a particular nodeset are required, one should get all triangles or tetrahedrons for which the nodeset was create in Cubit, and get all the connectivities of tris/tets.

Parameters
ms_idid of the BLOCKSET/SIDESET/BLOCKSET: from CUBIT
seeCubitBC (NODESET, SIDESET or BLOCKSET and more)
dimensions(0 - Nodes, 1 - Edges, 2 - Faces, 3 - Volume(tetrahedral))
Rangecontaining the retrieved entities
recursiveIf true, meshsets containing meshsets are queried recursively. Returns the contents of meshsets, but not the meshsets themselves if true.
Examples
mofem/atom_tests/prism_elements_from_surface.cpp, and mofem/tools/mesh_cut.cpp.

Definition at line 836 of file MeshsetsManager.cpp.

838 {
839 Interface &m_field = cOre;
840 moab::Interface &moab = m_field.get_moab();
842 auto miit =
843 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().find(
844 boost::make_tuple(msId, cubit_bc_type));
845 if (miit !=
846 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().end()) {
847 CHKERR miit->getMeshsetIdEntitiesByDimension(moab, dimension, entities,
848 recursive);
849 } else {
850 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
851 "msId = %d is not there", msId);
852 }
854}

◆ getEntitiesByDimension() [2/2]

MoFEMErrorCode MoFEM::MeshsetsManager::getEntitiesByDimension ( const int  ms_id,
const unsigned int  cubit_bc_type,
Range entities,
const bool  recursive = true 
) const

#include <src/interfaces/MeshsetsManager.hpp>

get entities related to CUBIT/meshset,

NODESET will get Vertices only, even if the NODESET contains edges, tris and tets SIDESET will get Tris, BLOCKSET will get Tets, DISPLACEMENTSET and FORCESET are stored in NODESET, PRESSURESET is stored in Sideset.

Parameters
ms_idid of the BLOCKSET/SIDESET/BLOCKSET: from CUBIT
seeCubitBC (NODESET, SIDESET or BLOCKSET and more)
Rangecontaining the retrieved entities related to the
recursiveIf true, meshsets containing meshsets are queried recursively. Returns the contents of meshsets, but not the meshsets themselves if true.

Definition at line 856 of file MeshsetsManager.cpp.

858 {
859 Interface &m_field = cOre;
860 moab::Interface &moab = m_field.get_moab();
862 auto miit =
863 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().find(
864 boost::make_tuple(ms_id, cubit_bc_type));
865 if (miit !=
866 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().end()) {
867 CHKERR miit->getMeshsetIdEntitiesByDimension(moab, entities, recursive);
868 } else {
869 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
870 "ms_id = %d is not there", ms_id);
871 }
873}

◆ getMeshset()

MoFEMErrorCode MoFEM::MeshsetsManager::getMeshset ( const int  ms_id,
const unsigned int  cubit_bc_type,
EntityHandle meshset 
) const

#include <src/interfaces/MeshsetsManager.hpp>

get meshset from CUBIT Id and CUBIT type

Parameters
ms_idid of the BLOCKSET/SIDESET/BLOCKSET: from CUBIT
seeCubitBC (NODESET, SIDESET or BLOCKSET and more)
meshsetwhere to store the retrieved entities
Examples
mofem/tools/mesh_cut.cpp, and mofem/tutorials/vec-5_free_surface/free_surface.cpp.

Definition at line 875 of file MeshsetsManager.cpp.

877 {
878 Interface &m_field = cOre;
880 auto miit =
881 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().find(
882 boost::make_tuple(ms_id, cubit_bc_type));
883 if (miit !=
884 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().end()) {
885 meshset = miit->meshset;
886 } else {
887 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
888 "ms_id = %d is not there", ms_id);
889 }
891}

◆ getMeshsetsByType()

MoFEMErrorCode MoFEM::MeshsetsManager::getMeshsetsByType ( const unsigned int  cubit_bc_type,
Range meshsets 
) const

#include <src/interfaces/MeshsetsManager.hpp>

get all CUBIT meshsets by CUBIT type

Parameters
seeCubitBC (NODESET, SIDESET or BLOCKSET and more).
meshsetsis range of meshsets

Definition at line 909 of file MeshsetsManager.cpp.

910 {
912 auto miit =
913 cubitMeshsets.get<CubitMeshsetType_mi_tag>().lower_bound(cubit_bc_type);
914 auto hi_miit =
915 cubitMeshsets.get<CubitMeshsetType_mi_tag>().upper_bound(cubit_bc_type);
916 for (; miit != hi_miit; miit++) {
917 meshsets.insert(miit->meshset);
918 }
920}

◆ getTags() [1/2]

MoFEMErrorCode MoFEM::MeshsetsManager::getTags ( int  verb = -1)

#include <src/interfaces/MeshsetsManager.hpp>

Get tag handles used on meshsets.

Retrieves MOAB tag handles for meshset identification and data storage. These tags follow CUBIT/MOAB conventions for nodesets, sidesets, and blocksets. The function initializes internal tag handles for subsequent meshset operations.

Parameters
verbverbosity level for output (-1 = default, higher values = more verbose)
Returns
MoFEMErrorCode Error code indicating success or failure

Definition at line 357 of file MeshsetsManager.cpp.

357 {
359 Interface &m_field = cOre;
360 moab::Interface &moab = m_field.get_moab();
362 bhTag_header, verb);
364}
MoFEMErrorCode getTags(int verb=-1)
Get tag handles used on meshsets.

◆ getTags() [2/2]

MoFEMErrorCode MoFEM::MeshsetsManager::getTags ( moab::Interface &  moab,
Tag nsTag,
Tag ssTag,
Tag nsTag_data,
Tag ssTag_data,
Tag bhTag,
Tag bhTag_header,
int  verb = -1 
)
static

#include <src/interfaces/MeshsetsManager.hpp>

Static version of getTags for external MOAB interface.

Parameters
moabreference to MOAB interface
nsTagreference to store nodeset tag handle
ssTagreference to store sideset tag handle
nsTag_datareference to store nodeset data tag handle
ssTag_datareference to store sideset data tag handle
bhTagreference to store blockset tag handle
bhTag_headerreference to store blockset header tag handle
verbverbosity level for output
Returns
MoFEMErrorCode Error code indicating success or failure

Definition at line 366 of file MeshsetsManager.cpp.

369 {
371
372 int default_val = -1;
373 CHKERR moab.tag_get_handle(DIRICHLET_SET_TAG_NAME, 1, MB_TYPE_INTEGER, nsTag,
374 MB_TAG_SPARSE | MB_TAG_CREAT, &default_val);
375
376 CHKERR moab.tag_get_handle(NEUMANN_SET_TAG_NAME, 1, MB_TYPE_INTEGER, ssTag,
377 MB_TAG_SPARSE | MB_TAG_CREAT, &default_val);
378
379 const int def_bc_data_len = 0;
380 std::string tag_name = std::string(DIRICHLET_SET_TAG_NAME) + "__BC_DATA";
381 CHKERR moab.tag_get_handle(
382 tag_name.c_str(), def_bc_data_len, MB_TYPE_OPAQUE, nsTag_data,
383 MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES | MB_TAG_VARLEN, NULL);
384
385 tag_name = std::string(NEUMANN_SET_TAG_NAME) + "__BC_DATA";
386 CHKERR moab.tag_get_handle(
387 tag_name.c_str(), def_bc_data_len, MB_TYPE_OPAQUE, ssTag_data,
388 MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES | MB_TAG_VARLEN, NULL);
389
390 CHKERR moab.tag_get_handle(MATERIAL_SET_TAG_NAME, 1, MB_TYPE_INTEGER, bhTag,
391 MB_TAG_SPARSE | MB_TAG_CREAT, &default_val);
392
393 std::vector<unsigned int> def_uint_zero(3, 0);
394 CHKERR moab.tag_get_handle(
395 BLOCK_HEADER, 3 * sizeof(unsigned int), MB_TYPE_INTEGER, bhTag_header,
396 MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES, &def_uint_zero[0]);
397
398 Tag block_attribs;
399 int def_Block_Attributes_length = 0;
400 CHKERR moab.tag_get_handle(
401 BLOCK_ATTRIBUTES, def_Block_Attributes_length, MB_TYPE_DOUBLE,
402 block_attribs, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN, NULL);
403
404 Tag entity_name_tag;
405 CHKERR moab.tag_get_handle(NAME_TAG_NAME, NAME_TAG_SIZE, MB_TYPE_OPAQUE,
406 entity_name_tag, MB_TAG_SPARSE | MB_TAG_CREAT);
407
409}

◆ initialiseDatabaseFromMesh()

MoFEMErrorCode MoFEM::MeshsetsManager::initialiseDatabaseFromMesh ( int  verb = DEFAULT_VERBOSITY)

#include <src/interfaces/MeshsetsManager.hpp>

Initialize container from mesh data.

Reads meshset information from the mesh database and populates the internal multi-index container. This includes discovering nodesets, sidesets, and blocksets with their associated tags and data.

Parameters
verbverbosity level for output
Returns
MoFEMErrorCode Error code indicating success or failure

Definition at line 120 of file MeshsetsManager.cpp.

120 {
121 Interface &m_field = cOre;
123 CHKERR readMeshsets(verb);
126
127 std::vector<const CubitMeshSets *> vec_ptr;
128 for (auto &m : cubitMeshsets) {
129 vec_ptr.push_back(&m);
130 }
131 sortMeshsets(vec_ptr);
132
133 for (auto m_ptr : vec_ptr) {
134 MOFEM_LOG("MeshsetMngWorld", Sev::inform)
135 << "meshset in database " << *m_ptr;
136 }
137 // Verbose synchronised print
138 for (auto m_ptr : vec_ptr) {
139 MOFEM_LOG("MeshsetMngSync", Sev::verbose)
140 << "meshset in database " << *m_ptr;
141 }
142 MOFEM_LOG_SEVERITY_SYNC(m_field.get_comm(), Sev::verbose);
143
145}
MoFEMErrorCode broadcastMeshsets(int verb=DEFAULT_VERBOSITY)
Broadcast meshsets across MPI processes.
MoFEMErrorCode readMeshsets(int verb=DEFAULT_VERBOSITY)
Read meshsets from mesh database.

◆ printDisplacementSet()

MoFEMErrorCode MoFEM::MeshsetsManager::printDisplacementSet ( ) const

#include <src/interfaces/MeshsetsManager.hpp>

Print meshsets with displacement boundary conditions.

Outputs information about all meshsets containing displacement boundary condition data, including constraint flags and prescribed values.

Returns
MoFEMErrorCode Error code indicating success or failure
Examples
mofem/tutorials/cor-7_elasticity_mixed_formulation/elasticity_mixed_formulation.cpp, and mofem/users_modules/basic_finite_elements/elasticity/elasticity.cpp.

Definition at line 411 of file MeshsetsManager.cpp.

411 {
412 DisplacementCubitBcData mydata;
414 CHKERR printBcSet(mydata, NODESET | mydata.tYpe.to_ulong());
416}
MoFEMErrorCode printBcSet(CUBIT_BC_DATA_TYPE &data, unsigned long int type) const

◆ printForceSet()

MoFEMErrorCode MoFEM::MeshsetsManager::printForceSet ( ) const

#include <src/interfaces/MeshsetsManager.hpp>

Print meshsets with force boundary conditions.

Outputs information about all meshsets containing force boundary condition data, including force and moment components.

Returns
MoFEMErrorCode Error code indicating success or failure
Examples
mofem/tutorials/cor-7_elasticity_mixed_formulation/elasticity_mixed_formulation.cpp, and mofem/users_modules/basic_finite_elements/elasticity/elasticity.cpp.

Definition at line 425 of file MeshsetsManager.cpp.

425 {
426 ForceCubitBcData mydata;
428 CHKERR printBcSet(mydata, NODESET | mydata.tYpe.to_ulong());
430}

◆ printHeatFluxSet()

MoFEMErrorCode MoFEM::MeshsetsManager::printHeatFluxSet ( ) const

#include <src/interfaces/MeshsetsManager.hpp>

Print meshsets with heat flux boundary conditions.

Outputs information about all meshsets containing heat flux boundary condition data, including flux magnitudes and directions.

Returns
MoFEMErrorCode Error code indicating success or failure

Definition at line 439 of file MeshsetsManager.cpp.

439 {
440 HeatFluxCubitBcData mydata;
442 CHKERR printBcSet(mydata, SIDESET | mydata.tYpe.to_ulong());
444}

◆ printMaterialsSet()

MoFEMErrorCode MoFEM::MeshsetsManager::printMaterialsSet ( ) const

#include <src/interfaces/MeshsetsManager.hpp>

Print meshsets with material properties.

Outputs information about all meshsets containing material data, including material parameters and constitutive model information.

Returns
MoFEMErrorCode Error code indicating success or failure
Examples
mofem/tutorials/cor-7_elasticity_mixed_formulation/elasticity_mixed_formulation.cpp, and mofem/users_modules/basic_finite_elements/elasticity/elasticity.cpp.

Definition at line 446 of file MeshsetsManager.cpp.

446 {
448 const Interface &m_field = cOre;
449 const moab::Interface &moab = m_field.get_moab();
451 (*this), BLOCKSET | MAT_ELASTICSET, it)) {
452 Mat_Elastic data;
453 CHKERR it->getAttributeDataStructure(data);
454 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << *it;
455 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << data;
456 Range tets;
457 CHKERR moab.get_entities_by_dimension(it->meshset, 3, tets, true);
458 MOFEM_LOG("MeshsetMngWorld", Sev::inform)
459 << "MAT_ELATIC msId " << it->getMeshsetId() << " nb. volumes "
460 << tets.size();
461 }
462
464 m_field, BLOCKSET | MAT_THERMALSET, it)) {
465 Mat_Thermal data;
466 CHKERR it->getAttributeDataStructure(data);
467 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << *it;
468 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << data;
469 }
470
472 m_field, BLOCKSET | MAT_MOISTURESET, it)) {
473 Mat_Moisture data;
474 CHKERR it->getAttributeDataStructure(data);
475 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << *it;
476 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << data;
477 }
479}
@ MAT_ELASTICSET
block name is "MAT_ELASTIC"
@ MAT_THERMALSET
block name is "MAT_THERMAL"
@ MAT_MOISTURESET
block name is "MAT_MOISTURE"
#define _IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet in a moFEM field.

◆ printPressureSet()

MoFEMErrorCode MoFEM::MeshsetsManager::printPressureSet ( ) const

#include <src/interfaces/MeshsetsManager.hpp>

Print meshsets with pressure boundary conditions.

Outputs information about all meshsets containing pressure boundary condition data, including pressure magnitudes and application flags.

Returns
MoFEMErrorCode Error code indicating success or failure

Definition at line 418 of file MeshsetsManager.cpp.

418 {
419 PressureCubitBcData mydata;
421 CHKERR printBcSet(mydata, SIDESET | mydata.tYpe.to_ulong());
423}

◆ printTemperatureSet()

MoFEMErrorCode MoFEM::MeshsetsManager::printTemperatureSet ( ) const

#include <src/interfaces/MeshsetsManager.hpp>

Print meshsets with temperature boundary conditions.

Outputs information about all meshsets containing temperature boundary condition data, including prescribed temperature values.

Returns
MoFEMErrorCode Error code indicating success or failure

Definition at line 432 of file MeshsetsManager.cpp.

432 {
433 TemperatureCubitBcData mydata;
435 CHKERR printBcSet(mydata, NODESET | mydata.tYpe.to_ulong());
437}

◆ readMeshsets()

MoFEMErrorCode MoFEM::MeshsetsManager::readMeshsets ( int  verb = DEFAULT_VERBOSITY)

#include <src/interfaces/MeshsetsManager.hpp>

Read meshsets from mesh database.

Scans the mesh for existing meshsets and populates the manager's internal data structures. This is typically called after mesh loading to discover all available nodesets, sidesets, and blocksets.

Parameters
verbverbosity level for output
Returns
MoFEMErrorCode Error code indicating success or failure

Definition at line 147 of file MeshsetsManager.cpp.

147 {
148 Interface &m_field = cOre;
149 moab::Interface &moab = m_field.get_moab();
151
152 Range meshsets;
153 CHKERR moab.get_entities_by_type(0, MBENTITYSET, meshsets, false);
154 for (auto m : meshsets) {
155 // check if meshset is cubit meshset
156 CubitMeshSets block(moab, m);
157 if ((block.cubitBcType & CubitBCType(NODESET | SIDESET | BLOCKSET)).any()) {
158 auto p = cubitMeshsets.insert(block);
159 if (!p.second) {
160 // blockset/nodeset/sideset set exist, could be created on other
161 // processor.
162 Range ents;
163 CHKERR m_field.get_moab().get_entities_by_handle(m, ents, true);
164 CHKERR m_field.get_moab().add_entities(p.first->getMeshset(), ents);
165 CHKERR m_field.get_moab().delete_entities(&m, 1);
166 }
167 }
168 }
169
170 std::vector<const CubitMeshSets *> vec_ptr;
171 for (auto &m : cubitMeshsets) {
172 vec_ptr.push_back(&m);
173 }
174 sortMeshsets(vec_ptr);
175
176 for (auto m_ptr : vec_ptr) {
177 MOFEM_LOG("MeshsetMngSync", Sev::verbose) << "read " << *m_ptr;
178 }
179 MOFEM_LOG_SEVERITY_SYNC(m_field.get_comm(), Sev::verbose);
180
182}

◆ setAttributes()

MoFEMErrorCode MoFEM::MeshsetsManager::setAttributes ( const CubitBCType  cubit_bc_type,
const int  ms_id,
const std::vector< double > &  attributes,
const std::string  name = "" 
)

#include <src/interfaces/MeshsetsManager.hpp>

Set attributes for CUBIT meshset.

Assigns attribute values to a meshset. Attributes are typically used for material properties or other numerical parameters associated with the meshset entities.

Parameters
cubit_bc_typetype of meshset (BLOCKSET, NODESET, SIDESET, etc.)
ms_idCUBIT ID of the target meshset
attributesvector of attribute values to assign
nameoptional name to assign to the meshset
Returns
MoFEMErrorCode Error code indicating success or failure
Examples
mofem/atom_tests/add_cubit_meshsets.cpp.

Definition at line 604 of file MeshsetsManager.cpp.

606 {
607 Interface &m_field = cOre;
608 moab::Interface &moab = m_field.get_moab();
610 auto cit =
611 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().find(
612 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
613 if (cit ==
614 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().end()) {
615 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
616 "Cannot find Cubit meshset with id: %d", ms_id);
617 }
618 if (name.size() > 0) {
619 bool success = cubitMeshsets.modify(cubitMeshsets.project<0>(cit),
620 CubitMeshSets_change_name(moab, name));
621 if (!success) {
622 SETERRQ(m_field.get_comm(), MOFEM_OPERATION_UNSUCCESSFUL,
623 "name to cubit meshset can not be set");
624 }
625 }
626 bool success =
627 cubitMeshsets.modify(cubitMeshsets.project<0>(cit),
628 CubitMeshSets_change_attributes(moab, attributes));
629 if (!success)
630 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
631 "modification unsuccessful");
632
633 std::ostringstream ss;
634 ss << "Block " << cit->getName();
635 ss << " Add attr: ";
636 for (unsigned int ii = 0; ii != attributes.size(); ii++) {
637 ss << attributes[ii] << " ";
638 }
639 MOFEM_LOG("MeshsetMngSelf", Sev::noisy) << ss.str();
640
642}

◆ setAttributesByDataStructure()

MoFEMErrorCode MoFEM::MeshsetsManager::setAttributesByDataStructure ( const CubitBCType  cubit_bc_type,
const int  ms_id,
const GenericAttributeData data,
const std::string  name = "" 
)

#include <src/interfaces/MeshsetsManager.hpp>

Set attributes using data structure.

Assigns material or other attributes to a meshset using a structured data object. This provides a more organized way to handle complex attribute data with proper typing and validation.

Parameters
cubit_bc_typetype of meshset (BLOCKSET, NODESET, SIDESET, etc.)
ms_idCUBIT ID of the target meshset
datastructured data containing attribute information
nameoptional name to assign to the meshset
Returns
MoFEMErrorCode Error code indicating success or failure
Examples
mofem/atom_tests/add_cubit_meshsets.cpp.

Definition at line 666 of file MeshsetsManager.cpp.

668 {
669 Interface &m_field = cOre;
670 moab::Interface &moab = m_field.get_moab();
672 auto cit =
673 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().find(
674 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
675 if (cit ==
676 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().end()) {
677 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
678 "Cannot find Cubit meshset with id: %d", ms_id);
679 }
680 if (name.size() > 0) {
681 bool success = cubitMeshsets.modify(cubitMeshsets.project<0>(cit),
682 CubitMeshSets_change_name(moab, name));
683 if (!success) {
684 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
685 "name to cubit meshset can not be set");
686 }
687 }
688 bool success = cubitMeshsets.modify(
689 cubitMeshsets.project<0>(cit),
690 CubitMeshSets_change_attributes_data_structure(moab, data));
691 if (!success)
692 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
693 "modification unsuccessful");
695}

◆ setBcData()

MoFEMErrorCode MoFEM::MeshsetsManager::setBcData ( const CubitBCType  cubit_bc_type,
const int  ms_id,
const GenericCubitBcData data 
)

#include <src/interfaces/MeshsetsManager.hpp>

Set boundary condition data for meshset.

Assigns boundary condition data to a meshset. This includes constraint information, prescribed values, and application flags for various boundary condition types (displacement, force, pressure, etc.).

Parameters
cubit_bc_typetype of meshset (BLOCKSET, NODESET, SIDESET, etc.)
ms_idCUBIT ID of the target meshset
databoundary condition data structure
Returns
MoFEMErrorCode Error code indicating success or failure
Examples
mofem/atom_tests/add_cubit_meshsets.cpp.

Definition at line 697 of file MeshsetsManager.cpp.

699 {
700 Interface &m_field = cOre;
701 moab::Interface &moab = m_field.get_moab();
703 auto cit =
704 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().find(
705 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
706 if (cit ==
707 cubitMeshsets.get<Composite_Cubit_msId_And_MeshsetType_mi_tag>().end()) {
708 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
709 "Cubit meshset with id is already there id = %d", ms_id);
710 }
711 bool success =
712 cubitMeshsets.modify(cubitMeshsets.project<0>(cit),
713 CubitMeshSets_change_bc_data_structure(moab, data));
714 if (!success)
715 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
716 "modification unsuccessful");
718}

◆ setMeshsetFromFile()

MoFEMErrorCode MoFEM::MeshsetsManager::setMeshsetFromFile ( )

#include <src/interfaces/MeshsetsManager.hpp>

Load meshset configuration from command line specified file.

Reads the configuration file name from the command line option '-meshsets_config' and loads meshset definitions from that file. This provides a convenient way to specify meshset configurations at runtime without hardcoding file paths.

Command line usage: -meshsets_config filename.cfg

Returns
MoFEMErrorCode Error code indicating success or failure

Definition at line 1649 of file MeshsetsManager.cpp.

1649 {
1650 Interface &m_field = cOre;
1651 PetscBool flg_file;
1652 char meshset_file_name[255] = "config_file.cfg";
1654 PetscOptionsBegin(m_field.get_comm(), "", "Set meshsets form file",
1655 "none");
1656 CHKERR PetscOptionsString("-meshsets_config", "meshsets config file name",
1657 "", "add_cubit_meshsets.in", meshset_file_name, 255,
1658 &flg_file);
1659 auto *json_config = m_field.getInterface<JsonConfigManager>();
1660 if (flg_file == PETSC_TRUE) {
1661 ifstream f(meshset_file_name);
1662 if (!f.good()) {
1663 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1664 "File configuring meshsets ( %s ) can not be open\n",
1665 meshset_file_name);
1666 }
1667 CHKERR setMeshsetFromFile(string(meshset_file_name));
1668 MOFEM_LOG("MeshsetMngWorld", Sev::inform)
1669 << "Printing all meshsets (old and added from meshsets "
1670 "configurational file)";
1671 for (auto cit = getBegin(); cit != getEnd(); cit++) {
1672 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << *cit;
1673 }
1674 } else if (json_config->hasMeshsetsSection()) {
1675 CHKERR json_config->applyMeshsets();
1676 }
1677 PetscOptionsEnd();
1679}
CubitMeshSet_multiIndex::iterator getBegin() const
get begin iterator of cubit meshset of given type (instead you can use IT_CUBITMESHSETS_TYPE_FOR_LOOP...
MoFEMErrorCode setMeshsetFromFile()
Load meshset configuration from command line specified file.
CubitMeshSet_multiIndex::iterator getEnd() const
get begin iterator of cubit meshset of given type (instead you can use IT_CUBITMESHSETS_TYPE_FOR_LOOP...