Skip to content
Snippets Groups Projects
Commit 96039b49 authored by Cory Quammen's avatar Cory Quammen
Browse files

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

This ensures field data is passed through
vtkPUnstructuredGridGhostCellsGenerator.

Modify test to check that field data is passed to output.
parent d2310987
No related branches found
No related tags found
No related merge requests found
...@@ -84,6 +84,18 @@ private: ...@@ -84,6 +84,18 @@ private:
vtkStandardNewMacro(vtkRTAnalyticSource2); 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 } // anonymous namespace
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -106,7 +118,17 @@ int TestPUnstructuredGridGhostCellsGenerator(int argc, char* argv[]) ...@@ -106,7 +118,17 @@ int TestPUnstructuredGridGhostCellsGenerator(int argc, char* argv[])
tetrahedralize->SetInputConnection(wavelet->GetOutputPort()); tetrahedralize->SetInputConnection(wavelet->GetOutputPort());
tetrahedralize->UpdatePiece(myRank, nbRanks, 0); 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 // Prepare the ghost cells generator
vtkNew<vtkPUnstructuredGridGhostCellsGenerator> ghostGenerator; vtkNew<vtkPUnstructuredGridGhostCellsGenerator> ghostGenerator;
...@@ -135,6 +157,14 @@ int TestPUnstructuredGridGhostCellsGenerator(int argc, char* argv[]) ...@@ -135,6 +157,14 @@ int TestPUnstructuredGridGhostCellsGenerator(int argc, char* argv[])
ret = EXIT_FAILURE; 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 // Check if algorithm works with empty input on all nodes except first one
vtkNew<vtkUnstructuredGrid> emptyGrid; vtkNew<vtkUnstructuredGrid> emptyGrid;
ghostGenerator->SetInputData(myRank == 0 ? initialGrid : emptyGrid); ghostGenerator->SetInputData(myRank == 0 ? initialGrid : emptyGrid);
...@@ -164,6 +194,12 @@ int TestPUnstructuredGridGhostCellsGenerator(int argc, char* argv[]) ...@@ -164,6 +194,12 @@ int TestPUnstructuredGridGhostCellsGenerator(int argc, char* argv[])
// Save the grid for further analysis // Save the grid for further analysis
outGrids[step] = ghostGenerator->GetOutput(); outGrids[step] = ghostGenerator->GetOutput();
if (!CheckFieldData(outGrids[step]->GetFieldData()))
{
cerr << "Field data was not copied" << std::endl;
ret = EXIT_FAILURE;
}
double elapsed = timer->GetElapsedTime(); double elapsed = timer->GetElapsedTime();
// get some performance statistics // get some performance statistics
......
...@@ -366,6 +366,14 @@ int vtkPUnstructuredGridGhostCellsGenerator::RequestData(vtkInformation* vtkNotU ...@@ -366,6 +366,14 @@ int vtkPUnstructuredGridGhostCellsGenerator::RequestData(vtkInformation* vtkNotU
output->ShallowCopy(this->Internals->CurrentGrid); output->ShallowCopy(this->Internals->CurrentGrid);
output->GetInformation()->Set(vtkDataObject::DATA_NUMBER_OF_GHOST_LEVELS(), maxGhostLevel); 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."); vtkDebugMacro("Produced " << maxGhostLevel << " ghost levels.");
delete this->Internals; 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