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
23#include <python/simulators/PyMain.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 {
35
37{
38private:
39 using TypeTag = Opm::Properties::TTag::FlowProblemTPFA;
41
42public:
43 PyBlackOilSimulator( const std::string& deckFilename);
45 std::shared_ptr<Opm::Deck> deck,
46 std::shared_ptr<Opm::EclipseState> state,
47 std::shared_ptr<Opm::Schedule> schedule,
48 std::shared_ptr<Opm::SummaryConfig> summary_config);
49 void advance(int report_step);
52 py::array_t<double> getFluidStateVariable(const std::string &name) const;
53 py::array_t<double> getCellVolumes();
54 double getDT();
55 py::array_t<double> getPorosity();
56 py::array_t<double> getPrimaryVariable(const std::string &variable) const;
57 py::array_t<int> getPrimaryVarMeaning(const std::string &variable) const;
58 std::map<std::string, int> getPrimaryVarMeaningMap(const std::string &variable) const;
59 int run();
61 py::array_t<double, py::array::c_style | py::array::forcecast> array);
63 const std::string &idx_name,
64 py::array_t<double,
65 py::array::c_style | py::array::forcecast> array);
66 void setupMpi(bool init_mpi, bool finalize_mpi);
67 int step();
69 int stepInit();
70
71private:
72 Opm::FlowMain<TypeTag>& getFlowMain() const;
73 PyFluidState<TypeTag>& getFluidState() const;
74 PyMaterialState<TypeTag>& getMaterialState() const;
75
76 const std::string deck_filename_;
77 bool has_run_init_ = false;
78 bool has_run_cleanup_ = false;
79 bool mpi_init_ = true;
80 bool mpi_finalize_ = true;
81 //bool debug_ = false;
82 // This *must* be declared before other pointers
83 // to simulator objects. This in order to deinitialize
84 // MPI at the correct time (ie after the other objects).
85 std::unique_ptr<Opm::PyMain> main_;
86
87 std::unique_ptr<Opm::FlowMain<TypeTag>> flow_main_;
88 Simulator* simulator_;
89 std::unique_ptr<PyFluidState<TypeTag>> fluid_state_;
90 std::unique_ptr<PyMaterialState<TypeTag>> material_state_;
91 std::shared_ptr<Opm::Deck> deck_;
92 std::shared_ptr<Opm::EclipseState> eclipse_state_;
93 std::shared_ptr<Opm::Schedule> schedule_;
94 std::shared_ptr<Opm::SummaryConfig> summary_config_;
95};
96
97} // namespace Opm::Pybind
98#endif // OPM_PY_BLACKOIL_SIMULATOR_HEADER_INCLUDED
Definition: PyBlackOilSimulator.hpp:37
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
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:235
This file provides the infrastructure to retrieve run-time parameters.
The Opm property system, traits with inheritance.