MCPcopy Create free account
hub / github.com/Kitware/VTK / DivideCells

Method DivideCells

IO/Parallel/vtkPChacoReader.cxx:300–376  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

298}
299//------------------------------------------------------------------------------
300int vtkPChacoReader::DivideCells(
301 vtkMultiProcessController* contr, vtkUnstructuredGrid* output, int source)
302{
303 int retVal = 1;
304
305 int i = 0;
306
307 int nprocs = contr->GetNumberOfProcesses();
308 int myrank = contr->GetLocalProcessId();
309
310 vtkUnstructuredGrid* mygrid = nullptr;
311
312 if (source == myrank)
313 {
314 vtkIdType ntotalcells = output->GetNumberOfCells();
315 vtkIdType nshare = ntotalcells / nprocs;
316 vtkIdType leftover = ntotalcells - (nprocs * nshare);
317
318 vtkIdType startId = 0;
319
320 for (i = 0; i < nprocs; i++)
321 {
322 if (!retVal && (i != myrank))
323 {
324 this->SendGrid(contr, i, nullptr); // we failed
325 continue;
326 }
327
328 vtkIdType ncells = ((i < leftover) ? nshare + 1 : nshare);
329
330 vtkIdType endId = startId + ncells - 1;
331
332 vtkUnstructuredGrid* ug = this->SubGrid(output, startId, endId);
333
334 if (i != myrank)
335 {
336 retVal = this->SendGrid(contr, i, ug);
337 ug->Delete();
338 }
339 else
340 {
341 mygrid = ug;
342 }
343 startId += ncells;
344 }
345 }
346 else
347 {
348 mygrid = this->GetGrid(contr, source);
349 if (mygrid == nullptr)
350 {
351 retVal = 0;
352 }
353 }
354
355 int vote = 0;
356 contr->Reduce(&retVal, &vote, 1, vtkCommunicator::SUM_OP, 0);
357 contr->Broadcast(&vote, 1, 0);

Callers 1

RequestDataMethod · 0.95

Calls 11

SendGridMethod · 0.95
SubGridMethod · 0.95
GetGridMethod · 0.95
GetNumberOfProcessesMethod · 0.80
DeleteMethod · 0.65
GetLocalProcessIdMethod · 0.45
GetNumberOfCellsMethod · 0.45
ReduceMethod · 0.45
BroadcastMethod · 0.45
InitializeMethod · 0.45
ShallowCopyMethod · 0.45

Tested by

no test coverage detected