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

Helper class for declaring a part. More...

#include <DeclarePart.hpp>

Public Member Functions

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

Fluent interface

PartDeclaration name (const std::string &part_name)
 Set the name of the part (must be called before declare()).
PartDeclaration rank (stk::mesh::EntityRank part_rank)
 Set the entity rank of the part.
PartDeclaration topology (stk::topology::topology_t part_topology)
 Set the topology of the part.
PartDeclaration role (IOPartRole io_part_role)
 Set the io role of the part (optional).
PartDeclaration subpart (const stk::mesh::Part &subpart)
 Add a subpart to the part (i.e, declare the given part as a subset of this part).
template<typename FieldType>
PartDeclaration put_field (FieldType &field, const typename FieldType::value_type *init_value)
 Create a scalar-valued field restriction for this part (optional) with the given initial value.
template<typename FieldType>
PartDeclaration put_field (FieldType &field, unsigned n1, const typename FieldType::value_type *init_value)
 Create a vector-valued field restriction for this part (optional) with the given initial value and n1 values per entity.
template<typename FieldType>
PartDeclaration put_field (FieldType &field, unsigned n1, unsigned n2, const typename FieldType::value_type *init_value)
 Create a tensor-valued field restriction for this part (optional) with the given initial value and n1 x n2 values per entity.
template<typename ComponentType, typename BackingFieldType = std::remove_cvref_t< decltype(impl::component_backing_field(std::declval<ComponentType&>()))>>
PartDeclaration put_component (ComponentType component, const typename BackingFieldType::value_type *init_value)
 Create a field restriction directly from a field-backed component declaration.
stk::mesh::Part & declare ()
 Declare a part with the given properties.
void print (std::ostream &os=std::cout) const
 Print the part declaration information to the output stream.

Detailed Description

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

There are three types of parts that may be declared:

  1. Named parts (name, but no rank or topology)
  2. Ranked parts (name and rank, but no topology)
  3. Topological parts (name and topology, but no rank)

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

For example, to create an element rank assembly part that contains all beams and spheres:

PartDeclaration part_decl(meta_data);
stk::mesh::Part &spheres = part_decl.name("spheres").topology(stk::topology::PARTICLE).role(IO).declare();
stk::mesh::Part &beams = part_decl.name("beams").topology(stk::topology::BEAM_2).role(IO).declare();
stk::mesh::Part &rigid_bodies =
part_decl.name("rigid_bodies").rank(ELEM_RANK).role(ASSEMBLY).subpart(spheres).subpart(beams).declare();
PartDeclaration(stk::mesh::MetaData &meta_data)
Canonical constructor.
Definition DeclarePart.hpp:89
@ ASSEMBLY
Definition DeclarePart.hpp:51
@ IO
Definition DeclarePart.hpp:51

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

You may also reuse the same PartDeclaration to declare multiple parts with similar properties:

PartDeclaration part_decl(meta_data);
auto io_particle_part_decl = part_decl.topology(stk::topology::PARTICLE).role(IO).declare();
stk::mesh::Part &spheres = io_particle_part_decl.name("spheres").declare();
stk::mesh::Part &points = io_particle_part_decl.name("points").declare();

Constructor & Destructor Documentation

◆ PartDeclaration() [1/3]

mundy::mesh::PartDeclaration::PartDeclaration ( stk::mesh::MetaData & meta_data)
inline

◆ PartDeclaration() [2/3]

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

◆ PartDeclaration() [3/3]

mundy::mesh::PartDeclaration::PartDeclaration ( PartDeclaration && )
default

Member Function Documentation

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ name()

PartDeclaration mundy::mesh::PartDeclaration::name ( const std::string & part_name)
inline

◆ rank()

PartDeclaration mundy::mesh::PartDeclaration::rank ( stk::mesh::EntityRank part_rank)
inline

◆ topology()

PartDeclaration mundy::mesh::PartDeclaration::topology ( stk::topology::topology_t part_topology)
inline

◆ role()

PartDeclaration mundy::mesh::PartDeclaration::role ( IOPartRole io_part_role)
inline

◆ subpart()

PartDeclaration mundy::mesh::PartDeclaration::subpart ( const stk::mesh::Part & subpart)
inline

◆ put_field() [1/3]

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

◆ put_field() [2/3]

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

◆ put_field() [3/3]

template<typename FieldType>
PartDeclaration mundy::mesh::PartDeclaration::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&>()))>>
PartDeclaration mundy::mesh::PartDeclaration::put_component ( ComponentType component,
const typename BackingFieldType::value_type * init_value )
inline

◆ declare()

stk::mesh::Part & mundy::mesh::PartDeclaration::declare ( )
inline

◆ print()

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