My Project
Loading...
Searching...
No Matches
PyBlackOilSimulator.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
20#ifndef OPM_PY_BLACKOIL_SIMULATOR_HEADER_INCLUDED
21#define OPM_PY_BLACKOIL_SIMULATOR_HEADER_INCLUDED
22
23#include <opm/simulators/flow/Main.hpp>
24#include <opm/simulators/flow/FlowMain.hpp>
25#include <opm/models/utils/propertysystem.hh>
26#include <opm/models/utils/parametersystem.hh>
27#include <opm/simulators/flow/python/Pybind11Exporter.hpp>
28#include <opm/simulators/flow/python/PyFluidState.hpp>
29#include <opm/simulators/flow/python/PyMaterialState.hpp>
30#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
31#include <opm/input/eclipse/Schedule/Schedule.hpp>
32#include <opm/input/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
33
34namespace Opm::Pybind {
36{
37private:
38 using TypeTag = Opm::Properties::TTag::FlowProblemTPFA;
39 using Simulator = Opm::GetPropType<TypeTag, Opm::Properties::Simulator>;
40
41public:
42 PyBlackOilSimulator( const std::string& deckFilename);
44 std::shared_ptr<Opm::Deck> deck,
45 std::shared_ptr<Opm::EclipseState> state,
46 std::shared_ptr<Opm::Schedule> schedule,
47 std::shared_ptr<Opm::SummaryConfig> summary_config);
48 void advance(int report_step);
49 bool checkSimulationFinished();
50 int currentStep();
51 py::array_t<double> getFluidStateVariable(const std::string &name) const;
52 py::array_t<double> getCellVolumes();
53 double getDT();
54 py::array_t<double> getPorosity();
55 py::array_t<double> getPrimaryVariable(const std::string &variable) const;
56 py::array_t<int> getPrimaryVarMeaning(const std::string &variable) const;
57 std::map<std::string, int> getPrimaryVarMeaningMap(const std::string &variable) const;
58 int run();
59 void setPorosity(
60 py::array_t<double, py::array::c_style | py::array::forcecast> array);
61 void setPrimaryVariable(
62 const std::string &idx_name,
63 py::array_t<double,
64 py::array::c_style | py::array::forcecast> array);
65 int step();
66 int stepCleanup();
67 int stepInit();
68
69private:
70 Opm::FlowMain<TypeTag>& getFlowMain() const;
71 PyFluidState<TypeTag>& getFluidState() const;
72 PyMaterialState<TypeTag>& getMaterialState() const;
73
74 const std::string deck_filename_;
75 bool has_run_init_ = false;
76 bool has_run_cleanup_ = false;
77 //bool debug_ = false;
78 // This *must* be declared before other pointers
79 // to simulator objects. This in order to deinitialize
80 // MPI at the correct time (ie after the other objects).
81 std::unique_ptr<Opm::Main> main_;
82
83 std::unique_ptr<Opm::FlowMain<TypeTag>> flow_main_;
84 Simulator* simulator_;
85 std::unique_ptr<PyFluidState<TypeTag>> fluid_state_;
86 std::unique_ptr<PyMaterialState<TypeTag>> material_state_;
87 std::shared_ptr<Opm::Deck> deck_;
88 std::shared_ptr<Opm::EclipseState> eclipse_state_;
89 std::shared_ptr<Opm::Schedule> schedule_;
90 std::shared_ptr<Opm::SummaryConfig> summary_config_;
91};
92
93} // namespace Opm::Pybind
94#endif // OPM_PY_BLACKOIL_SIMULATOR_HEADER_INCLUDED
Definition FlowMain.hpp:83
Definition PyBlackOilSimulator.hpp:36
Definition PyFluidState.hpp:35
Definition PyMaterialState.hpp:34