Smith  0.1
Smith is an implicit thermal structural mechanics simulation code.
parameterized_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 
18 namespace smith::heat_transfer {
19 
22  public:
31  ParameterizedLinearIsotropicConductor(double density = 1.0, double specific_heat_capacity = 1.0,
32  double conductivity_offset = 0.0)
33  : density_(density), specific_heat_capacity_(specific_heat_capacity), conductivity_offset_(conductivity_offset)
34  {
35  SLIC_ERROR_ROOT_IF(conductivity_offset_ < 0.0,
36  "Conductivity must be positive in the linear isotropic conductor material model.");
37 
38  SLIC_ERROR_ROOT_IF(density_ < 0.0, "Density must be positive in the linear isotropic conductor material model.");
39 
40  SLIC_ERROR_ROOT_IF(specific_heat_capacity_ < 0.0,
41  "Specific heat capacity must be positive in the linear isotropic conductor material model.");
42  }
43 
57  template <typename T1, typename T2, typename T3, typename T4>
58  SMITH_HOST_DEVICE auto operator()(const T1& /* x */, const T2& /* temperature */, const T3& temperature_gradient,
59  const T4& parameter) const
60  {
61  return smith::tuple{density_ * specific_heat_capacity_,
62  -1.0 * (conductivity_offset_ + get<0>(parameter)) * temperature_gradient};
63  }
64 
70  static constexpr int numParameters() { return 1; }
71 
72  private:
74  double density_;
75 
77  double specific_heat_capacity_;
78 
80  double conductivity_offset_;
81 };
82 
95  double specific_heat_capacity = 1.0,
96  double conductivity_offset = 1.0,
97  double d_conductivity_d_temperature = 0.0)
98  : density_(density),
99  specific_heat_capacity_(specific_heat_capacity),
100  conductivity_offset_(conductivity_offset),
101  d_conductivity_d_temperature_(d_conductivity_d_temperature)
102  {
103  SLIC_ERROR_ROOT_IF(density_ < 0.0, "Density must be positive in the linear isotropic conductor material model.");
104 
105  SLIC_ERROR_ROOT_IF(specific_heat_capacity_ < 0.0,
106  "Specific heat capacity must be positive in the linear isotropic conductor material model.");
107  }
108 
122  template <typename T1, typename T2, typename T3, typename T4>
123  SMITH_HOST_DEVICE auto operator()(const T1& /* x */, const T2& temperature, const T3& temperature_gradient,
124  const T4& parameter) const
125  {
126  const auto currentConductivity =
127  conductivity_offset_ + get<0>(parameter) + d_conductivity_d_temperature_ * temperature;
128 #if defined(SMITH_USE_CUDA) || defined(SMITH_USE_HIP)
129  assert(smith::get_value(currentConductivity) >= 0.0);
130 #else
131  SLIC_ERROR_ROOT_IF(
132  smith::get_value(currentConductivity) < 0.0,
133  "Conductivity in the IsotropicConductorWithLinearConductivityVsTemperature model has gone negative.");
134 #endif
135  return smith::tuple{density_ * specific_heat_capacity_, -1.0 * currentConductivity * temperature_gradient};
136  }
137 
143  static constexpr int numParameters() { return 1; }
144 
145  private:
147  double density_;
148 
150  double specific_heat_capacity_;
151 
153  double conductivity_offset_;
154 
156  double d_conductivity_d_temperature_;
157 };
158 
162  double source_offset_ = 0.0;
163 
174  template <typename T1, typename T2, typename T3, typename T4>
175  SMITH_HOST_DEVICE auto operator()(const T1& /* x */, const double /* time */, const T2& /* temperature */,
176  const T3& /* temperature_gradient */, const T4& parameter) const
177  {
178  return source_offset_ + parameter;
179  }
180 
186  static constexpr int numParameters() { return 1; }
187 };
188 
192  double flux_offset_ = 0.0;
193 
204  template <typename T1, typename T2, typename T3, typename T4>
205  SMITH_HOST_DEVICE auto operator()(const T1& /* x */, const T2& /* normal */, const double /* time */,
206  const T3& /* temperature */, const T4& parameter) const
207  {
208  return flux_offset_ + parameter;
209  }
210 
216  static constexpr int numParameters() { return 1; }
217 };
218 
219 } // 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
Linear isotropic conductor with a parameterized conductivity.
ParameterizedLinearIsotropicConductor(double density=1.0, double specific_heat_capacity=1.0, double conductivity_offset=0.0)
Construct a new Parameterized Linear Isotropic Conductor object.
SMITH_HOST_DEVICE auto operator()(const T1 &, const T2 &, const T3 &temperature_gradient, const T4 &parameter) const
Thermal material response operator.
static constexpr int numParameters()
The number of parameters in the model.
HeatTransfer helper structs.
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
static constexpr int numParameters()
The number of parameters in the model.
SMITH_HOST_DEVICE auto operator()(const T1 &, const T2 &, const double, const T3 &, const T4 &parameter) const
Evaluation function for the thermal flux on a boundary.
double flux_offset_
The constant flux applied to the boundary.
SMITH_HOST_DEVICE auto operator()(const T1 &, const T2 &temperature, const T3 &temperature_gradient, const T4 &parameter) const
Material response call for a linear isotropic material with linear conductivity vs temperature.
ParameterizedIsotropicConductorWithLinearConductivityVsTemperature(double density=1.0, double specific_heat_capacity=1.0, double conductivity_offset=1.0, double d_conductivity_d_temperature=0.0)
Construct a Parameterized Isotropic Conductor with Conductivity linear with Temparture object.
static constexpr int numParameters()
The number of parameters in the model.
SMITH_HOST_DEVICE auto operator()(const T1 &, const double, const T2 &, const T3 &, const T4 &parameter) const
Evaluation function for the constant thermal source model.
This is a class that mimics most of std::tuple's interface, except that it is usable in CUDA kernels ...
Definition: tuple.hpp:28
The material and load types for the thermal functional physics module.