Serac  0.1
Serac is an implicit thermal strucural mechanics simulation code.
thermal_material.hpp
Go to the documentation of this file.
1 // Copyright (c) 2019-2024, Lawrence Livermore National Security, LLC and
2 // other Serac 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 serac::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  SERAC_HOST_DEVICE auto operator()(const T1& /* x */, const T2& /* temperature */,
52  const T3& temperature_gradient) const
53  {
54  return serac::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  SERAC_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  SLIC_ERROR_ROOT_IF(
106  serac::get_value(currentConductivity) < 0.0,
107  "Conductivity in the IsotropicConductorWithLinearConductivityVsTemperature model has gone negative.");
108  return serac::tuple{density_ * specific_heat_capacity_, -1.0 * currentConductivity * temperature_gradient};
109  }
110 
111 private:
113  double density_;
114 
116  double specific_heat_capacity_;
117 
119  double reference_conductivity_;
120 
122  double d_conductivity_d_temperature_;
123 };
124 
130 template <int dim>
139  LinearConductor(double density = 1.0, double specific_heat_capacity = 1.0,
140  tensor<double, dim, dim> conductivity = Identity<dim>())
141  : density_(density), specific_heat_capacity_(specific_heat_capacity), conductivity_(conductivity)
142  {
143  SLIC_ERROR_ROOT_IF(density_ < 0.0, "Density must be positive in the linear conductor material model.");
144 
145  SLIC_ERROR_ROOT_IF(specific_heat_capacity_ < 0.0,
146  "Specific heat capacity must be positive in the linear conductor material model.");
147 
148  SLIC_ERROR_ROOT_IF(!is_symmetric_and_positive_definite(conductivity_),
149  "Conductivity tensor must be symmetric and positive definite.");
150  }
151 
162  template <typename T1, typename T2, typename T3>
163  SERAC_HOST_DEVICE auto operator()(const T1& /* x */, const T2& /* temperature */,
164  const T3& temperature_gradient) const
165  {
166  return serac::tuple{density_ * specific_heat_capacity_, -1.0 * conductivity_ * temperature_gradient};
167  }
168 
169 private:
171  double density_;
172 
174  double specific_heat_capacity_;
175 
177  tensor<double, dim, dim> conductivity_;
178 };
179 
183  double source_ = 0.0;
184 
194  template <typename T1, typename T2, typename T3>
195  SERAC_HOST_DEVICE auto operator()(const T1& /* x */, const double /* time */, const T2& /* temperature */,
196  const T3& /* temperature_gradient */) const
197  {
198  return source_;
199  }
200 };
201 
203 struct ConstantFlux {
205  double flux_ = 0.0;
206 
216  template <typename T1, typename T2, typename T3>
217  SERAC_HOST_DEVICE auto operator()(const T1& /* x */, const T2& /* normal */, const double /* time */,
218  const T3& /* temperature */) const
219  {
220  return flux_;
221  }
222 };
223 
224 } // namespace serac::heat_transfer
#define SERAC_HOST_DEVICE
Macro that evaluates to __host__ __device__ when compiling with nvcc and does nothing on a host compi...
Definition: accelerator.hpp:38
Implementation of the quadrature-function-based functional enabling rapid development of FEM formulat...
HeatTransfer helper structs.
SERAC_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:1424
constexpr SERAC_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:416
Constant thermal flux boundary model.
double flux_
The constant flux applied to the boundary.
SERAC_HOST_DEVICE auto operator()(const T1 &, const T2 &, const double, const T3 &) const
Evaluation function for the thermal flux on a boundary.
Constant thermal source model.
double source_
The constant source.
SERAC_HOST_DEVICE auto operator()(const T1 &, const double, const T2 &, const T3 &) const
Evaluation function for the constant thermal source model.
SERAC_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.
SERAC_HOST_DEVICE auto operator()(const T1 &, const T2 &, const T3 &temperature_gradient) const
Material response call for a linear anisotropic material.
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.
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.
SERAC_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