Physical Quantities  v1.0.0
C++ library of physical quantities, physical models, and units of measure for scientific computing. https://github.com/acodcha/phq
Loading...
Searching...
No Matches
ThermalConductivity.hpp
Go to the documentation of this file.
1// Copyright © 2020-2024 Alexandre Coderre-Chabot
2//
3// This file is part of Physical Quantities (PhQ), a C++ library of physical quantities, physical
4// models, and units of measure for scientific computing.
5//
6// Physical Quantities is hosted at:
7// https://github.com/acodcha/phq
8//
9// Physical Quantities is licensed under the MIT License:
10// https://mit-license.org
11//
12// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
13// associated documentation files (the "Software"), to deal in the Software without restriction,
14// including without limitation the rights to use, copy, modify, merge, publish, distribute,
15// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
16// furnished to do so, subject to the following conditions:
17// - The above copyright notice and this permission notice shall be included in all copies or
18// substantial portions of the Software.
19// - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
20// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM
23// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25#ifndef PHQ_THERMAL_CONDUCTIVITY_HPP
26#define PHQ_THERMAL_CONDUCTIVITY_HPP
27
28#include <array>
29#include <cstddef>
30#include <functional>
31#include <ostream>
32
35#include "SymmetricDyad.hpp"
37
38namespace PhQ {
39
40/// \brief Three-dimensional Euclidean Cauchy thermal conductivity symmetric dyadic tensor. Contains
41/// six components in Cartesian coordinates: xx, xy = yx, xz = zx, yy, yz = zy, and zz. In general,
42/// thermal conductivity is a tensor; however, in isotropic materials, thermal conductivity
43/// simplifies to a scalar. For the scalar components or resultants of a thermal conductivity
44/// tensor, see PhQ::ScalarThermalConductivity.
45template <typename NumericType = double>
47 : public DimensionalSymmetricDyad<Unit::ThermalConductivity, NumericType> {
48public:
49 /// \brief Default constructor. Constructs a thermal conductivity tensor with an uninitialized
50 /// value.
52
53 /// \brief Constructor. Constructs a thermal conductivity tensor with a given value expressed in a
54 /// given thermal conductivity unit.
57
58 /// \brief Constructor. Constructs a thermal conductivity tensor from a given scalar thermal
59 /// conductivity.
60 explicit constexpr ThermalConductivity(
61 const ScalarThermalConductivity<NumericType>& scalar_thermal_conductivity)
62 : ThermalConductivity<NumericType>(
63 {scalar_thermal_conductivity.Value(), 0.0, 0.0, scalar_thermal_conductivity.Value(), 0.0,
64 scalar_thermal_conductivity.Value()}) {}
65
66 /// \brief Destructor. Destroys this thermal conductivity tensor.
67 ~ThermalConductivity() noexcept = default;
68
69 /// \brief Copy constructor. Constructs a thermal conductivity tensor by copying another one.
70 constexpr ThermalConductivity(const ThermalConductivity<NumericType>& other) = default;
71
72 /// \brief Copy constructor. Constructs a thermal conductivity tensor by copying another one.
73 template <typename OtherNumericType>
74 explicit constexpr ThermalConductivity(const ThermalConductivity<OtherNumericType>& other)
75 : ThermalConductivity(static_cast<SymmetricDyad<NumericType>>(other.Value())) {}
76
77 /// \brief Move constructor. Constructs a thermal conductivity tensor by moving another one.
78 constexpr ThermalConductivity(ThermalConductivity<NumericType>&& other) noexcept = default;
79
80 /// \brief Copy assignment operator. Assigns this thermal conductivity tensor by copying another
81 /// one.
83 const ThermalConductivity<NumericType>& other) = default;
84
85 /// \brief Copy assignment operator. Assigns this thermal conductivity tensor by copying another
86 /// one.
87 template <typename OtherNumericType>
90 this->value = static_cast<SymmetricDyad<NumericType>>(other.Value());
91 return *this;
92 }
93
94 /// \brief Move assignment operator. Assigns this thermal conductivity tensor by moving another
95 /// one.
97 ThermalConductivity<NumericType>&& other) noexcept = default;
98
99 /// \brief Statically creates a thermal conductivity tensor of zero.
103
104 /// \brief Statically creates a thermal conductivity tensor from the given xx, xy, xz, yy, yz, and
105 /// zz Cartesian components expressed in a given pressure unit.
106 template <Unit::ThermalConductivity Unit>
107 [[nodiscard]] static constexpr ThermalConductivity<NumericType> Create(
108 const NumericType xx, const NumericType xy, const NumericType xz, const NumericType yy,
109 const NumericType yz, const NumericType zz) {
111 ConvertStatically<Unit::ThermalConductivity, Unit, Standard<Unit::ThermalConductivity>>(
113 }
114
115 /// \brief Statically creates a thermal conductivity tensor from the given xx, xy, xz, yy, yz, and
116 /// zz Cartesian components expressed in a given pressure unit.
117 template <Unit::ThermalConductivity Unit>
118 [[nodiscard]] static constexpr ThermalConductivity<NumericType> Create(
119 const std::array<NumericType, 6>& xx_xy_xz_yy_yz_zz) {
121 ConvertStatically<Unit::ThermalConductivity, Unit, Standard<Unit::ThermalConductivity>>(
122 SymmetricDyad<NumericType>{xx_xy_xz_yy_yz_zz})};
123 }
124
125 /// \brief Statically creates a thermal conductivity tensor with a given value expressed in a
126 /// given thermal conductivity unit.
127 template <Unit::ThermalConductivity Unit>
128 [[nodiscard]] static constexpr ThermalConductivity<NumericType> Create(
131 ConvertStatically<Unit::ThermalConductivity, Unit, Standard<Unit::ThermalConductivity>>(
132 value)};
133 }
134
135 /// \brief Returns the xx Cartesian component of this thermal conductivity tensor.
136 [[nodiscard]] constexpr ScalarThermalConductivity<NumericType> xx() const noexcept {
138 }
139
140 /// \brief Returns the xy = yx Cartesian component of this thermal conductivity tensor.
141 [[nodiscard]] constexpr ScalarThermalConductivity<NumericType> xy() const noexcept {
143 }
144
145 /// \brief Returns the xz = zx Cartesian component of this thermal conductivity tensor.
146 [[nodiscard]] constexpr ScalarThermalConductivity<NumericType> xz() const noexcept {
148 }
149
150 /// \brief Returns the yx = xy Cartesian component of this thermal conductivity tensor.
151 [[nodiscard]] constexpr ScalarThermalConductivity<NumericType> yx() const noexcept {
153 }
154
155 /// \brief Returns the yy Cartesian component of this thermal conductivity tensor.
156 [[nodiscard]] constexpr ScalarThermalConductivity<NumericType> yy() const noexcept {
158 }
159
160 /// \brief Returns the yz = zy Cartesian component of this thermal conductivity tensor.
161 [[nodiscard]] constexpr ScalarThermalConductivity<NumericType> yz() const noexcept {
163 }
164
165 /// \brief Returns the zx = xz Cartesian component of this thermal conductivity tensor.
166 [[nodiscard]] constexpr ScalarThermalConductivity<NumericType> zx() const noexcept {
168 }
169
170 /// \brief Returns the zy = yz Cartesian component of this thermal conductivity tensor.
171 [[nodiscard]] constexpr ScalarThermalConductivity<NumericType> zy() const noexcept {
173 }
174
175 /// \brief Returns the zz Cartesian component of this thermal conductivity tensor.
176 [[nodiscard]] constexpr ScalarThermalConductivity<NumericType> zz() const noexcept {
178 }
179
181 const ThermalConductivity<NumericType>& thermal_conductivity) const {
182 return ThermalConductivity<NumericType>{this->value + thermal_conductivity.value};
183 }
184
186 const ThermalConductivity<NumericType>& thermal_conductivity) const {
187 return ThermalConductivity<NumericType>{this->value - thermal_conductivity.value};
188 }
189
190 constexpr ThermalConductivity<NumericType> operator*(const NumericType number) const {
191 return ThermalConductivity<NumericType>{this->value * number};
192 }
193
194 constexpr ThermalConductivity<NumericType> operator/(const NumericType number) const {
195 return ThermalConductivity<NumericType>{this->value / number};
196 }
197
198 constexpr void operator+=(const ThermalConductivity<NumericType>& thermal_conductivity) noexcept {
199 this->value += thermal_conductivity.value;
200 }
201
202 constexpr void operator-=(const ThermalConductivity<NumericType>& thermal_conductivity) noexcept {
203 this->value -= thermal_conductivity.value;
204 }
205
206 constexpr void operator*=(const NumericType number) noexcept {
207 this->value *= number;
208 }
209
210 constexpr void operator/=(const NumericType number) noexcept {
211 this->value /= number;
212 }
213
214private:
215 /// \brief Constructor. Constructs a thermal conductivity tensor with a given value expressed in
216 /// the standard thermal conductivity unit.
219};
220
221template <typename NumericType>
222inline constexpr bool operator==(const ThermalConductivity<NumericType>& left,
223 const ThermalConductivity<NumericType>& right) noexcept {
224 return left.Value() == right.Value();
225}
226
227template <typename NumericType>
228inline constexpr bool operator!=(const ThermalConductivity<NumericType>& left,
229 const ThermalConductivity<NumericType>& right) noexcept {
230 return left.Value() != right.Value();
231}
232
233template <typename NumericType>
234inline constexpr bool operator<(const ThermalConductivity<NumericType>& left,
235 const ThermalConductivity<NumericType>& right) noexcept {
236 return left.Value() < right.Value();
237}
238
239template <typename NumericType>
240inline constexpr bool operator>(const ThermalConductivity<NumericType>& left,
241 const ThermalConductivity<NumericType>& right) noexcept {
242 return left.Value() > right.Value();
243}
244
245template <typename NumericType>
246inline constexpr bool operator<=(const ThermalConductivity<NumericType>& left,
247 const ThermalConductivity<NumericType>& right) noexcept {
248 return left.Value() <= right.Value();
249}
250
251template <typename NumericType>
252inline constexpr bool operator>=(const ThermalConductivity<NumericType>& left,
253 const ThermalConductivity<NumericType>& right) noexcept {
254 return left.Value() >= right.Value();
255}
256
257template <typename NumericType>
258inline std::ostream& operator<<(
259 std::ostream& stream, const ThermalConductivity<NumericType>& thermal_conductivity) {
260 stream << thermal_conductivity.Print();
261 return stream;
262}
263
264template <typename NumericType>
266 const NumericType number, const ThermalConductivity<NumericType>& thermal_conductivity) {
267 return thermal_conductivity * number;
268}
269
270} // namespace PhQ
271
272namespace std {
273
274template <typename NumericType>
275struct hash<PhQ::ThermalConductivity<NumericType>> {
276 inline size_t operator()(
277 const PhQ::ThermalConductivity<NumericType>& thermal_conductivity) const {
278 return hash<PhQ::SymmetricDyad<NumericType>>()(thermal_conductivity.Value());
279 }
280};
281
282} // namespace std
283
284#endif // PHQ_THERMAL_CONDUCTIVITY_HPP
constexpr NumericType Value() const noexcept
Value of this physical quantity expressed in its standard unit of measure.
Abstract base class that represents any dimensional symmetric dyadic tensor physical quantity....
static constexpr UnitType Unit()
Standard unit of measure for this physical quantity. This physical quantity's value is stored interna...
std::string Print() const
Prints this physical quantity as a string. This physical quantity's value is expressed in its standar...
PhQ::SymmetricDyad< NumericType > value
Value of this physical quantity expressed in its standard unit of measure.
constexpr const PhQ::SymmetricDyad< NumericType > & Value() const noexcept
Value of this physical quantity expressed in its standard unit of measure.
Scalar component or resultant of a three-dimensional Euclidean thermal conductivity symmetric dyadic ...
Symmetric three-dimensional Euclidean dyadic tensor. Contains six components in Cartesian coordinates...
static constexpr SymmetricDyad< NumericType > Zero()
Statically creates a three-dimensional symmetric dyadic tensor with its xx, xy, xz,...
Three-dimensional Euclidean Cauchy thermal conductivity symmetric dyadic tensor. Contains six compone...
constexpr ScalarThermalConductivity< NumericType > zy() const noexcept
Returns the zy = yz Cartesian component of this thermal conductivity tensor.
constexpr ScalarThermalConductivity< NumericType > xy() const noexcept
Returns the xy = yx Cartesian component of this thermal conductivity tensor.
constexpr ThermalConductivity(ThermalConductivity< NumericType > &&other) noexcept=default
Move constructor. Constructs a thermal conductivity tensor by moving another one.
constexpr void operator+=(const ThermalConductivity< NumericType > &thermal_conductivity) noexcept
ThermalConductivity()=default
Default constructor. Constructs a thermal conductivity tensor with an uninitialized value.
constexpr ThermalConductivity< NumericType > operator*(const NumericType number) const
ThermalConductivity(const SymmetricDyad< NumericType > &value, const Unit::ThermalConductivity unit)
Constructor. Constructs a thermal conductivity tensor with a given value expressed in a given thermal...
constexpr void operator-=(const ThermalConductivity< NumericType > &thermal_conductivity) noexcept
static constexpr ThermalConductivity< NumericType > Create(const NumericType xx, const NumericType xy, const NumericType xz, const NumericType yy, const NumericType yz, const NumericType zz)
Statically creates a thermal conductivity tensor from the given xx, xy, xz, yy, yz,...
constexpr ThermalConductivity< NumericType > operator-(const ThermalConductivity< NumericType > &thermal_conductivity) const
constexpr ThermalConductivity(const SymmetricDyad< NumericType > &value)
Constructor. Constructs a thermal conductivity tensor with a given value expressed in the standard th...
constexpr ThermalConductivity< NumericType > & operator=(const ThermalConductivity< NumericType > &other)=default
Copy assignment operator. Assigns this thermal conductivity tensor by copying another one.
constexpr ThermalConductivity< NumericType > operator/(const NumericType number) const
constexpr ThermalConductivity(const ScalarThermalConductivity< NumericType > &scalar_thermal_conductivity)
Constructor. Constructs a thermal conductivity tensor from a given scalar thermal conductivity.
~ThermalConductivity() noexcept=default
Destructor. Destroys this thermal conductivity tensor.
constexpr ScalarThermalConductivity< NumericType > zx() const noexcept
Returns the zx = xz Cartesian component of this thermal conductivity tensor.
static constexpr ThermalConductivity< NumericType > Create(const std::array< NumericType, 6 > &xx_xy_xz_yy_yz_zz)
Statically creates a thermal conductivity tensor from the given xx, xy, xz, yy, yz,...
constexpr ThermalConductivity< NumericType > & operator=(const ThermalConductivity< OtherNumericType > &other)
Copy assignment operator. Assigns this thermal conductivity tensor by copying another one.
constexpr ScalarThermalConductivity< NumericType > xz() const noexcept
Returns the xz = zx Cartesian component of this thermal conductivity tensor.
constexpr void operator*=(const NumericType number) noexcept
constexpr ScalarThermalConductivity< NumericType > yy() const noexcept
Returns the yy Cartesian component of this thermal conductivity tensor.
constexpr void operator/=(const NumericType number) noexcept
static constexpr ThermalConductivity< NumericType > Create(const SymmetricDyad< NumericType > &value)
Statically creates a thermal conductivity tensor with a given value expressed in a given thermal cond...
constexpr ScalarThermalConductivity< NumericType > yz() const noexcept
Returns the yz = zy Cartesian component of this thermal conductivity tensor.
constexpr ScalarThermalConductivity< NumericType > yx() const noexcept
Returns the yx = xy Cartesian component of this thermal conductivity tensor.
constexpr ScalarThermalConductivity< NumericType > xx() const noexcept
Returns the xx Cartesian component of this thermal conductivity tensor.
constexpr ThermalConductivity< NumericType > & operator=(ThermalConductivity< NumericType > &&other) noexcept=default
Move assignment operator. Assigns this thermal conductivity tensor by moving another one.
constexpr ScalarThermalConductivity< NumericType > zz() const noexcept
Returns the zz Cartesian component of this thermal conductivity tensor.
static constexpr ThermalConductivity< NumericType > Zero()
Statically creates a thermal conductivity tensor of zero.
constexpr ThermalConductivity< NumericType > operator+(const ThermalConductivity< NumericType > &thermal_conductivity) const
ThermalConductivity
Thermal conductivity units.
Namespace that encompasses all of the Physical Quantities library's content.
std::ostream & operator<<(std::ostream &stream, const Acceleration< NumericType > &acceleration)
constexpr bool operator<(const Acceleration< NumericType > &left, const Acceleration< NumericType > &right) noexcept
constexpr bool operator<=(const Acceleration< NumericType > &left, const Acceleration< NumericType > &right) noexcept
constexpr bool operator>(const Acceleration< NumericType > &left, const Acceleration< NumericType > &right) noexcept
constexpr Acceleration< NumericType > operator*(const NumericType number, const Acceleration< NumericType > &acceleration)
constexpr bool operator==(const Acceleration< NumericType > &left, const Acceleration< NumericType > &right) noexcept
constexpr bool operator>=(const Acceleration< NumericType > &left, const Acceleration< NumericType > &right) noexcept
constexpr bool operator!=(const Acceleration< NumericType > &left, const Acceleration< NumericType > &right) noexcept