From 2b869f648ef2376b8418f6c021fd58e0f9ba02eb Mon Sep 17 00:00:00 2001 From: Lucas Givord Date: Thu, 4 Apr 2024 12:16:50 +0200 Subject: [PATCH 1/3] vtkHDFReader: avoid to have UseCache and MergeParts enabled Using MergeParts implies to use the vtkAppendDataSet filter which doesn't support for now the static mesh so it's not possible to use these 2 features at the same time --- IO/HDF/Testing/Cxx/TestHDFReaderTransient.cxx | 1 + IO/HDF/vtkHDFReader.cxx | 7 +++++++ IO/HDF/vtkHDFReader.h | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/IO/HDF/Testing/Cxx/TestHDFReaderTransient.cxx b/IO/HDF/Testing/Cxx/TestHDFReaderTransient.cxx index 26f8e139557a..66b5987f7d83 100644 --- a/IO/HDF/Testing/Cxx/TestHDFReaderTransient.cxx +++ b/IO/HDF/Testing/Cxx/TestHDFReaderTransient.cxx @@ -639,6 +639,7 @@ int TestImageDataTransientWithCache(const std::string& dataRoot) { OpenerWorklet opener(dataRoot + "/Data/transient_wavelet.hdf"); opener.GetReader()->UseCacheOn(); + opener.GetReader()->SetMergeParts(false); return TestImageDataTransientBase(opener); } diff --git a/IO/HDF/vtkHDFReader.cxx b/IO/HDF/vtkHDFReader.cxx index 1ac6f2442111..f0d797766d01 100644 --- a/IO/HDF/vtkHDFReader.cxx +++ b/IO/HDF/vtkHDFReader.cxx @@ -1551,6 +1551,13 @@ int vtkHDFReader::RequestData(vtkInformation* vtkNotUsed(request), { return 0; } + + if (this->MergeParts && this->UseCache) + { + vtkErrorMacro(<< "Merge Parts and Use Cache are both enabled which is not supported for now."); + return 0; + } + if (this->HasTransientData) { double* values = outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS()); diff --git a/IO/HDF/vtkHDFReader.h b/IO/HDF/vtkHDFReader.h index 1699fad7aa71..f141420b7aa2 100644 --- a/IO/HDF/vtkHDFReader.h +++ b/IO/HDF/vtkHDFReader.h @@ -137,6 +137,9 @@ public: * * Internal cache is useful when reading transient data to never re-read something that has * already been cached. + * + * @note Incompatible with MergeParts as vtkAppendDataSet which is used internally doesn't + * support static mesh. */ vtkGetMacro(UseCache, bool); vtkSetMacro(UseCache, bool); @@ -154,6 +157,9 @@ public: * effectively double the memory constraints. * * Default is true + * + * @note Incompatible with UseCache as vtkAppendDataSet which is used internally doesn't + * support static mesh. */ vtkGetMacro(MergeParts, bool); vtkSetMacro(MergeParts, bool); -- GitLab From 8a97b0363e6edd60a92b5ba75c67cb965d744f79 Mon Sep 17 00:00:00 2001 From: Lucas Givord Date: Thu, 4 Apr 2024 12:22:43 +0200 Subject: [PATCH 2/3] vtkHDFReader: ensure that temporary meta array will be deleted Meta arrays, like __cellOriginalIds_, weren't correctly deleted because the clean method used for that didn't delete meta array for each partition. --- IO/HDF/vtkHDFReader.cxx | 22 ++++++++++++++-------- IO/HDF/vtkHDFReader.h | 9 +++++---- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/IO/HDF/vtkHDFReader.cxx b/IO/HDF/vtkHDFReader.cxx index f0d797766d01..63144ad950e1 100644 --- a/IO/HDF/vtkHDFReader.cxx +++ b/IO/HDF/vtkHDFReader.cxx @@ -1589,7 +1589,7 @@ int vtkHDFReader::RequestData(vtkInformation* vtkNotUsed(request), // Output cleanup after using mesh cache if (this->UseCache && this->MeshGeometryChangedFromPreviousTimeStep) { - this->CleanOriginalIds(output); + this->CleanOriginalIds(pData); } } else if (dataSetType == VTK_POLY_DATA) @@ -1602,7 +1602,7 @@ int vtkHDFReader::RequestData(vtkInformation* vtkNotUsed(request), // Output cleanup after using mesh cache if (this->UseCache && this->MeshGeometryChangedFromPreviousTimeStep) { - this->CleanOriginalIds(output); + this->CleanOriginalIds(pData); } } else if (dataSetType == VTK_OVERLAPPING_AMR) @@ -1658,16 +1658,22 @@ void vtkHDFReader::SetAttributeOriginalIdName(vtkIdType attribute, const std::st } //---------------------------------------------------------------------------- -void vtkHDFReader::CleanOriginalIds(vtkDataObject* output) +void vtkHDFReader::CleanOriginalIds(vtkPartitionedDataSet* output) { int attributesToClean[3] = { vtkDataObject::POINT, vtkDataObject::CELL, vtkDataObject::FIELD }; - for (int attributeType : attributesToClean) + + for (unsigned int i = 0; i < output->GetNumberOfPartitions(); ++i) { - std::string arrayName = this->GetAttributeOriginalIdName(attributeType); - vtkDataSetAttributes* attributes = output->GetAttributes(attributeType); - if (attributes && attributes->GetArray(arrayName.c_str())) + vtkDataObject* partition = output->GetPartitionAsDataObject(i); + + for (int attributeType : attributesToClean) { - attributes->RemoveArray(arrayName.c_str()); + std::string arrayName = this->GetAttributeOriginalIdName(attributeType); + vtkDataSetAttributes* attributes = partition->GetAttributes(attributeType); + if (attributes && attributes->GetArray(arrayName.c_str())) + { + attributes->RemoveArray(arrayName.c_str()); + } } } } diff --git a/IO/HDF/vtkHDFReader.h b/IO/HDF/vtkHDFReader.h index f141420b7aa2..d9d058faef8c 100644 --- a/IO/HDF/vtkHDFReader.h +++ b/IO/HDF/vtkHDFReader.h @@ -283,11 +283,12 @@ private: bool AddOriginalIds(vtkDataSetAttributes* attributes, vtkIdType size, const std::string& name); /** - * Removes the arrays from the object given in parameter containing - * the original ids use in the static mesh cache. It allows to avoid - * passing those arrays to subsequent pipeline elements. + * Removes the arrays for each partition from the object given in + * parameter containing the original ids use in the static mesh cache. + * It allows to avoid passing those arrays to subsequent pipeline + * elements. */ - void CleanOriginalIds(vtkDataObject* output); + void CleanOriginalIds(vtkPartitionedDataSet* output); protected: /** -- GitLab From 2165be67123c47ced79c8c9a7e5fff4ee80da670 Mon Sep 17 00:00:00 2001 From: Lucas Givord Date: Thu, 4 Apr 2024 12:27:22 +0200 Subject: [PATCH 3/3] vtkHDFReader: fix VTK_ABI_NAMESPACE_END VTK_ABI_NAMESPACE_END was not set at the end of the cxx file --- IO/HDF/vtkHDFReader.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/IO/HDF/vtkHDFReader.cxx b/IO/HDF/vtkHDFReader.cxx index 63144ad950e1..022d6103b4f8 100644 --- a/IO/HDF/vtkHDFReader.cxx +++ b/IO/HDF/vtkHDFReader.cxx @@ -1643,7 +1643,6 @@ bool vtkHDFReader::AddOriginalIds( attributes->AddArray(ids); return true; } -VTK_ABI_NAMESPACE_END //---------------------------------------------------------------------------- std::string vtkHDFReader::GetAttributeOriginalIdName(vtkIdType attribute) @@ -1677,3 +1676,5 @@ void vtkHDFReader::CleanOriginalIds(vtkPartitionedDataSet* output) } } } + +VTK_ABI_NAMESPACE_END -- GitLab