Mundy: Multibody Nonlocal Dynamics Version of the Day
Loading...
Searching...
No Matches
mundy::mesh::Class Class Reference

Semantic mesh class backed by synchronized data and assembly part hierarchies. More...

#include <Class.hpp>

Classes

struct  DeclarationSignature
 Canonical declaration signature used to validate repeated declarations by name. More...

Public Types

Type aliases
enum  { INVALID_ID = -1 }
enum class  DeclarationKind : unsigned { DeclarationKind::NAMED = 0u , DeclarationKind::RANKED = 1u , DeclarationKind::TOPOLOGICAL = 2u }
 How the class data/leaf-data parts were declared. More...
enum class  Type : unsigned { Type::PRIMARY = 0u , Type::SET = 1u }
 The type of class this is. Class rules: More...
using class_ordinal_t = unsigned

Public Member Functions

Constructors and destructor
 Class ()=delete
 No default constructor.
 Class (const Class &)=delete
 Non-copyable and non-movable, mirroring STK object semantics.
 Class (Class &&)=delete
Classoperator= (const Class &)=delete
Classoperator= (Class &&)=delete
 ~Class ()=default
 Destructor.
Part-like API
stk::mesh::MetaDatamesh_meta_data () noexcept
 Fetch the owning MetaData manager.
const stk::mesh::MetaDatamesh_meta_data () const noexcept
 Fetch the owning MetaData manager.
stk::mesh::MetaDatameta_data () noexcept
 Backward-compatible alias for mesh_meta_data().
const stk::mesh::MetaDatameta_data () const noexcept
 Backward-compatible alias for mesh_meta_data().
stk::mesh::EntityRank primary_entity_rank () const
 Fetch the primary entity rank for this class.
stk::topology topology () const
 Fetch the topology for this class.
const std::string & name () const noexcept
 Fetch the class name.
class_ordinal_t class_ordinal () const noexcept
 Fetch this class ordinal.
const DeclarationSignaturedeclaration_signature () const noexcept
 Fetch the declaration signature used to create this class.
bool force_no_induce () const
 Return whether this class suppresses induction.
bool has_io_support () const noexcept
 Return whether this class has IO hierarchy support enabled.
bool should_induce (stk::mesh::EntityRank from_rank) const
 Should this class induce membership from from_rank?
bool was_induced (stk::mesh::EntityRank rank) const
 Could entities of rank be induced into this class?
bool entity_membership_is_parallel_consistent () const
 Whether class membership must be parallel consistent.
void entity_membership_is_parallel_consistent (bool is_parallel_consistent)
 Set whether class membership must be parallel consistent.
Type class_type () const noexcept
 Fetch the class type.
bool is_set () const noexcept
 Fetch whether this class is a set.
bool is_primary () const noexcept
 Fetch whether this class is a primary class.
int64_t data_part_id () const
 Fetch the data-part id.
int64_t assembly_part_id () const
 Fetch the assembly-part id.
bool contains (const Class &other) const
 Check if other is contained by this class in both hierarchy channels.
const ClassVectorsubclasses () noexcept
 Direct subclasses declared through the Class API.
const ConstClassVectorsubclasses () const noexcept
 Direct subclasses declared through the Class API.
const ClassVectorsuperclasses () noexcept
 Direct superclasses declared through the Class API.
const ConstClassVectorsuperclasses () const noexcept
 Direct superclasses declared through the Class API.
const stk::mesh::PartVector & data_part_supersets () const
 Parts that are supersets of this class's data part.
const stk::mesh::PartVector & data_part_subsets () const
 Parts that are subsets of this class's data part.
const stk::mesh::PartVector & assembly_part_supersets () const
 Parts that are supersets of this class's assembly part.
const stk::mesh::PartVector & assembly_part_subsets () const
 Parts that are subsets of this class's assembly part.
Classget_or_create_induced_set (stk::mesh::EntityRank rank)
 Create an induced set for this class at rank if it doesn't already exist and return it.
Classget_induced_set (stk::mesh::EntityRank rank)
 Get an induced set for this class at rank if it exists, otherwise throw.
