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

Method StripGhostLayers

Common/DataModel/vtkAMRUtilities.cxx:263–342  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

261
262//------------------------------------------------------------------------------
263void vtkAMRUtilities::StripGhostLayers(
264 vtkOverlappingAMR* ghostedAMRData, vtkOverlappingAMR* strippedAMRData)
265{
266 assert("pre: input AMR data is nullptr" && (ghostedAMRData != nullptr));
267 assert("pre: outputAMR data is nullptr" && (strippedAMRData != nullptr));
268 double spacing[3];
269
270 if (!vtkAMRUtilities::HasPartiallyOverlappingGhostCells(ghostedAMRData))
271 {
272 strippedAMRData->CompositeShallowCopy(ghostedAMRData);
273 return;
274 }
275
276 // TODO: At some point we should check for overlapping cells within the
277 // same level, e.g., consider a level 0 with 2 abutting blocks that is
278 // ghosted by N !!!!
279 std::vector<unsigned int> blocksPerLevel(ghostedAMRData->GetNumberOfLevels());
280 for (unsigned int i = 0; i < blocksPerLevel.size(); i++)
281 {
282 blocksPerLevel[i] = ghostedAMRData->GetNumberOfBlocks(i);
283 }
284 strippedAMRData->Initialize(blocksPerLevel);
285 strippedAMRData->SetOrigin(ghostedAMRData->GetOrigin());
286 strippedAMRData->SetGridDescription(ghostedAMRData->GetGridDescription());
287
288 ghostedAMRData->GetSpacing(0, spacing);
289 strippedAMRData->SetSpacing(0, spacing);
290 unsigned int dataIdx = 0;
291 for (; dataIdx < ghostedAMRData->GetNumberOfBlocks(0); ++dataIdx)
292 {
293 vtkCartesianGrid* cg = ghostedAMRData->GetDataSetAsCartesianGrid(0, dataIdx);
294 // XXX: The vtkCartesianGrid could be used instead of using spacing, which would provide
295 // an alternative implementation when spacing is not available, which can happen when not using
296 // vtkUniformGrid.
297 vtkUniformGrid* grid = vtkUniformGrid::SafeDownCast(cg);
298 if (cg && !grid)
299 {
300 // this method supports nullptr data but not cartesian grid.
301 vtkErrorWithObjectMacro(nullptr, "Cannot StripGhostLayers for an AMR of non vtkUniformGrid");
302 return;
303 }
304 const vtkAMRBox& box = ghostedAMRData->GetAMRBox(0, dataIdx);
305 strippedAMRData->SetAMRBox(0, dataIdx, box);
306 strippedAMRData->SetDataSet(0, dataIdx, grid);
307 } // END for all data at level 0
308
309 int ghost[6];
310 unsigned int levelIdx = 1;
311 for (; levelIdx < ghostedAMRData->GetNumberOfLevels(); ++levelIdx)
312 {
313 dataIdx = 0;
314 ghostedAMRData->GetSpacing(levelIdx, spacing);
315 strippedAMRData->SetSpacing(levelIdx, spacing);
316 for (; dataIdx < ghostedAMRData->GetNumberOfBlocks(levelIdx); ++dataIdx)
317 {
318 vtkUniformGrid* grid =
319 vtkUniformGrid::SafeDownCast(ghostedAMRData->GetDataSetAsCartesianGrid(levelIdx, dataIdx));
320 int r = ghostedAMRData->GetRefinementRatio(levelIdx);

Callers

nothing calls this directly

Calls 15

GetGridDescriptionMethod · 0.80
GetAMRBoxMethod · 0.80
RemoveGhostsMethod · 0.80
GetGhostVectorMethod · 0.80
GetDataDescriptionMethod · 0.80
DeleteMethod · 0.65
assertFunction · 0.50
vtkAMRBoxClass · 0.50
CompositeShallowCopyMethod · 0.45
GetNumberOfLevelsMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected