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

Implementation of BasePhysics which uses FieldStates and gretl to track the computational graph, dynamically checkpoint, and back-propagate sensitivities. More...

#include <differentiable_physics.hpp>

Collaboration diagram for smith::DifferentiablePhysics:
Collaboration graph
[legend]

Public Member Functions

 DifferentiablePhysics (std::shared_ptr< Mesh > mesh, std::shared_ptr< gretl::DataStore > graph, const FieldState &shape_disp, const std::vector< FieldState > &states, const std::vector< FieldState > &params, std::shared_ptr< StateAdvancer > advancer, std::string physics_name, const std::vector< std::string > &reaction_names={})
 constructor
 
 ~DifferentiablePhysics ()
 destructor
 
void resetStates (int cycle=0, double time=0.0) override
 overload
 
virtual void resetAdjointStates () override
 overload
 
void completeSetup () override
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
std::vector< std::string > stateNames () const override
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
std::vector< std::string > parameterNames () const override
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
std::vector< std::string > dualNames () const override
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const FiniteElementStatestate (const std::string &state_name) const override
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const FiniteElementDualdual (const std::string &dual_name) const override
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const FiniteElementStateshapeDisplacement () const override
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const FiniteElementStateparameter (std::size_t parameter_index) const override
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const FiniteElementStateparameter (const std::string &parameter_name) const override
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
FiniteElementState loadCheckpointedState (const std::string &state_name, int cycle) override
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void setState (const std::string &state_name, const FiniteElementState &s) override
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void setShapeDisplacement (const FiniteElementState &s) override
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void setParameter (const size_t parameter_index, const FiniteElementState &parameter_state) override
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void setAdjointLoad (std::unordered_map< std::string, const smith::FiniteElementDual & > string_to_dual) override
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void setDualAdjointBcs (std::unordered_map< std::string, const smith::FiniteElementState & > string_to_bc) override
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const FiniteElementStateadjoint (const std::string &adjoint_name) const override
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
virtual void advanceTimestep (double dt) override
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void reverseAdjointTimestep () override
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
FiniteElementDual computeTimestepSensitivity (size_t parameter_index) override
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const FiniteElementDualcomputeTimestepShapeSensitivity () override
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const std::unordered_map< std::string, const smith::FiniteElementDual & > computeInitialConditionSensitivity () const override
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
std::vector< FieldStategetInitialFieldStates () const
 Get all the initial FieldStates.
 
std::vector< FieldStategetFieldStates () const
 Get all the current FieldStates.
 
std::vector< FieldStategetFieldParams () const
 Get all the parameter FieldStates.
 
std::vector< FieldStategetFieldStatesAndParamStates () const
 Get all the FieldStates... states first, parameters next.
 
FieldState getShapeDispFieldState () const
 Get the shape displacement FieldState.
 
std::vector< ReactionStategetReactionStates () const
 Get the current reactionStates.
 
std::shared_ptr< StateAdvancergetStateAdvancer () const
 Get state advancer.
 
- Public Member Functions inherited from smith::BasePhysics
 BasePhysics (std::string physics_name, std::shared_ptr< smith::Mesh > mesh, int cycle=0, double time=0.0, bool checkpoint_to_disk=false)
 Empty constructor. More...
 
 BasePhysics (BasePhysics &&other)=default
 Construct a new Base Physics object (copy constructor) More...
 
virtual double time () const
 Get the current forward-solution time. More...
 
virtual int cycle () const
 Get the current forward-solution cycle iteration number. More...
 
virtual double maxTime () const
 Get the maximum time reached by the forward solver. More...
 
virtual double minTime () const
 Get the initial time used by the forward solver. More...
 
virtual int maxCycle () const
 The maximum cycle (timestep iteration number) reached by the forward solver. More...
 
virtual int minCycle () const
 Get the initial cycle (timestep iteration number) used by the forward solver. More...
 
bool isQuasistatic () const
 Check if the physics is setup as quasistatic. More...
 
virtual const std::vector< double > & timesteps () const
 Get a vector of the timestep sizes (i.e. \(\Delta t\)s) taken by the forward solver. More...
 
virtual std::vector< std::string > adjointNames () const
 Get a vector of the finite element state adjoint solution names. More...
 
virtual const FiniteElementStatedualAdjoint (const std::string &dual_name) const
 Accessor for getting named finite element state dual adjoint (reaction adjoint load) from the physics modules. More...
 
virtual void outputStateToDisk (std::optional< std::string > paraview_output_dir={}) const
 Output the current state of the PDE fields in Sidre format and optionally in Paraview format if paraview_output_dir is given. More...
 
void loadCheckpointedStatesFromDisk (int cycle)
 load checkpointed states from disk into states array More...
 
virtual FiniteElementDual loadCheckpointedDual ([[maybe_unused]] const std::string &state_name, [[maybe_unused]] int cycle)
 Accessor for getting a single named finite element dual solution from the physics modules at a given checkpointed cycle index. More...
 
