PyRunModule.hpp
Go to the documentation of this file.
1/*
2 Copyright 2020 Equinor ASA.
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef EMBEDDED_PYTHON
20error BUG: The PyRunModule.hpp header should *not* be included in a configuration without EMBEDDED_PYTHON
21#endif
22
23#ifndef OPM_PY_RUN_MODULE
24#define OPM_PY_RUN_MODULE
25
26#include <pybind11/embed.h>
27#include <pybind11/pybind11.h>
28namespace py = pybind11;
29
30#include <memory>
31#include <string>
33
34namespace Opm {
35
36class EclipseState;
37class Schedule;
38class SummaryState;
39
40
41class __attribute__((visibility("default"))) PyRunModule {
42public:
43 PyRunModule(std::shared_ptr<const Python> python, const std::string& fname);
44
45 bool run(EclipseState& ecl_state, Schedule& sched, std::size_t report_step, SummaryState& st);
46
47private:
48 py::object run_function = py::none();
49 std::shared_ptr<const Python> python_handle;
50 py::module module;
51 py::module opm_embedded;
52 py::dict storage;
53};
54
55}
56#endif
error BUG
Definition: PyRunModule.hpp:28
const char *const string
Definition: cJSON.h:170
Definition: EclipseState.hpp:63
Definition: Schedule.hpp:113
Definition: SummaryState.hpp:65
const std::string none
Definition: LogUtil.hpp:48
Definition: A.hpp:4
@ error
Definition: ActionValue.hpp:21
class __attribute__((visibility("default"))) PyRunModule
Definition: PyRunModule.hpp:41