My Project
Loading...
Searching...
No Matches
PyRunModule.hpp
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 <filesystem>
31#include <functional>
32#include <memory>
33#include <string>
34#include <opm/input/eclipse/Python/Python.hpp>
35#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
36#include <opm/input/eclipse/Schedule/Schedule.hpp>
37#include <opm/input/eclipse/Schedule/SummaryState.hpp>
38
39namespace Opm {
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, const std::function<void(const std::string&, const std::vector<std::string>&)>& actionx_callback);
46
47private:
48 py::object run_function = py::none();
49 std::shared_ptr<const Python> python_handle;
50 py::module module;
51 std::filesystem::path module_path;
52 std::string module_name;
53 py::module opm_embedded;
54 py::dict storage;
55 bool executeInnerRunFunction(const std::function<void(const std::string&, const std::vector<std::string>&)>& actionx_callback);
56};
57
58}
59#endif
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30