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
TemperatureGradient.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_UNIT_TEMPERATURE_GRADIENT_HPP
26#define PHQ_UNIT_TEMPERATURE_GRADIENT_HPP
27
28#include <cstddef>
29#include <cstdint>
30#include <functional>
31#include <map>
32#include <ostream>
33#include <string_view>
34#include <unordered_map>
35
36#include "../Base.hpp"
37#include "../Dimension/ElectricCurrent.hpp"
38#include "../Dimension/Length.hpp"
39#include "../Dimension/LuminousIntensity.hpp"
40#include "../Dimension/Mass.hpp"
41#include "../Dimension/SubstanceAmount.hpp"
42#include "../Dimension/Temperature.hpp"
43#include "../Dimension/Time.hpp"
44#include "../Dimensions.hpp"
45#include "../Unit.hpp"
46#include "../UnitSystem.hpp"
47
48namespace PhQ {
49
50namespace Unit {
51
52/// \brief Temperature gradient units.
53enum class TemperatureGradient : int8_t {
54 /// \brief Kelvin per metre (K/m) temperature gradient unit.
56
57 /// \brief Kelvin per millimetre (K/mm) temperature gradient unit.
59
60 /// \brief Degree Celsius per metre (°C/m) temperature gradient unit.
62
63 /// \brief Degree Celsius per millimetre (°C/mm) temperature gradient unit.
65
66 /// \brief Degree Rankine per foot (°R/ft) temperature gradient unit.
68
69 /// \brief Degree Rankine per inch (°R/in) temperature gradient unit.
71
72 /// \brief Degree Fahrenheit per foot (°F/ft) temperature gradient unit.
74
75 /// \brief Degree Fahrenheit per inch (°F/in) temperature gradient unit.
77};
78
79} // namespace Unit
80
81/// \brief Standard temperature gradient unit: kelvin per metre (K/m).
82template <>
83inline constexpr const Unit::TemperatureGradient Standard<Unit::TemperatureGradient>{
85
86/// \brief Physical dimension set of temperature gradient units.
87template <>
88inline constexpr const Dimensions RelatedDimensions<Unit::TemperatureGradient>{
89 Dimensions{Dimension::Time{0}, Dimension::Length{-1}, Dimension::Mass{0},
90 Dimension::ElectricCurrent{0}, Dimension::Temperature{1},
91 Dimension::SubstanceAmount{0}, Dimension::LuminousIntensity{0}}
92};
93
94inline std::ostream& operator<<(std::ostream& stream, const Unit::TemperatureGradient unit) {
95 stream << Abbreviation(unit);
96 return stream;
97}
98
99namespace Internal {
100
101template <>
102inline const std::map<UnitSystem, Unit::TemperatureGradient>
103 ConsistentUnits<Unit::TemperatureGradient>{
108};
109
110template <>
111inline const std::map<Unit::TemperatureGradient, UnitSystem>
112 RelatedUnitSystems<Unit::TemperatureGradient>{
117};
118
119// clang-format off
120
121template <>
122inline const std::map<Unit::TemperatureGradient, std::string_view>
123 Abbreviations<Unit::TemperatureGradient>{
132};
133
134template <>
135inline const std::unordered_map<std::string_view, Unit::TemperatureGradient>
136 Spellings<Unit::TemperatureGradient>{
161};
162
163// clang-format on
164
165template <>
166template <typename NumericType>
167inline constexpr void
168Conversion<Unit::TemperatureGradient, Unit::TemperatureGradient::KelvinPerMetre>::FromStandard(
169 NumericType& /*value*/) noexcept {}
170
171template <>
172template <typename NumericType>
173inline constexpr void
174Conversion<Unit::TemperatureGradient, Unit::TemperatureGradient::KelvinPerMetre>::ToStandard(
175 NumericType& /*value*/) noexcept {}
176
177template <>
178template <typename NumericType>
179inline constexpr void
180Conversion<Unit::TemperatureGradient, Unit::TemperatureGradient::KelvinPerMillimetre>::FromStandard(
181 NumericType& value) noexcept {
182 value *= static_cast<NumericType>(0.001L);
183}
184
185template <>
186template <typename NumericType>
187inline constexpr void
188Conversion<Unit::TemperatureGradient, Unit::TemperatureGradient::KelvinPerMillimetre>::ToStandard(
189 NumericType& value) noexcept {
190 value *= static_cast<NumericType>(1000.0L);
191}
192
193template <>
194template <typename NumericType>
195inline constexpr void
196Conversion<Unit::TemperatureGradient, Unit::TemperatureGradient::CelsiusPerMetre>::FromStandard(
197 NumericType& /*value*/) noexcept {}
198
199template <>
200template <typename NumericType>
201inline constexpr void
202Conversion<Unit::TemperatureGradient, Unit::TemperatureGradient::CelsiusPerMetre>::ToStandard(
203 NumericType& /*value*/) noexcept {}
204
205template <>
206template <typename NumericType>
207inline constexpr void
208Conversion<Unit::TemperatureGradient, Unit::TemperatureGradient::CelsiusPerMillimetre>::
209 FromStandard(NumericType& value) noexcept {
210 value *= static_cast<NumericType>(0.001L);
211}
212
213template <>
214template <typename NumericType>
215inline constexpr void
216Conversion<Unit::TemperatureGradient, Unit::TemperatureGradient::CelsiusPerMillimetre>::ToStandard(
217 NumericType& value) noexcept {
218 value *= static_cast<NumericType>(1000.0L);
219}
220
221template <>
222template <typename NumericType>
223inline constexpr void
224Conversion<Unit::TemperatureGradient, Unit::TemperatureGradient::RankinePerFoot>::FromStandard(
225 NumericType& value) noexcept {
226 value *= static_cast<NumericType>(1.8L) * static_cast<NumericType>(0.3048L);
227}
228
229template <>
230template <typename NumericType>
231inline constexpr void
232Conversion<Unit::TemperatureGradient, Unit::TemperatureGradient::RankinePerFoot>::ToStandard(
233 NumericType& value) noexcept {
234 value /= (static_cast<NumericType>(1.8L) * static_cast<NumericType>(0.3048L));
235}
236
237template <>
238template <typename NumericType>
239inline constexpr void
240Conversion<Unit::TemperatureGradient, Unit::TemperatureGradient::RankinePerInch>::FromStandard(
241 NumericType& value) noexcept {
242 value *= static_cast<NumericType>(1.8L) * static_cast<NumericType>(0.0254L);
243}
244
245template <>
246template <typename NumericType>
247inline constexpr void
248Conversion<Unit::TemperatureGradient, Unit::TemperatureGradient::RankinePerInch>::ToStandard(
249 NumericType& value) noexcept {
250 value /= (static_cast<NumericType>(1.8L) * static_cast<NumericType>(0.0254L));
251}
252
253template <>
254template <typename NumericType>
255inline constexpr void
256Conversion<Unit::TemperatureGradient, Unit::TemperatureGradient::FahrenheitPerFoot>::FromStandard(
257 NumericType& value) noexcept {
258 value *= static_cast<NumericType>(1.8L) * static_cast<NumericType>(0.3048L);
259}
260
261template <>
262template <typename NumericType>
263inline constexpr void
264Conversion<Unit::TemperatureGradient, Unit::TemperatureGradient::FahrenheitPerFoot>::ToStandard(
265 NumericType& value) noexcept {
266 value /= (static_cast<NumericType>(1.8L) * static_cast<NumericType>(0.3048L));
267}
268
269template <>
270template <typename NumericType>
271inline constexpr void
272Conversion<Unit::TemperatureGradient, Unit::TemperatureGradient::FahrenheitPerInch>::FromStandard(
273 NumericType& value) noexcept {
274 value *= static_cast<NumericType>(1.8L) * static_cast<NumericType>(0.0254L);
275}
276
277template <>
278template <typename NumericType>
279inline constexpr void
280Conversion<Unit::TemperatureGradient, Unit::TemperatureGradient::FahrenheitPerInch>::ToStandard(
281 NumericType& value) noexcept {
282 value /= (static_cast<NumericType>(1.8L) * static_cast<NumericType>(0.0254L));
283}
284
285template <typename NumericType>
286inline const std::
287 map<Unit::TemperatureGradient, std::function<void(NumericType* values, const std::size_t size)>>
288 MapOfConversionsFromStandard<Unit::TemperatureGradient, NumericType>{
290 Conversions<Unit::TemperatureGradient, Unit::TemperatureGradient::KelvinPerMetre>::
291 FromStandard<NumericType>},
293 Conversions<Unit::TemperatureGradient, Unit::TemperatureGradient::KelvinPerMillimetre>::
294 FromStandard<NumericType>},
296 Conversions<Unit::TemperatureGradient, Unit::TemperatureGradient::CelsiusPerMetre>::
297 FromStandard<NumericType>},
299 Conversions<Unit::TemperatureGradient, Unit::TemperatureGradient::CelsiusPerMillimetre>::
300 FromStandard<NumericType>},
302 Conversions<Unit::TemperatureGradient, Unit::TemperatureGradient::RankinePerFoot>::
303 FromStandard<NumericType>},
305 Conversions<Unit::TemperatureGradient, Unit::TemperatureGradient::RankinePerInch>::
306 FromStandard<NumericType>},
308 Conversions<Unit::TemperatureGradient, Unit::TemperatureGradient::FahrenheitPerFoot>::
309 FromStandard<NumericType>},
311 Conversions<Unit::TemperatureGradient, Unit::TemperatureGradient::FahrenheitPerInch>::
312 FromStandard<NumericType>},
313};
314
315template <typename NumericType>
316inline const std::map<Unit::TemperatureGradient,
317 std::function<void(NumericType* const values, const std::size_t size)>>
318 MapOfConversionsToStandard<Unit::TemperatureGradient, NumericType>{
320 Conversions<Unit::TemperatureGradient, Unit::TemperatureGradient::KelvinPerMetre>::
321 ToStandard<NumericType>},
323 Conversions<Unit::TemperatureGradient, Unit::TemperatureGradient::KelvinPerMillimetre>::
324 ToStandard<NumericType>},
326 Conversions<Unit::TemperatureGradient, Unit::TemperatureGradient::CelsiusPerMetre>::
327 ToStandard<NumericType>},
329 Conversions<Unit::TemperatureGradient, Unit::TemperatureGradient::CelsiusPerMillimetre>::
330 ToStandard<NumericType>},
332 Conversions<Unit::TemperatureGradient, Unit::TemperatureGradient::RankinePerFoot>::
333 ToStandard<NumericType>},
335 Conversions<Unit::TemperatureGradient, Unit::TemperatureGradient::RankinePerInch>::
336 ToStandard<NumericType>},
338 Conversions<Unit::TemperatureGradient, Unit::TemperatureGradient::FahrenheitPerFoot>::
339 ToStandard<NumericType>},
341 Conversions<Unit::TemperatureGradient, Unit::TemperatureGradient::FahrenheitPerInch>::
342 ToStandard<NumericType>},
343};
344
345} // namespace Internal
346
347} // namespace PhQ
348
349#endif // PHQ_UNIT_TEMPERATURE_GRADIENT_HPP
TemperatureGradient
Temperature gradient units.
@ RankinePerInch
Degree Rankine per inch (°R/in) temperature gradient unit.
@ FahrenheitPerInch
Degree Fahrenheit per inch (°F/in) temperature gradient unit.
@ CelsiusPerMetre
Degree Celsius per metre (°C/m) temperature gradient unit.
@ FahrenheitPerFoot
Degree Fahrenheit per foot (°F/ft) temperature gradient unit.
@ RankinePerFoot
Degree Rankine per foot (°R/ft) temperature gradient unit.
@ CelsiusPerMillimetre
Degree Celsius per millimetre (°C/mm) temperature gradient unit.
@ KelvinPerMetre
Kelvin per metre (K/m) temperature gradient unit.
@ KelvinPerMillimetre
Kelvin per millimetre (K/mm) temperature gradient unit.
Namespace that encompasses all of the Physical Quantities library's content.
std::ostream & operator<<(std::ostream &stream, const Acceleration< NumericType > &acceleration)
@ FootPoundSecondRankine
Foot-pound-second-rankine (ft·lbf·s·°R) system.
@ MillimetreGramSecondKelvin
Millimetre-gram-second-kelvin (mm·g·s·K) system.
@ MetreKilogramSecondKelvin
Metre-kilogram-second-kelvin (m·kg·s·K) system.
@ InchPoundSecondRankine
Inch-pound-second-rankine (in·lbf·s·°R) system.
std::string_view Abbreviation(const Enumeration enumeration)
Returns the abbreviation of a given enumeration value. For example, PhQ::Abbreviation(PhQ::Unit::Time...
Definition Base.hpp:89