specfem::units::Quantity¶
Dim¶
-
template<int M, int L, int T, int A = 0>
struct Dim¶ Compile-time physical dimension representation.
Encodes dimensional exponents for mass, length, time, and angle. The angle dimension distinguishes frequency types (Hertz vs Omega).
- Template Parameters:
M – Mass exponent
L – Length exponent
T – Time exponent
A – Angle exponent (0 for Hertz, 1 for rad/s)
Quantity¶
-
template<typename D, typename Scale = std::ratio<1, 1>>
class Quantity¶ Type-safe physical quantity with compile-time dimensional analysis.
Represents a physical quantity with dimensions D and scale factor Scale. Prevents unit mismatches at compile time through template parameters. Arithmetic operations preserve dimensional correctness.
Meters distance(100.0); Seconds time(10.0); Velocity speed = distance / time; // Returns Velocity(10.0)
- Template Parameters:
D – Dimension type (Dim<M,L,T,A>)
Scale – Unit scale as std::ratio (default: 1/1 for SI base units)
Public Functions
-
inline explicit constexpr Quantity(type_real v = 0.0) noexcept¶
Construct a quantity from a raw value.
- Parameters:
v – Value in the specified units (default: 0.0)
-
inline constexpr type_real raw() const noexcept¶
Extract the raw numeric value.
Explicit method to emphasize stripping units is intentional.
- Returns:
constexpr type_real Numeric value without units
-
inline explicit constexpr operator type_real() const noexcept¶
Explicit conversion to raw numeric value.
- Returns:
constexpr type_real Numeric value without units
ratio_value¶
specfem::units::SI Dimensions¶
Warning
doxygennamespace: Cannot find namespace “specfem::units::SI” in doxygen xml output for project “specfem++” from directory: _build/doxygen/xml
Named Quantities¶
Warning
doxygentypedef: Cannot find typedef “specfem::units::Dimensionless” in doxygen xml output for project “specfem++” from directory: _build/doxygen/xml
-
using specfem::units::Kilometers = Quantity<SI::DimLength, std::ratio<1000, 1>>¶
Length in kilometers.
-
using specfem::units::KilogramPerCubicMeter = Quantity<SI::DimDensity, std::ratio<1000, 1>>¶
Density ( \( < \mathrm{kg/m^3} \))