Merge pull request #1011 from joakim-hove/python-namespace
Python namespace
This commit is contained in:
@@ -249,8 +249,8 @@ if (OPM_ENABLE_PYTHON)
|
||||
python/cxx/parsecontext.cpp
|
||||
python/cxx/parser.cpp
|
||||
python/cxx/schedule.cpp
|
||||
python/cxx/common.cpp
|
||||
python/cxx/common.hpp
|
||||
python/cxx/export.cpp
|
||||
python/cxx/export.hpp
|
||||
python/cxx/common_state.cpp
|
||||
python/cxx/common_state.hpp
|
||||
python/cxx/table_manager.cpp
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
#include <pybind11/pybind11.h>
|
||||
#include "common.hpp"
|
||||
|
||||
|
||||
PYBIND11_MODULE(libopmcommon_python, module) {
|
||||
opmcommon_python::export_ParseContext(module);
|
||||
opmcommon_python::export_Parser(module);
|
||||
opmcommon_python::export_Deck(module);
|
||||
opmcommon_python::export_DeckKeyword(module);
|
||||
opmcommon_python::export_Schedule(module);
|
||||
opmcommon_python::export_Well(module);
|
||||
opmcommon_python::export_Group(module);
|
||||
opmcommon_python::export_GroupTree(module);
|
||||
opmcommon_python::export_Connection(module);
|
||||
opmcommon_python::export_EclipseConfig(module);
|
||||
opmcommon_python::export_Eclipse3DProperties(module);
|
||||
opmcommon_python::export_EclipseState(module);
|
||||
opmcommon_python::export_TableManager(module);
|
||||
opmcommon_python::export_EclipseGrid(module);
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
#ifndef SUNBEAM_HPP
|
||||
#define SUNBEAM_HPP
|
||||
|
||||
#include <pybind11/pybind11.h>
|
||||
|
||||
namespace Opm { }
|
||||
namespace py = pybind11;
|
||||
|
||||
using namespace Opm;
|
||||
const py::return_value_policy ref_internal = py::return_value_policy::reference_internal;
|
||||
const py::return_value_policy python_owner = py::return_value_policy::take_ownership;
|
||||
const py::return_value_policy move = py::return_value_policy::move;
|
||||
|
||||
namespace opmcommon_python {
|
||||
|
||||
void export_Connection(py::module& module);
|
||||
void export_Deck(py::module& module);
|
||||
void export_DeckKeyword(py::module& module);
|
||||
void export_Eclipse3DProperties(py::module& module);
|
||||
void export_EclipseConfig(py::module& module);
|
||||
void export_EclipseGrid(py::module& module);
|
||||
void export_EclipseState(py::module& module);
|
||||
void export_Group(py::module& module);
|
||||
void export_GroupTree(py::module& module);
|
||||
void export_ParseContext(py::module& module);
|
||||
void export_Parser(py::module& module);
|
||||
void export_Schedule(py::module& module);
|
||||
void export_TableManager(py::module& module);
|
||||
void export_Well(py::module& module);
|
||||
}
|
||||
|
||||
#endif //SUNBEAM_HPP
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Connection.hpp>
|
||||
|
||||
#include "common.hpp"
|
||||
#include "export.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -15,7 +15,7 @@ std::string direction( const Connection& c ) {
|
||||
}
|
||||
|
||||
|
||||
void opmcommon_python::export_Connection(py::module& module) {
|
||||
void python::common::export_Connection(py::module& module) {
|
||||
|
||||
py::class_< Connection >( module, "Connection")
|
||||
.def_property_readonly("direction", &direction )
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <pybind11/pybind11.h>
|
||||
#include "converters.hpp"
|
||||
#include "common.hpp"
|
||||
#include "export.hpp"
|
||||
|
||||
|
||||
namespace {
|
||||
@@ -37,7 +37,7 @@ namespace {
|
||||
|
||||
}
|
||||
|
||||
void opmcommon_python::export_Deck(py::module &module) {
|
||||
void python::common::export_Deck(py::module &module) {
|
||||
|
||||
py::class_< Deck >(module, "Deck")
|
||||
.def( "__len__", &size )
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
|
||||
#include <opm/parser/eclipse/Utility/Typetools.hpp>
|
||||
|
||||
#include "common.hpp"
|
||||
#include "export.hpp"
|
||||
#include "converters.hpp"
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ struct DeckRecordIterator
|
||||
|
||||
}
|
||||
|
||||
void opmcommon_python::export_DeckKeyword(py::module& module) {
|
||||
void python::common::export_DeckKeyword(py::module& module) {
|
||||
py::class_< DeckKeyword >( module, "DeckKeyword")
|
||||
.def( "__repr__", &DeckKeyword::name )
|
||||
.def( "__str__", &str<DeckKeyword> )
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
#include "common.hpp"
|
||||
#include "export.hpp"
|
||||
#include "converters.hpp"
|
||||
|
||||
namespace {
|
||||
@@ -35,7 +35,7 @@ namespace {
|
||||
|
||||
}
|
||||
|
||||
void opmcommon_python::export_Eclipse3DProperties(py::module& module) {
|
||||
void python::common::export_Eclipse3DProperties(py::module& module) {
|
||||
|
||||
py::class_< Eclipse3DProperties >( module, "Eclipse3DProperties")
|
||||
.def( "getRegions", ®ions )
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
#include <opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp>
|
||||
|
||||
#include "common.hpp"
|
||||
#include "export.hpp"
|
||||
|
||||
|
||||
void opmcommon_python::export_EclipseConfig(py::module& module)
|
||||
void python::common::export_EclipseConfig(py::module& module)
|
||||
{
|
||||
py::class_< EclipseConfig >( module, "EclipseConfig" )
|
||||
.def( "init", &EclipseConfig::init, ref_internal)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/Fault.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/FaceDir.hpp>
|
||||
|
||||
#include "common.hpp"
|
||||
#include "export.hpp"
|
||||
|
||||
|
||||
namespace {
|
||||
@@ -41,7 +41,7 @@ namespace {
|
||||
|
||||
}
|
||||
|
||||
void opmcommon_python::export_EclipseGrid(py::module& module) {
|
||||
void python::common::export_EclipseGrid(py::module& module) {
|
||||
|
||||
py::class_< EclipseGrid >( module, "EclipseGrid")
|
||||
.def( "_getXYZ", &getXYZ )
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/FaultCollection.hpp>
|
||||
|
||||
#include "common.hpp"
|
||||
#include "export.hpp"
|
||||
|
||||
|
||||
namespace {
|
||||
@@ -85,7 +85,7 @@ namespace {
|
||||
|
||||
}
|
||||
|
||||
void opmcommon_python::export_EclipseState(py::module& module) {
|
||||
void python::common::export_EclipseState(py::module& module) {
|
||||
|
||||
py::class_< EclipseState >( module, "EclipseState" )
|
||||
.def_property_readonly( "title", &EclipseState::getTitle )
|
||||
|
||||
25
python/cxx/export.cpp
Normal file
25
python/cxx/export.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <pybind11/pybind11.h>
|
||||
#include "export.hpp"
|
||||
|
||||
|
||||
void python::common::export_all(py::module& module) {
|
||||
export_ParseContext(module);
|
||||
export_Parser(module);
|
||||
export_Deck(module);
|
||||
export_DeckKeyword(module);
|
||||
export_Schedule(module);
|
||||
export_Well(module);
|
||||
export_Group(module);
|
||||
export_GroupTree(module);
|
||||
export_Connection(module);
|
||||
export_EclipseConfig(module);
|
||||
export_Eclipse3DProperties(module);
|
||||
export_EclipseState(module);
|
||||
export_TableManager(module);
|
||||
export_EclipseGrid(module);
|
||||
}
|
||||
|
||||
|
||||
PYBIND11_MODULE(libopmcommon_python, module) {
|
||||
python::common::export_all(module);
|
||||
}
|
||||
33
python/cxx/export.hpp
Normal file
33
python/cxx/export.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef SUNBEAM_HPP
|
||||
#define SUNBEAM_HPP
|
||||
|
||||
#include <pybind11/pybind11.h>
|
||||
|
||||
namespace Opm {}
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
using namespace Opm;
|
||||
const py::return_value_policy ref_internal = py::return_value_policy::reference_internal;
|
||||
const py::return_value_policy python_owner = py::return_value_policy::take_ownership;
|
||||
const py::return_value_policy move = py::return_value_policy::move;
|
||||
|
||||
namespace python::common {
|
||||
void export_all(py::module& module);
|
||||
void export_Connection(py::module& module);
|
||||
void export_Deck(py::module& module);
|
||||
void export_DeckKeyword(py::module& module);
|
||||
void export_Eclipse3DProperties(py::module& module);
|
||||
void export_EclipseConfig(py::module& module);
|
||||
void export_EclipseGrid(py::module& module);
|
||||
void export_EclipseState(py::module& module);
|
||||
void export_Group(py::module& module);
|
||||
void export_GroupTree(py::module& module);
|
||||
void export_ParseContext(py::module& module);
|
||||
void export_Parser(py::module& module);
|
||||
void export_Schedule(py::module& module);
|
||||
void export_TableManager(py::module& module);
|
||||
void export_Well(py::module& module);
|
||||
}
|
||||
|
||||
#endif //SUNBEAM_HPP
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group2.hpp>
|
||||
#include <pybind11/stl.h>
|
||||
#include "common.hpp"
|
||||
#include "export.hpp"
|
||||
|
||||
|
||||
namespace {
|
||||
@@ -14,7 +14,7 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
void opmcommon_python::export_Group(py::module& module) {
|
||||
void python::common::export_Group(py::module& module) {
|
||||
|
||||
py::class_< Group2 >( module, "Group")
|
||||
.def_property_readonly( "name", &Group2::name)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GTNode.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||
|
||||
#include "common.hpp"
|
||||
#include "export.hpp"
|
||||
#include "converters.hpp"
|
||||
|
||||
namespace {
|
||||
@@ -15,7 +15,7 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
void opmcommon_python::export_GroupTree(py::module& module) {
|
||||
void python::common::export_GroupTree(py::module& module) {
|
||||
|
||||
py::class_<GTNode>(module, "GroupTree")
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
#include "common_state.hpp"
|
||||
#include "common.hpp"
|
||||
#include "export.hpp"
|
||||
|
||||
|
||||
namespace {
|
||||
@@ -12,7 +12,7 @@ namespace {
|
||||
|
||||
}
|
||||
|
||||
void opmcommon_python::export_ParseContext(py::module& module) {
|
||||
void python::common::export_ParseContext(py::module& module) {
|
||||
|
||||
py::class_< ParseContext >(module, "ParseContext" )
|
||||
.def(py::init<>())
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
#include "common_state.hpp"
|
||||
#include "common.hpp"
|
||||
#include "export.hpp"
|
||||
|
||||
|
||||
namespace {
|
||||
@@ -51,7 +51,7 @@ namespace {
|
||||
|
||||
}
|
||||
|
||||
void opmcommon_python::export_Parser(py::module& module) {
|
||||
void python::common::export_Parser(py::module& module) {
|
||||
|
||||
module.def( "parse", parse_file );
|
||||
module.def( "parse_string", parse_string);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <pybind11/stl.h>
|
||||
#include <pybind11/chrono.h>
|
||||
#include "common.hpp"
|
||||
#include "export.hpp"
|
||||
|
||||
|
||||
namespace {
|
||||
@@ -90,7 +90,7 @@ namespace {
|
||||
|
||||
}
|
||||
|
||||
void opmcommon_python::export_Schedule(py::module& module) {
|
||||
void python::common::export_Schedule(py::module& module) {
|
||||
|
||||
py::class_< Schedule >( module, "Schedule")
|
||||
.def("_groups", &get_groups )
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
|
||||
|
||||
#include "common.hpp"
|
||||
#include "export.hpp"
|
||||
|
||||
|
||||
namespace {
|
||||
@@ -16,7 +16,7 @@ namespace {
|
||||
|
||||
}
|
||||
|
||||
void opmcommon_python::export_TableManager(py::module& module) {
|
||||
void python::common::export_TableManager(py::module& module) {
|
||||
|
||||
py::class_< TableManager >( module, "Tables")
|
||||
.def( "__contains__", &TableManager::hasTables )
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well2.hpp>
|
||||
#include <pybind11/stl.h>
|
||||
#include "common.hpp"
|
||||
#include "export.hpp"
|
||||
|
||||
|
||||
namespace {
|
||||
@@ -33,7 +33,7 @@ namespace {
|
||||
|
||||
}
|
||||
|
||||
void opmcommon_python::export_Well(py::module& module) {
|
||||
void python::common::export_Well(py::module& module) {
|
||||
|
||||
py::class_< Well2 >( module, "Well")
|
||||
.def_property_readonly( "name", &Well2::name )
|
||||
|
||||
@@ -65,7 +65,7 @@ ext_modules = [
|
||||
'cxx/common_state.cpp',
|
||||
'cxx/table_manager.cpp',
|
||||
'cxx/well.cpp',
|
||||
'cxx/common.cpp'
|
||||
'cxx/export.cpp'
|
||||
],
|
||||
libraries=['opmcommon', 'boost_filesystem', 'boost_regex', 'ecl'],
|
||||
language='c++',
|
||||
|
||||
Reference in New Issue
Block a user