17 #include "gretl/data_store.hpp"
18 #include "smith/smith_config.hpp"
28 class DifferentiableSolver;
29 class DirichletBoundaryConditions;
30 class SecondOrderTimeDiscretizedWeakForms;
41 std::shared_ptr<DirichletBoundaryConditions> vector_bcs,
42 std::shared_ptr<SecondOrderTimeDiscretizedWeakForms> solid_dynamic_weak_forms,
55 template <
typename FirstParamSpace,
typename... ParamSpaces>
56 static std::vector<FieldState>
createParams(gretl::DataStore& graph,
const std::string& name,
57 const std::vector<std::string>& param_names,
const std::string& tag,
61 std::vector<FieldState> end_spaces{};
62 if constexpr (
sizeof...(ParamSpaces) > 0) {
63 end_spaces =
createParams<ParamSpaces...>(graph, name, param_names, tag, ++index);
65 end_spaces.insert(end_spaces.begin(), newParam);
71 template <
int spatial_dim,
typename ShapeDispSpace,
typename VectorSpace,
typename... ParamSpaces>
72 static auto buildWeakFormAndStates(
const std::shared_ptr<Mesh>& mesh,
const std::shared_ptr<gretl::DataStore>& graph,
74 const std::vector<std::string>& param_names,
double initial_time = 0.0)
76 auto shape_disp =
createFieldState(*graph, ShapeDispSpace{}, physics_name +
"_shape_displacement", mesh->tag());
77 auto disp =
createFieldState(*graph, VectorSpace{}, physics_name +
"_displacement", mesh->tag());
78 auto velo =
createFieldState(*graph, VectorSpace{}, physics_name +
"_velocity", mesh->tag());
79 auto acceleration =
createFieldState(*graph, VectorSpace{}, physics_name +
"_acceleration", mesh->tag());
80 auto time = graph->create_state<double,
double>(initial_time);
81 std::vector<FieldState> params =
82 createParams<ParamSpaces...>(*graph, physics_name +
"_param", param_names, mesh->tag());
83 std::vector<FieldState> states{disp, velo, acceleration};
87 spatial_dim, VectorSpace,
Parameters<VectorSpace, VectorSpace, VectorSpace, VectorSpace, ParamSpaces...>>;
88 auto input_spaces =
spaces({states[DISPLACEMENT], states[DISPLACEMENT], states[VELOCITY], states[ACCELERATION]});
89 auto param_spaces =
spaces(params);
90 input_spaces.insert(input_spaces.end(), param_spaces.begin(), param_spaces.end());
92 auto solid_mechanics_weak_form =
93 std::make_shared<SolidWeakFormT>(physics_name, mesh, time_rule,
space(states[DISPLACEMENT]), input_spaces);
95 return std::make_tuple(shape_disp, states, params, time, solid_mechanics_weak_form);
100 const std::vector<FieldState>& states_old,
101 const std::vector<FieldState>& params)
const override;
105 const std::vector<FieldState>& states,
106 const std::vector<FieldState>& params)
const override;
109 std::shared_ptr<DifferentiableSolver> solver_;
110 std::shared_ptr<DirichletBoundaryConditions> vector_bcs_;
111 std::shared_ptr<SecondOrderTimeDiscretizedWeakForms>
112 solid_dynamic_weak_forms_;
Implementation of the StateAdvancer interface for advancing the solution of solid mechanics problems.
STATE
State enum for indexing convenience.
SolidMechanicsStateAdvancer(std::shared_ptr< DifferentiableSolver > solid_solver, std::shared_ptr< DirichletBoundaryConditions > vector_bcs, std::shared_ptr< SecondOrderTimeDiscretizedWeakForms > solid_dynamic_weak_forms, ImplicitNewmarkSecondOrderTimeIntegrationRule time_rule)
Constructor.
static auto buildWeakFormAndStates(const std::shared_ptr< Mesh > &mesh, const std::shared_ptr< gretl::DataStore > &graph, ImplicitNewmarkSecondOrderTimeIntegrationRule time_rule, std::string physics_name, const std::vector< std::string > ¶m_names, double initial_time=0.0)
Utility function to consistently construct all the weak forms and FieldStates for a solid mechanics a...
static std::vector< FieldState > createParams(gretl::DataStore &graph, const std::string &name, const std::vector< std::string > ¶m_names, const std::string &tag, size_t index=0)
Recursive function for constructing parameter FieldStates of the appropriate space and name,...
std::vector< FieldState > advanceState(const TimeInfo &time_info, const FieldState &shape_disp, const std::vector< FieldState > &states_old, const std::vector< FieldState > ¶ms) const override
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::vector< ReactionState > computeReactions(const TimeInfo &time_info, const FieldState &shape_disp, const std::vector< FieldState > &states, const std::vector< FieldState > ¶ms) const override
This is an overloaded member function, provided for convenience. It differs from the above function o...
Base state advancer class, allows specification for quasi-static solve strategies,...
Smith mesh class which assists in constructing the appropriate parallel mfem meshes and registering a...
Accelerator functionality.
std::vector< const mfem::ParFiniteElementSpace * > spaces(const std::vector< FieldState > &states, const std::vector< FieldState > ¶ms={})
Get the spaces from the primal fields of a vector of field states.
gretl::State< FEFieldPtr, FEDualPtr > FieldState
typedef
FieldState createFieldState(gretl::DataStore &dataStore, const smith::FEFieldPtr &s)
initialize on the gretl::DataStore a FieldState with values from s
SMITH_HOST_DEVICE tuple< T... > make_tuple(const T &... args)
helper function for combining a list of values into a tuple
mfem::ParFiniteElementSpace & space(FieldState field)
Get the space from the primal field of a field states.
Methods for solving systems of equations as given by WeakForms. Tracks these operations on the gretl ...
Interface and implementations for advancing from one step to the next. Typically these are time integ...
encodes rules for time discretizing second order odes (involving first and second time derivatives)....
a struct that is used in the physics modules to clarify which template arguments are user-controlled ...
struct storing time and timestep information
Provides templated implementations for discretizing values, velocities and accelerations from current...