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

Function SynchronizeBlocks

IO/ParallelNetCDF/vtkPSLACReader.cxx:154–182  ·  view source on GitHub ↗

============================================================================= Make sure that each process has the same number of blocks in the same position. Assumes that all blocks are unstructured grids.

Source from the content-addressed store, hash-verified

152// Make sure that each process has the same number of blocks in the same
153// position. Assumes that all blocks are unstructured grids.
154static void SynchronizeBlocks(vtkMultiBlockDataSet* blocks, vtkMultiProcessController* controller,
155 vtkInformationIntegerKey* typeKey)
156{
157 unsigned long localNumBlocks = blocks->GetNumberOfBlocks();
158 unsigned long numBlocks;
159 controller->AllReduce(&localNumBlocks, &numBlocks, 1, vtkCommunicator::MAX_OP);
160 if (blocks->GetNumberOfBlocks() < numBlocks)
161 {
162 blocks->SetNumberOfBlocks(numBlocks);
163 }
164
165 for (unsigned int blockId = 0; blockId < numBlocks; blockId++)
166 {
167 vtkDataObject* object = blocks->GetBlock(blockId);
168 if (object && !object->IsA("vtkUnstructuredGrid"))
169 {
170 vtkGenericWarningMacro(<< "Sanity error: found a block that is not an unstructured grid.");
171 }
172 int localBlockExists = (object != nullptr);
173 int globalBlockExists = 0;
174 controller->AllReduce(&localBlockExists, &globalBlockExists, 1, vtkCommunicator::LOGICAL_OR_OP);
175 if (!localBlockExists && globalBlockExists)
176 {
177 vtkNew<vtkUnstructuredGrid> grid;
178 blocks->SetBlock(blockId, grid);
179 blocks->GetMetaData(blockId)->Set(typeKey, 1);
180 }
181 }
182}
183
184//=============================================================================
185// Structures used by ReadMidpointCoordinates to store and transfer midpoint

Callers 1

ReadConnectivityMethod · 0.85

Calls 8

SetNumberOfBlocksMethod · 0.80
GetBlockMethod · 0.80
IsAMethod · 0.80
SetBlockMethod · 0.80
GetNumberOfBlocksMethod · 0.45
AllReduceMethod · 0.45
SetMethod · 0.45
GetMetaDataMethod · 0.45

Tested by

no test coverage detected