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 <type_traits>
45#include <utility>
46#include <vector>
47
48namespace Dune {
49template<class Grid> class CartesianIndexMapper;
50}
51
52namespace Opm {
53
54template <class Grid, class EquilGrid, class GridView>
56{
57public:
58 using CollectiveCommunication = typename Grid::CollectiveCommunication;
59 using P2PCommunicatorType = Dune::Point2PointCommunicator<Dune::SimpleMessageBuffer>;
60 using IndexMapType = std::vector<int>;
61 using IndexMapStorageType = std::vector<IndexMapType>;
62
63 static constexpr int dimension = Grid::dimension;
64
65 enum { ioRank = 0 };
66
67 static const bool needsReordering =
68 !std::is_same<Grid, EquilGrid>::value;
69
70 CollectDataOnIORank(const Grid& grid,
71 const EquilGrid* equilGrid,
72 const GridView& gridView,
73 const Dune::CartesianIndexMapper<Grid>& cartMapper,
74 const Dune::CartesianIndexMapper<EquilGrid>* equilCartMapper,
75 const std::set<std::string>& fipRegionsInterregFlow = {});
76
77 // gather solution to rank 0 for EclipseWriter
78 void collect(const data::Solution& localCellData,
79 const std::map<std::pair<std::string, int>, double>& localBlockData,
80 const data::Wells& localWellData,
81 const data::WellBlockAveragePressures& localWBPData,
82 const data::GroupAndNetworkValues& localGroupAndNetworkData,
83 const data::Aquifers& localAquiferData,
84 const WellTestState& localWellTestState,
85 const InterRegFlowMap& interRegFlows,
86 const std::array<FlowsData<double>, 3>& localFlowsn,
87 const std::array<FlowsData<double>, 3>& localFloresn);
88
89 const std::map<std::pair<std::string, int>, double>& globalBlockData() const
90 { return globalBlockData_; }
91
92 const data::Solution& globalCellData() const
93 { return globalCellData_; }
94
95 data::Solution& globalCellData()
96 { return globalCellData_; }
97
98 const data::Wells& globalWellData() const
99 { return globalWellData_; }
100
101 const data::WellBlockAveragePressures& globalWBPData() const
102 { return this->globalWBPData_; }
103
104 const data::GroupAndNetworkValues& globalGroupAndNetworkData() const
106
107 const data::Aquifers& globalAquiferData() const
108 { return globalAquiferData_; }
109
110 const WellTestState& globalWellTestState() const
111 { return this->globalWellTestState_; }
112
114 { return this->globalInterRegFlows_; }
115
117 { return this->globalInterRegFlows_; }
118
119 const std::array<FlowsData<double>, 3>& globalFlowsn() const
120 { return globalFlowsn_; }
121
122 const std::array<FlowsData<double>, 3>& globalFloresn() const
123 { return globalFloresn_; }
124
125 bool isIORank() const
126 { return toIORankComm_.rank() == ioRank; }
127
128 bool isParallel() const
129 { return toIORankComm_.size() > 1; }
130
131 int localIdxToGlobalIdx(unsigned localIdx) const;
132
133 const std::vector<int>& localIdxToGlobalIdxMapping() const
134 {
136 }
137
139 { return needsReordering;}
140
141 std::size_t numCells () const
142 { return globalCartesianIndex_.size(); }
143
144 const std::vector<int>& globalRanks() const
145 { return globalRanks_; }
146
147 bool isCartIdxOnThisRank(int cartIdx) const;
148
149protected:
155 std::vector<int> globalRanks_;
156 data::Solution globalCellData_;
157 std::map<std::pair<std::string, int>, double> globalBlockData_;
158 data::Wells globalWellData_;
159 data::WellBlockAveragePressures globalWBPData_;
160 data::GroupAndNetworkValues globalGroupAndNetworkData_;
161 data::Aquifers globalAquiferData_;
162 WellTestState globalWellTestState_;
163 std::vector<int> localIdxToGlobalIdx_;
164 std::array<FlowsData<double>, 3> globalFlowsn_;
165 std::array<FlowsData<double>, 3> globalFloresn_;
169 std::vector<int> sortedCartesianIdx_;
170};
171
172} // end namespace Opm
173
174#endif // OPM_COLLECT_DATA_ON_IO_RANK_HPP
Definition: CollectDataOnIORank.hpp:49
Definition: CollectDataOnIORank.hpp:56
const data::Wells & globalWellData() const
Definition: CollectDataOnIORank.hpp:98
void collect(const data::Solution &localCellData, const std::map< std::pair< std::string, int >, double > &localBlockData, 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)
Definition: CollectDataOnIORank_impl.hpp:969
std::array< FlowsData< double >, 3 > globalFlowsn_
Definition: CollectDataOnIORank.hpp:164
@ ioRank
Definition: CollectDataOnIORank.hpp:65
std::vector< IndexMapType > IndexMapStorageType
Definition: CollectDataOnIORank.hpp:61
std::vector< int > localIdxToGlobalIdx_
Definition: CollectDataOnIORank.hpp:163
IndexMapStorageType indexMaps_
Definition: CollectDataOnIORank.hpp:154
data::Solution & globalCellData()
Definition: CollectDataOnIORank.hpp:95
std::vector< int > sortedCartesianIdx_
sorted list of cartesian indices present-
Definition: CollectDataOnIORank.hpp:169
static const bool needsReordering
Definition: CollectDataOnIORank.hpp:67
const data::GroupAndNetworkValues & globalGroupAndNetworkData() const
Definition: CollectDataOnIORank.hpp:104
data::GroupAndNetworkValues globalGroupAndNetworkData_
Definition: CollectDataOnIORank.hpp:160
int localIdxToGlobalIdx(unsigned localIdx) const
Definition: CollectDataOnIORank_impl.hpp:1091
data::WellBlockAveragePressures globalWBPData_
Definition: CollectDataOnIORank.hpp:159
InterRegFlowMap globalInterRegFlows_
Definition: CollectDataOnIORank.hpp:151
P2PCommunicatorType toIORankComm_
Definition: CollectDataOnIORank.hpp:150
WellTestState globalWellTestState_
Definition: CollectDataOnIORank.hpp:162
InterRegFlowMap & globalInterRegFlows()
Definition: CollectDataOnIORank.hpp:113
bool isParallel() const
Definition: CollectDataOnIORank.hpp:128
bool isIORank() const
Definition: CollectDataOnIORank.hpp:125
data::Solution globalCellData_
Definition: CollectDataOnIORank.hpp:156
typename Grid::CollectiveCommunication CollectiveCommunication
Definition: CollectDataOnIORank.hpp:58
bool isCartIdxOnThisRank(int cartIdx) const
Definition: CollectDataOnIORank_impl.hpp:1110
std::vector< int > globalRanks_
Definition: CollectDataOnIORank.hpp:155
const data::WellBlockAveragePressures & globalWBPData() const
Definition: CollectDataOnIORank.hpp:101
const data::Aquifers & globalAquiferData() const
Definition: CollectDataOnIORank.hpp:107
const std::map< std::pair< std::string, int >, double > & globalBlockData() const
Definition: CollectDataOnIORank.hpp:89
Dune::Point2PointCommunicator< Dune::SimpleMessageBuffer > P2PCommunicatorType
Definition: CollectDataOnIORank.hpp:59
data::Aquifers globalAquiferData_
Definition: CollectDataOnIORank.hpp:161
data::Wells globalWellData_
Definition: CollectDataOnIORank.hpp:158
const std::array< FlowsData< double >, 3 > & globalFlowsn() const
Definition: CollectDataOnIORank.hpp:119
bool doesNeedReordering() const
Definition: CollectDataOnIORank.hpp:138
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:846
IndexMapType localIndexMap_
Definition: CollectDataOnIORank.hpp:153
const std::vector< int > & globalRanks() const
Definition: CollectDataOnIORank.hpp:144
const WellTestState & globalWellTestState() const
Definition: CollectDataOnIORank.hpp:110
const data::Solution & globalCellData() const
Definition: CollectDataOnIORank.hpp:92
std::map< std::pair< std::string, int >, double > globalBlockData_
Definition: CollectDataOnIORank.hpp:157
static constexpr int dimension
Definition: CollectDataOnIORank.hpp:63
std::array< FlowsData< double >, 3 > globalFloresn_
Definition: CollectDataOnIORank.hpp:165
std::vector< int > IndexMapType
Definition: CollectDataOnIORank.hpp:60
std::size_t numCells() const
Definition: CollectDataOnIORank.hpp:141
const std::vector< int > & localIdxToGlobalIdxMapping() const
Definition: CollectDataOnIORank.hpp:133
IndexMapType globalCartesianIndex_
Definition: CollectDataOnIORank.hpp:152
const std::array< FlowsData< double >, 3 > & globalFloresn() const
Definition: CollectDataOnIORank.hpp:122
const InterRegFlowMap & globalInterRegFlows() const
Definition: CollectDataOnIORank.hpp:116
Inter-region flow accumulation maps for all region definition arrays.
Definition: InterRegFlows.hpp:179
Definition: SupportsFaceTag.hpp:27
Definition: BlackoilPhases.hpp:27