My Project
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/FlowMainEbos.hpp>
25 #include <opm/models/utils/propertysystem.hh>
26 #include <opm/simulators/flow/python/Pybind11Exporter.hpp>
27 #include <opm/simulators/flow/python/PyMaterialState.hpp>
28 #include <opm/input/eclipse/EclipseState/EclipseState.hpp>
29 #include <opm/input/eclipse/Schedule/Schedule.hpp>
30 #include <opm/input/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
31 
32 namespace Opm::Pybind {
34 {
35 private:
36  using TypeTag = Opm::Properties::TTag::EclFlowProblemTPFA;
37  using Simulator = Opm::GetPropType<TypeTag, Opm::Properties::Simulator>;
38 
39 public:
40  PyBlackOilSimulator( const std::string& deckFilename);
42  std::shared_ptr<Opm::Deck> deck,
43  std::shared_ptr<Opm::EclipseState> state,
44  std::shared_ptr<Opm::Schedule> schedule,
45  std::shared_ptr<Opm::SummaryConfig> summary_config);
46  bool checkSimulationFinished();
47  py::array_t<double> getPorosity();
48  int run();
49  void setPorosity(
50  py::array_t<double, py::array::c_style | py::array::forcecast> array);
51  int step();
52  void advance(int report_step);
53  int currentStep();
54  int stepInit();
55  int stepCleanup();
56  const Opm::FlowMainEbos<TypeTag>& getFlowMainEbos() const;
57 
58 private:
59  const std::string deckFilename_;
60  bool hasRunInit_ = false;
61  bool hasRunCleanup_ = false;
62  bool debug_ = false;
63  // This *must* be declared before other pointers
64  // to simulator objects. This in order to deinitialize
65  // MPI at the correct time (ie after the other objects).
66  std::unique_ptr<Opm::Main> main_;
67 
68  std::unique_ptr<Opm::FlowMainEbos<TypeTag>> mainEbos_;
69  Simulator *ebosSimulator_;
70  std::unique_ptr<PyMaterialState<TypeTag>> materialState_;
71  std::shared_ptr<Opm::Deck> deck_;
72  std::shared_ptr<Opm::EclipseState> eclipse_state_;
73  std::shared_ptr<Opm::Schedule> schedule_;
74  std::shared_ptr<Opm::SummaryConfig> summary_config_;
75 };
76 
77 } // namespace Opm::Pybind
78 #endif // OPM_PY_BLACKOIL_SIMULATOR_HEADER_INCLUDED
Definition: FlowMainEbos.hpp:89
Definition: PyBlackOilSimulator.hpp:34