============================================================================= Make sure that each process has the same number of blocks in the same position. Assumes that all blocks are unstructured grids.
| 152 | // Make sure that each process has the same number of blocks in the same |
| 153 | // position. Assumes that all blocks are unstructured grids. |
| 154 | static 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 |
no test coverage detected