virtual double getCheckpointedTimestep (int cycle) const
 Get a timestep increment which has been previously checkpointed at the give cycle. More...
 
virtual void initializeSummary (axom::sidre::DataStore &datastore, const double t_final, const double dt) const
 Initializes the Sidre structure for simulation summary data. More...
 
virtual void saveSummary (axom::sidre::DataStore &datastore, const double t) const
 Saves the summary data to the Sidre Datastore. More...
 
virtual ~BasePhysics ()=default
 Destroy the Base Solver object.
 
const smith::Meshmesh () const
 Returns a reference to the mesh object.
 
const mfem::ParMesh & mfemParMesh () const
 Returns a reference to the mfem ParMesh object.
 
mfem::ParMesh & mfemParMesh ()
 Returns a reference to the mfem ParMesh object.
 
std::string name () const
 Return the name of the physics.
 

Additional Inherited Members

- Protected Member Functions inherited from smith::BasePhysics
const FiniteElementDualshapeDisplacementSensitivity () const
 Internally used accessor for getting the shape displacement sensitivity from the physics modules. More...
 
void CreateParaviewDataCollection () const
 Create a paraview data collection for the physics package if requested.
 
void UpdateParaviewDataCollection (const std::string &paraview_output_dir) const
 Update the paraview states, duals, parameters, and metadata (cycle, time) in preparation for output. More...
 
void initializeBasePhysicsStates (int cycle, double time)
 Protected, non-virtual method to reset physics states to zero. This does not reset design parameters or shape. More...
 
std::unordered_map< std::string, FiniteElementStategetCheckpointedStates (int cycle)
 Accessor for getting all of the primal solutions from the physics modules at a given checkpointed cycle index. More...
 
- Protected Attributes inherited from smith::BasePhysics
std::string name_ = {}
 Name of the physics module.
 
std::shared_ptr< smith::Meshmesh_
 The primary mesh.
 
MPI_Comm comm_
 The MPI communicator.
 
std::vector< const smith::FiniteElementState * > states_
 List of finite element primal states associated with this physics module.
 
std::vector< const smith::FiniteElementState * > adjoints_
 List of finite element adjoint states associated with this physics module.
 
std::vector< const smith::FiniteElementDual * > duals_
 List of finite element duals associated with this physics module.
 
std::vector< const smith::FiniteElementState * > dual_adjoints_
 List of adjoint finite element duals associated with this physics module.
 
std::vector< ParameterInfoparameters_
 A vector of the parameters associated with this physics module.
 
std::unordered_map< std::string, std::vector< smith::FiniteElementState > > checkpoint_states_
 A map containing optionally in-memory checkpointed primal states for transient adjoint solvers.
 
std::unordered_map< std::string, smith::FiniteElementStatecached_checkpoint_states_
 A container relating a checkpointed cycle and the associated finite element state fields. More...
 
std::optional< int > cached_checkpoint_cycle_
 An optional int for disk-based checkpointing containing the cycle number of the last retrieved checkpoint.
 
bool is_quasistatic_ = true
 Whether the simulation is time-independent.
 
double time_
 Current time for the forward pass.
 
double dt_
 Current time step.
 
double max_time_
 The maximum time reached for the forward solver.
 
double min_time_
 The time the forward solver was initialized to.
 
std::vector< double > timesteps_
 A vector of the timestep sizes (i.e. \(\Delta t\)) taken by the forward solver.
 
int cycle_
 Current cycle (forward pass time iteration count)
 
int max_cycle_
 The maximum cycle (forward pass iteration count) reached by the forward solver.
 
int min_cycle_
 The cycle the forward solver was initialized to.
 
double ode_time_point_
 The value of time at which the ODE solver wants to evaluate the residual.
 
int mpi_rank_
 MPI rank.
 
int mpi_size_
 MPI size.
 
std::unique_ptr< mfem::ParaViewDataCollection > paraview_dc_
 DataCollection pointer for optional paraview output.
 
std::unordered_map< std::string, std::unique_ptr< mfem::ParGridFunction > > paraview_dual_grid_functions_
 A optional map of the dual names and duals in grid function form for paraview output.
 
std::unique_ptr< mfem::ParGridFunction > shape_sensitivity_grid_function_
 A optional view of the shape sensitivity in grid function form for paraview output.
 
smith::FiniteElementState shape_displacement_
 The shape displacement field.
 
smith::FiniteElementDual shape_displacement_dual_
 The shape displacement field sensitivity.
 
BoundaryConditionManager bcs_
 Boundary condition manager instance.
 
bool checkpoint_to_disk_
 A flag denoting whether to save the state to disk or memory as needed for dynamic adjoint solves.
 
- Static Protected Attributes inherited from smith::BasePhysics
static constexpr int FLOAT_PRECISION_ = 8
 Number of significant figures to output for floating-point.
 

Detailed Description

Implementation of BasePhysics which uses FieldStates and gretl to track the computational graph, dynamically checkpoint, and back-propagate sensitivities.

Definition at line 33 of file differentiable_physics.hpp.


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