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

Helper class for declaring a class. More...

#include <DeclareClass.hpp>

Public Member Functions

Constructors and Assignment Operators
 ClassDeclaration (stk::mesh::MetaData &meta_data)
 Canonical constructor.
 ClassDeclaration (const ClassDeclaration &)=default
 Copy/Move constructors and assignment operators.
 ClassDeclaration (ClassDeclaration &&)=default
ClassDeclarationoperator= (const ClassDeclaration &)=default
ClassDeclarationoperator= (ClassDeclaration &&)=default

Fluent interface

ClassDeclaration name (const std::string &class_name)
 Set the name of the class (must be called before declare()).
ClassDeclaration rank (stk::mesh::EntityRank class_rank)
 Set the entity rank of the class.
ClassDeclaration topology (stk::topology::topology_t class_topology)
 Set the topology of the class.
ClassDeclaration subclass (const Class &subclass)
 Add a subclass to the class (i.e, declare the given class as a subset of this class).
ClassDeclaration superclass (const Class &superclass)
 Add a superclass to the class (i.e, declare this class as a subset of the given class).
template<typename FieldType>
ClassDeclaration put_field (FieldType &field, const typename FieldType::value_type *init_value)
 Create a scalar-valued field restriction for this class (optional) with the given initial value.
template<typename FieldType>
ClassDeclaration put_field (FieldType &field, unsigned n1, const typename FieldType::value_type *init_value)
 Create a vector-valued field restriction for this class (optional) with the given initial value.
template<typename FieldType>
ClassDeclaration put_field (FieldType &field, unsigned n1, unsigned n2, const typename FieldType::value_type *init_value)
 Create a tensor-valued field restriction for this class (optional) with the given initial value.
template<typename ComponentType, typename BackingFieldType = std::remove_cvref_t< decltype(impl::component_backing_field(std::declval<ComponentType&>()))>>
ClassDeclaration put_component (ComponentType component, const typename BackingFieldType::value_type *init_value)
 Create a field restriction directly from a field-backed component declaration.
Classdeclare ()
 Declare a class with the given properties.
void print (std::ostream &os=std::cout) const
 Print the class declaration information to the output stream.

Detailed Description

This class is used to aid the declaration of a class on the mesh with reduced boilerplate. It uses a fluent interface to set the class properties and then declare the class.

There are three types of classes that may be declared:

  1. Named classes (name, but no rank or topology)
  2. Ranked class-sets (name and rank, but no topology)
  3. Topological primary classes (name and topology, but no rank)

You may not specify both a rank and a topology for the same class.

For example, to create a node-rank set that contains boundary and loading nodes:

ClassDeclaration class_decl(meta_data);
Class& boundary_nodes = class_decl.name("boundary_nodes").rank(NODE_RANK).declare();
Class& loading_nodes = class_decl.name("loading_nodes").rank(NODE_RANK).declare();
Class& all_nodes =
class_decl.name("all_nodes").rank(NODE_RANK).subclass(boundary_nodes).subclass(loading_nodes).declare();
ClassDeclaration(stk::mesh::MetaData &meta_data)
Canonical constructor.
Definition DeclareClass.hpp:88
Semantic mesh class backed by synchronized data and assembly part hierarchies.
Definition Class.hpp:128
const std::string & name() const noexcept
Fetch the class name.
Definition Class.hpp:212

These setters may be called in any order. Subclasses are optional, but you must call a valid combination of name, rank, and topology before declare().

You may also reuse the same ClassDeclaration to declare multiple classes with similar properties:

ClassDeclaration class_decl(meta_data);
auto particle_class_decl = class_decl.topology(stk::topology::PARTICLE).declare();
Class& spheres = particle_class_decl.name("spheres").declare();
Class& points = particle_class_decl.name("points").declare();

Constructor & Destructor Documentation

◆ ClassDeclaration() [1/3]

mundy::mesh::ClassDeclaration::ClassDeclaration ( stk::mesh::MetaData & meta_data)
inlineexplicit

◆ ClassDeclaration() [2/3]

mundy::mesh::ClassDeclaration::ClassDeclaration ( const ClassDeclaration & )
default

◆ ClassDeclaration() [3/3]

mundy::mesh::ClassDeclaration::ClassDeclaration ( ClassDeclaration && )
default

Member Function Documentation

◆ operator=() [1/2]

ClassDeclaration & mundy::mesh::ClassDeclaration::operator= ( const ClassDeclaration & )
default

◆ operator=() [2/2]

ClassDeclaration & mundy::mesh::ClassDeclaration::operator= ( ClassDeclaration && )
default

◆ name()

ClassDeclaration mundy::mesh::ClassDeclaration::name ( const std::string & class_name)
inline

◆ rank()

ClassDeclaration mundy::mesh::ClassDeclaration::rank ( stk::mesh::EntityRank class_rank)
inline

◆ topology()

ClassDeclaration mundy::mesh::ClassDeclaration::topology ( stk::topology::topology_t class_topology)
inline

◆ subclass()

ClassDeclaration mundy::mesh::ClassDeclaration::subclass ( const Class & subclass)
inline

◆ superclass()

ClassDeclaration mundy::mesh::ClassDeclaration::superclass ( const Class & superclass)
inline

◆ put_field() [1/3]

template<typename FieldType>
ClassDeclaration mundy::mesh::ClassDeclaration::put_field ( FieldType & field,
const typename FieldType::value_type * init_value )
inline

◆ put_field() [2/3]

template<typename FieldType>
ClassDeclaration mundy::mesh::ClassDeclaration::put_field ( FieldType & field,
unsigned n1,
const typename FieldType::value_type * init_value )
inline

◆ put_field() [3/3]

template<typename FieldType>
ClassDeclaration mundy::mesh::ClassDeclaration::put_field ( FieldType & field,
unsigned n1,
unsigned n2,
const typename FieldType::value_type * init_value )
inline

◆ put_component()

template<typename ComponentType, typename BackingFieldType = std::remove_cvref_t< decltype(impl::component_backing_field(std::declval<ComponentType&>()))>>
ClassDeclaration mundy::mesh::ClassDeclaration::put_component ( ComponentType component,
const typename BackingFieldType::value_type * init_value )
inline

◆ declare()

Class & mundy::mesh::ClassDeclaration::declare ( )
inline

◆ print()

void mundy::mesh::ClassDeclaration::print ( std::ostream & os = std::cout) const
inline