@@ -179,6 +179,23 @@ void getNullEdgeList(void *cpGridPointer, int sizeGID, int sizeLID,
179179 *err = ZOLTAN_OK ;
180180}
181181
182+ template <typename EdgeWeightType>
183+ EdgeWeightType sumOfGridEdges (const Dune::CpGrid& grid,
184+ const CombinedGridWellGraph& graph)
185+ {
186+ EdgeWeightType weWeight = 0 ;
187+ for (int edge=0 ; edge<grid.numFaces (); ++edge) {
188+ // assumes that transmissibility is positive (too obvious to leave an assert)
189+ const auto & addend = graph.transmissibility (edge);
190+ if (weWeight >= std::numeric_limits<EdgeWeightType>::max ()-addend) {
191+ weWeight = std::numeric_limits<EdgeWeightType>::max ();
192+ break ;
193+ }
194+ weWeight += graph.transmissibility (edge);
195+ }
196+ return weWeight;
197+ }
198+
182199template <typename ID >
183200void fillNBORGIDForSpecificCellAndIncrementNeighborCounter (const Dune::CpGrid& grid, int localCellId, ID globalID, int & neighborCounter, ID & nborGID) {
184201 for ( int local_face = 0 ; local_face < grid.numCellFaces (localCellId); ++local_face )
@@ -245,14 +262,14 @@ void getCpGridEdgeList(void *cpGridPointer, int sizeGID, int sizeLID,
245262#endif
246263}
247264template <typename ID , typename weightType>
248- void fillNBORGIDAndWeightsForSpecificCellAndIncrementNeighborCounterForGridWithWells (const CombinedGridWellGraph& graph, const int localCellId, ID globalID, int & neighborCounter, ID & nborGID, weightType *ewgts) {
265+ void fillNBORGIDAndWeightsForSpecificCellAndIncrementNeighborCounterForGridWithWells (const CombinedGridWellGraph& graph, const int localCellId, ID globalID, int & neighborCounter, ID & nborGID, weightType *ewgts, const weightType& weWeight ) {
249266 const Dune::CpGrid& grid = graph.getGrid ();
250267 // First the strong edges of the well completions.
251268 auto wellEdges = graph.getWellsGraph ()[localCellId];
252269 for ( auto edge : wellEdges)
253270 {
254271 nborGID[neighborCounter] = edge;
255- ewgts[neighborCounter++] = std::numeric_limits<weightType>:: max () ;
272+ ewgts[neighborCounter++] = weWeight ;
256273 }
257274
258275 // Now the ones of the grid that are not handled by the well completions
@@ -308,9 +325,12 @@ void getCpGridWellsEdgeList(void *graphPointer, int sizeGID, int sizeLID,
308325#endif
309326 int neighborCounter = 0 ;
310327
328+ // well edge weight for partitioning, big enough that wells should not get split
329+ float weWeight = sumOfGridEdges<float >(grid, graph);
330+
311331 for ( int cell = 0 ; cell < numCells; cell++ )
312332 {
313- fillNBORGIDAndWeightsForSpecificCellAndIncrementNeighborCounterForGridWithWells (graph, localID[cell], globalID, neighborCounter, nborGID, ewgts);
333+ fillNBORGIDAndWeightsForSpecificCellAndIncrementNeighborCounterForGridWithWells (graph, localID[cell], globalID, neighborCounter, nborGID, ewgts, weWeight );
314334#ifndef NDEBUG
315335 assert (neighborCounter-oldNeighborCounter==numEdges[cell]);
316336 oldNeighborCounter = neighborCounter;
@@ -416,12 +436,16 @@ void setCpGridZoltanGraphFunctions(Zoltan_Struct *zz,
416436template
417437void fillNBORGIDForSpecificCellAndIncrementNeighborCounter (const Dune::CpGrid&, int , int *, int &, int *& nborGID);
418438template
419- void fillNBORGIDAndWeightsForSpecificCellAndIncrementNeighborCounterForGridWithWells (const CombinedGridWellGraph&, const int , int *, int &, int *&, int *);
439+ void fillNBORGIDAndWeightsForSpecificCellAndIncrementNeighborCounterForGridWithWells (const CombinedGridWellGraph&, const int , int *, int &, int *&, int *, const int &);
440+ template
441+ int sumOfGridEdges (const Dune::CpGrid& grid, const CombinedGridWellGraph& graph);
420442
421443template
422444void fillNBORGIDForSpecificCellAndIncrementNeighborCounter (Dune::CpGrid const &, int , long *, int &, long *&);
423445template
424- void fillNBORGIDAndWeightsForSpecificCellAndIncrementNeighborCounterForGridWithWells (Dune::cpgrid::CombinedGridWellGraph const &, int , long *, int &, long *&, long *);
446+ void fillNBORGIDAndWeightsForSpecificCellAndIncrementNeighborCounterForGridWithWells (Dune::cpgrid::CombinedGridWellGraph const &, int , long *, int &, long *&, long *, const long &);
447+ template
448+ long sumOfGridEdges (const Dune::CpGrid& grid, const CombinedGridWellGraph& graph);
425449
426450#endif
427451
0 commit comments