Smith  0.1
Smith is an implicit thermal structural mechanics simulation code.
differentiable_solid_mechanics.hpp
Go to the documentation of this file.
1 // Copyright (c) Lawrence Livermore National Security, LLC and
2 // other smith Project Developers. See the top-level LICENSE file for
3 // details.
4 //
5 // SPDX-License-Identifier: (BSD-3-Clause)
6 
12 #pragma once
13 
14 #include <memory>
18 #include "gretl/strumm_walther_checkpoint_strategy.hpp"
19 
20 namespace smith {
21 
36 template <int dim, typename ShapeDispSpace, typename VectorSpace, typename... ParamSpaces>
37 auto buildSolidMechanics(std::shared_ptr<smith::Mesh> mesh,
38  std::shared_ptr<DifferentiableSolver> d_solid_nonlinear_solver,
39  smith::ImplicitNewmarkSecondOrderTimeIntegrationRule time_rule, size_t num_checkpoints,
40  std::string physics_name, const std::vector<std::string>& param_names = {})
41 {
42  auto graph =
43  std::make_shared<gretl::DataStore>(std::make_unique<gretl::StrummWaltherCheckpointStrategy>(num_checkpoints));
44  auto [shape_disp, states, params, time, solid_mechanics_weak_form] =
45  SolidMechanicsStateAdvancer::buildWeakFormAndStates<dim, ShapeDispSpace, VectorSpace, ParamSpaces...>(
46  mesh, graph, time_rule, physics_name, param_names);
47 
48  auto vector_bcs = std::make_shared<DirichletBoundaryConditions>(
49  mesh->mfemParMesh(), space(states[SolidMechanicsStateAdvancer::DISPLACEMENT]));
50 
51  auto state_advancer = std::make_shared<SolidMechanicsStateAdvancer>(d_solid_nonlinear_solver, vector_bcs,
52  solid_mechanics_weak_form, time_rule);
53 
54  auto physics = std::make_shared<DifferentiablePhysics>(mesh, graph, shape_disp, states, params, state_advancer,
55  physics_name, std::vector<std::string>{"reactions"});
56 
57  return std::make_tuple(physics, solid_mechanics_weak_form, vector_bcs);
58 }
59 
60 } // namespace smith
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 > &param_names, double initial_time=0.0)
Utility function to consistently construct all the weak forms and FieldStates for a solid mechanics a...
Implementation of BasePhysics which uses FieldStates and gretl to track the computational graph,...
Accelerator functionality.
Definition: smith.cpp:36
auto buildSolidMechanics(std::shared_ptr< smith::Mesh > mesh, std::shared_ptr< DifferentiableSolver > d_solid_nonlinear_solver, smith::ImplicitNewmarkSecondOrderTimeIntegrationRule time_rule, size_t num_checkpoints, std::string physics_name, const std::vector< std::string > &param_names={})
Helper function to generate the base-physics for solid mechanics.
SMITH_HOST_DEVICE tuple< T... > make_tuple(const T &... args)
helper function for combining a list of values into a tuple
Definition: tuple.hpp:266
mfem::ParFiniteElementSpace & space(FieldState field)
Get the space from the primal field of a field states.
Specifies parameterized residuals and various linearized evaluations for arbitrary nonlinear systems ...
encodes rules for time discretizing second order odes (involving first and second time derivatives)....
Specifies parametrized residuals and various linearized evaluations for arbitrary nonlinear systems o...