diff --git a/Filters/ParallelGeometry/Testing/Cxx/TestPUnstructuredGridGhostCellsGenerator.cxx b/Filters/ParallelGeometry/Testing/Cxx/TestPUnstructuredGridGhostCellsGenerator.cxx index 76ad46883b3dc82f4ec748cab3da668d8848cc74..91c124656ab86fec0b04366340d98e2be061733c 100644 --- a/Filters/ParallelGeometry/Testing/Cxx/TestPUnstructuredGridGhostCellsGenerator.cxx +++ b/Filters/ParallelGeometry/Testing/Cxx/TestPUnstructuredGridGhostCellsGenerator.cxx @@ -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 diff --git a/Filters/ParallelGeometry/vtkPUnstructuredGridGhostCellsGenerator.cxx b/Filters/ParallelGeometry/vtkPUnstructuredGridGhostCellsGenerator.cxx index d46d93083bd21527161200752374b126cf5d60b2..eac98f3461104d79cd65c35f68a6aa8004f3bbff 100644 --- a/Filters/ParallelGeometry/vtkPUnstructuredGridGhostCellsGenerator.cxx +++ b/Filters/ParallelGeometry/vtkPUnstructuredGridGhostCellsGenerator.cxx @@ -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;