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/parser/eclipse/Deck/Deck.hpp>
29 #include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
30 #include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
31 #include <opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
32 
33 namespace Opm::Pybind {
35 {
36 private:
38  using Simulator = Opm::GetPropType<TypeTag, Opm::Properties::Simulator>;
39 
40 public:
41  PyBlackOilSimulator( const std::string& deckFilename);
43  std::shared_ptr<Opm::Deck> deck,
44  std::shared_ptr<Opm::EclipseState> state,
45  std::shared_ptr<Opm::Schedule> schedule,
46  std::shared_ptr<Opm::SummaryConfig> summary_config);
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  int stepInit();
53  int stepCleanup();
54  const Opm::FlowMainEbos<TypeTag>& getFlowMainEbos() const;
55 
56 private:
57  const std::string deckFilename_;
58  bool hasRunInit_ = false;
59  bool hasRunCleanup_ = false;
60 
61  // This *must* be declared before other pointers
62  // to simulator objects. This in order to deinitialize
63  // MPI at the correct time (ie after the other objects).
64  std::unique_ptr<Opm::Main> main_;
65 
66  std::unique_ptr<Opm::FlowMainEbos<TypeTag>> mainEbos_;
67  Simulator *ebosSimulator_;
68  std::unique_ptr<PyMaterialState<TypeTag>> materialState_;
69  std::shared_ptr<Opm::Deck> deck_;
70  std::shared_ptr<Opm::EclipseState> eclipse_state_;
71  std::shared_ptr<Opm::Schedule> schedule_;
72  std::shared_ptr<Opm::SummaryConfig> summary_config_;
73 };
74 
75 } // namespace Opm::Pybind
76 #endif // OPM_PY_BLACKOIL_SIMULATOR_HEADER_INCLUDED
Definition: FlowMainEbos.hpp:87
Definition: PyBlackOilSimulator.hpp:35
Definition: BlackoilModelEbos.hpp:75