File: unit_system.cpp

package info (click to toggle)
opm-common 2025.10%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 96,920 kB
  • sloc: cpp: 291,772; python: 3,609; sh: 198; xml: 174; pascal: 136; makefile: 12
file content (29 lines) | stat: -rw-r--r-- 1,064 bytes parent folder | download
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
26
27
28
29
#include <fmt/format.h>

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

#include "export.hpp"

#include <python/cxx/OpmCommonPythonDoc.hpp>

void python::common::export_UnitSystem(py::module& module)
{

    using namespace Opm::Common::DocStrings;

    py::class_<UnitSystem>(module, "UnitSystem", UnitSystem_docstring)
        .def_property_readonly( "name", &UnitSystem::getName, UnitSystem_name_docstring);


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