python: added class UnitSystem.
This commit is contained in:
parent
32ac0034a7
commit
c0bd19c59e
@ -236,6 +236,7 @@ if (OPM_ENABLE_PYTHON)
|
||||
|
||||
add_custom_command(OUTPUT python/python/opm/libopmcommon_python.so
|
||||
DEPENDS
|
||||
python/cxx/unit_system.cpp
|
||||
python/cxx/connection.cpp
|
||||
python/cxx/converters.hpp
|
||||
python/cxx/deck.cpp
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
|
||||
|
||||
#include <pybind11/pybind11.h>
|
||||
#include "converters.hpp"
|
||||
@ -48,6 +49,15 @@ void python::common::export_Deck(py::module &module) {
|
||||
.def( "__getitem__", &getKeyword_string, ref_internal)
|
||||
.def( "__getitem__", &getKeyword_tuple, ref_internal)
|
||||
.def( "__str__", &str<Deck>)
|
||||
|
||||
.def("active_unit_system", [](const Deck& deck) -> const UnitSystem& {
|
||||
return deck.getActiveUnitSystem();
|
||||
} )
|
||||
|
||||
.def("default_unit_system", [](const Deck& deck) -> const UnitSystem& {
|
||||
return deck.getDefaultUnitSystem();
|
||||
} )
|
||||
|
||||
.def( "count", &count )
|
||||
;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
|
||||
void python::common::export_all(py::module& module) {
|
||||
export_UnitSystem(module);
|
||||
export_ParseContext(module);
|
||||
export_Parser(module);
|
||||
export_Deck(module);
|
||||
|
@ -14,6 +14,7 @@ const py::return_value_policy move = py::return_value_policy::move;
|
||||
|
||||
namespace python::common {
|
||||
void export_all(py::module& module);
|
||||
void export_UnitSystem(py::module& module);
|
||||
void export_Connection(py::module& module);
|
||||
void export_Deck(py::module& module);
|
||||
void export_DeckKeyword(py::module& module);
|
||||
|
10
python/cxx/unit_system.cpp
Normal file
10
python/cxx/unit_system.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
|
||||
|
||||
#include "export.hpp"
|
||||
|
||||
|
||||
void python::common::export_UnitSystem(py::module& module)
|
||||
{
|
||||
py::class_<UnitSystem>(module, "UnitSystem")
|
||||
.def_property_readonly( "type", &UnitSystem::getName );
|
||||
}
|
@ -51,6 +51,7 @@ ext_modules = [
|
||||
Extension(
|
||||
'libopmcommon_python',
|
||||
[
|
||||
'cxx/unit_system.cpp',
|
||||
'cxx/connection.cpp',
|
||||
'cxx/deck.cpp',
|
||||
'cxx/deck_keyword.cpp',
|
||||
|
@ -41,6 +41,9 @@ FIPNUM
|
||||
def test_create(self):
|
||||
parser = Parser()
|
||||
deck = parser.parse(self.spe3fn)
|
||||
active_unit_system = deck.active_unit_system()
|
||||
default_unit_system = deck.default_unit_system()
|
||||
self.assertEqual(active_unit_system.type, "Field")
|
||||
|
||||
context = ParseContext()
|
||||
deck = parser.parse(self.spe3fn, context)
|
||||
|
Loading…
Reference in New Issue
Block a user