20 #ifndef GEOS_MATH_UNITS_HPP_
21 #define GEOS_MATH_UNITS_HPP_
25 #include "common/format/Format.hpp"
40 {
return kelvin - constants::zeroDegreesCelsiusInKelvin; }
47 {
return celsius + constants::zeroDegreesCelsiusInKelvin; }
113 default:
return "unknown [?]";
115 case Pressure:
return "pressure [Pa]";
118 case Distance:
return "distance [m]";
119 case Time:
return "time [s]";
120 case Viscosity:
return "viscosity [Pa*s]";
121 case Enthalpy:
return "enthalpy [J/kg]";
122 case Density:
return "density [kg/m3]";
124 case Mass:
return "mass [kg]";
125 case Mole:
return "mole [mol]";
126 case MassRate:
return "mass rate [kg/s]";
127 case MoleRate:
return "mole rate [mol/s]";
146 case Time:
return "s";
151 case Mass:
return "kg";
152 case Mole:
return "mol";
170 default:
return GEOS_FMT(
"value of {} [?]", value );
171 case Dimensionless:
return GEOS_FMT(
"value of {} [1]", value );
172 case Pressure:
return GEOS_FMT(
"pressure of {} [Pa]", value );
173 case Temperature:
return GEOS_FMT(
"temperature of {} [K]", value );
175 case Distance:
return GEOS_FMT(
"distance of {} [s]", value );
176 case Time:
return GEOS_FMT(
"time of {} [s]", value );
177 case Viscosity:
return GEOS_FMT(
"viscosity of {} [Pa*s]", value );
178 case Enthalpy:
return GEOS_FMT(
"enthalpy of {} [J/kg]", value );
179 case Density:
return GEOS_FMT(
"density of {} [kg/m3]", value );
180 case Solubility:
return GEOS_FMT(
"solubility of {} [g/L]", value );
181 case Mass:
return GEOS_FMT(
"mass of {} [kg]", value );
182 case Mole:
return GEOS_FMT(
"mole of {} [mol]", value );
183 case MassRate:
return GEOS_FMT(
"mass rate of {} [kg/s]", value );
184 case MoleRate:
return GEOS_FMT(
"mole rate of {} [mol/s]", value );
185 case Transmissibility:
return GEOS_FMT(
"transmissibility of {} [(Pa*s*rm3/s)/Pa]", value );
196 using Days = std::chrono::duration< int64_t, std::ratio_multiply< std::ratio< 24 >, std::chrono::hours::period > >;
198 using Years = std::chrono::duration< int64_t, std::ratio_multiply< YearDaysRatio, Days::period > >;
201 static constexpr
double YearDays = ( double )YearDaysRatio::num / YearDaysRatio::den;
239 TimeFormatInfo(
double totalSeconds,
int years,
int days,
int hours,
int minutes,
int seconds );
273 template<
typename DURATION >
276 using namespace std::chrono;
278 auto const totalYears = duration_cast< units::Years >( value );
279 auto const daysOut = duration_cast< units::Days >( value - totalYears );
280 auto const hoursOut = duration_cast< hours >( value - totalYears - daysOut );
281 auto const minutesOut = duration_cast< minutes >( value - totalYears - daysOut - hoursOut );
282 auto const secondsOut = duration_cast< seconds >( value - totalYears - daysOut - hoursOut - minutesOut );
284 return TimeFormatInfo( duration< double >( value ).count(),
int( totalYears.count() ),
285 int( daysOut.count() ),
int( hoursOut.count() ),
286 int( minutesOut.count() ),
int( secondsOut.count() ) );
298 struct GEOS_FMT_NS::formatter<
geos::units::TimeFormatInfo > : GEOS_FMT_NS::formatter< std::string >
308 return GEOS_FMT_NS::formatter< std::string >::format( durationData.
toString(), ctx );
#define GEOS_HOST_DEVICE
Marks a host-device function.
Regroups useful constants that are globally used for math and physics computations.
constexpr GEOS_HOST_DEVICE double convertCToK(double celsius)
std::chrono::duration< int64_t, std::ratio_multiply< YearDaysRatio, Days::period > > Years
Year helper duration type, equivalent to C++20 std::chrono::years.
std::ratio< 146097, 400 > YearDaysRatio
One year = 365.2425 days (= 146097 / 400) following the Gregorian calendar and the C++ convention.
constexpr std::string_view getDescription(Unit unit)
static constexpr double YearSeconds
Seconds in a year.
std::chrono::high_resolution_clock SystemClock
Clock in use in GEOS to manipulate system times.
constexpr GEOS_HOST_DEVICE double convertKToC(double kelvin)
Unit
Enumerator of available unit types. Units are in SI by default.
@ Transmissibility
Transmissibility in m2/s.
@ Distance
Distance in meter.
@ Density
Density in kg/m³
@ MoleRate
Mole rate in mol/s.
@ MassRate
Mass rate in kg/s.
@ TemperatureInC
Temperature in Celcius.
@ Viscosity
Viscosity in Pa*s.
@ Solubility
Solubility in g/L.
@ Pressure
Pressure in Pascal.
@ Enthalpy
Enthalpy in J/kg.
@ Dimensionless
Label to use when a value has not physical dimension (ratio values, propotions...)
@ Temperature
Temperature in Kelvin.
@ Unknown
Default label when a unit is not known for a value.
static constexpr double HourSeconds
Seconds in a hour.
static constexpr double MinuteSeconds
Seconds in a minute.
static constexpr double DaySeconds
Seconds in a day.
constexpr std::string_view getSymbol(Unit unit)
static constexpr double YearDays
Days in one year (following the Gregorian calendar and the C++ convention) = 365.2425 days (= 146097 ...
string formatValue(real64 value, Unit unit)
Format the specified value coherently with the specified unit.
std::chrono::duration< int64_t, std::ratio_multiply< std::ratio< 24 >, std::chrono::hours::period > > Days
Day helper duration type, equivalent to C++20 std::chrono::days.
double real64
64-bit floating point type.
std::int32_t integer
Signed integer type.
std::string_view string_view
String type.