PyBlackOilSimulator.hpp
Go to the documentation of this file.
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
25#include <opm/models/utils/propertysystem.hh>
26#include <opm/models/utils/parametersystem.hh>
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);
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();
60 py::array_t<double, py::array::c_style | py::array::forcecast> array);
62 const std::string &idx_name,
63 py::array_t<double,
64 py::array::c_style | py::array::forcecast> array);
65 void setupMpi(bool init_mpi, bool finalize_mpi);
66 int step();
68 int stepInit();
69
70private:
71 Opm::FlowMain<TypeTag>& getFlowMain() const;
72 PyFluidState<TypeTag>& getFluidState() const;
73 PyMaterialState<TypeTag>& getMaterialState() const;
74
75 const std::string deck_filename_;
76 bool has_run_init_ = false;
77 bool has_run_cleanup_ = false;
78 bool mpi_init_ = true;
79 bool mpi_finalize_ = true;
80 //bool debug_ = false;
81 // This *must* be declared before other pointers
82 // to simulator objects. This in order to deinitialize
83 // MPI at the correct time (ie after the other objects).
84 std::unique_ptr<Opm::Main> main_;
85
86 std::unique_ptr<Opm::FlowMain<TypeTag>> flow_main_;
87 Simulator* simulator_;
88 std::unique_ptr<PyFluidState<TypeTag>> fluid_state_;
89 std::unique_ptr<PyMaterialState<TypeTag>> material_state_;
90 std::shared_ptr<Opm::Deck> deck_;
91 std::shared_ptr<Opm::EclipseState> eclipse_state_;
92 std::shared_ptr<Opm::Schedule> schedule_;
93 std::shared_ptr<Opm::SummaryConfig> summary_config_;
94};
95
96} // namespace Opm::Pybind
97#endif // OPM_PY_BLACKOIL_SIMULATOR_HEADER_INCLUDED
Definition: FlowMain.hpp:83
Definition: PyBlackOilSimulator.hpp:36
void setPorosity(py::array_t< double, py::array::c_style|py::array::forcecast > array)
PyBlackOilSimulator(std::shared_ptr< Opm::Deck > deck, std::shared_ptr< Opm::EclipseState > state, std::shared_ptr< Opm::Schedule > schedule, std::shared_ptr< Opm::SummaryConfig > summary_config)
py::array_t< double > getPorosity()
void setPrimaryVariable(const std::string &idx_name, py::array_t< double, py::array::c_style|py::array::forcecast > array)
void setupMpi(bool init_mpi, bool finalize_mpi)
py::array_t< double > getPrimaryVariable(const std::string &variable) const
py::array_t< double > getCellVolumes()
py::array_t< double > getFluidStateVariable(const std::string &name) const
py::array_t< int > getPrimaryVarMeaning(const std::string &variable) const
void advance(int report_step)
std::map< std::string, int > getPrimaryVarMeaningMap(const std::string &variable) const
PyBlackOilSimulator(const std::string &deckFilename)
Definition: PyFluidState.hpp:35
Definition: PyMaterialState.hpp:34
Definition: Pybind11Exporter.hpp:11