File: unit_system.cpp

package info (click to toggle)
opm-common 2022.10%2Bds-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 78,468 kB
  • sloc: cpp: 164,554; python: 2,872; sh: 216; xml: 174; ansic: 149; pascal: 136; makefile: 12
file content (25 lines) | stat: -rw-r--r-- 831 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <fmt/format.h>

#include <opm/input/eclipse/Units/UnitSystem.hpp>

#include "export.hpp"


void python::common::export_UnitSystem(py::module& module)
{
    py::class_<UnitSystem>(module, "UnitSystem")
        .def_property_readonly( "name", &UnitSystem::getName );


    py::class_<Dimension>(module, "Dimension")
        .def_property_readonly("scaling", &Dimension::getSIScaling)
        .def_property_readonly("offset", &Dimension::getSIOffset)
        .def("__repr__", [](const Dimension& dim) {
            auto scaling = dim.getSIScaling();
            auto offset = dim.getSIOffset();
            if (dim.getSIOffset() != 0)
                return fmt::format("Dimension(scaling={}, offset={})", scaling, offset);
            else
                return fmt::format("Dimension(scaling={})", scaling);
        });
}