@@ -88,42 +88,8 @@ void getNullNumEdgesList(void *cpGridPointer, int sizeGID, int sizeLID,
88
88
*err = ZOLTAN_OK;
89
89
}
90
90
91
- int getNumberOfEdgesForSpecificCell (const Dune::CpGrid& grid, int localCellId) {
92
- // For the graph there is an edge only if the face has two neighbors.
93
- // Therefore we need to check each face
94
- int edges = 0 ;
95
- for ( int local_face = 0 ; local_face < grid.numCellFaces (localCellId); ++local_face )
96
- {
97
- const int face = grid.cellFace (localCellId, local_face);
98
- if ( grid.faceCell (face, 0 ) != -1 && grid.faceCell (face, 1 ) != -1 )
99
- {
100
- ++edges;
101
- }
102
- }
103
- return edges;
104
- }
105
91
106
- void getCpGridNumEdgesList (void *cpGridPointer, int sizeGID, int sizeLID,
107
- int numCells,
108
- ZOLTAN_ID_PTR globalID, ZOLTAN_ID_PTR localID,
109
- int *numEdges, int *err)
110
- {
111
- (void ) globalID;
112
- const Dune::CpGrid& grid = *static_cast <const Dune::CpGrid*>(cpGridPointer);
113
- if ( sizeGID != 1 || sizeLID != 1 || numCells != grid.numCells () )
114
- {
115
- *err = ZOLTAN_FATAL;
116
- return ;
117
- }
118
- for ( int i = 0 ; i < numCells; i++ )
119
- {
120
- numEdges[i] = getNumberOfEdgesForSpecificCell (grid, localID[i]);
121
- }
122
-
123
- *err = ZOLTAN_OK;
124
- }
125
-
126
- int getNumberOfEdgesForSpecificCellForGridWithWells (const CombinedGridWellGraph& graph, int localCellId) {
92
+ int getNumberOfEdgesForSpecificCell (const CombinedGridWellGraph& graph, int localCellId) {
127
93
const Dune::CpGrid& grid = graph.getGrid ();
128
94
// Initial set of faces is the ones of the well completions
129
95
auto edges = graph.getWellsGraph ()[localCellId];
@@ -162,7 +128,7 @@ void getCpGridWellsNumEdgesList(void *graphPointer, int sizeGID, int sizeLID,
162
128
}
163
129
for ( int i = 0 ; i < numCells; i++ )
164
130
{
165
- numEdges[i] = getNumberOfEdgesForSpecificCellForGridWithWells (graph, localID[i]);
131
+ numEdges[i] = getNumberOfEdgesForSpecificCell (graph, localID[i]);
166
132
}
167
133
*err = ZOLTAN_OK;
168
134
}
@@ -179,79 +145,15 @@ void getNullEdgeList(void *cpGridPointer, int sizeGID, int sizeLID,
179
145
*err = ZOLTAN_OK;
180
146
}
181
147
182
- template <typename ID>
183
- void fillNBORGIDForSpecificCellAndIncrementNeighborCounter (const Dune::CpGrid& grid, int localCellId, ID globalID, int & neighborCounter, ID& nborGID) {
184
- for ( int local_face = 0 ; local_face < grid.numCellFaces (localCellId); ++local_face )
185
- {
186
- const int face = grid.cellFace (localCellId, local_face);
187
- int otherCell = grid.faceCell (face, 0 );
188
- if ( otherCell == localCellId || otherCell == -1 )
189
- {
190
- otherCell = grid.faceCell (face, 1 );
191
- if ( otherCell == localCellId || otherCell == -1 )
192
- continue ;
193
- }
194
- nborGID[neighborCounter++] = globalID[otherCell];
195
- }
196
- }
197
-
198
- void getCpGridEdgeList (void *cpGridPointer, int sizeGID, int sizeLID,
199
- int numCells, ZOLTAN_ID_PTR globalID, ZOLTAN_ID_PTR localID,
200
- int *numEdges,
201
- ZOLTAN_ID_PTR nborGID, int *nborProc,
202
- int wgtDim, float *ewgts, int *err)
203
- {
204
- (void ) wgtDim; (void ) globalID; (void ) numEdges; (void ) ewgts;
205
- const Dune::CpGrid& grid = *static_cast <const Dune::CpGrid*>(cpGridPointer);
206
- if ( sizeGID != 1 || sizeLID != 1 || numCells != grid.numCells () )
207
- {
208
- *err = ZOLTAN_FATAL;
209
- return ;
210
- }
211
- #ifndef NDEBUG
212
- int oldNeighborCounter = 0 ;
213
- #endif
214
- int neighborCounter = 0 ;
215
-
216
- for ( int cell = 0 ; cell < numCells; cell++ )
217
- {
218
- fillNBORGIDForSpecificCellAndIncrementNeighborCounter (grid, localID[cell], globalID, neighborCounter, nborGID);
219
- #ifndef NDEBUG
220
- assert (numEdges[cell] == neighborCounter - oldNeighborCounter);
221
- oldNeighborCounter = neighborCounter;
222
- #endif
223
- }
224
-
225
- const int myrank = grid.comm ().rank ();
226
-
227
- for ( int i = 0 ; i < neighborCounter; ++i )
228
- {
229
- nborProc[i] = myrank;
230
- }
231
- #if defined(DEBUG) && false // The index set will not be initialized here!
232
- // The above relies heavily on the grid not being distributed already.
233
- // Therefore we check here that all cells are owned by us.
234
- GlobalLookupIndexSet<Dune::CpGrid::ParallelIndexSet>
235
- globalIdxSet (grid.getCellIndexSet (),
236
- grid.numCells ());
237
- for ( int cell = 0 ; cell < numCells; cell++ )
238
- {
239
- if ( globalIdxSet.pair (cell)->local ().attribute () !=
240
- Dune::CpGrid::ParallelIndexSet::LocalIndex::Attribute::owner )
241
- {
242
- *err = ZOLTAN_FATAL;
243
- }
244
- }
245
- #endif
246
- }
247
148
template <typename ID, typename weightType>
248
- void fillNBORGIDAndWeightsForSpecificCellAndIncrementNeighborCounterForGridWithWells (const CombinedGridWellGraph& graph, const int localCellId, ID globalID, int & neighborCounter, ID& nborGID, weightType *ewgts) {
149
+ void fillNBORGIDAndWeightsForSpecificCellAndIncrementNeighborCounter (const CombinedGridWellGraph& graph, const int localCellId, ID globalID, int & neighborCounter, ID& nborGID, weightType *ewgts) {
249
150
const Dune::CpGrid& grid = graph.getGrid ();
250
151
// First the strong edges of the well completions.
251
152
auto wellEdges = graph.getWellsGraph ()[localCellId];
252
153
for ( auto edge : wellEdges)
253
154
{
254
155
nborGID[neighborCounter] = edge;
156
+ std::cout << " Setting weightType = max" << std::endl;
255
157
ewgts[neighborCounter++] = std::numeric_limits<weightType>::max ();
256
158
}
257
159
@@ -310,7 +212,7 @@ void getCpGridWellsEdgeList(void *graphPointer, int sizeGID, int sizeLID,
310
212
311
213
for ( int cell = 0 ; cell < numCells; cell++ )
312
214
{
313
- fillNBORGIDAndWeightsForSpecificCellAndIncrementNeighborCounterForGridWithWells (graph, localID[cell], globalID, neighborCounter, nborGID, ewgts);
215
+ fillNBORGIDAndWeightsForSpecificCellAndIncrementNeighborCounter (graph, localID[cell], globalID, neighborCounter, nborGID, ewgts);
314
216
#ifndef NDEBUG
315
217
assert (neighborCounter-oldNeighborCounter==numEdges[cell]);
316
218
oldNeighborCounter = neighborCounter;
@@ -353,6 +255,8 @@ CombinedGridWellGraph::CombinedGridWellGraph(const CpGrid& grid,
353
255
// wellsGraph not needed
354
256
return ;
355
257
}
258
+ if (edgeWeightsMethod == logTransEdgeWgt)
259
+ findMaxMinTrans ();
356
260
wellsGraph_.resize (grid.numCells ());
357
261
const auto & cpgdim = grid.logicalCartesianSize ();
358
262
// create compressed lookup from cartesian.
@@ -362,33 +266,17 @@ CombinedGridWellGraph::CombinedGridWellGraph(const CpGrid& grid,
362
266
{
363
267
cartesian_to_compressed[grid.globalCell ()[i]] = i;
364
268
}
365
- well_indices_.init (*wells, possibleFutureConnections, cpgdim, cartesian_to_compressed);
269
+ if (wells) {
270
+ // If we're not taking the wells into account here we don't init the connections
271
+ well_indices_.init (*wells, possibleFutureConnections, cpgdim, cartesian_to_compressed);
272
+ addCompletionSetToGraph ();
273
+ } else {
274
+ // std::vector<OpmWellType> emptyWells = {};
275
+ // well_indices_.init({}, {}, cpgdim, cartesian_to_compressed);
276
+ }
366
277
std::vector<int >().swap (cartesian_to_compressed); // free memory.
367
- addCompletionSetToGraph ();
368
-
369
- if (edgeWeightsMethod == logTransEdgeWgt)
370
- findMaxMinTrans ();
371
278
}
372
279
373
- void setCpGridZoltanGraphFunctions (Zoltan_Struct *zz, const Dune::CpGrid& grid,
374
- bool pretendNull)
375
- {
376
- Dune::CpGrid *gridPointer = const_cast <Dune::CpGrid*>(&grid);
377
- if ( pretendNull )
378
- {
379
- Zoltan_Set_Num_Obj_Fn (zz, getNullNumCells, gridPointer);
380
- Zoltan_Set_Obj_List_Fn (zz, getNullVertexList, gridPointer);
381
- Zoltan_Set_Num_Edges_Multi_Fn (zz, getNullNumEdgesList, gridPointer);
382
- Zoltan_Set_Edge_List_Multi_Fn (zz, getNullEdgeList, gridPointer);
383
- }
384
- else
385
- {
386
- Zoltan_Set_Num_Obj_Fn (zz, getCpGridNumCells, gridPointer);
387
- Zoltan_Set_Obj_List_Fn (zz, getCpGridVertexList, gridPointer);
388
- Zoltan_Set_Num_Edges_Multi_Fn (zz, getCpGridNumEdgesList, gridPointer);
389
- Zoltan_Set_Edge_List_Multi_Fn (zz, getCpGridEdgeList, gridPointer);
390
- }
391
- }
392
280
393
281
void setCpGridZoltanGraphFunctions (Zoltan_Struct *zz,
394
282
const CombinedGridWellGraph& graph,
@@ -414,14 +302,10 @@ void setCpGridZoltanGraphFunctions(Zoltan_Struct *zz,
414
302
// Explicit template instantiation for METIS
415
303
#if HAVE_METIS
416
304
template
417
- void fillNBORGIDForSpecificCellAndIncrementNeighborCounter (const Dune::CpGrid&, int , int *, int &, int *& nborGID);
418
- template
419
- void fillNBORGIDAndWeightsForSpecificCellAndIncrementNeighborCounterForGridWithWells (const CombinedGridWellGraph&, const int , int *, int &, int *&, int *);
305
+ void fillNBORGIDAndWeightsForSpecificCellAndIncrementNeighborCounter (const CombinedGridWellGraph&, const int , int *, int &, int *&, int *);
420
306
421
307
template
422
- void fillNBORGIDForSpecificCellAndIncrementNeighborCounter (Dune::CpGrid const &, int , long *, int &, long *&);
423
- template
424
- void fillNBORGIDAndWeightsForSpecificCellAndIncrementNeighborCounterForGridWithWells (Dune::cpgrid::CombinedGridWellGraph const &, int , long *, int &, long *&, long *);
308
+ void fillNBORGIDAndWeightsForSpecificCellAndIncrementNeighborCounter (Dune::cpgrid::CombinedGridWellGraph const &, int , long *, int &, long *&, long *);
425
309
426
310
#endif
427
311
0 commit comments