Mesh Oriented datABase  (version 5.6.0)
An array-based unstructured mesh library
NCHelperScrip.cpp
Go to the documentation of this file.
1 /*
2  * NCHelperScrip.cpp
3  */
4 
5 #include "NCHelperScrip.hpp"
6 #include "moab/ReadUtilIface.hpp"
7 #include "AEntityFactory.hpp"
9 #ifdef MOAB_HAVE_MPI
11 #endif
12 #ifdef MOAB_HAVE_ZOLTAN
14 #endif
15 
16 namespace moab
17 {
18 
19 bool NCHelperScrip::can_read_file( ReadNC* readNC, int /*fileId*/ )
20 {
21  std::vector< std::string >& dimNames = readNC->dimNames;
22 
23  // If dimension names "grid_size" AND "grid_corners" AND "grid_rank" exist then it should be the Scrip grid
24  if( ( std::find( dimNames.begin(), dimNames.end(), std::string( "grid_size" ) ) != dimNames.end() ) &&
25  ( std::find( dimNames.begin(), dimNames.end(), std::string( "grid_corners" ) ) != dimNames.end() ) &&
26  ( std::find( dimNames.begin(), dimNames.end(), std::string( "grid_rank" ) ) != dimNames.end() ) )
27  {
28  return true;
29  }
30 
31  return false;
32 }
34 {
35  Interface*& mbImpl = _readNC->mbImpl;
36  std::vector< std::string >& dimNames = _readNC->dimNames;
37  std::vector< int >& dimLens = _readNC->dimLens;
38 
39  unsigned int idx;
40  std::vector< std::string >::iterator vit;
41 
42  // get grid_size
43  if( ( vit = std::find( dimNames.begin(), dimNames.end(), "grid_size" ) ) != dimNames.end() )
44  {
45  idx = vit - dimNames.begin();
46  grid_size = dimLens[idx];
47  }
48 
49  // get grid_corners
50  if( ( vit = std::find( dimNames.begin(), dimNames.end(), "grid_corners" ) ) != dimNames.end() )
51  {
52  idx = vit - dimNames.begin();
53  grid_corners = dimLens[idx];
54  }
55 
56  // get grid_rank
57  if( ( vit = std::find( dimNames.begin(), dimNames.end(), "grid_rank" ) ) != dimNames.end() )
58  {
59  idx = vit - dimNames.begin();
60  grid_rank = dimLens[idx];
61  }
62 
63  // do not need conventional tags
64  Tag convTagsCreated = 0;
65  int def_val = 0;
66  MB_CHK_SET_ERR( mbImpl->tag_get_handle( "__CONV_TAGS_CREATED", 1, MB_TYPE_INTEGER, convTagsCreated,
67  MB_TAG_SPARSE | MB_TAG_CREAT, &def_val ),
68  "Trouble getting _CONV_TAGS_CREATED tag" );
69  int create_conv_tags_flag = 1;
70  MB_CHK_SET_ERR( mbImpl->tag_set_data( convTagsCreated, &_fileSet, 1, &create_conv_tags_flag ),
71  "Trouble setting _CONV_TAGS_CREATED tag" );
72 
73  // decide now the units, by looking at grid_center_lon
74  int xCellVarId;
75  int success = NCFUNC( inq_varid )( _fileId, "grid_center_lon", &xCellVarId );
76  if( success ) MB_CHK_SET_ERR( MB_FAILURE, "Trouble getting grid_center_lon" );
77  std::map< std::string, ReadNC::VarData >& varInfo = _readNC->varInfo;
78  auto vmit = varInfo.find( "grid_center_lon" );
79  if( varInfo.end() == vmit ) MB_SET_ERR( MB_FAILURE, "Couldn't find variable " << "grid_center_lon" );
80  ReadNC::VarData& glData = vmit->second;
81  auto attIt = glData.varAtts.find( "units" );
82  if( attIt != glData.varAtts.end() )
83  {
84  unsigned int sz = attIt->second.attLen;
85  std::string att_data;
86  att_data.resize( sz + 1 );
87  att_data[sz] = '\000';
88  success =
89  NCFUNC( get_att_text )( _fileId, attIt->second.attVarId, attIt->second.attName.c_str(), &att_data[0] );
90  if( 0 == success && att_data.find( "radians" ) != std::string::npos ) degrees = false;
91  }
92 
93  return MB_SUCCESS;
94 }
96 {
97  Interface*& mbImpl = _readNC->mbImpl;
98  DebugOutput& dbgOut = _readNC->dbgOut;
99  Tag& mGlobalIdTag = _readNC->mGlobalIdTag;
100  ErrorCode rval;
101 
102 #ifdef MOAB_HAVE_MPI
103  int rank = 0;
104  int procs = 1;
105  bool& isParallel = _readNC->isParallel;
106  ParallelComm* myPcomm = NULL;
107  if( isParallel )
108  {
109  myPcomm = _readNC->myPcomm;
110  rank = myPcomm->proc_config().proc_rank();
111  procs = myPcomm->proc_config().proc_size();
112  }
113 
114  if( procs >= 2 )
115  {
116  // Shift rank to obtain a rotated trivial partition
117  int shifted_rank = rank;
118  int& trivialPartitionShift = _readNC->trivialPartitionShift;
119  if( trivialPartitionShift > 0 ) shifted_rank = ( rank + trivialPartitionShift ) % procs;
120 
121  // Compute the number of local cells on this proc
122  nLocalCells = int( std::floor( 1.0 * grid_size / procs ) );
123 
124  // The starting global cell index in the MPAS file for this proc
125  int start_cell_idx = shifted_rank * nLocalCells;
126 
127  // Number of extra cells after equal split over procs
128  int iextra = grid_size % procs;
129 
130  // Allocate extra cells over procs
131  if( shifted_rank < iextra ) nLocalCells++;
132  start_cell_idx += std::min( shifted_rank, iextra );
133 
134  start_cell_idx++; // 0 based -> 1 based
135 
136  // Redistribute local cells after trivial partition (e.g. apply Zoltan partition)
137  MB_CHK_SET_ERR( redistribute_local_cells( start_cell_idx, myPcomm ),
138  "Failed to redistribute local cells after trivial partition" );
139  }
140  else
141  {
144  }
145 #else
148 #endif
149  dbgOut.tprintf( 1, " localGidCells.psize() = %d\n", (int)localGidCells.psize() );
150  dbgOut.tprintf( 1, " localGidCells.size() = %d\n", (int)localGidCells.size() );
151 
152  // double grid_corner_lat(grid_size, grid_corners) ;
153  // double grid_corner_lon(grid_size, grid_corners) ;
154  int xvId, yvId;
155  int success = NCFUNC( inq_varid )( _fileId, "grid_corner_lon", &xvId );
156  if( success ) MB_SET_ERR( MB_FAILURE, "Failed to get variable id of grid_corner_lon" );
157  success = NCFUNC( inq_varid )( _fileId, "grid_corner_lat", &yvId );
158  if( success ) MB_SET_ERR( MB_FAILURE, "Failed to get variable id of grid_corner_lat" );
159 
160  // important upgrade: read masks if they exist, and save them as tags
161  int gmId = -1;
162  int sizeMasks = 0;
163 #ifdef MOAB_HAVE_PNETCDF
164  int factorRequests = 2; // we would read in general only 2 variables, xv and yv
165 #endif
166  success = NCFUNC( inq_varid )( _fileId, "grid_imask", &gmId );
167  Tag maskTag = 0; // not sure yet if we have the masks or not
168  if( success )
169  {
170  gmId = -1; // we do not have masks
171  }
172  else
173  {
174  sizeMasks = nLocalCells;
175 #ifdef MOAB_HAVE_PNETCDF
176  factorRequests = 3; // we also need to read masks distributed
177 #endif
178  // create the maskTag GRID_IMASK, with default value of 1
179  int def_val = 1;
180  MB_CHK_SET_ERR( mbImpl->tag_get_handle( "GRID_IMASK", 1, MB_TYPE_INTEGER, maskTag, MB_TAG_DENSE | MB_TAG_CREAT,
181  &def_val ),
182  "Trouble creating GRID_IMASK tag" );
183  }
184 
185  std::vector< double > xv( nLocalCells * grid_corners );
186  std::vector< double > yv( nLocalCells * grid_corners );
187  std::vector< int > masks( sizeMasks );
188 #ifdef MOAB_HAVE_PNETCDF
189  size_t nb_reads = localGidCells.psize();
190  std::vector< int > requests( nb_reads * factorRequests );
191  std::vector< int > statuss( nb_reads * factorRequests );
192  size_t idxReq = 0;
193 #endif
194  size_t indexInArray = 0;
195  size_t indexInMaskArray = 0;
196  for( Range::pair_iterator pair_iter = localGidCells.pair_begin(); pair_iter != localGidCells.pair_end();
197  ++pair_iter )
198  {
199  EntityHandle starth = pair_iter->first;
200  EntityHandle endh = pair_iter->second;
201  NCDF_SIZE read_starts[2] = { static_cast< NCDF_SIZE >( starth - 1 ), 0 };
202  NCDF_SIZE read_counts[2] = { static_cast< NCDF_SIZE >( endh - starth + 1 ),
203  static_cast< NCDF_SIZE >( grid_corners ) };
204 
205  // Do a partial read in each subrange
206 #ifdef MOAB_HAVE_PNETCDF
207  success = NCFUNCREQG( _vara_double )( _fileId, xvId, read_starts, read_counts, &( xv[indexInArray] ),
208  &requests[idxReq++] );
209 #else
210  success = NCFUNCAG( _vara_double )( _fileId, xvId, read_starts, read_counts, &( xv[indexInArray] ) );
211 #endif
212  if( success ) MB_SET_ERR( MB_FAILURE, "Failed to read grid_corner_lon data in a loop" );
213 
214  // Do a partial read in each subrange
215 #ifdef MOAB_HAVE_PNETCDF
216  success = NCFUNCREQG( _vara_double )( _fileId, yvId, read_starts, read_counts, &( yv[indexInArray] ),
217  &requests[idxReq++] );
218 #else
219  success = NCFUNCAG( _vara_double )( _fileId, yvId, read_starts, read_counts, &( yv[indexInArray] ) );
220 #endif
221  if( success ) MB_SET_ERR( MB_FAILURE, "Failed to read grid_corner_lat data in a loop" );
222  // Increment the index for next subrange
223  indexInArray += ( endh - starth + 1 ) * grid_corners;
224 
225  if( gmId >= 0 ) // it means we need to read masks too, distributed:
226  {
227  NCDF_SIZE read_st = static_cast< NCDF_SIZE >( starth - 1 );
228  NCDF_SIZE read_ct = static_cast< NCDF_SIZE >( endh - starth + 1 );
229  // Do a partial read in each subrange, for mask variable:
230 #ifdef MOAB_HAVE_PNETCDF
231  success = NCFUNCREQG( _vara_int )( _fileId, gmId, &read_st, &read_ct, &( masks[indexInMaskArray] ),
232  &requests[idxReq++] );
233 #else
234  success = NCFUNCAG( _vara_int )( _fileId, gmId, &read_st, &read_ct, &( masks[indexInMaskArray] ) );
235 #endif
236  if( success ) MB_SET_ERR( MB_FAILURE, "Failed on mask read " );
237  indexInMaskArray += endh - starth + 1;
238  }
239  }
240 
241 #ifdef MOAB_HAVE_PNETCDF
242  // Wait outside the loop
243  success = NCFUNC( wait_all )( _fileId, requests.size(), &requests[0], &statuss[0] );
244  if( success ) MB_SET_ERR( MB_FAILURE, "Failed on wait_all" );
245 #endif
246 
247  // int grid_dims(grid_rank)
248  {
249  int gdId;
250  int success = NCFUNC( inq_varid )( _fileId, "grid_dims", &gdId );
251  if( success ) MB_SET_ERR( MB_FAILURE, "Failed to get variable id of grid_dims" );
252 
253  // If rectilinear attribute present, mark it
254  std::vector< int > vecDimSizes( 3, 0 );
255  Tag rectilinearTag;
256  // Tag data contains: guessed mesh type, mesh size1, mesh size 2
257  // Example: CS(0)/ICO(1)/ICOD(2), num_elements, num_nodes
258  // : RLL(3), num_lat, num_lon
259 
260  // create the maskTag GRID_IMASK, with default value of 1
261 
262  vecDimSizes[0] = ( grid_rank == 2 ? 1 /* moab::TempestRemapper::RLL */ : 0 /* moab::TempestRemapper::CS */ );
263  vecDimSizes[1] = grid_size; // number of elements
264  vecDimSizes[2] = grid_size; // number of elements
265  rval = mbImpl->tag_get_handle( "ClimateMetadata", 3, MB_TYPE_INTEGER, rectilinearTag,
266  MB_TAG_SPARSE | MB_TAG_CREAT, vecDimSizes.data() );
267  if( MB_ALREADY_ALLOCATED != rval && MB_SUCCESS != rval )
268  MB_CHK_SET_ERR( rval, "can't create rectilinear sizes tag" );
269 
270  if( grid_rank == 2 )
271  {
272  NCDF_SIZE read_starts[1] = { static_cast< NCDF_SIZE >( 0 ) };
273  NCDF_SIZE read_counts[1] = { static_cast< NCDF_SIZE >( grid_rank ) };
274 
275  // Do a partial read in each subrange
276 #ifdef MOAB_HAVE_PNETCDF
277  std::vector< int > requeststatus( 2 );
278  success = NCFUNCREQG( _vara_int )( _fileId, gdId, read_starts, read_counts, vecDimSizes.data() + 1,
279  &requeststatus[0] );
280  if( success ) MB_SET_ERR( MB_FAILURE, "Failed to read grid_dims data" );
281 
282  // Wait outside the loop
283  success = NCFUNC( wait_all )( _fileId, 1, &requeststatus[0], &requeststatus[1] );
284  if( success ) MB_SET_ERR( MB_FAILURE, "Failed on wait_all" );
285 #else
286  success = NCFUNCAG( _vara_int )( _fileId, gdId, read_starts, read_counts, vecDimSizes.data() + 1 );
287  if( success ) MB_SET_ERR( MB_FAILURE, "Failed to read grid_dims data" );
288 #endif
289  }
290 
291  rval = mbImpl->tag_set_data( rectilinearTag, &_fileSet, 1, vecDimSizes.data() );
292  }
293 
294  // so we read xv, yv for all corners in the local mesh, and masks if they exist
295 
296  // Create vertices; first identify different ones, with a tolerance
297  std::map< Node3D, EntityHandle > vertex_map;
298 
299  // Set vertex coordinates
300  // will read all xv, yv, but use only those with correct mask on
301 
302  int elem_index = 0; // local index in netcdf arrays
303  double pideg = 1.; // radians
304  if( degrees ) pideg = acos( -1.0 ) / 180.0;
305 
306  for( ; elem_index < nLocalCells; elem_index++ )
307  {
308  // set area and fraction on those elements too
309  for( int k = 0; k < grid_corners; k++ )
310  {
311  int index_v_arr = grid_corners * elem_index + k;
312  double x, y;
313  x = xv[index_v_arr];
314  y = yv[index_v_arr];
315  double cosphi = cos( pideg * y );
316  double zmult = sin( pideg * y );
317  double xmult = cosphi * cos( x * pideg );
318  double ymult = cosphi * sin( x * pideg );
319  Node3D pt( xmult, ymult, zmult );
320  vertex_map[pt] = 0;
321  }
322  }
323  int nLocalVertices = (int)vertex_map.size();
324  std::vector< double* > arrays;
325  EntityHandle start_vertex, vtx_handle;
326  MB_CHK_SET_ERR( _readNC->readMeshIface->get_node_coords( 3, nLocalVertices, 0, start_vertex, arrays ),
327  "Failed to create local vertices" );
328 
329  vtx_handle = start_vertex;
330  // Copy vertex coordinates into entity sequence coordinate arrays
331  // and copy handle into vertex_map.
332  double *x = arrays[0], *y = arrays[1], *z = arrays[2];
333  for( auto i = vertex_map.begin(); i != vertex_map.end(); ++i )
334  {
335  i->second = vtx_handle;
336  ++vtx_handle;
337  *x = i->first.coords[0];
338  ++x;
339  *y = i->first.coords[1];
340  ++y;
341  *z = i->first.coords[2];
342  ++z;
343  }
344 
345  EntityHandle start_cell;
346  int nv = grid_corners;
347  EntityType mdb_type = MBVERTEX;
348  if( nv == 3 )
349  mdb_type = MBTRI;
350  else if( nv == 4 )
351  mdb_type = MBQUAD;
352  else if( nv > 4 ) // (nv > 4)
353  mdb_type = MBPOLYGON;
354 
355  Range tmp_range;
356  EntityHandle* conn_arr;
357 
358  MB_CHK_SET_ERR( _readNC->readMeshIface->get_element_connect( nLocalCells, nv, mdb_type, 0, start_cell, conn_arr ),
359  "Failed to create local cells" );
360  tmp_range.insert( start_cell, start_cell + nLocalCells - 1 );
361 
362  elem_index = 0;
363 
364  for( ; elem_index < nLocalCells; elem_index++ )
365  {
366  for( int k = 0; k < nv; k++ )
367  {
368  int index_v_arr = nv * elem_index + k;
369  if( nv > 1 )
370  {
371  double x = xv[index_v_arr];
372  double y = yv[index_v_arr];
373  double cosphi = cos( pideg * y );
374  double zmult = sin( pideg * y );
375  double xmult = cosphi * cos( x * pideg );
376  double ymult = cosphi * sin( x * pideg );
377  Node3D pt( xmult, ymult, zmult );
378  conn_arr[elem_index * nv + k] = vertex_map[pt];
379  }
380  }
381  EntityHandle cell = start_cell + elem_index;
382  // set other tags, like xc, yc, frac, area
383  /*MB_CHK_SET_ERR( mbImpl->tag_set_data( xcTag, &cell, 1, &xc[elem_index] ), "Failed to set xc tag" );
384  MB_CHK_SET_ERR( mbImpl->tag_set_data( ycTag, &cell, 1, &yc[elem_index] ), "Failed to set yc tag" );
385  MB_CHK_SET_ERR( mbImpl->tag_set_data( areaTag, &cell, 1, &area[elem_index] ), "Failed to set area tag" );
386  MB_CHK_SET_ERR( mbImpl->tag_set_data( fracTag, &cell, 1, &frac[elem_index] ), "Failed to set frac tag" );
387 */
388  // set the global id too:
389  int globalId = localGidCells[elem_index];
390 
391  MB_CHK_SET_ERR( mbImpl->tag_set_data( mGlobalIdTag, &cell, 1, &globalId ), "Failed to set global id tag" );
392  if( gmId >= 0 )
393  {
394  int localMask = masks[elem_index];
395  MB_CHK_SET_ERR( mbImpl->tag_set_data( maskTag, &cell, 1, &localMask ), "Failed to set mask tag" );
396  }
397  }
398 
399  MB_CHK_SET_ERR( mbImpl->add_entities( _fileSet, tmp_range ), "Failed to add new cells to current file set" );
400 
401  // modify local file set, to merge coincident vertices, and to correct repeated vertices in elements
402  std::vector< Tag > tagList;
403  tagList.push_back( mGlobalIdTag );
404  if( gmId >= 0 ) tagList.push_back( maskTag );
406  "Failed to remove duplicate vertices" );
407 
408  MB_CHK_ERR( mbImpl->get_entities_by_dimension( _fileSet, 2, faces ) );
409  Range all_verts;
410  MB_CHK_ERR( mbImpl->get_connectivity( faces, all_verts ) );
411  MB_CHK_ERR( mbImpl->add_entities( _fileSet, all_verts ) );
412  // need to add adjacencies; TODO: fix this for all nc readers
413  // copy this logic from migrate mesh in par comm graph
414  Core* mb = (Core*)mbImpl;
415  AEntityFactory* adj_fact = mb->a_entity_factory();
416  if( !adj_fact->vert_elem_adjacencies() )
417  adj_fact->create_vert_elem_adjacencies();
418  else
419  {
420  for( Range::iterator it = faces.begin(); it != faces.end(); ++it )
421  {
422  EntityHandle eh = *it;
423  const EntityHandle* conn = NULL;
424  int num_nodes = 0;
425  MB_CHK_ERR( mb->get_connectivity( eh, conn, num_nodes ) );
426  adj_fact->notify_create_entity( eh, conn, num_nodes );
427  }
428  }
429 
430 #ifdef MOAB_HAVE_MPI
431  if( myPcomm )
432  {
433  double tol = 1.e-12; // this is the same as static tolerance in NCHelper
434  ParallelMergeMesh pmm( myPcomm, tol );
436  /* do not do local merge*/ false,
437  /* 2d cells*/ 2 ),
438  "Failed to merge vertices in parallel" );
439 
440  // assign global ids only for vertices, cells have them fine
441  MB_CHK_ERR( myPcomm->assign_global_ids( _fileSet, /*dim*/ 0 ) );
442  // remove all sets, edges and vertices from the file set
443  Range edges, vertices;
444  MB_CHK_ERR( mbImpl->get_entities_by_dimension( _fileSet, 1, edges, /*recursive*/ true ) );
445  MB_CHK_ERR( mbImpl->get_entities_by_dimension( _fileSet, 0, vertices, /*recursive*/ true ) );
446  MB_CHK_ERR( mbImpl->remove_entities( _fileSet, edges ) );
447  MB_CHK_ERR( mbImpl->remove_entities( _fileSet, vertices ) );
448 
449  Range intfSets = myPcomm->interface_sets();
450  // empty intf sets
451  MB_CHK_ERR( mbImpl->clear_meshset( intfSets ) );
452  // delete the sets without shame :)
453  //sets.merge(intfSets);
454  //MB_CHK_ERR( myPcomm->delete_entities(sets) ); // will also clean shared ents !
455  MB_CHK_ERR( myPcomm->delete_entities( edges ) ); // will also clean shared ents !
456  }
457 #else
458  MB_CHK_ERR( mbImpl->remove_entities( _fileSet, all_verts ) );
459 #endif
460 
461  return MB_SUCCESS;
462 }
463 
464 #ifdef MOAB_HAVE_MPI
465 ErrorCode NCHelperScrip::redistribute_local_cells( int start_cell_idx, ParallelComm* pco )
466 {
467  // If possible, apply Zoltan partition
468 #ifdef MOAB_HAVE_ZOLTAN
470  {
471  // Read grid_center_lat coordinates of cell centers
472  int xCellVarId;
473  int success = NCFUNC( inq_varid )( _fileId, "grid_center_lon", &xCellVarId );
474  if( success ) MB_SET_ERR( MB_FAILURE, "Failed to get variable id of grid_center_lon" );
475  std::vector< double > xc( nLocalCells );
476  NCDF_SIZE read_start = static_cast< NCDF_SIZE >( start_cell_idx - 1 );
477  NCDF_SIZE read_count = static_cast< NCDF_SIZE >( nLocalCells );
478  success = NCFUNCAG( _vara_double )( _fileId, xCellVarId, &read_start, &read_count, &xc[0] );
479  if( success ) MB_SET_ERR( MB_FAILURE, "Failed to read grid_center_lat data" );
480 
481  // Read grid_center_lon coordinates of cell centers
482  int yCellVarId;
483  success = NCFUNC( inq_varid )( _fileId, "grid_center_lat", &yCellVarId );
484  if( success ) MB_SET_ERR( MB_FAILURE, "Failed to get variable id of grid_center_lat" );
485  std::vector< double > yc( nLocalCells );
486  success = NCFUNCAG( _vara_double )( _fileId, yCellVarId, &read_start, &read_count, &yc[0] );
487  if( success ) MB_SET_ERR( MB_FAILURE, "Failed to read grid_center_lon data" );
488 
489  // Zoltan partition using RCB; maybe more studies would be good, as to which partition
490  // is better
491  Interface*& mbImpl = _readNC->mbImpl;
492  DebugOutput& dbgOut = _readNC->dbgOut;
493  ZoltanPartitioner* mbZTool = new ZoltanPartitioner( mbImpl, pco, false, 0, NULL );
494  std::vector< double > xCell( nLocalCells );
495  std::vector< double > yCell( nLocalCells );
496  std::vector< double > zCell( nLocalCells );
497  double pideg = 1.; // radians
498  if( degrees ) pideg = acos( -1.0 ) / 180.0;
499  double x, y, cosphi;
500  for( int i = 0; i < nLocalCells; i++ )
501  {
502  x = xc[i];
503  y = yc[i];
504  cosphi = cos( pideg * y );
505  zCell[i] = sin( pideg * y );
506  xCell[i] = cosphi * cos( x * pideg );
507  yCell[i] = cosphi * sin( x * pideg );
508  }
509  MB_CHK_SET_ERR( mbZTool->repartition( xCell, yCell, zCell, start_cell_idx, "RCB", localGidCells ),
510  "Error in Zoltan partitioning" );
511  delete mbZTool;
512 
513  dbgOut.tprintf( 1, "After Zoltan partitioning, localGidCells.psize() = %d\n", (int)localGidCells.psize() );
514  dbgOut.tprintf( 1, " localGidCells.size() = %d\n", (int)localGidCells.size() );
515 
516  // This is important: local cells are now redistributed, so nLocalCells might be different!
518 
519  return MB_SUCCESS;
520  }
521 #else
522  UNUSED( pco );
523 #endif
524 
525  // By default, apply trivial partition
526  localGidCells.insert( start_cell_idx, start_cell_idx + nLocalCells - 1 );
527 
528  return MB_SUCCESS;
529 }
530 #endif
531 
532 } /* namespace moab */