mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Add possible future connections to the grid methods that handle the well connections
This commit is contained in:
@@ -196,13 +196,14 @@ doLoadBalance_(const Dune::EdgeWeightMethod edgeWeightsMethod,
|
||||
const auto wells = ((mpiSize > 1) || partitionJacobiBlocks)
|
||||
? schedule.getWellsatEnd()
|
||||
: std::vector<Well>{};
|
||||
|
||||
const auto& possibleFutureConnections = schedule.getPossibleFutureConnections();
|
||||
// Distribute the grid and switch to the distributed view.
|
||||
if (mpiSize > 1) {
|
||||
this->distributeGrid(edgeWeightsMethod, ownersFirst, partitionMethod,
|
||||
serialPartitioning, enableDistributedWells,
|
||||
imbalanceTol, loadBalancerSet != 0,
|
||||
faceTrans, wells,
|
||||
possibleFutureConnections,
|
||||
eclState1, parallelWells);
|
||||
}
|
||||
|
||||
@@ -215,7 +216,7 @@ doLoadBalance_(const Dune::EdgeWeightMethod edgeWeightsMethod,
|
||||
#if HAVE_OPENCL || HAVE_ROCSPARSE || HAVE_CUDA
|
||||
if (partitionJacobiBlocks) {
|
||||
this->cell_part_ = this->grid_->
|
||||
zoltanPartitionWithoutScatter(&wells, faceTrans.data(),
|
||||
zoltanPartitionWithoutScatter(&wells, &possibleFutureConnections, faceTrans.data(),
|
||||
numJacobiBlocks,
|
||||
imbalanceTol);
|
||||
}
|
||||
@@ -282,17 +283,18 @@ extractFaceTrans(const GridView& gridView) const
|
||||
template <class ElementMapper, class GridView, class Scalar>
|
||||
void
|
||||
GenericCpGridVanguard<ElementMapper, GridView, Scalar>::
|
||||
distributeGrid(const Dune::EdgeWeightMethod edgeWeightsMethod,
|
||||
const bool ownersFirst,
|
||||
const Dune::PartitionMethod partitionMethod,
|
||||
const bool serialPartitioning,
|
||||
const bool enableDistributedWells,
|
||||
const double imbalanceTol,
|
||||
const bool loadBalancerSet,
|
||||
const std::vector<double>& faceTrans,
|
||||
const std::vector<Well>& wells,
|
||||
EclipseState& eclState1,
|
||||
FlowGenericVanguard::ParallelWellStruct& parallelWells)
|
||||
distributeGrid(const Dune::EdgeWeightMethod edgeWeightsMethod,
|
||||
const bool ownersFirst,
|
||||
const Dune::PartitionMethod partitionMethod,
|
||||
const bool serialPartitioning,
|
||||
const bool enableDistributedWells,
|
||||
const double imbalanceTol,
|
||||
const bool loadBalancerSet,
|
||||
const std::vector<double>& faceTrans,
|
||||
const std::vector<Well>& wells,
|
||||
const std::unordered_map<std::string, std::set<std::array<int,3>>>& possibleFutureConnections,
|
||||
EclipseState& eclState1,
|
||||
FlowGenericVanguard::ParallelWellStruct& parallelWells)
|
||||
{
|
||||
if (auto* eclState = dynamic_cast<ParallelEclipseState*>(&eclState1);
|
||||
eclState != nullptr)
|
||||
@@ -300,7 +302,7 @@ distributeGrid(const Dune::EdgeWeightMethod edgeWeightsMethod,
|
||||
this->distributeGrid(edgeWeightsMethod, ownersFirst, partitionMethod,
|
||||
serialPartitioning, enableDistributedWells,
|
||||
imbalanceTol, loadBalancerSet, faceTrans,
|
||||
wells, eclState, parallelWells);
|
||||
wells, possibleFutureConnections, eclState, parallelWells);
|
||||
}
|
||||
else {
|
||||
const auto message = std::string {
|
||||
@@ -319,17 +321,18 @@ distributeGrid(const Dune::EdgeWeightMethod edgeWeightsMethod,
|
||||
template <class ElementMapper, class GridView, class Scalar>
|
||||
void
|
||||
GenericCpGridVanguard<ElementMapper, GridView, Scalar>::
|
||||
distributeGrid(const Dune::EdgeWeightMethod edgeWeightsMethod,
|
||||
const bool ownersFirst,
|
||||
const Dune::PartitionMethod partitionMethod,
|
||||
const bool serialPartitioning,
|
||||
const bool enableDistributedWells,
|
||||
const double imbalanceTol,
|
||||
const bool loadBalancerSet,
|
||||
const std::vector<double>& faceTrans,
|
||||
const std::vector<Well>& wells,
|
||||
ParallelEclipseState* eclState,
|
||||
FlowGenericVanguard::ParallelWellStruct& parallelWells)
|
||||
distributeGrid(const Dune::EdgeWeightMethod edgeWeightsMethod,
|
||||
const bool ownersFirst,
|
||||
const Dune::PartitionMethod partitionMethod,
|
||||
const bool serialPartitioning,
|
||||
const bool enableDistributedWells,
|
||||
const double imbalanceTol,
|
||||
const bool loadBalancerSet,
|
||||
const std::vector<double>& faceTrans,
|
||||
const std::vector<Well>& wells,
|
||||
const std::unordered_map<std::string, std::set<std::array<int,3>>>& possibleFutureConnections,
|
||||
ParallelEclipseState* eclState,
|
||||
FlowGenericVanguard::ParallelWellStruct& parallelWells)
|
||||
{
|
||||
OPM_TIMEBLOCK(gridDistribute);
|
||||
const auto isIORank = this->grid_->comm().rank() == 0;
|
||||
@@ -347,13 +350,14 @@ distributeGrid(const Dune::EdgeWeightMethod edgeWeightsMethod,
|
||||
: std::vector<int>{};
|
||||
//For this case, simple partitioning is selected automatically
|
||||
parallelWells =
|
||||
std::get<1>(this->grid_->loadBalance(handle, parts, &wells, ownersFirst,
|
||||
std::get<1>(this->grid_->loadBalance(handle, parts, &wells, &possibleFutureConnections, ownersFirst,
|
||||
addCornerCells, overlapLayers));
|
||||
}
|
||||
else {
|
||||
parallelWells =
|
||||
std::get<1>(this->grid_->loadBalance(handle, edgeWeightsMethod,
|
||||
&wells, serialPartitioning,
|
||||
&wells, &possibleFutureConnections,
|
||||
serialPartitioning,
|
||||
faceTrans.data(), ownersFirst,
|
||||
addCornerCells, overlapLayers,
|
||||
partitionMethod, imbalanceTol,
|
||||
|
||||
@@ -165,29 +165,31 @@ protected:
|
||||
private:
|
||||
std::vector<double> extractFaceTrans(const GridView& gridView) const;
|
||||
|
||||
void distributeGrid(const Dune::EdgeWeightMethod edgeWeightsMethod,
|
||||
const bool ownersFirst,
|
||||
const Dune::PartitionMethod partitionMethod,
|
||||
const bool serialPartitioning,
|
||||
const bool enableDistributedWells,
|
||||
const double imbalanceTol,
|
||||
const bool loadBalancerSet,
|
||||
const std::vector<double>& faceTrans,
|
||||
const std::vector<Well>& wells,
|
||||
EclipseState& eclState,
|
||||
FlowGenericVanguard::ParallelWellStruct& parallelWells);
|
||||
void distributeGrid(const Dune::EdgeWeightMethod edgeWeightsMethod,
|
||||
const bool ownersFirst,
|
||||
const Dune::PartitionMethod partitionMethod,
|
||||
const bool serialPartitioning,
|
||||
const bool enableDistributedWells,
|
||||
const double imbalanceTol,
|
||||
const bool loadBalancerSet,
|
||||
const std::vector<double>& faceTrans,
|
||||
const std::vector<Well>& wells,
|
||||
const std::unordered_map<std::string, std::set<std::array<int,3>>>& possibleFutureConnections,
|
||||
EclipseState& eclState,
|
||||
FlowGenericVanguard::ParallelWellStruct& parallelWells);
|
||||
|
||||
void distributeGrid(const Dune::EdgeWeightMethod edgeWeightsMethod,
|
||||
const bool ownersFirst,
|
||||
const Dune::PartitionMethod partitionMethod,
|
||||
const bool serialPartitioning,
|
||||
const bool enableDistributedWells,
|
||||
const double imbalanceTol,
|
||||
const bool loadBalancerSet,
|
||||
const std::vector<double>& faceTrans,
|
||||
const std::vector<Well>& wells,
|
||||
ParallelEclipseState* eclState,
|
||||
FlowGenericVanguard::ParallelWellStruct& parallelWells);
|
||||
void distributeGrid(const Dune::EdgeWeightMethod edgeWeightsMethod,
|
||||
const bool ownersFirst,
|
||||
const Dune::PartitionMethod partitionMethod,
|
||||
const bool serialPartitioning,
|
||||
const bool enableDistributedWells,
|
||||
const double imbalanceTol,
|
||||
const bool loadBalancerSet,
|
||||
const std::vector<double>& faceTrans,
|
||||
const std::vector<Well>& wells,
|
||||
const std::unordered_map<std::string, std::set<std::array<int,3>>>& possibleFutureConnections,
|
||||
ParallelEclipseState* eclState,
|
||||
FlowGenericVanguard::ParallelWellStruct& parallelWells);
|
||||
|
||||
protected:
|
||||
virtual const std::string& zoltanParams() const = 0;
|
||||
|
||||
@@ -78,12 +78,14 @@ void BdaSolverInfo<Matrix,Vector>::
|
||||
prepare(const Grid& grid,
|
||||
const Dune::CartesianIndexMapper<Grid>& cartMapper,
|
||||
const std::vector<Well>& wellsForConn,
|
||||
const std::unordered_map<std::string, std::set<std::array<int,3>>>& possibleFutureConnections,
|
||||
const std::vector<int>& cellPartition,
|
||||
const std::size_t nonzeroes,
|
||||
const bool useWellConn)
|
||||
{
|
||||
if (numJacobiBlocks_ > 1) {
|
||||
detail::setWellConnections(grid, cartMapper, wellsForConn,
|
||||
possibleFutureConnections,
|
||||
useWellConn,
|
||||
wellConnectionsGraph_,
|
||||
numJacobiBlocks_);
|
||||
@@ -239,12 +241,13 @@ using BM = Dune::BCRSMatrix<MatrixBlock<Scalar,Dim,Dim>>;
|
||||
template<class Scalar, int Dim>
|
||||
using BV = Dune::BlockVector<Dune::FieldVector<Scalar,Dim>>;
|
||||
|
||||
#define INSTANTIATE_GRID(T, Dim, Grid) \
|
||||
template void BdaSolverInfo<BM<T,Dim>,BV<T,Dim>>:: \
|
||||
prepare(const Grid&, \
|
||||
const Dune::CartesianIndexMapper<Grid>&, \
|
||||
const std::vector<Well>&, \
|
||||
const std::vector<int>&, \
|
||||
#define INSTANTIATE_GRID(T, Dim, Grid) \
|
||||
template void BdaSolverInfo<BM<T,Dim>,BV<T,Dim>>:: \
|
||||
prepare(const Grid&, \
|
||||
const Dune::CartesianIndexMapper<Grid>&, \
|
||||
const std::vector<Well>&, \
|
||||
const std::unordered_map<std::string, std::set<std::array<int,3>>>&, \
|
||||
const std::vector<int>&, \
|
||||
const std::size_t, const bool);
|
||||
using PolyHedralGrid3D = Dune::PolyhedralGrid<3, 3>;
|
||||
#if HAVE_DUNE_ALUGRID
|
||||
|
||||
@@ -60,6 +60,7 @@ struct BdaSolverInfo
|
||||
void prepare(const Grid& grid,
|
||||
const Dune::CartesianIndexMapper<Grid>& cartMapper,
|
||||
const std::vector<Well>& wellsForConn,
|
||||
const std::unordered_map<std::string, std::set<std::array<int,3>>>& possibleFutureConnections,
|
||||
const std::vector<int>& cellPartition,
|
||||
const std::size_t nonzeroes,
|
||||
const bool useWellConn);
|
||||
@@ -207,6 +208,7 @@ public:
|
||||
bdaBridge_->prepare(this->simulator_.vanguard().grid(),
|
||||
this->simulator_.vanguard().cartesianIndexMapper(),
|
||||
this->simulator_.vanguard().schedule().getWellsatEnd(),
|
||||
this->simulator_.vanguard().schedule().getPossibleFutureConnections(),
|
||||
this->simulator_.vanguard().cellPartition(),
|
||||
this->getMatrix().nonzeroes(), this->useWellConn_);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace detail
|
||||
/// \param useWellConn Boolean that is true when UseWellContribusion is true
|
||||
/// \param wellGraph Cell IDs of well cells stored in a graph.
|
||||
template<class Grid, class CartMapper, class W>
|
||||
void setWellConnections(const Grid& grid, const CartMapper& cartMapper, const W& wells, bool useWellConn, std::vector<std::set<int>>& wellGraph, int numJacobiBlocks)
|
||||
void setWellConnections(const Grid& grid, const CartMapper& cartMapper, const W& wells, const std::unordered_map<std::string, std::set<std::array<int,3>>>& possibleFutureConnections, bool useWellConn, std::vector<std::set<int>>& wellGraph, int numJacobiBlocks)
|
||||
{
|
||||
if ( grid.comm().size() > 1 || numJacobiBlocks > 1)
|
||||
{
|
||||
@@ -62,7 +62,7 @@ namespace detail
|
||||
cart[ cartMapper.cartesianIndex( i ) ] = i;
|
||||
|
||||
Dune::cpgrid::WellConnections well_indices;
|
||||
well_indices.init(wells, cpgdim, cart);
|
||||
well_indices.init(wells, &possibleFutureConnections, cpgdim, cart);
|
||||
|
||||
for (auto& well : well_indices)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user