Smith  0.1
Smith is an implicit thermal structural mechanics simulation code.
Static Public Member Functions | List of all members
smith::StateManager Class Reference

Manages the lifetimes of FEState objects such that restarts are abstracted from physics modules. More...

#include <state_manager.hpp>

Static Public Member Functions

static void initialize (axom::sidre::DataStore &ds, const std::string &output_directory)
 Initializes the StateManager with a sidre DataStore (into which state will be written/read) More...
 
static bool hasState (const std::string &name)
 Checks if StateManager has a state with the given name. More...
 
template<typename FunctionSpace >
static FiniteElementState newState (FunctionSpace space, const std::string &state_name, const std::string &mesh_tag)
 Factory method for creating a new FEState object. More...
 
static FiniteElementState newState (const mfem::ParFiniteElementSpace &space, const std::string &state_name)
 Factory method for creating a new FEState object. More...
 
static void storeState (FiniteElementState &state)
 Store a pre-constructed finite element state in the state manager. More...
 
template<typename T >
static void storeQuadratureData (const std::string &mesh_tag, std::shared_ptr< QuadratureData< T >> qdata)
 Store a pre-constructed Quadrature Data in the state manager. More...
 
template<typename T >
static std::shared_ptr< QuadratureData< T > > newQuadratureDataBuffer (const std::string &mesh_tag, const Domain &domain, int order, int dim, T initial_state)
 Create a shared ptr to a quadrature data buffer for the given material type. More...
 
static bool hasDual (const std::string &name)
 Checks if StateManager has a dual with the given name. More...
 
template<typename FunctionSpace >
static FiniteElementDual newDual (FunctionSpace space, const std::string &dual_name, const std::string &mesh_tag)
 Factory method for creating a new FEDual object. More...
 
static FiniteElementDual newDual (const mfem::ParFiniteElementSpace &space, const std::string &dual_name)
 Factory method for creating a new FEDual object. More...
 
static void storeDual (FiniteElementDual &dual)
 Store a pre-constructed finite element dual in the state manager. More...
 
static void updateState (const FiniteElementState &state)
 Updates the StateManager-owned grid function using the values from a given FiniteElementState. More...
 
static void updateDual (const FiniteElementDual &dual)
 Updates the StateManager-owned grid function using the values from a given FiniteElementDual. More...
 
static void save (const double t, const int cycle, const std::string &mesh_tag)
 Updates the Conduit Blueprint state in the datastore and saves to a file. More...
 
static double load (const int cycle_to_load, const std::string &mesh_tag)
 Loads an existing DataCollection. More...
 
static void reset ()
 Resets the underlying global datacollection object. More...
 
static bool hasMesh (const std::string &mesh_tag)
 Checks if StateManager has a mesh with the given mesh_tag. More...
 
static mfem::ParMesh & setMesh (std::unique_ptr< mfem::ParMesh > pmesh, const std::string &mesh_tag)
 Gives ownership of mesh to StateManager. More...
 
static mfem::ParMesh & mesh (const std::string &mesh_tag)
 Returns a non-owning reference to mesh held by StateManager. More...
 
static FiniteElementStateshapeDisplacement (const std::string &mesh_tag)
 Get the shape displacement finite element state. More...
 
static FiniteElementDualshapeDisplacementDual (const std::string &mesh_tag)
 Get the shape displacement finite element dual. More...
 
static void loadCheckpointedStates (int cycle_to_load, std::vector< FiniteElementState * > states_to_load)
 loads the finite element states from a previously checkpointed cycle More...
 
static FiniteElementDualshapeDisplacementSensitivity (const std::string &mesh_tag)
 Get the shape displacement sensitivity finite element dual. More...
 
static std::string collectionID (const mfem::ParMesh *pmesh)
 Returns the datacollection ID for a given mesh. More...
 
static bool isRestart ()
 Returns true if data was loaded into a DataCollection.
 
static int cycle (std::string mesh_tag)
 Get the current cycle (iteration number) from the underlying datacollection. More...
 
static double time (std::string mesh_tag)
 Get the current simulation time from the underlying datacollection. More...
 

Detailed Description

Manages the lifetimes of FEState objects such that restarts are abstracted from physics modules.

Definition at line 41 of file state_manager.hpp.

Member Function Documentation

◆ collectionID()

std::string smith::StateManager::collectionID ( const mfem::ParMesh *  pmesh)
static

Returns the datacollection ID for a given mesh.

Parameters
[in]pmeshPointer to a mesh (non-owning)
Returns
The collection ID corresponding to the DataCollection that owns the mesh pointed to by pmesh. If pmesh is nullptr then the default collection ID is returned.
Note
A raw pointer comparison is used to identify the datacollection, i.e., pmesh must either been returned by either the setMesh() or mesh() method

Definition at line 291 of file state_manager.cpp.

◆ cycle()

int smith::StateManager::cycle ( std::string  mesh_tag)
static

Get the current cycle (iteration number) from the underlying datacollection.

Parameters
mesh_tagThe datacollection (mesh name) to query
Returns
The current forward cycle (iteration/timestep number)
Note
This will return the cycle for the last written or loaded data collection

