15 #include "gretl/data_store.hpp"
27 class TimestepEstimator;
46 const FieldState& shape_disp,
const std::vector<FieldState>& states,
47 const std::vector<FieldState>& params, std::shared_ptr<StateAdvancer> advancer,
48 std::string physics_name,
const std::vector<ReactionInfo>& reaction_infos = {});
62 std::vector<std::string>
stateNames()
const override;
68 std::vector<std::string>
dualNames()
const override;
109 void setAdjointLoad(std::unordered_map<std::string, const smith::FiniteElementDual&> string_to_dual)
override;
112 void setDualAdjointBcs(std::unordered_map<std::string, const smith::FiniteElementState&> string_to_bc)
override;
165 void initializeReactionStates();
167 std::shared_ptr<gretl::DataStore> checkpointer_;
168 std::shared_ptr<StateAdvancer> advancer_;
170 std::vector<FieldState> initial_field_states_;
172 std::vector<FieldState> field_states_;
173 std::vector<FieldState> field_params_;
174 std::unique_ptr<FieldState>
175 field_shape_displacement_;
177 std::map<std::string, size_t> state_name_to_field_index_;
178 std::map<std::string, size_t> param_name_to_field_index_;
179 std::vector<std::string> state_names_;
180 std::vector<std::string> param_names_;
182 std::vector<ReactionInfo> reaction_infos_;
183 mutable std::vector<ReactionState> reaction_states_;
184 std::map<std::string, size_t> reaction_name_to_reaction_index_;
185 std::vector<std::string> reaction_names_;
187 std::vector<gretl::Int> milestones_;
The base interface class for a generic PDE solver.
This is the abstract base class for a generic forward solver.
virtual double time() const
Get the current forward-solution time.
const smith::Mesh & mesh() const
Returns a reference to the mesh object.
virtual int cycle() const
Get the current forward-solution cycle iteration number.
BasePhysics implementation that stores differentiable states in gretl for checkpointed reverse solves...
void resetStates(int cycle=0, double time=0.0) override
Base method to reset physics states to the initial time. This does not reset design parameters or sha...
FiniteElementDual loadCheckpointedDual(const std::string &state_name, int cycle) override
Accessor for getting a single named finite element dual solution from the physics modules at a given ...
void reverseAdjointTimestep() override
Reverse one recorded timestep through the gretl graph.
void completeSetup() override
Complete the setup and allocate the necessary data structures.
std::vector< FieldState > getFieldStates() const
Get the current primal state fields.
std::vector< std::string > parameterNames() const override
Get a vector of the finite element state parameter names.
std::vector< FieldState > getInitialFieldStates() const
Get the initial state fields captured before any timesteps were advanced.
void setShapeDisplacement(const FiniteElementState &shape_displacement) override
Set the current shape displacement for the underlying mesh.
std::vector< FieldState > getFieldParams() const
Get all the parameter FieldStates.
FieldState getShapeDispFieldState() const
Get the tracked shape displacement field.
const FiniteElementState & adjoint(const std::string &adjoint_name) const override
Accessor for getting named finite element state adjoint solution from the physics modules.
void setDualAdjointBcs(std::unordered_map< std::string, const smith::FiniteElementState & > string_to_bc) override
Set the dual loads (dirichlet values) for the adjoint reverse timestep solve This must be called afte...
std::vector< std::string > dualNames() const override
Get a vector of the finite element state dual (reaction) solution names.
FiniteElementDual computeTimestepSensitivity(size_t parameter_index) override
Compute the implicit sensitivity of the quantity of interest used in defining the adjoint load with r...
virtual void resetAdjointStates() override
Base method to reset physics states back to the end of time to start adjoint calculations again....
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 > ¶ms, std::shared_ptr< StateAdvancer > advancer, std::string physics_name, const std::vector< ReactionInfo > &reaction_infos={})
Construct a differentiable physics wrapper around a state advancer and its tracked fields.
void setAdjointLoad(std::unordered_map< std::string, const smith::FiniteElementDual & > string_to_dual) override
Set the loads for the adjoint reverse timestep solve.
const FiniteElementDual & computeTimestepShapeSensitivity() override
Compute the implicit sensitivity of the quantity of interest used in defining the adjoint load with r...
const FiniteElementState & parameter(std::size_t parameter_index) const override
Accessor for getting indexed finite element state parameter fields from the physics modules.
void setState(const std::string &state_name, const FiniteElementState &s) override
Set the primal solution field values of the underlying physics solver.
const FiniteElementState & shapeDisplacement() const override
Accessor for getting the shape displacement field from the physics modules.
~DifferentiablePhysics()
Destructor.
FiniteElementState loadCheckpointedState(const std::string &state_name, int cycle) override
Return a state for a stored checkpoint cycle.
std::vector< FieldState > getFieldStatesAndParamStates() const
Get the tracked state fields followed by the tracked parameter fields.
virtual void advanceTimestep(double dt) override
Advance the state variables according to the chosen time integrator.
const FiniteElementState & state(const std::string &state_name) const override
Accessor for getting named finite element state primal solution from the physics modules.
std::shared_ptr< StateAdvancer > getStateAdvancer() const
Get the state advancer used for forward solves.
std::vector< ReactionState > getReactionStates() const
Get the current differentiable reaction outputs.
std::vector< std::string > stateNames() const override
Get a vector of the finite element state primal solution names.
const FiniteElementDual & dual(const std::string &dual_name) const override
Accessor for getting named finite element state dual (reaction) solution from the physics modules.
const std::unordered_map< std::string, const smith::FiniteElementDual & > computeInitialConditionSensitivity() const override
Compute the implicit sensitivity of the quantity of interest with respect to the initial condition fi...
void setParameter(const size_t parameter_index, const FiniteElementState ¶meter_state) override
Deep copy a parameter field into the internally-owned parameter used for simulations.
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.
Accelerator functionality.
gretl::State< FEFieldPtr, FEDualPtr > FieldState
typedef
Defines the SystemBase struct for common system functionality.