Skip to content

Commit 6c6d154

Browse files
committed
Enable multiplyWellConnectivity with Metis and Zoltan
1 parent 5482c2e commit 6c6d154

5 files changed

Lines changed: 56 additions & 13 deletions

File tree

opm/grid/GraphOfGridWrappers.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,13 +550,13 @@ zoltanPartitioningWithGraphOfGrid(const Dune::CpGrid& grid,
550550
float mIWC = 1; // multiply edge weights between a well's cells. Used when allowDistributedWells=true.
551551
for (const auto& [key, value] : params)
552552
{
553-
if (key=="EnvelopeWellLayers")
553+
if (key=="EnvelopeWellLayers") {
554554
layers = std::stoi(value);
555-
else if (key=="MultiplyWellConnectivities") {
555+
} else if (key=="MultiplyWellConnectivities") {
556556
mIWC = std::stof(value);
557-
}
558-
else
557+
} else {
559558
Zoltan_Set_Param(zz, key.c_str(), value.c_str());
559+
}
560560
}
561561

562562
// root process has the whole grid, other ranks nothing

opm/grid/common/MetisPartition.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ metisSerialGraphPartitionGridOnRoot(const CpGrid& cpgrid,
276276
if( wells )
277277
{
278278
// well edge weight for partitioning, big enough that wells should not get split
279-
idx_t weWeight = sumOfGridEdges<idx_t>(cpgrid, *gridAndWells);
279+
idx_t weWeight = calculateWellEdgeWeight<idx_t>(cpgrid, *gridAndWells);
280280

281281
int neighborCounter = 0;
282282
for( int cell = 0; cell < n; cell++ )

opm/grid/common/ZoltanGraphFunctions.cpp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ void getNullEdgeList(void *cpGridPointer, int sizeGID, int sizeLID,
180180
}
181181

182182
template <typename EdgeWeightType>
183-
EdgeWeightType sumOfGridEdges(const Dune::CpGrid& grid,
184-
const CombinedGridWellGraph& graph)
183+
EdgeWeightType calculateWellEdgeWeight(const Dune::CpGrid& grid,
184+
const CombinedGridWellGraph& graph)
185185
{
186186
EdgeWeightType weWeight = 0;
187187
for (int edge=0; edge<grid.numFaces(); ++edge) {
@@ -191,7 +191,26 @@ EdgeWeightType sumOfGridEdges(const Dune::CpGrid& grid,
191191
weWeight = std::numeric_limits<EdgeWeightType>::max();
192192
break;
193193
}
194-
weWeight += graph.transmissibility(edge);
194+
weWeight += addend;
195+
}
196+
197+
// when multipltWellConnectivities is provided, set the well weight to the average of grid weight times that coefficient
198+
float mWC = graph.getMultiplyWellConnectivities();
199+
if (mWC > 0) {
200+
if (weWeight != std::numeric_limits<EdgeWeightType>::max()) {
201+
weWeight /= grid.numFaces();
202+
} else {
203+
// grid is too big, start over and use maximum instead of the average
204+
weWeight = 0;
205+
for (int edge=0; edge<grid.numFaces(); ++edge) {
206+
weWeight = std::max(weWeight, static_cast<float>(graph.transmissibility(edge)));
207+
}
208+
}
209+
if (weWeight < std::numeric_limits<EdgeWeightType>::max()/mWC) {
210+
weWeight *= mWC;
211+
} else {
212+
weWeight = std::numeric_limits<EdgeWeightType>::max();
213+
}
195214
}
196215
return weWeight;
197216
}
@@ -326,7 +345,7 @@ void getCpGridWellsEdgeList(void *graphPointer, int sizeGID, int sizeLID,
326345
int neighborCounter = 0;
327346

328347
// well edge weight for partitioning, big enough that wells should not get split
329-
float weWeight = sumOfGridEdges<float>(grid, graph);
348+
float weWeight = calculateWellEdgeWeight<float>(grid, graph);
330349

331350
for( int cell = 0; cell < numCells; cell++ )
332351
{

opm/grid/common/ZoltanGraphFunctions.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,17 @@ class CombinedGridWellGraph
193193
else
194194
return 1.0;
195195
}
196+
197+
void setMultiplyWellConnectivities(const float& mWC)
198+
{
199+
multiplyWellConnectivities = mWC;
200+
}
201+
202+
float getMultiplyWellConnectivities() const
203+
{
204+
return multiplyWellConnectivities;
205+
}
206+
196207
private:
197208

198209
void addCompletionSetToGraph()
@@ -239,6 +250,7 @@ class CombinedGridWellGraph
239250
int edgeWeightsMethod_;
240251
WellConnections well_indices_;
241252
double log_min_;
253+
float multiplyWellConnectivities = -1;
242254
};
243255

244256
/// \brief Get the number of edges of the graph of the grid and the wells for one cell

opm/grid/common/ZoltanPartition.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,14 @@ zoltanGraphPartitionGridOnRoot(const CpGrid& cpgrid,
326326
}
327327
setDefaultZoltanParameters(zz);
328328
Zoltan_Set_Param(zz, "IMBALANCE_TOL", std::to_string(zoltanImbalanceTol).c_str());
329-
for (const auto& [key, value] : params)
330-
Zoltan_Set_Param(zz, key.c_str(), value.c_str());
329+
float mWC = -1;
330+
for (const auto& [key, value] : params) {
331+
if (key=="MultiplyWellConnectivities") {
332+
mWC = std::stof(value);
333+
} else {
334+
Zoltan_Set_Param(zz, key.c_str(), value.c_str());
335+
}
336+
}
331337

332338
// For the load balancer one process has the whole grid and
333339
// all others an empty partition before loadbalancing.
@@ -344,6 +350,7 @@ zoltanGraphPartitionGridOnRoot(const CpGrid& cpgrid,
344350
transmissibilities,
345351
partitionIsEmpty,
346352
edgeWeightsMethod));
353+
gridAndWells->setMultiplyWellConnectivities(mWC);
347354
Dune::cpgrid::setCpGridZoltanGraphFunctions(zz, *gridAndWells,
348355
partitionIsEmpty);
349356
}
@@ -523,8 +530,13 @@ class ZoltanSerialPartitioner
523530
else
524531
Zoltan_Set_Param(zz, "NUM_GLOBAL_PARTS", std::to_string(cc.size()).c_str());
525532

526-
for (const auto& [key, value] : params)
527-
Zoltan_Set_Param(zz, key.c_str(), value.c_str());
533+
for (const auto& [key, value] : params) {
534+
if (key=="MultiplyWellConnectivities") {
535+
gridAndWells->setMultiplyWellConnectivities(std::stof(value));
536+
} else {
537+
Zoltan_Set_Param(zz, key.c_str(), value.c_str());
538+
}
539+
}
528540

529541
// For the load balancer one process has the whole grid and
530542
// all others an empty partition before loadbalancing.

0 commit comments

Comments
 (0)