@@ -88,42 +88,8 @@ void getNullNumEdgesList(void *cpGridPointer, int sizeGID, int sizeLID,
8888        *err = ZOLTAN_OK;
8989}
9090
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- }
10591
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) {
12793    const  Dune::CpGrid&  grid = graph.getGrid ();
12894    //  Initial set of faces is the ones of the well completions
12995    auto  edges = graph.getWellsGraph ()[localCellId];
@@ -162,7 +128,7 @@ void getCpGridWellsNumEdgesList(void *graphPointer, int sizeGID, int sizeLID,
162128    }
163129    for ( int  i = 0 ; i < numCells;  i++ )
164130    {
165-         numEdges[i] = getNumberOfEdgesForSpecificCellForGridWithWells (graph, localID[i]);
131+         numEdges[i] = getNumberOfEdgesForSpecificCell (graph, localID[i]);
166132    }
167133    *err = ZOLTAN_OK;
168134}
@@ -179,73 +145,8 @@ void getNullEdgeList(void *cpGridPointer, int sizeGID, int sizeLID,
179145    *err = ZOLTAN_OK;
180146}
181147
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- }
247148template <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) {
249150    const  Dune::CpGrid&  grid = graph.getGrid ();
250151    //  First the strong edges of the well completions.
251152    auto  wellEdges = graph.getWellsGraph ()[localCellId];
@@ -310,7 +211,7 @@ void getCpGridWellsEdgeList(void *graphPointer, int sizeGID, int sizeLID,
310211
311212    for ( int  cell = 0 ; cell < numCells;  cell++ )
312213    {
313-         fillNBORGIDAndWeightsForSpecificCellAndIncrementNeighborCounterForGridWithWells (graph, localID[cell], globalID, neighborCounter, nborGID, ewgts);
214+         fillNBORGIDAndWeightsForSpecificCellAndIncrementNeighborCounter (graph, localID[cell], globalID, neighborCounter, nborGID, ewgts);
314215#ifndef  NDEBUG
315216        assert (neighborCounter-oldNeighborCounter==numEdges[cell]);
316217        oldNeighborCounter = neighborCounter;
@@ -354,41 +255,24 @@ CombinedGridWellGraph::CombinedGridWellGraph(const CpGrid& grid,
354255        return ;
355256    }
356257    wellsGraph_.resize (grid.numCells ());
357-     const  auto & cpgdim = grid.logicalCartesianSize ();
358-     //  create compressed lookup from cartesian.
359-     std::vector<int > cartesian_to_compressed (cpgdim[0 ]*cpgdim[1 ]*cpgdim[2 ], -1 );
258+     if  (wells) {
259+         const  auto & cpgdim = grid.logicalCartesianSize ();
260+         //  create compressed lookup from cartesian.
261+         std::vector<int > cartesian_to_compressed (cpgdim[0 ]*cpgdim[1 ]*cpgdim[2 ], -1 );
360262
361-     for ( int  i=0 ; i < grid.numCells (); ++i )
362-     {
363-         cartesian_to_compressed[grid.globalCell ()[i]] = i;
263+         for ( int  i=0 ; i < grid.numCells (); ++i )
264+         {
265+             cartesian_to_compressed[grid.globalCell ()[i]] = i;
266+         }
267+         //  If we're not taking the wells into account here we don't init the connections
268+         well_indices_.init (*wells, possibleFutureConnections, cpgdim, cartesian_to_compressed);
269+         std::vector<int >().swap (cartesian_to_compressed); //  free memory.
270+         addCompletionSetToGraph ();
364271    }
365-     well_indices_.init (*wells, possibleFutureConnections, cpgdim, cartesian_to_compressed);
366-     std::vector<int >().swap (cartesian_to_compressed); //  free memory.
367-     addCompletionSetToGraph ();
368- 
369272    if  (edgeWeightsMethod == logTransEdgeWgt)
370273        findMaxMinTrans ();
371274}
372275
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- }
392276
393277void  setCpGridZoltanGraphFunctions (Zoltan_Struct *zz,
394278                                   const  CombinedGridWellGraph& graph,
@@ -414,14 +298,10 @@ void setCpGridZoltanGraphFunctions(Zoltan_Struct *zz,
414298//  Explicit template instantiation for METIS
415299#if  HAVE_METIS
416300template 
417- void  fillNBORGIDForSpecificCellAndIncrementNeighborCounter (const  Dune::CpGrid&, int , int *, int &, int *& nborGID);
418- template 
419- void  fillNBORGIDAndWeightsForSpecificCellAndIncrementNeighborCounterForGridWithWells (const  CombinedGridWellGraph&, const  int , int *, int &, int *&, int *);
301+ void  fillNBORGIDAndWeightsForSpecificCellAndIncrementNeighborCounter (const  CombinedGridWellGraph&, const  int , int *, int &, int *&, int *);
420302
421303template 
422- void  fillNBORGIDForSpecificCellAndIncrementNeighborCounter (Dune::CpGrid const &, int , long *, int &, long *&);
423- template 
424- void  fillNBORGIDAndWeightsForSpecificCellAndIncrementNeighborCounterForGridWithWells (Dune::cpgrid::CombinedGridWellGraph const &, int , long *, int &, long *&, long *);
304+ void  fillNBORGIDAndWeightsForSpecificCellAndIncrementNeighborCounter (Dune::cpgrid::CombinedGridWellGraph const &, int , long *, int &, long *&, long *);
425305
426306#endif 
427307
0 commit comments