Definition at line 302 of file state_manager.cpp.

◆ hasDual()

static bool smith::StateManager::hasDual ( const std::string &  name)
inlinestatic

Checks if StateManager has a dual with the given name.

Parameters
nameA string that uniquely identifies the name
Returns
True if dual exists with the given name

Definition at line 236 of file state_manager.hpp.

◆ hasMesh()

static bool smith::StateManager::hasMesh ( const std::string &  mesh_tag)
inlinestatic

Checks if StateManager has a mesh with the given mesh_tag.

Parameters
[in]mesh_tagA string that uniquely identifies the mesh
Returns
True if mesh exists with the given mesh_tag

Definition at line 356 of file state_manager.hpp.

◆ hasState()

static bool smith::StateManager::hasState ( const std::string &  name)
inlinestatic

Checks if StateManager has a state with the given name.

Parameters
[in]nameA string that uniquely identifies the state
Returns
True if state exists with the given name

Definition at line 55 of file state_manager.hpp.

◆ initialize()

void smith::StateManager::initialize ( axom::sidre::DataStore &  ds,
const std::string &  output_directory 
)
static

Initializes the StateManager with a sidre DataStore (into which state will be written/read)

Parameters
[in]dsThe DataStore to use
[in]output_directoryThe directory to output files to - cannot be empty

Definition at line 103 of file state_manager.cpp.

◆ load()

static double smith::StateManager::load ( const int  cycle_to_load,
const std::string &  mesh_tag 
)
inlinestatic

Loads an existing DataCollection.

Parameters
[in]cycle_to_loadWhat cycle to load the DataCollection from
[in]mesh_tagThe mesh_tag associated with the DataCollection when it was saved
Returns
The time from specified restart cycle. Otherwise zero.

Definition at line 323 of file state_manager.hpp.

◆ loadCheckpointedStates()

void smith::StateManager::loadCheckpointedStates ( int  cycle_to_load,
std::vector< FiniteElementState * >  states_to_load 
)
static

loads the finite element states from a previously checkpointed cycle

Parameters
cycle_to_load
states_to_load

Definition at line 79 of file state_manager.cpp.

◆ mesh()

mfem::ParMesh & smith::StateManager::mesh ( const std::string &  mesh_tag)
static

Returns a non-owning reference to mesh held by StateManager.

Parameters
[in]mesh_tagA string that uniquely identifies the mesh
Precondition
A mesh identified by mesh_tag must be registered - either via load() or setMesh()

Definition at line 283 of file state_manager.cpp.

◆ newDual() [1/2]

FiniteElementDual smith::StateManager::newDual ( const mfem::ParFiniteElementSpace &  space,
const std::string &  dual_name 
)
static

Factory method for creating a new FEDual object.

Parameters
spaceA finite element space to copy for use in the new dual
dual_nameThe name of the new dual
Returns
The constructed finite element dual

Definition at line 191 of file state_manager.cpp.

◆ newDual() [2/2]

template<typename FunctionSpace >
static FiniteElementDual smith::StateManager::newDual ( FunctionSpace  space,
const std::string &  dual_name,
const std::string &  mesh_tag 
)
inlinestatic

Factory method for creating a new FEDual object.

Template Parameters
FunctionSpaceThe function space (e.g. H1<1>) to build the finite element dual on
Parameters
spaceThe function space (e.g. H1<1>) to build the finite element dual on
dual_nameThe name of the new finite element dual field
mesh_tagThe tag for the stored mesh used to construct the finite element state
See also
FiniteElementDual::FiniteElementDual
Note
If this is a restart then the options (except for the name) will be ignored

Definition at line 250 of file state_manager.hpp.

◆ newQuadratureDataBuffer()

template<typename T >
static std::shared_ptr<QuadratureData<T> > smith::StateManager::newQuadratureDataBuffer ( const std::string &  mesh_tag,
const Domain domain,
int  order,
int  dim,
initial_state 
)
inlinestatic

Create a shared ptr to a quadrature data buffer for the given material type.

Template Parameters
Tthe type to be created at each quadrature point
Parameters
mesh_tagThe tag for the stored mesh used to locate the datacollection
domainThe spatial domain over which to allocate the quadrature data
orderThe order of the discretization of the primal fields
dimThe spatial dimension of the mesh
initial_statethe value to be broadcast to each quadrature point
Returns
shared pointer to quadrature data buffer

Definition at line 207 of file state_manager.hpp.

◆ newState() [1/2]

FiniteElementState smith::StateManager::newState ( const mfem::ParFiniteElementSpace &  space,
const std::string &  state_name 
)
static

Factory method for creating a new FEState object.

Parameters
spaceA finite element space to copy for use in the new state
state_nameThe name of the new state
Returns
The constructed finite element state

Definition at line 155 of file state_manager.cpp.

◆ newState() [2/2]

template<typename FunctionSpace >
static FiniteElementState smith::StateManager::newState ( FunctionSpace  space,
const std::string &  state_name,
const std::string &  mesh_tag 
)
inlinestatic

Factory method for creating a new FEState object.