const Classget_induced_set (stk::mesh::EntityRank rank) const
bool has_induced_set (stk::mesh::EntityRank rank) const
bool operator== (const Class &rhs) const
 Equality comparison.
bool operator!= (const Class &rhs) const
 Inequality comparison.
template<class A>
const A * attribute () const
 Query attribute attached to the class data part.
stk::mesh::Part & data_part () noexcept
 Fetch the non-io data hierarchy part.
const stk::mesh::Part & data_part () const noexcept
 Fetch the non-io data hierarchy part.
stk::mesh::Part & leaf_part () noexcept
 Fetch the io leaf data part.
const stk::mesh::Part & leaf_part () const noexcept
 Fetch the io leaf data part.
stk::mesh::Part & assembly_part () noexcept
 Fetch the assembly hierarchy part.
const stk::mesh::Part & assembly_part () const noexcept
 Fetch the assembly hierarchy part.
stk::mesh::Part & leaf_assembly_part () noexcept
 Fetch the leaf assembly part.
const stk::mesh::Part & leaf_assembly_part () const noexcept
 Fetch the leaf assembly part.
 operator stk::mesh::Selector () const
 Treat this class as the selector for its assembly hierarchy.
 operator const stk::mesh::Part & () const noexcept
 Treat this class as its assembly part for read-only STK APIs such as Bucket::member(...).
Actions
void declare_subset (Class &sub_class)
 Declare sub_class as a direct subclass in both hierarchy channels. sub_class must have the same primary entity rank as this class.
void set_assembly_part_ids (unsigned assembly_part_id, unsigned leaf_assembly_part_id)
 Assign deterministic ids to assembly-type parts for IO/visualization stability.

Detailed Description

Classes handle the map between class hierarchy logic and STK's io system. We don't set the rules, we just work around them and try to make them easier to use. The main rules are:

  • There are two types of Classes: primary classes and sets.
  • A primary class is one that was assigned a topology upon declaration; it is the only type of class that can have primary entity members. Importantly, an entity can reside in one and only one primary class of the same rank.
  • Entities may be members of zero or more primary classes of higher rank. These entities will automatically acquire the data and selector membership of these primary classes.
  • Primary classes may have subclasses (of either primary or set type), which inherit the data and selector membership of their parent class. These subclasses must have the same rank as the parent class.
  • A set is a class that has an assigned rank but no topology; it is used for giving data to specific groups of entities. An entity can reside in zero or more sets independent of primary class membership.
  • Sets do not induce membership to lower ranks but may have subclasses of the same rank.

Unsupported features and limitations that break the above rules when IO support is enabled:

  • No ELEMENT_RANK sets
  • No primary classes of NODE_RANK

TODO(palmerb4): Introduce a runtime flag for disabling Class IO rules, thereby allowing for ELEMENT_RANK sets and NODE_RANK primary classes. TODO(palmerb4): Induced sets should be an implementation detail. Mostly because they are inextensible. It's not that they always exist and always contain all lower rank entities, it's that they contain all data that you wish to store on lower rank entities so if you decide to remove all the node fields for a class, then no induced node rank class will be created for that class. This minimizes the number of parts created per class.

Classes handle the STK IO part hierarchy by introducing multiple parts per class + optional induced set parts. They handle the interface logic between a (top down) polymorphic class hierarchy and a (bottom up) disjoint part hierarchy. The set of parts changes based on the class type: (1/2) Primary classes + Sets:

  • data_part() contains all data for this class; it is not an IO part and is a superset to the data parts of all subsets.
  • leaf_part() contains all entities that reside within this primary; it is the concrete IO part and will never have subsets. It is a subset of the data part.
  • assembly_part() contains all entities in this class and all of its subsets; it is an IO assembly part and superset to the assembly parts of all subsets. Think of this part as synonymous with the class itself.
  • leaf_assembly_part() contains all entities within the leaf part; it is an IO assembly part and exists solely to keep assembly membership homogeneous. It is a subset of the assembly part.