CollectDataOnIORank.hpp
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
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 2 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 Consult the COPYING file in the top-level source directory of this
20 module for the precise wording of the license and the list of
21 copyright holders.
22*/
23#ifndef OPM_COLLECT_DATA_ON_IO_RANK_HPP
24#define OPM_COLLECT_DATA_ON_IO_RANK_HPP
25
26#include <opm/grid/common/p2pcommunicator.hh>
27
28#include <opm/input/eclipse/Schedule/Well/WellTestState.hpp>
29
30#include <opm/output/data/Aquifer.hpp>
31#include <opm/output/data/Cells.hpp>
32#include <opm/output/data/Groups.hpp>
33#include <opm/output/data/Solution.hpp>
34#include <opm/output/data/Wells.hpp>
35
38
39#include <array>
40#include <cstddef>
41#include <map>
42#include <set>
43#include <string>
44#include <tuple>
45#include <type_traits>
46#include <utility>
47#include <vector>
48
49namespace Dune {
50template<class Grid> class CartesianIndexMapper;
51}
52
53namespace Opm {
54
55template <class Grid, class EquilGrid, class GridView>
57{
58public:
60 using P2PCommunicatorType = Dune::Point2PointCommunicator<Dune::SimpleMessageBuffer>;
61 using IndexMapType = std::vector<int>;
62 using IndexMapStorageType = std::vector<IndexMapType>;
63
64 static constexpr int dimension = Grid::dimension;
65
66 enum { ioRank = 0 };
67
68 static const bool needsReordering =
69 !std::is_same<Grid, EquilGrid>::value;
70
71 CollectDataOnIORank(const Grid& grid,
72 const EquilGrid* equilGrid,
73 const GridView& gridView,
74 const Dune::CartesianIndexMapper<Grid>& cartMapper,
75 const Dune::CartesianIndexMapper<EquilGrid>* equilCartMapper,
76 const std::set<std::string>& fipRegionsInterregFlow = {});
77
78 // gather solution to rank 0 for EclipseWriter
79 void collect(const data::Solution& localCellData,
80 const std::map<std::pair<std::string, int>, double>& localBlockData,
81 std::map<std::pair<std::string, int>, double>& localExtraBlockData,
82 const data::Wells& localWellData,
83 const data::WellBlockAveragePressures& localWBPData,
84 const data::GroupAndNetworkValues& localGroupAndNetworkData,
85 const data::Aquifers& localAquiferData,
86 const WellTestState& localWellTestState,
87 const InterRegFlowMap& interRegFlows,
88 const std::array<FlowsData<double>, 3>& localFlowsn,
89 const std::array<FlowsData<double>, 3>& localFloresn,
90 const std::map<std::tuple<std::string, int, int>, double>& localLgrBlockData);
91
92 const std::map<std::pair<std::string, int>, double>& globalBlockData() const
93 { return globalBlockData_; }
94
95 const std::map<std::tuple<std::string, int, int>, double>& globalLgrBlockData() const
96 { return globalLgrBlockData_; }
97
98 const data::Solution& globalCellData() const
99 { return globalCellData_; }
100
101 data::Solution& globalCellData()
102 { return globalCellData_; }
103
104 const data::Wells& globalWellData() const
105 { return globalWellData_; }
106
107 const data::WellBlockAveragePressures& globalWBPData() const
108 { return this->globalWBPData_; }
109
110 const data::GroupAndNetworkValues& globalGroupAndNetworkData() const
112
113 const data::Aquifers& globalAquiferData() const
114 { return globalAquiferData_; }
115
116 const WellTestState& globalWellTestState() const
117 { return this->globalWellTestState_; }
118
120 { return this->globalInterRegFlows_; }
121
123 { return this->globalInterRegFlows_; }
124
125 const std::array<FlowsData<double>, 3>& globalFlowsn() const
126 { return globalFlowsn_; }
127
128 const std::array<FlowsData<double>, 3>& globalFloresn() const
129 { return globalFloresn_; }
130
131 bool isIORank() const
132 { return toIORankComm_.rank() == ioRank; }
133
134 bool isParallel() const
135 { return toIORankComm_.size() > 1; }
136
137 int localIdxToGlobalIdx(unsigned localIdx) const;
138
139 const std::vector<int>& localIdxToGlobalIdxMapping() const
140 {
142 }
143
145 { return needsReordering;}
146
147 std::size_t numCells () const
148 { return globalCartesianIndex_.size(); }
149
150 const std::vector<int>& globalRanks() const
151 { return globalRanks_; }
152
153 bool isCartIdxOnThisRank(int cartIdx) const;
154
155protected:
161 std::vector<int> globalRanks_;
162 data::Solution globalCellData_;
163 std::map<std::pair<std::string, int>, double> globalBlockData_;
164 std::map<std::tuple<std::string, int, int>, double> globalLgrBlockData_;
165 data::Wells globalWellData_;
166 data::WellBlockAveragePressures globalWBPData_;
167 data::GroupAndNetworkValues globalGroupAndNetworkData_;
168 data::Aquifers globalAquiferData_;
169 WellTestState globalWellTestState_;
170 std::vector<int> localIdxToGlobalIdx_;
171 std::array<FlowsData<double>, 3> globalFlowsn_;
172 std::array<FlowsData<double>, 3> globalFloresn_;
176 std::vector<int> sortedCartesianIdx_;
177};
178
179} // end namespace Opm
180
181#endif // OPM_COLLECT_DATA_ON_IO_RANK_HPP
Definition: CollectDataOnIORank.hpp:50
Definition: CollectDataOnIORank.hpp:57
const data::Wells & globalWellData() const
Definition: CollectDataOnIORank.hpp:104
std::array< FlowsData< double >, 3 > globalFlowsn_
Definition: CollectDataOnIORank.hpp:171
std::vector< IndexMapType > IndexMapStorageType
Definition: CollectDataOnIORank.hpp:62
std::vector< int > localIdxToGlobalIdx_
Definition: CollectDataOnIORank.hpp:170
IndexMapStorageType indexMaps_
Definition: CollectDataOnIORank.hpp:160
data::Solution & globalCellData()
Definition: CollectDataOnIORank.hpp:101
std::vector< int > sortedCartesianIdx_
sorted list of cartesian indices present-
Definition: CollectDataOnIORank.hpp:176
static const bool needsReordering
Definition: CollectDataOnIORank.hpp:68
const data::GroupAndNetworkValues & globalGroupAndNetworkData() const
Definition: CollectDataOnIORank.hpp:110
data::GroupAndNetworkValues globalGroupAndNetworkData_
Definition: CollectDataOnIORank.hpp:167
const std::map< std::tuple< std::string, int, int >, double > & globalLgrBlockData() const
Definition: CollectDataOnIORank.hpp:95
int localIdxToGlobalIdx(unsigned localIdx) const
Definition: CollectDataOnIORank_impl.hpp:1197
typename Grid::Communication CollectiveCommunication
Definition: CollectDataOnIORank.hpp:59
data::WellBlockAveragePressures globalWBPData_
Definition: CollectDataOnIORank.hpp:166
InterRegFlowMap globalInterRegFlows_
Definition: CollectDataOnIORank.hpp:157
P2PCommunicatorType toIORankComm_
Definition: CollectDataOnIORank.hpp:156
WellTestState globalWellTestState_
Definition: CollectDataOnIORank.hpp:169
InterRegFlowMap & globalInterRegFlows()
Definition: CollectDataOnIORank.hpp:119
bool isParallel() const
Definition: CollectDataOnIORank.hpp:134
bool isIORank() const
Definition: CollectDataOnIORank.hpp:131
data::Solution globalCellData_
Definition: CollectDataOnIORank.hpp:162
bool isCartIdxOnThisRank(int cartIdx) const
Definition: CollectDataOnIORank_impl.hpp:1216
@ ioRank
Definition: CollectDataOnIORank.hpp:66
std::vector< int > globalRanks_
Definition: CollectDataOnIORank.hpp:161
const data::WellBlockAveragePressures & globalWBPData() const
Definition: CollectDataOnIORank.hpp:107
const data::Aquifers & globalAquiferData() const
Definition: CollectDataOnIORank.hpp:113
const std::map< std::pair< std::string, int >, double > & globalBlockData() const
Definition: CollectDataOnIORank.hpp:92
Dune::Point2PointCommunicator< Dune::SimpleMessageBuffer > P2PCommunicatorType
Definition: CollectDataOnIORank.hpp:60
data::Aquifers globalAquiferData_
Definition: CollectDataOnIORank.hpp:168
data::Wells globalWellData_
Definition: CollectDataOnIORank.hpp:165
const std::array< FlowsData< double >, 3 > & globalFlowsn() const
Definition: CollectDataOnIORank.hpp:125
bool doesNeedReordering() const
Definition: CollectDataOnIORank.hpp:144
CollectDataOnIORank(const Grid &grid, const EquilGrid *equilGrid, const GridView &gridView, const Dune::CartesianIndexMapper< Grid > &cartMapper, const Dune::CartesianIndexMapper< EquilGrid > *equilCartMapper, const std::set< std::string > &fipRegionsInterregFlow={})
Definition: CollectDataOnIORank_impl.hpp:929
IndexMapType localIndexMap_
Definition: CollectDataOnIORank.hpp:159
const std::vector< int > & globalRanks() const
Definition: CollectDataOnIORank.hpp:150
const WellTestState & globalWellTestState() const
Definition: CollectDataOnIORank.hpp:116
const data::Solution & globalCellData() const
Definition: CollectDataOnIORank.hpp:98
std::map< std::pair< std::string, int >, double > globalBlockData_
Definition: CollectDataOnIORank.hpp:163
static constexpr int dimension
Definition: CollectDataOnIORank.hpp:64
std::array< FlowsData< double >, 3 > globalFloresn_
Definition: CollectDataOnIORank.hpp:172
std::vector< int > IndexMapType
Definition: CollectDataOnIORank.hpp:61
std::size_t numCells() const
Definition: CollectDataOnIORank.hpp:147
const std::vector< int > & localIdxToGlobalIdxMapping() const
Definition: CollectDataOnIORank.hpp:139
IndexMapType globalCartesianIndex_
Definition: CollectDataOnIORank.hpp:158
void collect(const data::Solution &localCellData, const std::map< std::pair< std::string, int >, double > &localBlockData, std::map< std::pair< std::string, int >, double > &localExtraBlockData, const data::Wells &localWellData, const data::WellBlockAveragePressures &localWBPData, const data::GroupAndNetworkValues &localGroupAndNetworkData, const data::Aquifers &localAquiferData, const WellTestState &localWellTestState, const InterRegFlowMap &interRegFlows, const std::array< FlowsData< double >, 3 > &localFlowsn, const std::array< FlowsData< double >, 3 > &localFloresn, const std::map< std::tuple< std::string, int, int >, double > &localLgrBlockData)
Definition: CollectDataOnIORank_impl.hpp:1055
const std::array< FlowsData< double >, 3 > & globalFloresn() const
Definition: CollectDataOnIORank.hpp:128
const InterRegFlowMap & globalInterRegFlows() const
Definition: CollectDataOnIORank.hpp:122
std::map< std::tuple< std::string, int, int >, double > globalLgrBlockData_
Definition: CollectDataOnIORank.hpp:164
Inter-region flow accumulation maps for all region definition arrays.
Definition: InterRegFlows.hpp:179
Definition: fvbaseprimaryvariables.hh:161
Dune::Communication< MPIComm > Communication
Definition: ParallelCommunication.hpp:30
Definition: blackoilbioeffectsmodules.hh:45