Skip to content
Snippets Groups Projects
Commit daec5f50 authored by Cory Quammen's avatar Cory Quammen Committed by Kitware Robot
Browse files

Merge topic 'ghost-cells-generator-copy-field-data' into paraview/release


96039b49 Shallow copy field data from input to output in ghost cells generator

Acked-by: default avatarKitware Robot <kwrobot@kitware.com>
Acked-by: default avatarYohann Bearzi <yohann.bearzi@kitware.com>
Merge-request: !6451
parents d2310987 96039b49
No related branches found
No related tags found
No related merge requests found
......@@ -84,6 +84,18 @@ private:
vtkStandardNewMacro(vtkRTAnalyticSource2);
bool CheckFieldData(vtkFieldData* fd)
{
vtkUnsignedCharArray* fdArray = vtkUnsignedCharArray::SafeDownCast(fd->GetArray("FieldData"));
if (!fdArray || fdArray->GetValue(0) != 2)
{
cerr << "Field data array value is not the same as the input" << endl;
return false;
}
return true;
}
} // anonymous namespace
//------------------------------------------------------------------------------
......@@ -106,7 +118,17 @@ int TestPUnstructuredGridGhostCellsGenerator(int argc, char* argv[])
tetrahedralize->SetInputConnection(wavelet->GetOutputPort());
tetrahedralize->UpdatePiece(myRank, nbRanks, 0);
vtkUnstructuredGrid* initialGrid = tetrahedralize->GetOutput();
vtkNew<vtkUnstructuredGrid> initialGrid;
initialGrid->ShallowCopy(tetrahedralize->GetOutput());
// Add field data
vtkNew<vtkUnsignedCharArray> fdArray;
fdArray->SetNumberOfTuples(1);
fdArray->SetName("FieldData");
fdArray->SetValue(0, 2);
vtkNew<vtkFieldData> fd;
fd->AddArray(fdArray);
initialGrid->SetFieldData(fd);
// Prepare the ghost cells generator
vtkNew<vtkPUnstructuredGridGhostCellsGenerator> ghostGenerator;
......@@ -135,6 +157,14 @@ int TestPUnstructuredGridGhostCellsGenerator(int argc, char* argv[])
ret = EXIT_FAILURE;
}
// Check that field data is copied
ghostGenerator->Update();
if (!CheckFieldData(ghostGenerator->GetOutput()->GetFieldData()))
{
cerr << "Field data was not copied correctly" << std::endl;
ret = EXIT_FAILURE;
}
// Check if algorithm works with empty input on all nodes except first one
vtkNew<vtkUnstructuredGrid> emptyGrid;
ghostGenerator->SetInputData(myRank == 0 ? initialGrid : emptyGrid);
......@@ -164,6 +194,12 @@ int TestPUnstructuredGridGhostCellsGenerator(int argc, char* argv[])
// Save the grid for further analysis
outGrids[step] = ghostGenerator->GetOutput();
if (!CheckFieldData(outGrids[step]->GetFieldData()))
{
cerr << "Field data was not copied" << std::endl;
ret = EXIT_FAILURE;
}
double elapsed = timer->GetElapsedTime();
// get some performance statistics
......
......@@ -366,6 +366,14 @@ int vtkPUnstructuredGridGhostCellsGenerator::RequestData(vtkInformation* vtkNotU
output->ShallowCopy(this->Internals->CurrentGrid);
output->GetInformation()->Set(vtkDataObject::DATA_NUMBER_OF_GHOST_LEVELS(), maxGhostLevel);
// copy field data
if (cleanedInput && cleanedInput->GetFieldData())
{
vtkNew<vtkFieldData> fd;
fd->ShallowCopy(cleanedInput->GetFieldData());
output->SetFieldData(fd);
}
vtkDebugMacro("Produced " << maxGhostLevel << " ghost levels.");
delete this->Internals;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment