Commit 524ba39d authored by Chuck Atkins's avatar Chuck Atkins Committed by Kitware Robot
Browse files

Merge topic 'multiple-ghostcell-layers'


 Updated vtkPUnstructuredGridGhostCellsGenerator
Acked-by: Kitware Robot's avatarKitware Robot <>
Reviewed-by: default avatarJoachim Pouderoux <>
Merge-request: !1107
parents ffd7a24f e8c9e0af
......@@ -145,40 +145,45 @@ int TestPUnstructuredGridGhostCellsGenerator(int argc, char* argv[])
// Check ghost cells generated with and without the global point ids
// for several ghost layer levels
int maxGhostLevel = 2;
vtkUnstructuredGrid* outGrids[2];
for(int ghostLevel = 1; ghostLevel <= maxGhostLevel; ++ghostLevel)
for(int step = 0; step < 2; ++step)
ghostGenerator->SetUseGlobalPointIds(step == 0 ? 1 : 0);
vtkNew<vtkTimerLog> timer;
ghostGenerator->UpdatePiece(rankId, nbRanks, 1);
ghostGenerator->UpdatePiece(rankId, nbRanks, ghostLevel);
// Save the grid for further analyze
// Save the grid for further analysis
outGrids[step] = ghostGenerator->GetOutput();
double ellapsed = timer->GetElapsedTime();
double elapsed = timer->GetElapsedTime();
// get some performance statistics
double minGhostUpdateTime = 0.0;
double maxGhostUpdateTime = 0.0;
double avgGhostUpdateTime = 0.0;
controller->Reduce(&ellapsed, &minGhostUpdateTime, 1, vtkCommunicator::MIN_OP, 0);
controller->Reduce(&ellapsed, &maxGhostUpdateTime, 1, vtkCommunicator::MAX_OP, 0);
controller->Reduce(&ellapsed, &avgGhostUpdateTime, 1, vtkCommunicator::SUM_OP, 0);
controller->Reduce(&elapsed, &minGhostUpdateTime, 1, vtkCommunicator::MIN_OP, 0);
controller->Reduce(&elapsed, &maxGhostUpdateTime, 1, vtkCommunicator::MAX_OP, 0);
controller->Reduce(&elapsed, &avgGhostUpdateTime, 1, vtkCommunicator::SUM_OP, 0);
avgGhostUpdateTime /= static_cast<double>(nbRanks);
"-- Ellapsed Time: min=%f, avg=%f, max=%f\n",
minGhostUpdateTime, avgGhostUpdateTime, maxGhostUpdateTime);
"-- Ghost Level: %i Elapsed Time: min=%f, avg=%f, max=%f\n",
ghostLevel, minGhostUpdateTime, avgGhostUpdateTime, maxGhostUpdateTime);
vtkIdType initialNbOfCells = initialGrid->GetNumberOfCells();
if (outGrids[0]->GetNumberOfCells() != outGrids[1]->GetNumberOfCells())
"Grids obtained with and without global ids do not have the same number of cells!\n");
"Grids obtained with and without global ids for ghost level %i do not have the same number of cells!\n",
......@@ -189,13 +194,15 @@ int TestPUnstructuredGridGhostCellsGenerator(int argc, char* argv[])
if (initialNbOfCells >= outGrids[step]->GetNumberOfCells())
"Obtained grids has less or as many cells as the input grid!\n");
"Obtained grids for ghost level %i has less or as many cells as the input grid!\n",
if (!ghosts)
"Ghost cells array not found at step %d!\n", step);
"Ghost cells array not found at ghost level %i, step %d!\n",
ghostLevel, step);
......@@ -206,14 +213,16 @@ int TestPUnstructuredGridGhostCellsGenerator(int argc, char* argv[])
if (i < initialNbOfCells && val != 0)
"Cell %d is not supposed to be a ghost cell but it is!\n", i);
"Ghost Level %i Cell %d is not supposed to be a ghost cell but it is!\n",
ghostLevel, i);
if (i >= initialNbOfCells && val != 1)
"Cell %d is supposed to be a ghost cell but it's not!\n", i);
"Ghost Level %i Cell %d is supposed to be a ghost cell but it's not!\n",
ghostLevel, i);
......@@ -222,6 +231,8 @@ int TestPUnstructuredGridGhostCellsGenerator(int argc, char* argv[])
return ret;
......@@ -34,6 +34,33 @@
// .SECTION Thanks
// This filter has been developed by Joachim Pouderoux, Kitware SAS 2015.
// This filter was expanded to compute multiple ghost layers by Boonthanome
// Nouanesengsy and John Patchett, Los Alamos National Laboratory 2016.
// ************************************************
// This filter uses different algorithms when obtaining the first layer of
// ghost cells and getting subsequent layers.
// First ghost cell layer algorithm:
// - each proc obtains surface points using the surface filter
// - perform an all-to-all to share surface points with each other
// - for each other proc, look at their points, and see if any points
// match any of your local points
// - for each matching point, find all local cells which use those points,
// and send those cells to that proc. mark the cells that were sent
// (used for later ghost layers)
// - receive all cells sent to you, and merge everything together
// Subsequent ghost layers
// - for each cell that was sent last round, find all other local cells
// which border these cells. 'local cells' also includes all ghost cells
// which i have. send these cells to the same proc, and mark them as sent
// last round
// - receive all cells sent to you, and merge everything together
// - if another layer is needed, repeat
#ifndef vtkPUnstructuredGridGhostCellsGenerator_h
#define vtkPUnstructuredGridGhostCellsGenerator_h
......@@ -43,6 +70,7 @@
class vtkMultiProcessController;
class vtkUnstructuredGrid;
class vtkUnstructuredGridBase;
class VTKFILTERSPARALLELGEOMETRY_EXPORT vtkPUnstructuredGridGhostCellsGenerator:
public vtkUnstructuredGridAlgorithm
......@@ -72,6 +100,23 @@ public:
// Description:
// Specify if the data has global cell ids.
// If more than one layer of ghost cells is needed, global cell ids are
// necessary. If global cell ids are not provided, they will be computed
// internally.
// If false, global cell ids will be computed, then deleted afterwards.
// Default is FALSE.
vtkSetMacro(HasGlobalCellIds, bool);
vtkGetMacro(HasGlobalCellIds, bool);
vtkBooleanMacro(HasGlobalCellIds, bool);
// Description:
// Specify the name of the global cell ids data array if the GlobalIds
// attribute array is not set. Default is "GlobalNodeIds".
// Description:
// Specify if the filter must generate the ghost cells only if required by
// the pipeline.
......@@ -88,25 +133,39 @@ protected:
virtual int RequestData(vtkInformation *, vtkInformationVector **,
vtkInformationVector *);
void GetFirstGhostLayer(int, vtkUnstructuredGrid *);
void ExtractAndReduceSurfacePoints();
void ComputeSharedPoints();
void ExtractAndSendGhostCells();
void ExtractAndSendGhostCells(vtkUnstructuredGridBase *);
void ReceiveAndMergeGhostCells(int, vtkUnstructuredGridBase *,
vtkUnstructuredGrid *);
void AddGhostLayer(int ghostLevel, int maxGhostLevel);
void FindGhostCells();
void AddGlobalCellIds();
void RemoveGlobalCellIds();
void ReceiveAndMergeGhostCells(vtkUnstructuredGrid*);
vtkMultiProcessController *Controller;
int NumRanks;
int RankId;
char* GlobalPointIdsArrayName;
char *GlobalPointIdsArrayName;
bool UseGlobalPointIds;
char *GlobalCellIdsArrayName;
bool HasGlobalCellIds;
bool BuildIfRequired;
struct vtkInternals;
vtkInternals* Internals;
vtkInternals *Internals;
vtkPUnstructuredGridGhostCellsGenerator(const vtkPUnstructuredGridGhostCellsGenerator&); // Not implemented
void operator=(const vtkPUnstructuredGridGhostCellsGenerator&); // Not implemented
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment