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

Helper class for declaring entities. More...

#include <DeclareEntities.hpp>

Classes

class  NodeBuilder
 Nested builder for nodes. More...
class  ElementBuilder

Public Member Functions

Getters
size_t num_nodes () const
 Get the current number of nodes to be declared.
size_t num_elements () const
 Get the current number of elements to be declared.

Actions

const size_t
 MUNDY_DEPRECATED_MSG ("To be removed. We traded reserve speed benefits for reference stability upon pushback resizing.") void reserve(const size_t
 No-op: std::deque storage does not support reserve(), but references remain stable across push_back regardless of size.
EntityDeclarationdeclare_entities (stk::mesh::BulkData &bulk_data)
 Declare the entities in the mesh. This method will declare the entities in the mesh, share them, and set the field data according to the information already provided to the builder.

Private Helpers

std::ostream & operator<< (std::ostream &os, const DeclareLinksInfo &info)
std::ostream & operator<< (std::ostream &os, const DeclareNodeInfo &info)
 Overload the operator<<.
std::ostream & operator<< (std::ostream &os, const DeclareElementInfo &info)
 Overload the operator<<.

Detailed Description

This class is used to aid the declaration of entities in a mesh. Use it to build up a parallel synchonous list of nodes and elements that should be declared in the mesh. Once complete, use it to perform the declaration, sharing, and setting of field data automatically.

Note
We emphasize that all processes should own exact copies of the same EntityDeclaration. This choice means that EntityDeclaration is not optimally performant but the cost of duplicating entity information is cheap in comparison to the burden of determining parallel ownership and sharing.
The create_* methods within this class are not thread safe. To perform parallel construction of entities, use the create_nodes and create_elements methods to create a vector of entities to populate and then populate them in parallel.

Example usage declaring a pearl necklace (a chain of spheres connected by springs):

const int num_nodes = 7;
const int num_edges = 6;
for (int i = 0; i < num_nodes; ++i) {
builder.create_node().owning_proc(0).id(i + 1);
}
for (int i = 0; i < num_edges; ++i) {
auto& spring = builder.create_element();
spring.owning_proc(0).id(i + 1).topology(stk::topology::BEAM_2).nodes({i + 1, i + 2});
}
for (int i = 0; i < num_nodes; ++i) {
auto& sphere = builder.create_element();
sphere.owning_proc(0).id(i + 1 + num_edges).topology(stk::topology::PARTICLE).nodes({i + 1});
}
builder.declare_entities(bulk_data);
Helper class for declaring entities.
Definition DeclareEntities.hpp:96
size_t num_nodes() const
Get the current number of nodes to be declared.
Definition DeclareEntities.hpp:587
EntityDeclaration & declare_entities(stk::mesh::BulkData &bulk_data)
Declare the entities in the mesh. This method will declare the entities in the mesh,...
Definition DeclareEntities.cpp:195
const stk::mesh::FastMeshIndex & i
Definition FieldViews.hpp:312

Member Function Documentation

◆ num_nodes()

size_t mundy::mesh::EntityDeclaration::num_nodes ( ) const
inline

◆ num_elements()

size_t mundy::mesh::EntityDeclaration::num_elements ( ) const
inline

◆ MUNDY_DEPRECATED_MSG()

mundy::mesh::EntityDeclaration::MUNDY_DEPRECATED_MSG ( "To be removed. We traded reserve speed benefits for reference stability upon pushback resizing." ) const

◆ declare_entities()

EntityDeclaration & mundy::mesh::EntityDeclaration::declare_entities ( stk::mesh::BulkData & bulk_data)
Note
This method may open and close multiple STK modification cycles internally to handle parallel sharing and auto-aura propagation. If the caller has not opened a cycle, one will be opened automatically.
Parameters
bulk_dataThe bulk data

◆ operator<< [1/3]

std::ostream & operator<< ( std::ostream & os,
const DeclareLinksInfo & info )
friend

◆ operator<< [2/3]

std::ostream & operator<< ( std::ostream & os,
const DeclareNodeInfo & info )
friend

◆ operator<< [3/3]

std::ostream & operator<< ( std::ostream & os,
const DeclareElementInfo & info )
friend

Member Data Documentation

◆ size_t

const mundy::mesh::EntityDeclaration::size_t