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

Unified fluent builder for declaring both field-backed and shared-backed components. More...

#include <DeclareComponent.hpp>

Public Member Functions

Constructors and Assignment Operators
 ComponentDeclaration (stk::mesh::MetaData &meta_data)
 Construct with a MetaData reference (required for field-backed declarations; optional for shared).
 ComponentDeclaration ()
 Default constructor for shared-backed declarations that do not require MetaData.
 ComponentDeclaration (const ComponentDeclaration &)=default
 ComponentDeclaration (ComponentDeclaration &&)=default
ComponentDeclarationoperator= (const ComponentDeclaration &)=default
ComponentDeclarationoperator= (ComponentDeclaration &&)=default
Fluent setters
ComponentDeclaration rank (stk::mesh::EntityRank rank) const
 Set the entity rank of the component.
ComponentDeclaration name (const std::string &component_name) const
 Set the name of the component.
ComponentDeclaration role (Ioss::Field::RoleType field_role) const
 Set the I/O role for field-backed components.
ComponentDeclaration output_type (stk::io::FieldOutputType output_type) const
 Set the STK output type for field-backed components.

Terminal transitions

template<typename T>
auto type () const
 Fix the field scalar type before choosing a component backend.
template<typename AccessLike>
auto field () const
 Commit to a field-backed component with the given access shape.
template<typename AccessLike, typename SharedSource>
auto shared (SharedSource &&source) const
 Commit to a shared-backed component with the given access shape and source.
template<typename Tag>
auto tag () const
 Attach a semantic tag before choosing a component backend.

Detailed Description

ComponentDeclaration is the preferred entry point for all component declarations. It accumulates declaration metadata through a fluent chain of setters and then materializes either a field-backed component (via .field<A>().declare()) or a shared-backed component (via .shared<A>(source).declare()).

The builder transitions through implementation-detail intermediate types as the fluent chain accumulates type information; use auto to hold these intermediate results.

The backend is selected explicitly by calling .field<A>() for a field-backed component or .shared<A>(source) for a shared-backed component, then .declare().

Field-backed example:
ComponentDeclaration decl(meta_data);
auto velocity = decl.rank(NODE_RANK)
.name("velocity")
.role(Ioss::Field::TRANSIENT)
.field<mundy::math::Vector3<double>>()
.declare();
ComponentDeclaration(stk::mesh::MetaData &meta_data)
Construct with a MetaData reference (required for field-backed declarations; optional for shared).
Definition DeclareComponent.hpp:105
Shared-backed example:
auto stiffness = decl.rank(ELEMENT_RANK)
.name("stiffness")
.shared<double>(1.0)
.declare();
auto shared(SharedSource &&source) const
Commit to a shared-backed component with the given access shape and source.
Definition DeclareComponent.hpp:179
ComponentDeclaration rank(stk::mesh::EntityRank rank) const
Set the entity rank of the component.
Definition DeclareComponent.hpp:121
ComponentDeclaration name(const std::string &component_name) const
Set the name of the component.
Definition DeclareComponent.hpp:129
Tagged field component:
ComponentDeclaration decl(meta_data);
auto tagged = decl.rank(NODE_RANK)
.name("velocity")
.tag<VelocityTag>()
.field<mundy::math::Vector3<double>>()
.declare();
auto field() const
Commit to a field-backed component with the given access shape.
Definition DeclareComponent.hpp:171
auto tag() const
Attach a semantic tag before choosing a component backend.
Definition DeclareComponent.hpp:197
A small helper type for tying a Tag to an underlying value.
Definition aggregate.hpp:52
Snapshot reuse:
Intermediate builder values are copyable and may be reused to declare multiple components that share common properties:
ComponentDeclaration decl(meta_data);
auto node_vec3 = decl.rank(NODE_RANK)
.role(Ioss::Field::TRANSIENT)
.field<mundy::math::Vector3<double>>();
auto velocity = node_vec3.name("velocity").declare();
auto force = node_vec3.name("force").declare();
ComponentDeclaration role(Ioss::Field::RoleType field_role) const
Set the I/O role for field-backed components.
Definition DeclareComponent.hpp:139

Constructor & Destructor Documentation

◆ ComponentDeclaration() [1/4]

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

◆ ComponentDeclaration() [2/4]

mundy::mesh::ComponentDeclaration::ComponentDeclaration ( )
inline

◆ ComponentDeclaration() [3/4]

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

◆ ComponentDeclaration() [4/4]

mundy::mesh::ComponentDeclaration::ComponentDeclaration ( ComponentDeclaration && )
default

Member Function Documentation

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ rank()

ComponentDeclaration mundy::mesh::ComponentDeclaration::rank ( stk::mesh::EntityRank rank) const
inline

◆ name()

ComponentDeclaration mundy::mesh::ComponentDeclaration::name ( const std::string & component_name) const
inline

◆ role()

ComponentDeclaration mundy::mesh::ComponentDeclaration::role ( Ioss::Field::RoleType field_role) const
inline

The typical Mundy application will label fields as TRANSIENT or MESH.

◆ output_type()

ComponentDeclaration mundy::mesh::ComponentDeclaration::output_type ( stk::io::FieldOutputType output_type) const
inline

◆ type()

template<typename T>
auto mundy::mesh::ComponentDeclaration::type ( ) const
inline

◆ field()

template<typename AccessLike>
auto mundy::mesh::ComponentDeclaration::field ( ) const
inline
Template Parameters
AccessLikeAccess shape: arithmetic type, Mundy math type, or explicit access:: tag.

◆ shared()

template<typename AccessLike, typename SharedSource>
auto mundy::mesh::ComponentDeclaration::shared ( SharedSource && source) const
inline

◆ tag()

template<typename Tag>
auto mundy::mesh::ComponentDeclaration::tag ( ) const
inline
Template Parameters
TagTag type to attach to the resulting component.