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

Method ReadConnectivity

IO/ParallelNetCDF/vtkPSLACReader.cxx:516–790  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

514
515//------------------------------------------------------------------------------
516int vtkPSLACReader::ReadConnectivity(
517 int meshFD, vtkMultiBlockDataSet* surfaceOutput, vtkMultiBlockDataSet* volumeOutput)
518{
519 //---------------------------------
520 // Call the superclass to read the arrays from disk and assemble the
521 // primitives. The superclass will call the ReadTetrahedron*Array methods,
522 // which we have overridden to read only a partition of the cells.
523 if (!this->Superclass::ReadConnectivity(meshFD, surfaceOutput, volumeOutput))
524 {
525 return 0;
526 }
527
528 //---------------------------------
529 // Right now, the output only has blocks that are defined by the local piece.
530 // However, downstream components will expect the multiblock structure to be
531 // uniform amongst all processes. Thus, we correct that problem here by
532 // adding empty blocks for those not in our local piece.
533 SynchronizeBlocks(surfaceOutput, this->Controller, IS_EXTERNAL_SURFACE());
534 SynchronizeBlocks(volumeOutput, this->Controller, IS_INTERNAL_VOLUME());
535
536 //---------------------------------
537 // This multiblock that contains both outputs provides an easy way to iterate
538 // over all cells in both output.
539 vtkNew<vtkMultiBlockDataSet> compositeOutput;
540 compositeOutput->SetNumberOfBlocks(2);
541 compositeOutput->SetBlock(SURFACE_OUTPUT, surfaceOutput);
542 compositeOutput->SetBlock(VOLUME_OUTPUT, volumeOutput);
543
544 // ---------------------------------
545 // All the cells have "global" ids. That is, an index into a global list of
546 // all possible points. We don't want to have to read in all points in all
547 // processes, so here we are going to figure out what points we need to load
548 // locally, make maps between local and global ids, and convert the ids in the
549 // connectivity arrays from global ids to local ids.
550
551 this->PInternal->LocalToGlobalIds = vtkSmartPointer<vtkIdTypeArray>::New();
552 this->PInternal->LocalToGlobalIds->SetName("GlobalIds");
553
554 // Iterate over all points of all cells and mark what points we encounter
555 // in GlobalToLocalIds.
556 this->PInternal->GlobalToLocalIds.clear();
557 vtkSmartPointer<vtkCompositeDataIterator> outputIter;
558 for (outputIter.TakeReference(compositeOutput->NewIterator()); !outputIter->IsDoneWithTraversal();
559 outputIter->GoToNextItem())
560 {
561 vtkUnstructuredGrid* ugrid =
562 vtkUnstructuredGrid::SafeDownCast(compositeOutput->GetDataSet(outputIter));
563 vtkCellArray* cells = ugrid->GetCells();
564
565 vtkIdType npts;
566 const vtkIdType* pts;
567 for (cells->InitTraversal(); cells->GetNextCell(npts, pts);)
568 {
569 for (vtkIdType i = 0; i < npts; i++)
570 {
571 // The following inserts an entry into the map if one does not exist.
572 // We will assign actual local ids later.
573 this->PInternal->GlobalToLocalIds[pts[i]] = -1;

Callers

nothing calls this directly

Calls 15

SynchronizeBlocksFunction · 0.85
nc_inq_varidFunction · 0.85
SetNumberOfBlocksMethod · 0.80
SetBlockMethod · 0.80
GatherVMethod · 0.80
GoToNextCellMethod · 0.80
NewFunction · 0.50
SortFunction · 0.50
SetNameMethod · 0.45
clearMethod · 0.45
TakeReferenceMethod · 0.45
NewIteratorMethod · 0.45

Tested by

no test coverage detected