Smith  0.1
Smith is an implicit thermal structural mechanics simulation code.
green_saint_venant_thermoelastic.hpp
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 
7 #pragma once
8 
11 
13 
17 template <typename T, int dim>
18 auto greenStrain(const tensor<T, dim, dim>& grad_u)
19 {
20  return 0.5 * (grad_u + transpose(grad_u) + dot(transpose(grad_u), grad_u));
21 }
22 
25  double density;
26  double E;
27  double nu;
28  double C_v;
29  double alpha;
30  double theta_ref;
31  double kappa;
32 
34  struct State {
35  double strain_trace;
36  };
37 
56  template <typename T1, typename T2, typename T3, int dim>
57  auto operator()(State& state, const tensor<T1, dim, dim>& grad_u, T2 theta, const tensor<T3, dim>& grad_theta) const
58  {
59  const double K = E / (3.0 * (1.0 - 2.0 * nu));
60  const double G = 0.5 * E / (1.0 + nu);
61  static constexpr auto I = Identity<dim>();
62  auto F = grad_u + I;
63  const auto Eg = greenStrain(grad_u);
64  const auto trEg = tr(Eg);
65 
66  // stress
67  const auto S = 2.0 * G * dev(Eg) + K * (trEg - 3.0 * alpha * (theta - theta_ref)) * I;
68  const auto Piola = dot(F, S);
69 
70  // internal heat source
71  const auto s0 = -3.0 * K * alpha * theta * (trEg - state.strain_trace);
72 
73  // heat flux
74  const auto q0 = -kappa * grad_theta;
75 
76  state.strain_trace = get_value(trEg);
77 
78  return smith::tuple{Piola, C_v, s0, q0};
79  }
80 
86  template <typename T1, typename T2, int dim>
87  auto calculateFreeEnergy(const tensor<T1, dim, dim>& grad_u, T2 theta) const
88  {
89  const double K = E / (3.0 * (1.0 - 2.0 * nu));
90  const double G = 0.5 * E / (1.0 + nu);
91  auto strain = greenStrain(grad_u);
92  auto trE = tr(strain);
93  auto psi_1 = G * squared_norm(dev(strain)) + 0.5 * K * trE * trE;
94  using std::log;
95  auto logT = log(theta / theta_ref);
96  auto psi_2 = C_v * (theta - theta_ref - theta * logT);
97  auto psi_3 = -3.0 * K * alpha * (theta - theta_ref) * trE;
98  return psi_1 + psi_2 + psi_3;
99  }
100 };
101 
104  double density;
105  double E;
106  double nu;
107  double C_v;
108  double alpha0;
109  double theta_ref;
110  double kappa;
111 
113  struct State {
114  double strain_trace;
115  };
116 
137  template <typename T1, typename T2, typename T3, typename T4, int dim>
138  auto operator()(State& state, const tensor<T1, dim, dim>& grad_u, T2 theta, const tensor<T3, dim>& grad_theta,
139  T4 thermal_expansion_scaling) const
140  {
141  auto [scale, unused] = thermal_expansion_scaling;
142  const double K = E / (3.0 * (1.0 - 2.0 * nu));
143  const double G = 0.5 * E / (1.0 + nu);
144  static constexpr auto I = Identity<dim>();
145  auto F = grad_u + I;
146  const auto Eg = greenStrain(grad_u);
147  const auto trEg = tr(Eg);
148  auto alpha = alpha0 * scale;
149 
150  // stress
151  const auto S = 2.0 * G * dev(Eg) + K * (trEg - 3.0 * alpha * (theta - theta_ref)) * I;
152  const auto Piola = dot(F, S);
153 
154  // internal heat source
155  const auto s0 = -3.0 * K * alpha * theta * (trEg - state.strain_trace);
156 
157  // heat flux
158  const auto q0 = -kappa * grad_theta;
159 
160  state.strain_trace = get_value(trEg);
161 
162  return smith::tuple{Piola, C_v, s0, q0};
163  }
164 
171  template <typename T1, typename T2, typename T3, int dim>
172  auto calculateFreeEnergy(const tensor<T1, dim, dim>& grad_u, T2 theta, T3 thermal_expansion_scaling) const
173  {
174  auto [scale, unused] = thermal_expansion_scaling;
175  const double K = E / (3.0 * (1.0 - 2.0 * nu));
176  const double G = 0.5 * E / (1.0 + nu);
177  auto strain = greenStrain(grad_u);
178  auto trE = tr(strain);
179  const double alpha = alpha0 * scale;
180  auto psi_1 = G * squared_norm(dev(strain)) + 0.5 * K * trE * trE;
181  using std::log;
182  auto logT = log(theta / theta_ref);
183  auto psi_2 = C_v * (theta - theta_ref - theta * logT);
184  auto psi_3 = -3.0 * K * alpha * (theta - theta_ref) * trE;
185  return psi_1 + psi_2 + psi_3;
186  }
187 };
188 
189 } // namespace smith::thermomechanics
Thermomechanics helper data types.
auto greenStrain(const tensor< T, dim, dim > &grad_u)
Compute Green's strain from the displacement gradient.
SMITH_HOST_DEVICE auto log(dual< gradient_type > a)
implementation of the natural logarithm function for dual numbers
Definition: dual.hpp:389
constexpr SMITH_HOST_DEVICE auto squared_norm(const isotropic_tensor< T, m, m > &I)
compute the squared Frobenius norm (tr(dot(transpose(I), I))) of an isotropic tensor
constexpr SMITH_HOST_DEVICE auto transpose(const isotropic_tensor< T, m, m > &I)
return the transpose of an isotropic tensor
constexpr SMITH_HOST_DEVICE auto dev(const tensor< T, n, n > &A)
Calculates the deviator of a matrix (rank-2 tensor)
Definition: tensor.hpp:1193
constexpr SMITH_HOST_DEVICE auto get_value(const T &arg)
return the "value" part from a given type. For non-dual types, this is just the identity function
Definition: dual.hpp:445
constexpr SMITH_HOST_DEVICE auto tr(const isotropic_tensor< T, m, m > &I)
calculate the trace of an isotropic tensor
constexpr SMITH_HOST_DEVICE auto dot(const isotropic_tensor< S, m, m > &I, const tensor< T, m, n... > &A)
dot product between an isotropic and (nonisotropic) tensor
Arbitrary-rank tensor class.
Definition: tensor.hpp:28
auto calculateFreeEnergy(const tensor< T1, dim, dim > &grad_u, T2 theta) const
evaluate free energy density
auto operator()(State &state, const tensor< T1, dim, dim > &grad_u, T2 theta, const tensor< T3, dim > &grad_theta) const
Evaluate constitutive variables for thermomechanics.
auto operator()(State &state, const tensor< T1, dim, dim > &grad_u, T2 theta, const tensor< T3, dim > &grad_theta, T4 thermal_expansion_scaling) const
Evaluate constitutive variables for thermomechanics.
auto calculateFreeEnergy(const tensor< T1, dim, dim > &grad_u, T2 theta, T3 thermal_expansion_scaling) const
evaluate free energy density
This is a class that mimics most of std::tuple's interface, except that it is usable in CUDA kernels ...
Definition: tuple.hpp:28
Implementation of the tensor class used by Functional.
Implements a std::tuple-like object that works in CUDA kernels.