16 #include <unordered_map>
19 #include "axom/sidre/core/MFEMSidreDataCollection.hpp"
48 static void initialize(axom::sidre::DataStore& ds,
const std::string& output_directory);
61 template <
typename FunctionSpace>
64 SLIC_ERROR_ROOT_IF(!ds_,
"Serac's data store was not initialized - call StateManager::initialize first");
65 SLIC_ERROR_ROOT_IF(datacolls_.find(mesh_tag) == datacolls_.end(),
66 axom::fmt::format(
"Mesh tag '{}' not found in the data store", mesh_tag));
67 SLIC_ERROR_ROOT_IF(named_states_.find(state_name) != named_states_.end(),
68 axom::fmt::format(
"StateManager already contains a state named '{}'", state_name));
103 template <
typename FunctionSpace>
106 SLIC_ERROR_ROOT_IF(!ds_,
"Serac's data store was not initialized - call StateManager::initialize first");
107 SLIC_ERROR_ROOT_IF(datacolls_.find(mesh_tag) == datacolls_.end(),
108 axom::fmt::format(
"Mesh tag '{}' not found in the data store", mesh_tag));
109 SLIC_ERROR_ROOT_IF(named_states_.find(dual_name) != named_duals_.end(),
110 axom::fmt::format(
"StateManager already contains a dual named '{}'", dual_name));
143 SLIC_ERROR_ROOT_IF(named_states_.find(state.
name()) == named_states_.end(),
144 axom::fmt::format(
"State manager does not contain state named '{}'", state.
name()));
159 SLIC_ERROR_ROOT_IF(named_duals_.find(
dual.name()) == named_duals_.end(),
160 axom::fmt::format(
"State manager does not contain dual named '{}'",
dual.name()));
162 dual.space().GetRestrictionMatrix()->MultTranspose(
dual, *named_duals_[
dual.name()]);
171 static void save(
const double t,
const int cycle,
const std::string& mesh_tag);
179 static double load(
const int cycle_to_load,
const std::string& mesh_tag)
183 return newDataCollection(mesh_tag, cycle_to_load);
197 named_states_.clear();
198 named_duals_.clear();
199 shape_displacements_.clear();
212 static mfem::ParMesh&
setMesh(std::unique_ptr<mfem::ParMesh> pmesh,
const std::string& mesh_tag);
219 static mfem::ParMesh&
mesh(
const std::string& mesh_tag);
239 std::vector<std::reference_wrapper<FiniteElementState>> states_to_load);
260 static std::string
collectionID(
const mfem::ParMesh* pmesh);
273 static int cycle(std::string mesh_tag);
283 static double time(std::string mesh_tag);
292 static double newDataCollection(
const std::string& name,
const std::optional<int> cycle_to_load = {});
299 static void constructShapeFields(
const std::string& mesh_tag);
305 static std::unordered_map<std::string, axom::sidre::MFEMSidreDataCollection> datacolls_;
308 static std::unordered_map<std::string, std::unique_ptr<FiniteElementState>> shape_displacements_;
313 static bool is_restart_;
316 static axom::sidre::DataStore* ds_;
318 static std::string output_dir_;
321 static std::unordered_map<std::string, mfem::ParGridFunction*> named_states_;
323 static std::unordered_map<std::string, mfem::ParGridFunction*> named_duals_;
Class for encapsulating the dual vector space of a finite element space (i.e. the space of linear for...
Class for encapsulating the critical MFEM components of a primal finite element field.
void fillGridFunction(mfem::ParGridFunction &grid_function) const
Fill a user-provided grid function based on the underlying true vector.
std::string name() const
Returns the name of the FEState (field)
Manages the lifetimes of FEState objects such that restarts are abstracted from physics modules.
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
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)
static void updateState(const FiniteElementState &state)
Updates the StateManager-owned grid function using the values from a given FiniteElementState.
static bool isRestart()
Returns true if data was loaded into a DataCollection.
static void updateDual(const FiniteElementDual &dual)
Updates the StateManager-owned grid function using the values from a given FiniteElementDual.
static void storeDual(FiniteElementDual &dual)
Store a pre-constructed finite element dual in the state manager.
static int cycle(std::string mesh_tag)
Get the current cycle (iteration number) from the underlying datacollection.
static double load(const int cycle_to_load, const std::string &mesh_tag)
Loads an existing DataCollection.
static double time(std::string mesh_tag)
Get the current simulation time from the underlying datacollection.
static FiniteElementState newState(FunctionSpace space, const std::string &state_name, const std::string &mesh_tag)
Factory method for creating a new FEState object.
static std::string collectionID(const mfem::ParMesh *pmesh)
Returns the datacollection ID for a given mesh.
static void reset()
Resets the underlying global datacollection object.
static FiniteElementDual newDual(FunctionSpace space, const std::string &dual_name, const std::string &mesh_tag)
Factory method for creating a new FEDual object.
static mfem::ParMesh & mesh(const std::string &mesh_tag)
Returns a non-owning reference to mesh held by StateManager.
static void storeState(FiniteElementState &state)
Store a pre-constructed finite element state in the state manager.
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.
static FiniteElementState & shapeDisplacement(const std::string &mesh_tag)
Get the shape displacement finite element state.
static mfem::ParMesh & setMesh(std::unique_ptr< mfem::ParMesh > pmesh, const std::string &mesh_tag)
Gives ownership of mesh to StateManager.
static FiniteElementDual & shapeDisplacementSensitivity(const std::string &mesh_tag)
Get the shape displacement sensitivity finite element dual.
This contains a class that represents the dual of a finite element vector space, i....
This file contains the declaration of structure that manages the MFEM objects that make up the state ...
This file contains the all the necessary functions and macros required for logging as well as a helpe...
Accelerator functionality.
constexpr int SHAPE_ORDER
Polynomial order used to discretize the shape displacement field.
constexpr H1< SHAPE_ORDER, 2 > SHAPE_DIM_2
Function space for shape displacement on dimension 2 meshes.
constexpr H1< SHAPE_ORDER, 3 > SHAPE_DIM_3
Function space for shape displacement on dimension 2 meshes.
dual(double, T) -> dual< T >
class template argument deduction guide for type dual.
This file contains the declaration of the structures that manage quadrature point data.
Dual number struct (value plus gradient)