Smith  0.1
Smith is an implicit thermal structural mechanics simulation code.
thermal_material.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 
13 #pragma once
14 
16 
17 namespace smith::heat_transfer {
18 
28  LinearIsotropicConductor(double density = 1.0, double specific_heat_capacity = 1.0, double conductivity = 1.0)
29  : density_(density), specific_heat_capacity_(specific_heat_capacity), conductivity_(conductivity)
30  {
31  SLIC_ERROR_ROOT_IF(conductivity_ < 0.0,
32  "Conductivity must be positive in the linear isotropic conductor material model.");
33 
34  SLIC_ERROR_ROOT_IF(density_ < 0.0, "Density must be positive in the linear isotropic conductor material model.");
35 
36  SLIC_ERROR_ROOT_IF(specific_heat_capacity_ < 0.0,
37  "Specific heat capacity must be positive in the linear isotropic conductor material model.");
38  }
39 
50  template <typename T1, typename T2, typename T3>
51  SMITH_HOST_DEVICE auto operator()(const T1& /* x */, const T2& /* temperature */,
52  const T3& temperature_gradient) const
53  {
54  return smith::tuple{density_ * specific_heat_capacity_, -1.0 * conductivity_ * temperature_gradient};
55  }
56 
57  private:
59  double density_;
60 
62  double specific_heat_capacity_;
63 
65  double conductivity_;
66 };
67 
78  IsotropicConductorWithLinearConductivityVsTemperature(double density = 1.0, double specific_heat_capacity = 1.0,
79  double reference_conductivity = 1.0,
80  double d_conductivity_d_temperature = 0.0)
81  : density_(density),
82  specific_heat_capacity_(specific_heat_capacity),
83  reference_conductivity_(reference_conductivity),
84  d_conductivity_d_temperature_(d_conductivity_d_temperature)
85  {
86  SLIC_ERROR_ROOT_IF(density_ < 0.0, "Density must be positive in the linear isotropic conductor material model.");
87  SLIC_ERROR_ROOT_IF(specific_heat_capacity_ < 0.0,
88  "Specific heat capacity must be positive in the linear isotropic conductor material model.");
89  }
90 
101  template <typename T1, typename T2, typename T3>
102  SMITH_HOST_DEVICE auto operator()(const T1& /* x */, const T2& temperature, const T3& temperature_gradient) const
103  {
104  const auto currentConductivity = reference_conductivity_ + d_conductivity_d_temperature_ * temperature;
105 #if defined(SMITH_USE_CUDA) || defined(SMITH_USE_HIP)
106  assert(smith::get_value(currentConductivity) >= 0.0);
107 #else
108  SLIC_ERROR_ROOT_IF(
109  smith::get_value(currentConductivity) < 0.0,
110  "Conductivity in the IsotropicConductorWithLinearConductivityVsTemperature model has gone negative.");
111 #endif
112  return smith::tuple{density_ * specific_heat_capacity_, -1.0 * currentConductivity * temperature_gradient};
113  }
114 
115  private:
117  double density_;
118 
120  double specific_heat_capacity_;
121 
123  double reference_conductivity_;
124 
126  double d_conductivity_d_temperature_;
127 };
128 
134 template <int dim>
143  LinearConductor(double density = 1.0, double specific_heat_capacity = 1.0,
144  tensor<double, dim, dim> conductivity = Identity<dim>())
145  : density_(density), specific_heat_capacity_(specific_heat_capacity), conductivity_(conductivity)
146  {
147  SLIC_ERROR_ROOT_IF(density_ < 0.0, "Density must be positive in the linear conductor material model.");
148 
149  SLIC_ERROR_ROOT_IF(specific_heat_capacity_ < 0.0,
150  "Specific heat capacity must be positive in the linear conductor material model.");
151 
152  SLIC_ERROR_ROOT_IF(!is_symmetric_and_positive_definite(conductivity_),
153  "Conductivity tensor must be symmetric and positive definite.");
154  }
155 
166  template <typename T1, typename T2, typename T3>
167  SMITH_HOST_DEVICE auto operator()(const T1& /* x */, const T2& /* temperature */,
168  const T3& temperature_gradient) const
169  {
170  return smith::tuple{density_ * specific_heat_capacity_, -1.0 * conductivity_ * temperature_gradient};
171  }
172 
173  private:
175  double density_;
176 
178  double specific_heat_capacity_;
179 
181  tensor<double, dim, dim> conductivity_;
182 };
183 
187  double source_ = 0.0;
188 
198  template <typename T1, typename T2, typename T3>
199  SMITH_HOST_DEVICE auto operator()(const T1& /* x */, const double /* time */, const T2& /* temperature */,
200  const T3& /* temperature_gradient */) const
201  {
202  return source_;
203  }
204 };
205 
207 struct ConstantFlux {
209  double flux_ = 0.0;
210 
220  template <typename T1, typename T2, typename T3>
221  SMITH_HOST_DEVICE auto operator()(const T1& /* x */, const T2& /* normal */, const double /* time */,
222  const T3& /* temperature */) const
223  {
224  return flux_;
225  }
226 };
227 
228 } // namespace smith::heat_transfer
#define SMITH_HOST_DEVICE
Macro that evaluates to __host__ __device__ when compiling with nvcc or amdclang and does nothing on ...
Definition: accelerator.hpp:37
Implementation of the quadrature-function-based functional enabling rapid development of FEM formulat...
HeatTransfer helper structs.
SMITH_HOST_DEVICE bool is_symmetric_and_positive_definite(tensor< double, 2, 2 > A)
Return whether a matrix is symmetric and positive definite This check uses Sylvester's criterion,...
Definition: tensor.hpp:1512
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
Constant thermal flux boundary model.
SMITH_HOST_DEVICE auto operator()(const T1 &, const T2 &, const double, const T3 &) const
Evaluation function for the thermal flux on a boundary.
double flux_
The constant flux applied to the boundary.
Constant thermal source model.
double source_
The constant source.
SMITH_HOST_DEVICE auto operator()(const T1 &, const double, const T2 &, const T3 &) const
Evaluation function for the constant thermal source model.
SMITH_HOST_DEVICE auto operator()(const T1 &, const T2 &temperature, const T3 &temperature_gradient) const
Material response call for a linear isotropic material with linear conductivity vs temperature.
IsotropicConductorWithLinearConductivityVsTemperature(double density=1.0, double specific_heat_capacity=1.0, double reference_conductivity=1.0, double d_conductivity_d_temperature=0.0)
Construct a Isotropic Conductor with Conductivity linear with Temparture object.
Linear anisotropic thermal material model.
LinearConductor(double density=1.0, double specific_heat_capacity=1.0, tensor< double, dim, dim > conductivity=Identity< dim >())
Construct a new Linear Isotropic Conductor object.
SMITH_HOST_DEVICE auto operator()(const T1 &, const T2 &, const T3 &temperature_gradient) const
Material response call for a linear anisotropic material.
Linear isotropic heat transfer material model.
LinearIsotropicConductor(double density=1.0, double specific_heat_capacity=1.0, double conductivity=1.0)
Construct a new Linear Isotropic Conductor object.
SMITH_HOST_DEVICE auto operator()(const T1 &, const T2 &, const T3 &temperature_gradient) const
Material response call for a linear isotropic material.
This is a class that mimics most of std::tuple's interface, except that it is usable in CUDA kernels ...
Definition: tuple.hpp:28