diff --git a/IO/IOSS/Testing/CMakeLists.txt b/IO/IOSS/Testing/CMakeLists.txt index 5a71e5c020e45695491613febf9c2a3b2fed7b1a..44923a0811258979c3e8ddfd51b590e4b0fa7d3f 100644 --- a/IO/IOSS/Testing/CMakeLists.txt +++ b/IO/IOSS/Testing/CMakeLists.txt @@ -14,6 +14,7 @@ set(datasets Data/Exodus/ExRestarts/blow.e Data/Exodus/ExRestarts/blow.e-s.001 Data/Exodus/ExRestarts/blow.ex-timeseries + Data/Exodus/ghost.ex2 Data/Exodus/hello_world_fix-d_frf.frq Data/Exodus/RubiksCubeWithRotations_gold.g Data/Exodus/SAND2020-4077_O-tri6sWFace2.exo diff --git a/IO/IOSS/Testing/Cxx/CMakeLists.txt b/IO/IOSS/Testing/Cxx/CMakeLists.txt index 0828c8d692367c3ab275c653315a22cb155c2dc8..42ee4f0426b4d754e7c93ab374162bd8d16c0aec 100644 --- a/IO/IOSS/Testing/Cxx/CMakeLists.txt +++ b/IO/IOSS/Testing/Cxx/CMakeLists.txt @@ -12,6 +12,7 @@ vtk_add_test_cxx(vtkIOIOSSCxxTests tests TestIOSSNoElementBlocks.cxx,NO_VALID TestIOSSTri6.cxx TestIOSSUnsupported.cxx,NO_VALID + TestIOSSGhostArray.cxx,NO_VALID ) if (VTK_USE_LARGE_DATA) diff --git a/IO/IOSS/Testing/Cxx/TestIOSSGhostArray.cxx b/IO/IOSS/Testing/Cxx/TestIOSSGhostArray.cxx new file mode 100644 index 0000000000000000000000000000000000000000..ebe4c6a3a3e258c7bddf5f1e0d5b274c909bfb85 --- /dev/null +++ b/IO/IOSS/Testing/Cxx/TestIOSSGhostArray.cxx @@ -0,0 +1,56 @@ +/*========================================================================= + + Program: Visualization Toolkit + Module: TestIOSSGhostArray.cxx + + Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen + All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notice for more information. + +=========================================================================*/ + +#include "vtkCellData.h" +#include "vtkDataSet.h" +#include "vtkDataSetAttributes.h" +#include "vtkIOSSReader.h" +#include "vtkLogger.h" +#include "vtkPartitionedDataSetCollection.h" +#include "vtkTestUtilities.h" +#include "vtkUnsignedCharArray.h" + +#include + +int TestIOSSGhostArray(int argc, char* argv[]) +{ + vtkNew reader; + char* fileNameC = vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/Exodus/ghost.ex2"); + reader->AddFileName(fileNameC); + delete[] fileNameC; + reader->Update(); + + auto pdsc = vtkPartitionedDataSetCollection::SafeDownCast(reader->GetOutputDataObject(0)); + auto dataset = pdsc->GetPartition(0, 0); + auto cd = dataset->GetCellData(); + auto ghostArray = + vtkUnsignedCharArray::SafeDownCast(cd->GetArray(vtkDataSetAttributes::GhostArrayName())); + if (ghostArray) + { + // Check the values in the ghost array - first should be 0, second should be 1 + if (ghostArray->GetValue(0) != 0) + { + vtkLog(ERROR, "First cell ghost value was not 0"); + return EXIT_FAILURE; + } + if (ghostArray->GetValue(1) != vtkDataSetAttributes::DUPLICATECELL) + { + vtkLog(ERROR, "Second cell ghost value was not 1"); + return EXIT_FAILURE; + } + } + + return EXIT_SUCCESS; +} diff --git a/IO/IOSS/vtkIOSSReader.cxx b/IO/IOSS/vtkIOSSReader.cxx index 885655477ce266959c86c76075b59e2cac70bcf7..34218f0a6dceddeda66bd690ce1f454314464745 100644 --- a/IO/IOSS/vtkIOSSReader.cxx +++ b/IO/IOSS/vtkIOSSReader.cxx @@ -2119,6 +2119,17 @@ bool vtkIOSSReader::vtkInternals::GetFields(vtkDataSetAttributes* dsa, { dsa->SetGlobalIds(vtkDataArray::SafeDownCast(array)); } + else if (fieldname == vtkDataSetAttributes::GhostArrayName()) + { + // Handle vtkGhostType attribute specially. Convert it to the expected vtkUnsignedCharArray. + vtkNew ghostArray; + ghostArray->SetName(vtkDataSetAttributes::GhostArrayName()); + ghostArray->SetNumberOfComponents(1); + ghostArray->SetNumberOfTuples(array->GetNumberOfTuples()); + + ghostArray->CopyComponent(0, vtkDataArray::SafeDownCast(array), 0); + dsa->AddArray(ghostArray); + } else { dsa->AddArray(array); diff --git a/Testing/Data/Exodus/ghost.ex2.sha512 b/Testing/Data/Exodus/ghost.ex2.sha512 new file mode 100644 index 0000000000000000000000000000000000000000..a149df785a36bb371e8e7da9f7bfd8726b84312d --- /dev/null +++ b/Testing/Data/Exodus/ghost.ex2.sha512 @@ -0,0 +1 @@ +45528e62b204d9c01cc2984f8373b7bb08f7e4902221b37d39d9c568892641c8d5622b73d23355c25fdbf71daf188b29f52471647a90c78955e15a30e43a17f1