Serac  0.1
Serac is an implicit thermal strucural mechanics simulation code.
Static Public Member Functions | List of all members
serac::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...
 
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 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 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 void loadCheckpointedStates (int cycle_to_load, std::vector< std::reference_wrapper< 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 serac::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 303 of file state_manager.cpp.

◆ cycle()

int serac::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 314 of file state_manager.cpp.

◆ initialize()

void serac::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 115 of file state_manager.cpp.

◆ load()

static double serac::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 179 of file state_manager.hpp.

◆ loadCheckpointedStates()

void serac::StateManager::loadCheckpointedStates ( int  cycle_to_load,
std::vector< std::reference_wrapper< 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 93 of file state_manager.cpp.

◆ mesh()

mfem::ParMesh & serac::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 294 of file state_manager.cpp.

◆ newDual() [1/2]

FiniteElementDual serac::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 199 of file state_manager.cpp.

◆ newDual() [2/2]

template<typename FunctionSpace >
static FiniteElementDual serac::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 104 of file state_manager.hpp.

◆ newState() [1/2]

FiniteElementState serac::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 159 of file state_manager.cpp.

◆ newState() [2/2]

template<typename FunctionSpace >
static FiniteElementState serac::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 62 of file state_manager.hpp.

◆ reset()

static void serac::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 195 of file state_manager.hpp.

◆ save()

void serac::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 213 of file state_manager.cpp.

◆ setMesh()

mfem::ParMesh & serac::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 228 of file state_manager.cpp.

◆ shapeDisplacement()

FiniteElementState & serac::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 130 of file state_manager.cpp.

◆ shapeDisplacementSensitivity()

static FiniteElementDual& serac::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 serac::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 173 of file state_manager.cpp.

◆ storeState()

void serac::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 135 of file state_manager.cpp.

◆ time()

double serac::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 321 of file state_manager.cpp.

◆ updateDual()

static void serac::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 157 of file state_manager.hpp.

◆ updateState()

static void serac::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 141 of file state_manager.hpp.


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