Smith  0.1
Smith is an implicit thermal structural mechanics simulation code.
solid_mechanics_state_advancer.cpp
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 
13 
14 namespace smith {
15 
17  std::shared_ptr<smith::DifferentiableSolver> solver, std::shared_ptr<smith::DirichletBoundaryConditions> vector_bcs,
18  std::shared_ptr<SecondOrderTimeDiscretizedWeakForms> solid_dynamic_weak_forms,
20  : solver_(solver),
21  vector_bcs_(vector_bcs),
22  solid_dynamic_weak_forms_(solid_dynamic_weak_forms),
23  time_rule_(time_rule)
24 {
25 }
26 
27 std::vector<FieldState> SolidMechanicsStateAdvancer::advanceState(const TimeInfo& time_info,
28  const FieldState& shape_disp,
29  const std::vector<FieldState>& states_old_,
30  const std::vector<FieldState>& params) const
31 {
32  std::vector<FieldState> states_old = states_old_;
33  if (time_info.cycle() == 0) {
34  states_old[ACCELERATION] = solve(*solid_dynamic_weak_forms_->final_reaction_weak_form, shape_disp, states_old_,
35  params, time_info, *solver_, *vector_bcs_, ACCELERATION);
36  }
37 
38  std::vector<FieldState> solid_inputs{states_old[DISPLACEMENT], states_old[DISPLACEMENT], states_old[VELOCITY],
39  states_old[ACCELERATION]};
40 
41  auto displacement = solve(*solid_dynamic_weak_forms_->time_discretized_weak_form, shape_disp, solid_inputs, params,
42  time_info, *solver_, *vector_bcs_);
43 
44  std::vector<FieldState> states = states_old;
45 
46  states[DISPLACEMENT] = displacement;
47  states[VELOCITY] =
48  time_rule_.dot(time_info, displacement, states_old[DISPLACEMENT], states_old[VELOCITY], states_old[ACCELERATION]);
49  states[ACCELERATION] = time_rule_.ddot(time_info, displacement, states_old[DISPLACEMENT], states_old[VELOCITY],
50  states_old[ACCELERATION]);
51 
52  return states;
53 }
54 
55 std::vector<ReactionState> SolidMechanicsStateAdvancer::computeReactions(const TimeInfo& time_info,
56  const FieldState& shape_disp,
57  const std::vector<FieldState>& states,
58  const std::vector<FieldState>& params) const
59 {
60  std::vector<FieldState> solid_inputs{states[DISPLACEMENT], states[VELOCITY], states[ACCELERATION]};
61  solid_inputs.insert(solid_inputs.end(), params.begin(), params.end());
62  return {evaluateWeakForm(solid_dynamic_weak_forms_->final_reaction_weak_form, time_info, shape_disp, solid_inputs,
63  states[DISPLACEMENT])};
64 }
65 
66 } // namespace smith
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.
std::vector< FieldState > advanceState(const TimeInfo &time_info, const FieldState &shape_disp, const std::vector< FieldState > &states_old, const std::vector< FieldState > &params) 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 > &params) const override
This is an overloaded member function, provided for convenience. It differs from the above function o...
This file contains the declaration of the DifferentiableSolver interface.
Contains DirichletBoundaryConditions class for interaction with the differentiable solve interfaces.
Accelerator functionality.
Definition: smith.cpp:36
auto evaluateWeakForm(const std::shared_ptr< WeakForm > &weak_form, const TimeInfo &time_info, FieldState shape_disp, const std::vector< FieldState > &field_states, FieldState field_for_residual_space)
gretl-function implementation which evaluates the residual force (which is minus the mechanical force...
Definition: reaction.hpp:26
gretl::State< FEFieldPtr, FEDualPtr > FieldState
typedef
Definition: field_state.hpp:22
FieldState solve(const WeakForm &weak_form, const FieldState &shape_disp, const std::vector< FieldState > &states, const std::vector< FieldState > &params, const TimeInfo &time_info, const DifferentiableSolver &solver, const DirichletBoundaryConditions &bcs, size_t unknown_state_index)
Solve a nonlinear system of equations as defined by the weak form, assuming that the field indexed by...
Reaction class which is a names combination of a weak form and a set of dirichlet constrained nodes.
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)....
SMITH_HOST_DEVICE auto dot([[maybe_unused]] const TimeInfo &t, [[maybe_unused]] const T1 &field_new, [[maybe_unused]] const T2 &field_old, [[maybe_unused]] const T3 &velo_old, [[maybe_unused]] const T4 &accel_old) const
evaluate time derivative discretization of the ode state as used by the integration rule
SMITH_HOST_DEVICE auto ddot([[maybe_unused]] const TimeInfo &t, [[maybe_unused]] const T1 &field_new, [[maybe_unused]] const T2 &field_old, [[maybe_unused]] const T3 &velo_old, [[maybe_unused]] const T4 &accel_old) const
evaluate time derivative discretization of the ode state as used by the integration rule
struct storing time and timestep information
Definition: common.hpp:18
size_t cycle() const
accessor for cycle
Definition: common.hpp:32
Specifies parametrized residuals and various linearized evaluations for arbitrary nonlinear systems o...
Specifies interface for evaluating weak form residuals and their gradients.