Physical Quantities  v1.0.0
C++ library of physical quantities, physical models, and units of measure for scientific computing. https://github.com/acodcha/phq
LinearThermalExpansionCoefficient.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_LINEAR_THERMAL_EXPANSION_COEFFICIENT_HPP
26 #define PHQ_LINEAR_THERMAL_EXPANSION_COEFFICIENT_HPP
27 
28 #include <cstddef>
29 #include <functional>
30 #include <ostream>
31 
32 #include "DimensionalScalar.hpp"
33 #include "ScalarStrain.hpp"
36 
37 namespace PhQ {
38 
39 /// \brief Linear thermal expansion coefficient. Not to be confused with the volumetric thermal
40 /// expansion coefficient; see PhQ::VolumetricThermalExpansionCoefficient. For isotropic materials,
41 /// the volumetric thermal expansion coefficient is usually three times the linear thermal expansion
42 /// coefficient.
43 template <typename NumericType = double>
45  : public DimensionalScalar<Unit::ReciprocalTemperature, NumericType> {
46 public:
47  /// \brief Default constructor. Constructs a linear thermal expansion coefficient with an
48  /// uninitialized value.
50 
51  /// \brief Constructor. Constructs a linear thermal expansion coefficient with a given value
52  /// expressed in a given reciprocal temperature unit.
54  : DimensionalScalar<Unit::ReciprocalTemperature, NumericType>(value, unit) {}
55 
56  /// \brief Destructor. Destroys this linear thermal expansion coefficient.
57  ~LinearThermalExpansionCoefficient() noexcept = default;
58 
59  /// \brief Copy constructor. Constructs a linear thermal expansion coefficient by copying another
60  /// one.
62  const LinearThermalExpansionCoefficient<NumericType>& other) = default;
63 
64  /// \brief Copy constructor. Constructs a linear thermal expansion coefficient by copying another
65  /// one.
66  template <typename OtherNumericType>
68  const LinearThermalExpansionCoefficient<OtherNumericType>& other)
69  : LinearThermalExpansionCoefficient(static_cast<NumericType>(other.Value())) {}
70 
71  /// \brief Move constructor. Constructs a linear thermal expansion coefficient by moving another
72  /// one.
74  LinearThermalExpansionCoefficient<NumericType>&& other) noexcept = default;
75 
76  /// \brief Copy assignment operator. Assigns this linear thermal expansion coefficient by copying
77  /// another one.
79  const LinearThermalExpansionCoefficient<NumericType>& other) = default;
80 
81  /// \brief Copy assignment operator. Assigns this linear thermal expansion coefficient by copying
82  /// another one.
83  template <typename OtherNumericType>
86  this->value = static_cast<NumericType>(other.Value());
87  return *this;
88  }
89 
90  /// \brief Move assignment operator. Assigns this linear thermal expansion coefficient by moving
91  /// another one.
93  LinearThermalExpansionCoefficient<NumericType>&& other) noexcept = default;
94 
95  /// \brief Statically creates a linear thermal expansion coefficient of zero.
96  [[nodiscard]] static constexpr LinearThermalExpansionCoefficient<NumericType> Zero() {
97  return LinearThermalExpansionCoefficient<NumericType>{static_cast<NumericType>(0)};
98  }
99 
100  /// \brief Statically creates a linear thermal expansion coefficient with a given value expressed
101  /// in a given reciprocal temperature unit.
102  template <Unit::ReciprocalTemperature Unit>
104  const NumericType value) {
106  ConvertStatically<Unit::ReciprocalTemperature, Unit, Standard<Unit::ReciprocalTemperature>>(
107  value)};
108  }
109 
111  const LinearThermalExpansionCoefficient<NumericType>& linear_thermal_expansion_coefficient)
112  const {
114  this->value + linear_thermal_expansion_coefficient.value};
115  }
116 
118  const LinearThermalExpansionCoefficient<NumericType>& linear_thermal_expansion_coefficient)
119  const {
121  this->value - linear_thermal_expansion_coefficient.value};
122  }
123 
125  const NumericType number) const {
127  }
128 
130  const TemperatureDifference<NumericType>& temperature_difference) const {
131  return ScalarStrain<NumericType>{*this, temperature_difference};
132  }
133 
135  const NumericType number) const {
137  }
138 
139  constexpr NumericType operator/(
140  const LinearThermalExpansionCoefficient<NumericType>& linear_thermal_expansion_coefficient)
141  const noexcept {
142  return this->value / linear_thermal_expansion_coefficient.value;
143  }
144 
146  linear_thermal_expansion_coefficient) noexcept {
147  this->value += linear_thermal_expansion_coefficient.value;
148  }
149 
151  linear_thermal_expansion_coefficient) noexcept {
152  this->value -= linear_thermal_expansion_coefficient.value;
153  }
154 
155  constexpr void operator*=(const NumericType number) noexcept {
156  this->value *= number;
157  }
158 
159  constexpr void operator/=(const NumericType number) noexcept {
160  this->value /= number;
161  }
162 
163 private:
164  /// \brief Constructor. Constructs a linear thermal expansion coefficient with a given value
165  /// expressed in the standard reciprocal temperature unit.
166  explicit constexpr LinearThermalExpansionCoefficient(const NumericType value)
168 };
169 
170 template <typename NumericType>
171 inline constexpr bool operator==(
173  const LinearThermalExpansionCoefficient<NumericType>& right) noexcept {
174  return left.Value() == right.Value();
175 }
176 
177 template <typename NumericType>
178 inline constexpr bool operator!=(
180  const LinearThermalExpansionCoefficient<NumericType>& right) noexcept {
181  return left.Value() != right.Value();
182 }
183 
184 template <typename NumericType>
185 inline constexpr bool operator<(
187  const LinearThermalExpansionCoefficient<NumericType>& right) noexcept {
188  return left.Value() < right.Value();
189 }
190 
191 template <typename NumericType>
192 inline constexpr bool operator>(
194  const LinearThermalExpansionCoefficient<NumericType>& right) noexcept {
195  return left.Value() > right.Value();
196 }
197 
198 template <typename NumericType>
199 inline constexpr bool operator<=(
201  const LinearThermalExpansionCoefficient<NumericType>& right) noexcept {
202  return left.Value() <= right.Value();
203 }
204 
205 template <typename NumericType>
206 inline constexpr bool operator>=(
208  const LinearThermalExpansionCoefficient<NumericType>& right) noexcept {
209  return left.Value() >= right.Value();
210 }
211 
212 template <typename NumericType>
213 inline std::ostream& operator<<(
214  std::ostream& stream,
215  const LinearThermalExpansionCoefficient<NumericType>& linear_thermal_expansion_coefficient) {
216  stream << linear_thermal_expansion_coefficient.Print();
217  return stream;
218 }
219 
220 template <typename NumericType>
222  const NumericType number,
223  const LinearThermalExpansionCoefficient<NumericType>& linear_thermal_expansion_coefficient) {
224  return linear_thermal_expansion_coefficient * number;
225 }
226 
227 template <typename NumericType>
229  const LinearThermalExpansionCoefficient<NumericType>& linear_thermal_expansion_coefficient,
230  const TemperatureDifference<NumericType>& temperature_difference)
231  : ScalarStrain<NumericType>(
232  linear_thermal_expansion_coefficient.Value() * temperature_difference.Value()) {}
233 
234 template <typename NumericType>
236  const LinearThermalExpansionCoefficient<NumericType>& linear_thermal_expansion_coefficient)
237  const {
238  return ScalarStrain<NumericType>{linear_thermal_expansion_coefficient, *this};
239 }
240 
241 } // namespace PhQ
242 
243 namespace std {
244 
245 template <typename NumericType>
246 struct hash<PhQ::LinearThermalExpansionCoefficient<NumericType>> {
247  inline size_t operator()(const PhQ::LinearThermalExpansionCoefficient<NumericType>&
248  linear_thermal_expansion_coefficient) const {
249  return hash<NumericType>()(linear_thermal_expansion_coefficient.Value());
250  }
251 };
252 
253 } // namespace std
254 
255 #endif // PHQ_LINEAR_THERMAL_EXPANSION_COEFFICIENT_HPP
Abstract base class that represents any dimensional scalar physical quantity. Such a physical quantit...
double value
Value of this physical quantity expressed in its standard unit of measure.
constexpr double Value() const noexcept
Value of this physical quantity expressed in its standard unit of measure.
static constexpr Unit::ReciprocalTemperature 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...
Linear thermal expansion coefficient. Not to be confused with the volumetric thermal expansion coeffi...
constexpr ScalarStrain< NumericType > operator*(const TemperatureDifference< NumericType > &temperature_difference) const
constexpr void operator-=(const LinearThermalExpansionCoefficient< NumericType > &linear_thermal_expansion_coefficient) noexcept
constexpr void operator/=(const NumericType number) noexcept
constexpr LinearThermalExpansionCoefficient< NumericType > operator-(const LinearThermalExpansionCoefficient< NumericType > &linear_thermal_expansion_coefficient) const
constexpr void operator+=(const LinearThermalExpansionCoefficient< NumericType > &linear_thermal_expansion_coefficient) noexcept
~LinearThermalExpansionCoefficient() noexcept=default
Destructor. Destroys this linear thermal expansion coefficient.
constexpr NumericType operator/(const LinearThermalExpansionCoefficient< NumericType > &linear_thermal_expansion_coefficient) const noexcept
constexpr LinearThermalExpansionCoefficient< NumericType > operator/(const NumericType number) const
LinearThermalExpansionCoefficient(const NumericType value, const Unit::ReciprocalTemperature unit)
Constructor. Constructs a linear thermal expansion coefficient with a given value expressed in a give...
static constexpr LinearThermalExpansionCoefficient< NumericType > Zero()
Statically creates a linear thermal expansion coefficient of zero.
constexpr LinearThermalExpansionCoefficient(LinearThermalExpansionCoefficient< NumericType > &&other) noexcept=default
Move constructor. Constructs a linear thermal expansion coefficient by moving another one.
constexpr LinearThermalExpansionCoefficient< NumericType > & operator=(const LinearThermalExpansionCoefficient< OtherNumericType > &other)
Copy assignment operator. Assigns this linear thermal expansion coefficient by copying another one.
constexpr void operator*=(const NumericType number) noexcept
static constexpr LinearThermalExpansionCoefficient< NumericType > Create(const NumericType value)
Statically creates a linear thermal expansion coefficient with a given value expressed in a given rec...
constexpr LinearThermalExpansionCoefficient(const NumericType value)
Constructor. Constructs a linear thermal expansion coefficient with a given value expressed in the st...
constexpr LinearThermalExpansionCoefficient< NumericType > & operator=(LinearThermalExpansionCoefficient< NumericType > &&other) noexcept=default
Move assignment operator. Assigns this linear thermal expansion coefficient by moving another one.
constexpr LinearThermalExpansionCoefficient< NumericType > & operator=(const LinearThermalExpansionCoefficient< NumericType > &other)=default
Copy assignment operator. Assigns this linear thermal expansion coefficient by copying another one.
constexpr LinearThermalExpansionCoefficient< NumericType > operator*(const NumericType number) const
constexpr LinearThermalExpansionCoefficient< NumericType > operator+(const LinearThermalExpansionCoefficient< NumericType > &linear_thermal_expansion_coefficient) const
LinearThermalExpansionCoefficient()=default
Default constructor. Constructs a linear thermal expansion coefficient with an uninitialized value.
Scalar component or resultant of a three-dimensional Euclidean strain symmetric dyadic tensor....
ScalarStrain()=default
Default constructor. Constructs a scalar strain with an uninitialized value.
Temperature difference. Not to be confused with temperature; see PhQ::Temperature....
constexpr TemperatureDifference< NumericType > operator*(const NumericType number) const
ReciprocalTemperature
Reciprocal temperature units. Reciprocal temperature is the inverse of temperature.
Namespace that encompasses all of the Physical Quantities library's content.
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
constexpr bool operator!=(const Acceleration< NumericType > &left, const Acceleration< NumericType > &right) noexcept
std::ostream & operator<<(std::ostream &stream, const Acceleration< NumericType > &acceleration)