ParallelEclipseState.hpp
Go to the documentation of this file.
1/*
2 Copyright 2019 Equinor AS.
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#ifndef PARALLEL_ECLIPSE_STATE_HPP
20#define PARALLEL_ECLIPSE_STATE_HPP
21
22#include <dune/common/version.hh>
23#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
24#include <opm/input/eclipse/EclipseState/Grid/TranCalculator.hpp>
25#include <dune/common/parallel/mpihelper.hh>
26
28
29#include <functional>
30
31namespace Opm {
32
33
42class ParallelFieldPropsManager : public FieldPropsManager {
43public:
44 friend class ParallelEclipseState;
46 template<class Grid>
47 friend class PropsDataHandle;
48
51 ParallelFieldPropsManager(FieldPropsManager& manager);
52
55 ParallelFieldPropsManager(FieldPropsManager& manager, Parallel::Communication comm);
56
59 std::vector<int> actnum() const override;
60
63 void reset_actnum(const std::vector<int>& actnum) override;
64
66 std::vector<double> porv(bool global = false) const override;
67
70 const std::vector<int>& get_int(const std::string& keyword) const override;
71
74 const std::vector<double>& get_double(const std::string& keyword) const override;
75
79 std::vector<int> get_global_int(const std::string& keyword) const override;
80
84 std::vector<double> get_global_double(const std::string& keyword) const override;
85
88 bool has_int(const std::string& keyword) const override;
89
92 bool has_double(const std::string& keyword) const override;
93
95 std::vector<std::string> fip_regions() const override;
96
102 template<class T>
103 void resetCartesianMapper(const T* mapper)
104 {
105 m_activeSize = std::bind(&T::compressedSize, mapper);
106 m_local2Global = std::bind(&T::cartesianIndex, mapper,
107 std::placeholders::_1);
108 }
109
110 bool tran_active(const std::string& keyword) const override;
111
112 void apply_tran(const std::string& keyword, std::vector<double>& trans) const override;
113
114 void copyTran(const FieldPropsManager& from)
115 {
116 m_tran = from.getTran();
117 }
118
119 template<class Serializer>
120 void serializeOp(Serializer& serializer)
121 {
122 serializer(m_tran);
123 }
124
125protected:
126 std::map<std::string, Fieldprops::FieldData<int>> m_intProps;
127 std::map<std::string, Fieldprops::FieldData<double>> m_doubleProps;
128 FieldPropsManager& m_manager;
130 std::function<int(void)> m_activeSize;
131 std::function<int(const int)> m_local2Global;
132 std::unordered_map<std::string, Fieldprops::TranCalculator> m_tran;
133};
134
135
147class ParallelEclipseState : public EclipseState {
149 template<class Grid>
150 friend class PropsDataHandle;
151public:
154
158 ParallelEclipseState(const Deck& deck);
159
165
169
174
176 const FieldPropsManager& fieldProps() const override;
177
180 const FieldPropsManager& globalFieldProps() const override;
181
187
190 const EclipseGrid& getInputGrid() const override;
191
197 template<class T>
198 void resetCartesianMapper(const T* mapper)
199 {
200 m_fieldProps.resetCartesianMapper(mapper);
201 }
202private:
203 bool m_parProps = false;
204 ParallelFieldPropsManager m_fieldProps;
206};
207
208
209} // end namespace Opm
210#endif // PARALLEL_ECLIPSE_STATE_HPP
Parallel frontend to the EclipseState.
Definition: ParallelEclipseState.hpp:147
ParallelEclipseState(const Deck &deck)
Construct from a deck instance.
void switchToGlobalProps()
Switch to global field properties.
const EclipseGrid & getInputGrid() const override
Returns a const ref to the eclipse grid.
const FieldPropsManager & fieldProps() const override
Returns a const ref to current field properties.
ParallelEclipseState(Parallel::Communication comm)
Default constructor.
void computeFipRegionStatistics() override
Compute basic descriptive statistics about all FIP region sets.
void switchToDistributedProps()
Switch to distributed field properies.
const FieldPropsManager & globalFieldProps() const override
Returns a const ref to global field properties.
ParallelEclipseState(const Deck &deck, Parallel::Communication comm)
Construct from a deck instance.
void resetCartesianMapper(const T *mapper)
Resets the underlying cartesian mapper \detail This has to be the cartesian mapper of the distributed...
Definition: ParallelEclipseState.hpp:198
Parallel frontend to the field properties.
Definition: ParallelEclipseState.hpp:42
void resetCartesianMapper(const T *mapper)
Resets the underlying cartesian mapper \detail This has to be the cartesian mapper of the distributed...
Definition: ParallelEclipseState.hpp:103
std::unordered_map< std::string, Fieldprops::TranCalculator > m_tran
calculators map
Definition: ParallelEclipseState.hpp:132
std::map< std::string, Fieldprops::FieldData< int > > m_intProps
Map of integer properties in process-local compressed indices.
Definition: ParallelEclipseState.hpp:126
bool has_double(const std::string &keyword) const override
Check if a double property is available.
bool tran_active(const std::string &keyword) const override
std::vector< std::string > fip_regions() const override
Returns a list of registered FIP regions.
std::vector< int > actnum() const override
Returns actnum vector.
std::vector< double > porv(bool global=false) const override
Returns the pore volume vector.
std::vector< double > get_global_double(const std::string &keyword) const override
Returns a double property using global cartesian indices.
ParallelFieldPropsManager(FieldPropsManager &manager)
Constructor.
void serializeOp(Serializer &serializer)
Definition: ParallelEclipseState.hpp:120
bool has_int(const std::string &keyword) const override
Check if an integer property is available.
std::function< int(const int)> m_local2Global
mapping from local to global cartesian indices
Definition: ParallelEclipseState.hpp:131
void copyTran(const FieldPropsManager &from)
Definition: ParallelEclipseState.hpp:114
void apply_tran(const std::string &keyword, std::vector< double > &trans) const override
std::vector< int > get_global_int(const std::string &keyword) const override
Returns an int property using global cartesian indices.
const std::vector< double > & get_double(const std::string &keyword) const override
Returns a double property using compressed indices.
ParallelFieldPropsManager(FieldPropsManager &manager, Parallel::Communication comm)
Constructor.
void reset_actnum(const std::vector< int > &actnum) override
Reset the actnum vector.
FieldPropsManager & m_manager
Underlying field property manager (only used on root process).
Definition: ParallelEclipseState.hpp:128
std::map< std::string, Fieldprops::FieldData< double > > m_doubleProps
Map of double properties in process-local compressed indices.
Definition: ParallelEclipseState.hpp:127
Parallel::Communication m_comm
Collective communication handler.
Definition: ParallelEclipseState.hpp:129
const std::vector< int > & get_int(const std::string &keyword) const override
Returns an int property using compressed indices.
std::function< int(void)> m_activeSize
active size function of the grid
Definition: ParallelEclipseState.hpp:130
A Data handle to communicate the field properties during load balance.
Definition: PropsDataHandle.hpp:54
Dune::Communication< MPIComm > Communication
Definition: ParallelCommunication.hpp:30
Definition: BlackoilPhases.hpp:27