Store constant AMR arrays with less memory

The `AmrArrays` filter generates some cell fields that specify information
about the hierarchy, which are constant across all cells in a partition.
These were previously stored as an array with the same value throughout.
Now, the field is stored as an `ArrayHandleConstant`, which does not
require any real storage. Recent changes to VTK-m allow code to extract the
array as a component efficiently without knowing the storage type.

Fixes #794
This commit is contained in:
Kenneth Moreland 2023-08-31 14:03:30 -05:00
parent bd7ac82411
commit 7992e1b6bf
2 changed files with 15 additions and 13 deletions

@ -0,0 +1,8 @@
# Store constant AMR arrays with less memory
The `AmrArrays` filter generates some cell fields that specify information
about the hierarchy, which are constant across all cells in a partition.
These were previously stored as an array with the same value throughout.
Now, the field is stored as an `ArrayHandleConstant`, which does not
require any real storage. Recent changes to VTK-m allow code to extract the
array as a component efficiently without knowing the storage type.

@ -274,21 +274,15 @@ void AmrArrays::GenerateIndexArrays()
{
vtkm::cont::DataSet partition = this->AmrDataSet.GetPartition(this->PartitionIds.at(l).at(b));
vtkm::cont::ArrayHandle<vtkm::Id> fieldAmrLevel;
vtkm::cont::ArrayCopy(
vtkm::cont::ArrayHandleConstant<vtkm::Id>(l, partition.GetNumberOfCells()), fieldAmrLevel);
partition.AddCellField("vtkAmrLevel", fieldAmrLevel);
partition.AddCellField(
"vtkAmrLevel", vtkm::cont::ArrayHandleConstant<vtkm::Id>(l, partition.GetNumberOfCells()));
vtkm::cont::ArrayHandle<vtkm::Id> fieldBlockId;
vtkm::cont::ArrayCopy(
vtkm::cont::ArrayHandleConstant<vtkm::Id>(b, partition.GetNumberOfCells()), fieldBlockId);
partition.AddCellField("vtkAmrIndex", fieldBlockId);
partition.AddCellField(
"vtkAmrIndex", vtkm::cont::ArrayHandleConstant<vtkm::Id>(b, partition.GetNumberOfCells()));
vtkm::cont::ArrayHandle<vtkm::Id> fieldPartitionIndex;
vtkm::cont::ArrayCopy(vtkm::cont::ArrayHandleConstant<vtkm::Id>(
this->PartitionIds.at(l).at(b), partition.GetNumberOfCells()),
fieldPartitionIndex);
partition.AddCellField("vtkCompositeIndex", fieldPartitionIndex);
partition.AddCellField("vtkCompositeIndex",
vtkm::cont::ArrayHandleConstant<vtkm::Id>(
this->PartitionIds.at(l).at(b), partition.GetNumberOfCells()));
this->AmrDataSet.ReplacePartition(this->PartitionIds.at(l).at(b), partition);
}