2016-11-11 08:02:34 -06:00
|
|
|
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
// vi: set et ts=4 sw=4 sts=4:
|
|
|
|
/*
|
|
|
|
This file is part of the Open Porous Media project (OPM).
|
|
|
|
|
|
|
|
OPM is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
OPM is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
Consult the COPYING file in the top-level source directory of this
|
|
|
|
module for the precise wording of the license and the list of
|
|
|
|
copyright holders.
|
|
|
|
*/
|
2018-07-12 03:23:26 -05:00
|
|
|
#ifndef EWOMS_COLLECT_TO_IO_RANK_HH
|
|
|
|
#define EWOMS_COLLECT_TO_IO_RANK_HH
|
2016-11-11 08:02:34 -06:00
|
|
|
|
2021-05-03 04:48:31 -05:00
|
|
|
#include <opm/output/data/Aquifer.hpp>
|
2017-12-07 05:38:48 -06:00
|
|
|
#include <opm/output/data/Cells.hpp>
|
|
|
|
#include <opm/output/data/Solution.hpp>
|
2018-02-09 02:22:38 -06:00
|
|
|
#include <opm/output/data/Wells.hpp>
|
2020-02-19 06:00:35 -06:00
|
|
|
#include <opm/output/data/Groups.hpp>
|
2022-02-14 09:43:36 -06:00
|
|
|
|
2021-12-14 01:30:15 -06:00
|
|
|
#include <opm/input/eclipse/Schedule/Well/WellTestState.hpp>
|
2017-12-07 05:38:48 -06:00
|
|
|
|
2018-02-08 05:20:17 -06:00
|
|
|
#include <opm/grid/common/p2pcommunicator.hh>
|
2016-11-11 08:02:34 -06:00
|
|
|
|
2022-02-14 09:43:36 -06:00
|
|
|
#include <ebos/eclinterregflows.hh>
|
|
|
|
|
2021-05-03 04:48:31 -05:00
|
|
|
#include <map>
|
2021-04-09 06:51:56 -05:00
|
|
|
#include <utility>
|
2021-05-03 04:48:31 -05:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace Dune {
|
|
|
|
template<class Grid> class CartesianIndexMapper;
|
|
|
|
}
|
2016-11-11 08:02:34 -06:00
|
|
|
|
2019-09-05 10:04:39 -05:00
|
|
|
namespace Opm {
|
2018-07-12 03:26:11 -05:00
|
|
|
|
2021-05-03 04:48:31 -05:00
|
|
|
template <class Grid, class EquilGrid, class GridView>
|
2018-07-12 03:16:20 -05:00
|
|
|
class CollectDataToIORank
|
|
|
|
{
|
|
|
|
public:
|
2021-05-03 04:48:31 -05:00
|
|
|
using CollectiveCommunication = typename Grid::CollectiveCommunication;
|
|
|
|
using P2PCommunicatorType = Dune::Point2PointCommunicator<Dune::SimpleMessageBuffer>;
|
|
|
|
using IndexMapType = std::vector<int>;
|
|
|
|
using IndexMapStorageType = std::vector<IndexMapType>;
|
2016-11-11 08:02:34 -06:00
|
|
|
|
2018-07-12 03:36:48 -05:00
|
|
|
static const int dimension = Grid::dimension;
|
2016-11-11 08:02:34 -06:00
|
|
|
|
2018-07-12 03:16:20 -05:00
|
|
|
enum { ioRank = 0 };
|
2016-11-11 08:02:34 -06:00
|
|
|
|
2018-07-12 03:36:48 -05:00
|
|
|
static const bool needsReordering =
|
2021-05-03 04:48:31 -05:00
|
|
|
!std::is_same<Grid, EquilGrid>::value;
|
2018-07-12 03:16:20 -05:00
|
|
|
|
2021-05-03 04:48:31 -05:00
|
|
|
CollectDataToIORank(const Grid& grid,
|
2021-05-11 07:48:50 -05:00
|
|
|
const EquilGrid* equilGrid,
|
2021-05-03 04:48:31 -05:00
|
|
|
const GridView& gridView,
|
|
|
|
const Dune::CartesianIndexMapper<Grid>& cartMapper,
|
2022-02-14 09:43:36 -06:00
|
|
|
const Dune::CartesianIndexMapper<EquilGrid>* equilCartMapper,
|
|
|
|
const std::set<std::string>& fipRegionsInterregFlow = {});
|
2021-04-09 06:51:56 -05:00
|
|
|
|
2018-07-12 03:16:20 -05:00
|
|
|
// gather solution to rank 0 for EclipseWriter
|
2021-05-25 05:00:04 -05:00
|
|
|
void collect(const data::Solution& localCellData,
|
2018-07-12 03:26:11 -05:00
|
|
|
const std::map<std::pair<std::string, int>, double>& localBlockData,
|
2020-12-01 02:09:06 -06:00
|
|
|
const std::map<std::size_t, double>& localWBPData,
|
2021-05-25 05:00:04 -05:00
|
|
|
const data::Wells& localWellData,
|
|
|
|
const data::GroupAndNetworkValues& localGroupAndNetworkData,
|
2021-10-02 13:28:44 -05:00
|
|
|
const data::Aquifers& localAquiferData,
|
2022-02-14 09:43:36 -06:00
|
|
|
const WellTestState& localWellTestState,
|
|
|
|
const EclInterRegFlowMap& interRegFlows);
|
2016-11-11 08:02:34 -06:00
|
|
|
|
2020-12-01 02:09:06 -06:00
|
|
|
const std::map<std::size_t, double>& globalWBPData() const
|
|
|
|
{ return this->globalWBPData_; }
|
|
|
|
|
2018-07-12 03:16:20 -05:00
|
|
|
const std::map<std::pair<std::string, int>, double>& globalBlockData() const
|
2018-07-12 03:26:11 -05:00
|
|
|
{ return globalBlockData_; }
|
2018-01-19 08:45:42 -06:00
|
|
|
|
2021-05-25 05:00:04 -05:00
|
|
|
const data::Solution& globalCellData() const
|
2018-07-12 03:26:11 -05:00
|
|
|
{ return globalCellData_; }
|
2017-12-07 05:38:48 -06:00
|
|
|
|
2021-05-25 05:00:04 -05:00
|
|
|
const data::Wells& globalWellData() const
|
2018-07-12 03:26:11 -05:00
|
|
|
{ return globalWellData_; }
|
2018-02-09 02:22:38 -06:00
|
|
|
|
2021-10-02 13:28:44 -05:00
|
|
|
const WellTestState& globalWellTestState() const
|
|
|
|
{ return this->globalWellTestState_; }
|
|
|
|
|
2021-05-25 05:00:04 -05:00
|
|
|
const data::GroupAndNetworkValues& globalGroupAndNetworkData() const
|
2020-09-20 15:16:07 -05:00
|
|
|
{ return globalGroupAndNetworkData_; }
|
2020-02-19 06:00:35 -06:00
|
|
|
|
2021-05-25 05:00:04 -05:00
|
|
|
const data::Aquifers& globalAquiferData() const
|
2020-12-15 02:02:35 -06:00
|
|
|
{ return globalAquiferData_; }
|
|
|
|
|
2022-02-14 09:43:36 -06:00
|
|
|
EclInterRegFlowMap& globalInterRegFlows()
|
|
|
|
{ return this->globalInterRegFlows_; }
|
|
|
|
|
|
|
|
const EclInterRegFlowMap& globalInterRegFlows() const
|
|
|
|
{ return this->globalInterRegFlows_; }
|
|
|
|
|
2018-07-12 03:16:20 -05:00
|
|
|
bool isIORank() const
|
2018-07-12 03:26:11 -05:00
|
|
|
{ return toIORankComm_.rank() == ioRank; }
|
2016-11-11 08:02:34 -06:00
|
|
|
|
2018-07-12 03:16:20 -05:00
|
|
|
bool isParallel() const
|
2018-07-12 03:26:11 -05:00
|
|
|
{ return toIORankComm_.size() > 1; }
|
2016-11-11 08:02:34 -06:00
|
|
|
|
2021-05-03 04:48:31 -05:00
|
|
|
int localIdxToGlobalIdx(unsigned localIdx) const;
|
2017-12-07 05:38:48 -06:00
|
|
|
|
2018-07-12 03:26:11 -05:00
|
|
|
size_t numCells () const
|
|
|
|
{ return globalCartesianIndex_.size(); }
|
2016-11-11 08:02:34 -06:00
|
|
|
|
2018-07-12 03:16:20 -05:00
|
|
|
const std::vector<int>& globalRanks() const
|
2018-07-12 03:26:11 -05:00
|
|
|
{ return globalRanks_; }
|
2018-01-12 08:32:43 -06:00
|
|
|
|
2021-05-03 04:48:31 -05:00
|
|
|
bool isCartIdxOnThisRank(int cartIdx) const;
|
2018-07-12 03:16:20 -05:00
|
|
|
|
|
|
|
protected:
|
2018-07-12 03:26:11 -05:00
|
|
|
P2PCommunicatorType toIORankComm_;
|
2022-02-14 09:43:36 -06:00
|
|
|
EclInterRegFlowMap globalInterRegFlows_;
|
2018-07-12 03:26:11 -05:00
|
|
|
IndexMapType globalCartesianIndex_;
|
|
|
|
IndexMapType localIndexMap_;
|
|
|
|
IndexMapStorageType indexMaps_;
|
2018-07-31 08:35:15 -05:00
|
|
|
std::vector<int> globalRanks_;
|
2021-05-25 05:00:04 -05:00
|
|
|
data::Solution globalCellData_;
|
2018-07-12 03:16:20 -05:00
|
|
|
std::map<std::pair<std::string, int>, double> globalBlockData_;
|
2020-12-01 02:09:06 -06:00
|
|
|
std::map<std::size_t, double> globalWBPData_;
|
2021-05-25 05:00:04 -05:00
|
|
|
data::Wells globalWellData_;
|
|
|
|
data::GroupAndNetworkValues globalGroupAndNetworkData_;
|
|
|
|
data::Aquifers globalAquiferData_;
|
2021-10-02 13:28:44 -05:00
|
|
|
WellTestState globalWellTestState_;
|
2019-10-11 17:00:35 -05:00
|
|
|
std::vector<int> localIdxToGlobalIdx_;
|
2020-09-08 13:28:42 -05:00
|
|
|
/// \brief sorted list of cartesian indices present-
|
|
|
|
///
|
|
|
|
/// non-empty only when running in parallel
|
|
|
|
std::vector<int> sortedCartesianIdx_;
|
2018-07-12 03:16:20 -05:00
|
|
|
};
|
2016-11-11 08:02:34 -06:00
|
|
|
|
2019-09-05 10:04:39 -05:00
|
|
|
} // end namespace Opm
|
2018-07-12 03:23:26 -05:00
|
|
|
|
2016-11-11 08:02:34 -06:00
|
|
|
#endif
|