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
Diffusivity.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_DIFFUSIVITY_HPP
26#define PHQ_UNIT_DIFFUSIVITY_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 Diffusivity units.
53enum class Diffusivity : int8_t {
54 /// \brief Square metre per second (m^2/s) diffusivity unit.
56
57 /// \brief Square nautical mile per second (nmi^2/s) diffusivity unit.
59
60 /// \brief Square mile per second (mi^2/s) diffusivity unit.
62
63 /// \brief Square kilometre per second (km^2/s) diffusivity unit.
65
66 /// \brief Hectare per second (ha/s) diffusivity unit.
68
69 /// \brief Acre per second (ac/s) diffusivity unit.
71
72 /// \brief Square yard per second (yd^2/s) diffusivity unit.
74
75 /// \brief Square foot per second (ft^2/s) diffusivity unit.
77
78 /// \brief Square decimetre per second (dm^2/s) diffusivity unit.
80
81 /// \brief Square inch per second (in^2/s) diffusivity unit.
83
84 /// \brief Square centimetre per second (cm^2/s) diffusivity unit.
86
87 /// \brief Square millimetre per second (mm^2/s) diffusivity unit.
89
90 /// \brief Square milliinch per second (mil^2/s) diffusivity unit.
92
93 /// \brief Square micrometre per second (μm^2/s) diffusivity unit.
95
96 /// \brief Square microinch per second (μin^2/s) diffusivity unit.
98};
99
100} // namespace Unit
101
102/// \brief Standard diffusivity unit: square metre per second (m^2/s).
103template <>
104inline constexpr const Unit::
105 Diffusivity Standard<Unit::Diffusivity>{Unit::Diffusivity::SquareMetrePerSecond};
106
107/// \brief Physical dimension set of diffusivity units.
108template <>
109inline constexpr const Dimensions RelatedDimensions<Unit::Diffusivity>{
110 Dimensions{Dimension::Time{-1}, Dimension::Length{2}, Dimension::Mass{0},
111 Dimension::ElectricCurrent{0}, Dimension::Temperature{0},
112 Dimension::SubstanceAmount{0}, Dimension::LuminousIntensity{0}}
113};
114
115inline std::ostream& operator<<(std::ostream& stream, const Unit::Diffusivity unit) {
116 stream << Abbreviation(unit);
117 return stream;
118}
119
120namespace Internal {
121
122template <>
123inline const std::map<UnitSystem, Unit::Diffusivity> ConsistentUnits<Unit::Diffusivity>{
128};
129
130template <>
131inline const std::map<Unit::Diffusivity, UnitSystem> RelatedUnitSystems<Unit::Diffusivity>{
136};
137
138// clang-format off
139
140template <>
141inline const std::map<Unit::Diffusivity, std::string_view> Abbreviations<Unit::Diffusivity>{
157};
158
159template <>
160inline const std::unordered_map<std::string_view, Unit::Diffusivity> Spellings<Unit::Diffusivity>{
199};
200
201// clang-format on
202
203template <>
204template <typename NumericType>
205inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareMetrePerSecond>::
206 FromStandard(NumericType& /*value*/) noexcept {}
207
208template <>
209template <typename NumericType>
210inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareMetrePerSecond>::
211 ToStandard(NumericType& /*value*/) noexcept {}
212
213template <>
214template <typename NumericType>
215inline constexpr void
216Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareNauticalMilePerSecond>::FromStandard(
217 NumericType& value) noexcept {
218 value /= static_cast<NumericType>(1852.0L) * static_cast<NumericType>(1852.0L);
219}
220
221template <>
222template <typename NumericType>
223inline constexpr void
224Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareNauticalMilePerSecond>::ToStandard(
225 NumericType& value) noexcept {
226 value *= static_cast<NumericType>(1852.0L) * static_cast<NumericType>(1852.0L);
227}
228
229template <>
230template <typename NumericType>
231inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareMilePerSecond>::
232 FromStandard(NumericType& value) noexcept {
233 value /= static_cast<NumericType>(1609.344L) * static_cast<NumericType>(1609.344L);
234}
235
236template <>
237template <typename NumericType>
238inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareMilePerSecond>::
239 ToStandard(NumericType& value) noexcept {
240 value *= static_cast<NumericType>(1609.344L) * static_cast<NumericType>(1609.344L);
241}
242
243template <>
244template <typename NumericType>
245inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareKilometrePerSecond>::
246 FromStandard(NumericType& value) noexcept {
247 value *= static_cast<NumericType>(0.000001L);
248}
249
250template <>
251template <typename NumericType>
252inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareKilometrePerSecond>::
253 ToStandard(NumericType& value) noexcept {
254 value *= static_cast<NumericType>(1000000.0L);
255}
256
257template <>
258template <typename NumericType>
259inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::HectarePerSecond>::
260 FromStandard(NumericType& value) noexcept {
261 value *= static_cast<NumericType>(0.0001L);
262}
263
264template <>
265template <typename NumericType>
266inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::HectarePerSecond>::
267 ToStandard(NumericType& value) noexcept {
268 value *= static_cast<NumericType>(10000.0L);
269}
270
271template <>
272template <typename NumericType>
273inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::AcrePerSecond>::FromStandard(
274 NumericType& value) noexcept {
275 value *= static_cast<NumericType>(640.0L)
276 / (static_cast<NumericType>(1609.344L) * static_cast<NumericType>(1609.344L));
277}
278
279template <>
280template <typename NumericType>
281inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::AcrePerSecond>::ToStandard(
282 NumericType& value) noexcept {
283 value *= static_cast<NumericType>(1609.344L) * static_cast<NumericType>(1609.344L)
284 / static_cast<NumericType>(640.0L);
285}
286
287template <>
288template <typename NumericType>
289inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareYardPerSecond>::
290 FromStandard(NumericType& value) noexcept {
291 value /= static_cast<NumericType>(0.9144L) * static_cast<NumericType>(0.9144L);
292}
293
294template <>
295template <typename NumericType>
296inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareYardPerSecond>::
297 ToStandard(NumericType& value) noexcept {
298 value *= static_cast<NumericType>(0.9144L) * static_cast<NumericType>(0.9144L);
299}
300
301template <>
302template <typename NumericType>
303inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareFootPerSecond>::
304 FromStandard(NumericType& value) noexcept {
305 value /= static_cast<NumericType>(0.3048L) * static_cast<NumericType>(0.3048L);
306}
307
308template <>
309template <typename NumericType>
310inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareFootPerSecond>::
311 ToStandard(NumericType& value) noexcept {
312 value *= static_cast<NumericType>(0.3048L) * static_cast<NumericType>(0.3048L);
313}
314
315template <>
316template <typename NumericType>
317inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareDecimetrePerSecond>::
318 FromStandard(NumericType& value) noexcept {
319 value *= static_cast<NumericType>(100.0L);
320}
321
322template <>
323template <typename NumericType>
324inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareDecimetrePerSecond>::
325 ToStandard(NumericType& value) noexcept {
326 value *= static_cast<NumericType>(0.01L);
327}
328
329template <>
330template <typename NumericType>
331inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareInchPerSecond>::
332 FromStandard(NumericType& value) noexcept {
333 value /= static_cast<NumericType>(0.0254L) * static_cast<NumericType>(0.0254L);
334}
335
336template <>
337template <typename NumericType>
338inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareInchPerSecond>::
339 ToStandard(NumericType& value) noexcept {
340 value *= static_cast<NumericType>(0.0254L) * static_cast<NumericType>(0.0254L);
341}
342
343template <>
344template <typename NumericType>
345inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareCentimetrePerSecond>::
346 FromStandard(NumericType& value) noexcept {
347 value *= static_cast<NumericType>(10000.0L);
348}
349
350template <>
351template <typename NumericType>
352inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareCentimetrePerSecond>::
353 ToStandard(NumericType& value) noexcept {
354 value *= static_cast<NumericType>(0.0001L);
355}
356
357template <>
358template <typename NumericType>
359inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareMillimetrePerSecond>::
360 FromStandard(NumericType& value) noexcept {
361 value *= static_cast<NumericType>(1000000.0L);
362}
363
364template <>
365template <typename NumericType>
366inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareMillimetrePerSecond>::
367 ToStandard(NumericType& value) noexcept {
368 value *= static_cast<NumericType>(0.000001L);
369}
370
371template <>
372template <typename NumericType>
373inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareMilliinchPerSecond>::
374 FromStandard(NumericType& value) noexcept {
375 value /= static_cast<NumericType>(0.0000254L) * static_cast<NumericType>(0.0000254L);
376}
377
378template <>
379template <typename NumericType>
380inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareMilliinchPerSecond>::
381 ToStandard(NumericType& value) noexcept {
382 value *= static_cast<NumericType>(0.0000254L) * static_cast<NumericType>(0.0000254L);
383}
384
385template <>
386template <typename NumericType>
387inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareMicrometrePerSecond>::
388 FromStandard(NumericType& value) noexcept {
389 value *= static_cast<NumericType>(1000000000000.0L);
390}
391
392template <>
393template <typename NumericType>
394inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareMicrometrePerSecond>::
395 ToStandard(NumericType& value) noexcept {
396 value *= static_cast<NumericType>(0.000000000001L);
397}
398
399template <>
400template <typename NumericType>
401inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareMicroinchPerSecond>::
402 FromStandard(NumericType& value) noexcept {
403 value /= static_cast<NumericType>(0.0000000254L) * static_cast<NumericType>(0.0000000254L);
404}
405
406template <>
407template <typename NumericType>
408inline constexpr void Conversion<Unit::Diffusivity, Unit::Diffusivity::SquareMicroinchPerSecond>::
409 ToStandard(NumericType& value) noexcept {
410 value *= static_cast<NumericType>(0.0000000254L) * static_cast<NumericType>(0.0000000254L);
411}
412
413template <typename NumericType>
414inline const std::map<Unit::Diffusivity,
415 std::function<void(NumericType* const, const std::size_t size)>>
416 MapOfConversionsFromStandard<Unit::Diffusivity, NumericType>{
418 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareMetrePerSecond>::
419 FromStandard<NumericType> },
421 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareNauticalMilePerSecond>::
422 FromStandard<NumericType> },
424 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareMilePerSecond>::
425 FromStandard<NumericType> },
427 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareKilometrePerSecond>::
428 FromStandard<NumericType> },
430 Conversions<Unit::Diffusivity, Unit::Diffusivity::HectarePerSecond>::
431 FromStandard<NumericType> },
433 Conversions<Unit::Diffusivity, Unit::Diffusivity::AcrePerSecond>::FromStandard<NumericType>},
435 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareYardPerSecond>::
436 FromStandard<NumericType> },
438 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareFootPerSecond>::
439 FromStandard<NumericType> },
441 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareDecimetrePerSecond>::
442 FromStandard<NumericType> },
444 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareInchPerSecond>::
445 FromStandard<NumericType> },
447 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareCentimetrePerSecond>::
448 FromStandard<NumericType> },
450 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareMillimetrePerSecond>::
451 FromStandard<NumericType> },
453 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareMilliinchPerSecond>::
454 FromStandard<NumericType> },
456 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareMicrometrePerSecond>::
457 FromStandard<NumericType> },
459 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareMicroinchPerSecond>::
460 FromStandard<NumericType> },
461};
462
463template <typename NumericType>
464inline const std::map<Unit::Diffusivity,
465 std::function<void(NumericType* values, const std::size_t size)>>
466 MapOfConversionsToStandard<Unit::Diffusivity, NumericType>{
468 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareMetrePerSecond>::
469 ToStandard<NumericType> },
471 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareNauticalMilePerSecond>::
472 ToStandard<NumericType> },
474 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareMilePerSecond>::
475 ToStandard<NumericType> },
477 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareKilometrePerSecond>::
478 ToStandard<NumericType> },
480 Conversions<Unit::Diffusivity, Unit::Diffusivity::HectarePerSecond>::
481 ToStandard<NumericType> },
483 Conversions<Unit::Diffusivity, Unit::Diffusivity::AcrePerSecond>::ToStandard<NumericType>},
485 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareYardPerSecond>::
486 ToStandard<NumericType> },
488 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareFootPerSecond>::
489 ToStandard<NumericType> },
491 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareDecimetrePerSecond>::
492 ToStandard<NumericType> },
494 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareInchPerSecond>::
495 ToStandard<NumericType> },
497 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareCentimetrePerSecond>::
498 ToStandard<NumericType> },
500 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareMillimetrePerSecond>::
501 ToStandard<NumericType> },
503 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareMilliinchPerSecond>::
504 ToStandard<NumericType> },
506 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareMicrometrePerSecond>::
507 ToStandard<NumericType> },
509 Conversions<Unit::Diffusivity, Unit::Diffusivity::SquareMicroinchPerSecond>::
510 ToStandard<NumericType> },
511};
512
513} // namespace Internal
514
515} // namespace PhQ
516
517#endif // PHQ_UNIT_DIFFUSIVITY_HPP
Diffusivity
Diffusivity units.
@ SquareFootPerSecond
Square foot per second (ft^2/s) diffusivity unit.
@ SquareCentimetrePerSecond
Square centimetre per second (cm^2/s) diffusivity unit.
@ SquareDecimetrePerSecond
Square decimetre per second (dm^2/s) diffusivity unit.
@ SquareKilometrePerSecond
Square kilometre per second (km^2/s) diffusivity unit.
@ SquareMicrometrePerSecond
Square micrometre per second (μm^2/s) diffusivity unit.
@ HectarePerSecond
Hectare per second (ha/s) diffusivity unit.
@ SquareNauticalMilePerSecond
Square nautical mile per second (nmi^2/s) diffusivity unit.
@ SquareYardPerSecond
Square yard per second (yd^2/s) diffusivity unit.
@ SquareMilePerSecond
Square mile per second (mi^2/s) diffusivity unit.
@ SquareMillimetrePerSecond
Square millimetre per second (mm^2/s) diffusivity unit.
@ AcrePerSecond
Acre per second (ac/s) diffusivity unit.
@ SquareMilliinchPerSecond
Square milliinch per second (mil^2/s) diffusivity unit.
@ SquareMicroinchPerSecond
Square microinch per second (μin^2/s) diffusivity unit.
@ SquareInchPerSecond
Square inch per second (in^2/s) diffusivity unit.
@ SquareMetrePerSecond
Square metre per second (m^2/s) diffusivity 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