SPH
Classes | Enumerations | Functions | Variables
Units.h File Reference
#include "math/MathUtils.h"
#include "objects/containers/FlatMap.h"
#include "objects/containers/StaticArray.h"
#include "objects/utility/StringUtils.h"
#include "objects/wrappers/Expected.h"
#include "physics/Constants.h"

Go to the source code of this file.

Classes

class  UnitDimensions
 
class  UnitSystem
 
class  Unit
 Single benchmark unit. More...
 

Enumerations

enum class  BasicDimension { LENGTH , MASS , TIME , ANGLE }
 

Functions

Unit operator+ (const Unit &u1, const Unit &u2)
 
Unit operator- (const Unit &u1, const Unit &u2)
 
Unit operator* (const Unit &u, const Float f)
 
Unit operator* (const Float f, const Unit &u)
 
Unit operator* (const Unit &u1, const Unit &u2)
 
Unit operator/ (const Unit &u1, const Unit &u2)
 
INLINE Unit operator""_kg (long double value)
 
INLINE Unit operator""_g (long double value)
 
INLINE Unit operator""_m (long double value)
 
INLINE Unit operator""_cm (long double value)
 
INLINE Unit operator""_mm (long double value)
 
INLINE Unit operator""_km (long double value)
 
INLINE Unit operator""_s (long double value)
 
INLINE Unit operator""_rad (long double value)
 
INLINE Unit operator""_mps (long double value)
 
Expected< UnitparseUnit (const std::string &text)
 

Variables

constexpr Size DIMENSION_CNT = 4
 
UnitSystem CODE_UNITS
 

Enumeration Type Documentation

◆ BasicDimension

enum BasicDimension
strong

There are three different unit systems in the code: 1) Code units Currently selected unit system, used for actual computation in the code. Or more precisely, we don't use runtime dimensional analysis in the actual simulation for performance reasons, we convert the input quantities (values and units) into floats or doubles using the selected code units. These units determine the accuracy of the code; if a nanometer is selected as a unit of length in a simulation of protoplanetary disk, you can expect a loss of precision. Select the code units so that the typical values of quantities in your simulation correspond to the unit values of code units.

2) Reference units Unit system used as a reference for all conversions. Used for convenience as we do not want to define conversions between each pair of unit systems; for each unit system, we simply define its relation to the reference units. This is always SI, for simplicity.

3) Input/output units Selected units of input or output values.

Enumerator
LENGTH 
MASS 
TIME 
ANGLE 

Definition at line 29 of file Units.h.

Function Documentation

◆ operator""_cm()

INLINE Unit operator""_cm ( long double  value)

Definition at line 449 of file Units.h.

◆ operator""_g()

INLINE Unit operator""_g ( long double  value)

Definition at line 443 of file Units.h.

◆ operator""_kg()

INLINE Unit operator""_kg ( long double  value)

Definition at line 440 of file Units.h.

◆ operator""_km()

INLINE Unit operator""_km ( long double  value)

Definition at line 455 of file Units.h.

◆ operator""_m()

INLINE Unit operator""_m ( long double  value)

Definition at line 446 of file Units.h.

◆ operator""_mm()

INLINE Unit operator""_mm ( long double  value)

Definition at line 452 of file Units.h.

◆ operator""_mps()

INLINE Unit operator""_mps ( long double  value)

Definition at line 464 of file Units.h.

◆ operator""_rad()

INLINE Unit operator""_rad ( long double  value)

Definition at line 461 of file Units.h.

◆ operator""_s()

INLINE Unit operator""_s ( long double  value)

Definition at line 458 of file Units.h.

◆ operator*() [1/3]

Unit operator* ( const Float  f,
const Unit u 
)
inline

Definition at line 393 of file Units.h.

◆ operator*() [2/3]

Unit operator* ( const Unit u,
const Float  f 
)
inline

Definition at line 387 of file Units.h.

◆ operator*() [3/3]

Unit operator* ( const Unit u1,
const Unit u2 
)
inline

Definition at line 397 of file Units.h.

◆ operator+()

Unit operator+ ( const Unit u1,
const Unit u2 
)
inline

Definition at line 375 of file Units.h.

◆ operator-()

Unit operator- ( const Unit u1,
const Unit u2 
)
inline

Definition at line 381 of file Units.h.

◆ operator/()

Unit operator/ ( const Unit u1,
const Unit u2 
)
inline

Definition at line 403 of file Units.h.

◆ parseUnit()

Expected<Unit> parseUnit ( const std::string &  text)

Definition at line 86 of file Units.cpp.

Variable Documentation

◆ CODE_UNITS

UnitSystem CODE_UNITS
extern

Definition at line 6 of file Units.cpp.

◆ DIMENSION_CNT

constexpr Size DIMENSION_CNT = 4
constexpr

Definition at line 36 of file Units.h.