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

Function DistributeAMRBoxes

IO/CatalystConduit/vtkConduitToDataObject.cxx:251–329  ·  view source on GitHub ↗

distribute AMRBoxes to all processes

Source from the content-addressed store, hash-verified

249
250// distribute AMRBoxes to all processes
251void DistributeAMRBoxes(
252 const LocalInfo& rankInfo, const GlobalInfo& globalInfo, vtkOverlappingAMR* amr)
253{
254 vtkMultiProcessController* controller = vtkMultiProcessController::GetGlobalController();
255
256 if (globalInfo.NbOfProcesses == 1 || !controller)
257 {
258 return;
259 }
260 std::vector<vtkIdType> boxBoundsOffsets(globalInfo.NbOfProcesses, 0);
261 std::vector<vtkIdType> boxBoundsCounts(globalInfo.NbOfProcesses);
262 std::vector<int> boxExtentsLocal(8 * rankInfo.NbOfBlocks, 0);
263 std::vector<int> boxExtentsGlobal(8 * globalInfo.NbOfBlocks, 0);
264
265 for (int rank = 0; rank < globalInfo.NbOfProcesses; ++rank)
266 {
267 int num_blocks = 0;
268 for (int level = 0; level < globalInfo.NbOfLevels; level++)
269 {
270 num_blocks += globalInfo.BlocksPerLevelAndRank[level + rank * globalInfo.NbOfLevels];
271 }
272 boxBoundsCounts[rank] = num_blocks * 8;
273 if (rank > 0)
274 {
275 boxBoundsOffsets[rank] = boxBoundsCounts[rank - 1] + boxBoundsOffsets[rank - 1];
276 }
277 }
278
279 int local_index = 0;
280 for (std::map<int, std::pair<int, int>>::const_iterator it = rankInfo.DomainBlockLevelIds.begin();
281 it != rankInfo.DomainBlockLevelIds.end(); ++it)
282 {
283 int level = it->second.first;
284 int id = it->second.second + rankInfo.BlockOffsets[level];
285
286 vtkAMRBox box = amr->GetAMRBox(level, id);
287 const int* loCorner = box.GetLoCorner();
288 const int* hiCorner = box.GetHiCorner();
289 int offset = 8 * local_index;
290 boxExtentsLocal[offset + 0] = level;
291 boxExtentsLocal[offset + 1] = id;
292 boxExtentsLocal[offset + 2] = loCorner[0];
293 boxExtentsLocal[offset + 3] = loCorner[1];
294 boxExtentsLocal[offset + 4] = loCorner[2];
295 boxExtentsLocal[offset + 5] = hiCorner[0];
296 boxExtentsLocal[offset + 6] = hiCorner[1];
297 boxExtentsLocal[offset + 7] = hiCorner[2];
298 ++local_index;
299 }
300
301 controller->AllGatherV(boxExtentsLocal.data(), boxExtentsGlobal.data(), boxExtentsLocal.size(),
302 boxBoundsCounts.data(), boxBoundsOffsets.data());
303 for (int block = 0; block < globalInfo.NbOfBlocks; ++block)
304 {
305 int level = boxExtentsGlobal[8 * block];
306 int id = boxExtentsGlobal[8 * block + 1];
307 int* dims = &boxExtentsGlobal[8 * block + 2];
308 vtkAMRBox box(dims[0], dims[1], dims[2], dims[3], dims[4], dims[5]);

Callers 1

FillAMRMeshFunction · 0.85

Calls 10

GetAMRBoxMethod · 0.80
AllGatherVMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
SetAMRBoxMethod · 0.45
GetSpacingMethod · 0.45
AllReduceMethod · 0.45
SetSpacingMethod · 0.45

Tested by

no test coverage detected