Loading...
Searching...
No Matches
Opm::unit::convert Namespace Reference

Unit conversion routines. More...

## Functions

constexpr double | from (const double q, const double unit)
| Convert from external units of measurements to equivalent internal units of measurements.
constexpr double | to (const double q, const double unit)
| Convert from internal units of measurements to equivalent external units of measurements.

## Detailed Description

Unit conversion routines.

## Function Documentation

## from()

constexpr double Opm::unit::convert::from | ( | const double | q,
|  | const double | unit
| ) |  |

constexpr

Convert from external units of measurements to equivalent internal units of measurements.

Note: The internal units of measurements are ALWAYS, and exclusively, SI.

Example: Convert a double `kx`, containing a permeability value in units of milli-darcy (mD) to the equivalent value in SI units (i.e., ).

using namespace Opm::unit;
using namespace Opm::prefix;
convert::from(kx, milli*darcy);
Opm::prefix
Conversion prefix for units.
Definition Units.hpp:59
Opm::unit::convert::from
constexpr double from(const double q, const double unit)
Convert from external units of measurements to equivalent internal units of measurements.
Definition Units.hpp:227
Opm::unit
Definition of various units.
Definition Units.hpp:84

Parameters

  [in] | q | Physical quantity.
  [in] | unit | Physical unit of measurement.

Returns
  Value of `q` in equivalent SI units of measurements.

## to()

constexpr double Opm::unit::convert::to | ( | const double | q,
|  | const double | unit
| ) |  |

constexpr

Convert from internal units of measurements to equivalent external units of measurements.

Note: The internal units of measurements are ALWAYS, and exclusively, SI.

Example: Convert a `std::vector<double> p`, containing pressure values in the SI unit Pascal (i.e., unit::Pascal) to the equivalent values in Psi (unit::psia).

using namespace Opm::unit;
std::transform(p.begin(), p.end(), p.begin(),
std::bind(convert::to, std::placeholders::_1, psia));
Opm::unit::convert::to
constexpr double to(const double q, const double unit)
Convert from internal units of measurements to equivalent external units of measurements.
Definition Units.hpp:250

Parameters

  [in] | q | Physical quantity, measured in SI units.
  [in] | unit | Physical unit of measurement.

Returns
  Value of `q` in unit `unit`.