Template Parameters
FunctionSpaceThe function space (e.g. H1<1>) to build the finite element state on
Parameters
spaceThe function space (e.g. H1<1>) to build the finite element state on
state_nameThe name of the new finite element state field
mesh_tagThe tag for the stored mesh used to construct the finite element state
See also
FiniteElementState::FiniteElementState
Note
If this is a restart then the options (except for the name) will be ignored

Definition at line 69 of file state_manager.hpp.

◆ reset()

static void smith::StateManager::reset ( )
inlinestatic

Resets the underlying global datacollection object.

After this method, the StateManager is in the same state that it would be after the program started and before any StateManager methods have been called. If the client wants to use StateManager after a call to reset(), the initialize() method must be called.

Definition at line 339 of file state_manager.hpp.

◆ save()

void smith::StateManager::save ( const double  t,
const int  cycle,
const std::string &  mesh_tag 
)
static

Updates the Conduit Blueprint state in the datastore and saves to a file.

Parameters
[in]tThe current sim time
[in]cycleThe current iteration number of the simulation
[in]mesh_tagA string that uniquely identifies the mesh (and accompanying fields) to save

Definition at line 203 of file state_manager.cpp.

◆ setMesh()

mfem::ParMesh & smith::StateManager::setMesh ( std::unique_ptr< mfem::ParMesh >  pmesh,
const std::string &  mesh_tag 
)
static

Gives ownership of mesh to StateManager.

Parameters
[in]pmeshThe mesh to register
[in]mesh_tagA string that uniquely identifies the mesh
Returns
A pointer to the stored mesh whose ownership was just passed to StateManager

Definition at line 227 of file state_manager.cpp.

◆ shapeDisplacement()

FiniteElementState & smith::StateManager::shapeDisplacement ( const std::string &  mesh_tag)
static

Get the shape displacement finite element state.

This is the vector-valued H1 field of order 1 (linear nodal displacements) representing perturbations of the underlying mesh. This is used for shape optimization problems.

Parameters
mesh_tagA string that uniquely identifies the mesh
Returns
The linear nodal shape displacement field

Definition at line 125 of file state_manager.cpp.

◆ shapeDisplacementDual()

FiniteElementDual & smith::StateManager::shapeDisplacementDual ( const std::string &  mesh_tag)
static

Get the shape displacement finite element dual.

This is the linear form which is dual to a vector-valued H1 field of order 1 (linear nodal displacements) representing sensitivities to perturbations of the underlying mesh. This is used for shape optimization problems.

Parameters
mesh_tagA string that uniquely identifies the mesh
Returns
The linear nodal shape displacement dual

Definition at line 118 of file state_manager.cpp.

◆ shapeDisplacementSensitivity()

static FiniteElementDual& smith::StateManager::shapeDisplacementSensitivity ( const std::string &  mesh_tag)
static

Get the shape displacement sensitivity finite element dual.

This is the vector-valued H1 dual of order 1 representing sensitivities of the shape displacement field of the underlying mesh. This is used for shape optimization problems.

Parameters
mesh_tagA string that uniquely identifies the mesh
Returns
The linear shape sensitivity field

◆ storeDual()

void smith::StateManager::storeDual ( FiniteElementDual dual)
static

Store a pre-constructed finite element dual in the state manager.

Parameters
dualThe finite element dual to store

Definition at line 167 of file state_manager.cpp.

◆ storeQuadratureData()

template<typename T >
static void smith::StateManager::storeQuadratureData ( const std::string &  mesh_tag,
std::shared_ptr< QuadratureData< T >>  qdata 
)
inlinestatic

Store a pre-constructed Quadrature Data in the state manager.

Template Parameters
Tthe type to be created at each quadrature point
Parameters
mesh_tagThe tag for the stored mesh used to locate the datacollection
qdataThe quadrature data to store

Definition at line 106 of file state_manager.hpp.

◆ storeState()

void smith::StateManager::storeState ( FiniteElementState state)
static

Store a pre-constructed finite element state in the state manager.

Parameters
stateThe finite element state to store

Definition at line 132 of file state_manager.cpp.

◆ time()

double smith::StateManager::time ( std::string  mesh_tag)
static

Get the current simulation time from the underlying datacollection.

Parameters
mesh_tagThe datacollection (mesh name) to query
Returns
The current forward simulation time
Note
This will return the cycle for the last written or loaded data collection

Definition at line 308 of file state_manager.cpp.

◆ updateDual()

static void smith::StateManager::updateDual ( const FiniteElementDual dual)
inlinestatic

Updates the StateManager-owned grid function using the values from a given FiniteElementDual.

This sync operation must occur prior to writing a restart file.

Parameters
dualThe dual used to update the internal grid function

Definition at line 301 of file state_manager.hpp.

◆ updateState()

static void smith::StateManager::updateState ( const FiniteElementState state)
inlinestatic

Updates the StateManager-owned grid function using the values from a given FiniteElementState.

This sync operation must occur prior to writing a restart file.

Parameters
stateThe state used to update the internal grid function

Definition at line 285 of file state_manager.hpp.


The documentation for this class was generated from the following files: