opm-common
Toggle main menu visibility
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
20
error 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>
28
namespace
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
39
namespace
Opm
{
40
41
class
__attribute__((visibility(
"default"
))) PyRunModule {
42
public
:
43
PyRunModule(std::shared_ptr<const Python> python,
const
std::string& fname);
44
45
bool
run(EclipseState& ecl_state,
46
Schedule& sched,
47
std::size_t report_step,
48
SummaryState& st,
49
const
std::function<
void
(
const
std::string&,
const
std::vector<std::string>&)>& actionx_callback,
50
const
std::unordered_map<std::string, double>& target_wellpi = {});
51
52
private
:
53
py::object run_function = py::none();
54
std::shared_ptr<const Python> python_handle;
55
py::module module;
56
std::filesystem::path module_path;
57
std::string module_name;
58
py::module opm_embedded;
59
py::dict storage;
60
bool
executeInnerRunFunction(
const
std::function<
void
(
const
std::string&,
const
std::vector<std::string>&)>& actionx_callback);
61
};
62
63
}
64
#endif
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition
Exceptions.hpp:30
opm
input
eclipse
Python
PyRunModule.hpp
Generated by
1.17.0