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
EnergyFlux.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_ENERGY_FLUX_HPP
26#define PHQ_UNIT_ENERGY_FLUX_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 Energy flux units.
53enum class EnergyFlux : int8_t {
54 /// \brief Watt per square metre (W/m^2) energy flux unit.
56
57 /// \brief Nanowatt per square millimetre (nW/mm^2) energy flux unit.
59
60 /// \brief Foot-pound per square foot per second (ft·lbf/ft^2/s) energy flux unit.
62
63 /// \brief Inch-pound per square inch per second (in·lbf/in^2/s) energy flux unit.
65};
66
67} // namespace Unit
68
69/// \brief Standard energy flux unit: watt per square metre (W/m^2).
70template <>
71inline constexpr const Unit::
72 EnergyFlux Standard<Unit::EnergyFlux>{Unit::EnergyFlux::WattPerSquareMetre};
73
74/// \brief Physical dimension set of energy flux units.
75template <>
76inline constexpr const Dimensions RelatedDimensions<Unit::EnergyFlux>{
77 Dimensions{Dimension::Time{-3}, Dimension::Length{0}, Dimension::Mass{1},
78 Dimension::ElectricCurrent{0}, Dimension::Temperature{0},
79 Dimension::SubstanceAmount{0}, Dimension::LuminousIntensity{0}}
80};
81
82inline std::ostream& operator<<(std::ostream& stream, const Unit::EnergyFlux unit) {
83 stream << Abbreviation(unit);
84 return stream;
85}
86
87namespace Internal {
88
89template <>
90inline const std::map<UnitSystem, Unit::EnergyFlux> ConsistentUnits<Unit::EnergyFlux>{
95};
96
97template <>
98inline const std::map<Unit::EnergyFlux, UnitSystem> RelatedUnitSystems<Unit::EnergyFlux>{
103};
104
105// clang-format off
106
107template <>
108inline const std::map<Unit::EnergyFlux, std::string_view> Abbreviations<Unit::EnergyFlux>{
113};
114
115template <>
116inline const std::unordered_map<std::string_view, Unit::EnergyFlux> Spellings<Unit::EnergyFlux>{
172};
173
174// clang-format on
175
176template <>
177template <typename NumericType>
178inline constexpr void Conversion<Unit::EnergyFlux, Unit::EnergyFlux::WattPerSquareMetre>::
179 FromStandard(NumericType& /*value*/) noexcept {}
180
181template <>
182template <typename NumericType>
183inline constexpr void Conversion<Unit::EnergyFlux, Unit::EnergyFlux::WattPerSquareMetre>::
184 ToStandard(NumericType& /*value*/) noexcept {}
185
186template <>
187template <typename NumericType>
188inline constexpr void Conversion<Unit::EnergyFlux, Unit::EnergyFlux::NanowattPerSquareMillimetre>::
189 FromStandard(NumericType& value) noexcept {
190 value *= static_cast<NumericType>(1000.0L);
191}
192
193template <>
194template <typename NumericType>
195inline constexpr void Conversion<Unit::EnergyFlux, Unit::EnergyFlux::NanowattPerSquareMillimetre>::
196 ToStandard(NumericType& value) noexcept {
197 value *= static_cast<NumericType>(0.001L);
198}
199
200template <>
201template <typename NumericType>
202inline constexpr void
203Conversion<Unit::EnergyFlux, Unit::EnergyFlux::FootPoundPerSquareFootPerSecond>::FromStandard(
204 NumericType& value) noexcept {
205 value *= static_cast<NumericType>(0.3048L)
206 / (static_cast<NumericType>(0.45359237L) * static_cast<NumericType>(9.80665L));
207}
208
209template <>
210template <typename NumericType>
211inline constexpr void
212Conversion<Unit::EnergyFlux, Unit::EnergyFlux::FootPoundPerSquareFootPerSecond>::ToStandard(
213 NumericType& value) noexcept {
214 value *= static_cast<NumericType>(0.45359237L) * static_cast<NumericType>(9.80665L)
215 / static_cast<NumericType>(0.3048L);
216}
217
218template <>
219template <typename NumericType>
220inline constexpr void
221Conversion<Unit::EnergyFlux, Unit::EnergyFlux::InchPoundPerSquareInchPerSecond>::FromStandard(
222 NumericType& value) noexcept {
223 value *= static_cast<NumericType>(0.0254L)
224 / (static_cast<NumericType>(0.45359237L) * static_cast<NumericType>(9.80665L));
225}
226
227template <>
228template <typename NumericType>
229inline constexpr void
230Conversion<Unit::EnergyFlux, Unit::EnergyFlux::InchPoundPerSquareInchPerSecond>::ToStandard(
231 NumericType& value) noexcept {
232 value *= static_cast<NumericType>(0.45359237L) * static_cast<NumericType>(9.80665L)
233 / static_cast<NumericType>(0.0254L);
234}
235
236template <typename NumericType>
237inline const std::
238 map<Unit::EnergyFlux, std::function<void(NumericType* values, const std::size_t size)>>
239 MapOfConversionsFromStandard<Unit::EnergyFlux, NumericType>{
241 Conversions<Unit::EnergyFlux, Unit::EnergyFlux::WattPerSquareMetre>::
242 FromStandard<NumericType>},
244 Conversions<Unit::EnergyFlux, Unit::EnergyFlux::NanowattPerSquareMillimetre>::
245 FromStandard<NumericType>},
247 Conversions<Unit::EnergyFlux, Unit::EnergyFlux::FootPoundPerSquareFootPerSecond>::
248 FromStandard<NumericType>},
250 Conversions<Unit::EnergyFlux, Unit::EnergyFlux::InchPoundPerSquareInchPerSecond>::
251 FromStandard<NumericType>},
252};
253
254template <typename NumericType>
255inline const std::
256 map<Unit::EnergyFlux, std::function<void(NumericType* const values, const std::size_t size)>>
257 MapOfConversionsToStandard<Unit::EnergyFlux, NumericType>{
259 Conversions<Unit::EnergyFlux, Unit::EnergyFlux::WattPerSquareMetre>::
260 ToStandard<NumericType>},
262 Conversions<Unit::EnergyFlux, Unit::EnergyFlux::NanowattPerSquareMillimetre>::
263 ToStandard<NumericType>},
265 Conversions<Unit::EnergyFlux, Unit::EnergyFlux::FootPoundPerSquareFootPerSecond>::
266 ToStandard<NumericType>},
268 Conversions<Unit::EnergyFlux, Unit::EnergyFlux::InchPoundPerSquareInchPerSecond>::
269 ToStandard<NumericType>},
270};
271
272} // namespace Internal
273
274} // namespace PhQ
275
276#endif // PHQ_UNIT_ENERGY_FLUX_HPP
EnergyFlux
Energy flux units.
@ NanowattPerSquareMillimetre
Nanowatt per square millimetre (nW/mm^2) energy flux unit.
@ FootPoundPerSquareFootPerSecond
Foot-pound per square foot per second (ft·lbf/ft^2/s) energy flux unit.
@ InchPoundPerSquareInchPerSecond
Inch-pound per square inch per second (in·lbf/in^2/s) energy flux unit.
@ WattPerSquareMetre
Watt per square metre (W/m^2) energy flux 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