Smith  0.1
Smith is an implicit thermal structural mechanics simulation code.
solid_mechanics_with_internal_vars_system.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 
16 
17 namespace smith {
18 
19 namespace detail {
20 
21 template <typename MaterialType, typename AlphaType, typename AlphaDotType, typename DerivType, typename... ParamTypes>
23 auto evaluateCoupledInternalVariableMaterial(const MaterialType& material, const TimeInfo& t_info, AlphaType alpha,
24  AlphaDotType alpha_dot, DerivType deriv_u, ParamTypes&&... params)
25 {
26  if constexpr (requires { material(t_info, alpha, alpha_dot, deriv_u, std::forward<ParamTypes>(params)...); }) {
27  return material(t_info, alpha, alpha_dot, deriv_u, std::forward<ParamTypes>(params)...);
28  } else {
29  return material(alpha, alpha_dot, deriv_u, std::forward<ParamTypes>(params)...);
30  }
31 }
32 
33 template <typename MaterialType, typename StateType, typename GradUType, typename GradVType, typename AlphaType,
34  typename... ParamTypes>
36 auto evaluateSolidInternalVariableMaterial(const MaterialType& material, const TimeInfo& t_info, StateType& state,
37  const GradUType& grad_u, const GradVType& grad_v, AlphaType alpha,
38  ParamTypes&&... params)
39 {
40  return material(t_info, state, grad_u, grad_v, alpha, std::forward<ParamTypes>(params)...);
41 }
42 
43 template <typename MaterialType>
47  using State = typename MaterialType::State;
48 
49  MaterialType material;
50  double density;
51 
52  template <typename StateType, typename GradUType, typename GradVType, typename AlphaType, typename AlphaDotType,
53  typename... ParamTypes>
55  auto operator()(const TimeInfo& t_info, StateType& state, GradUType grad_u, GradVType grad_v, AlphaType alpha,
56  AlphaDotType /*alpha_dot*/, ParamTypes&&... params) const
57  {
58  return evaluateSolidInternalVariableMaterial(material, t_info, state, grad_u, grad_v, get<VALUE>(alpha),
59  std::forward<ParamTypes>(params)...);
60  }
61 };
62 
63 } // namespace detail
64 
78 template <int dim, int disp_order, typename DispRule, typename SolidCoupling, typename StateSpace, typename StateRule,
79  typename StateCoupling, typename MaterialType>
82  std::shared_ptr<InternalVariableSystem<dim, StateSpace, StateRule, StateCoupling>> /*internal_variables*/,
83  const MaterialType& material, const std::string& domain_name)
84 {
85  auto solid_material = detail::CoupledSolidInternalVariableMaterialAdapter<MaterialType>{material, material.density};
86 
87  solid->setMaterial(solid_material, domain_name);
88 }
89 
98 template <int dim, typename StateSpace, typename StateRule, typename StateCoupling, int disp_order, typename DispRule,
99  typename SolidCoupling, typename MaterialType>
101  std::shared_ptr<InternalVariableSystem<dim, StateSpace, StateRule, StateCoupling>> internal_variables,
103  const MaterialType& material, const std::string& domain_name)
104 {
105  internal_variables->addEvolution(
106  domain_name, [=](auto t_info, auto alpha, auto alpha_dot, auto u, auto /*v*/, auto /*a*/, auto... params) {
107  return detail::evaluateCoupledInternalVariableMaterial(material, t_info, alpha, alpha_dot, get<DERIVATIVE>(u),
108  params...);
109  });
110 }
111 
112 template <int dim, int disp_order, typename DispRule, typename SolidCoupling, typename StateSpace, typename StateRule,
113  typename StateCoupling, typename MaterialType>
124  const MaterialType& material, const std::string& domain_name)
125 {
126  setCoupledSolidMechanicsInternalVariableMaterial(solid, state, material, domain_name);
127 }
128 
129 } // namespace smith
auto evaluateCoupledInternalVariableMaterial(const MaterialType &material, const TimeInfo &t_info, AlphaType alpha, AlphaDotType alpha_dot, DerivType deriv_u, ParamTypes &&... params)
Dispatch internal-variable material calls with or without explicit TimeInfo.
auto evaluateSolidInternalVariableMaterial(const MaterialType &material, const TimeInfo &t_info, StateType &state, const GradUType &grad_u, const GradVType &grad_v, AlphaType alpha, ParamTypes &&... params)
Evaluate solid/internal-variable material using TimeInfo-aware signature.
Accelerator functionality.
Definition: smith.cpp:36
void setCoupledSolidMechanicsInternalVarsMaterial(std::shared_ptr< SolidMechanicsSystem< dim, disp_order, DispRule, SolidCoupling >> solid, std::shared_ptr< InternalVariableSystem< dim, StateSpace, StateRule, StateCoupling >> state, const MaterialType &material, const std::string &domain_name)
Backward-compatible alias for setCoupledSolidMechanicsInternalVariableMaterial.
requires(detail::has_time_rule_v< SelfFields >) auto buildSolidMechanicsSystem(std
Build a SolidMechanicsSystem from already-registered field packs.
void setCoupledInternalVariableMaterial(std::shared_ptr< InternalVariableSystem< dim, StateSpace, StateRule, StateCoupling >> internal_variables, std::shared_ptr< SolidMechanicsSystem< dim, disp_order, DispRule, SolidCoupling >>, const MaterialType &material, const std::string &domain_name)
Register an internal-variable evolution law using solid displacement coupling.
void setCoupledSolidMechanicsInternalVariableMaterial(std::shared_ptr< SolidMechanicsSystem< dim, disp_order, DispRule, SolidCoupling >> solid, std::shared_ptr< InternalVariableSystem< dim, StateSpace, StateRule, StateCoupling >>, const MaterialType &material, const std::string &domain_name)
Register a solid material integrand on a SolidMechanicsSystem that is coupled to an InternalVariableS...
Defines the SolidMechanicsSystem struct and its factory function.
Standalone composable system for a first-order internal variable (damage, plasticity,...
System for a single internal variable using a two-state first-order rule.
System struct for solid dynamics with configurable time integration.
struct storing time and timestep information
Definition: common.hpp:18
Adapts coupled internal-variable solids to solid-system material interface.
typename MaterialType::State State
Material state type forwarded to solid system.
auto operator()(const TimeInfo &t_info, StateType &state, GradUType grad_u, GradVType grad_v, AlphaType alpha, AlphaDotType, ParamTypes &&... params) const
Evaluate wrapped material with current internal-variable value.