Incoming changes to the AMR data model of VTK

One year ago, @spyridon97 opened this issue to show that the AMR data model was not adapted with the way VTK had been developped and required a refactoring in order to be integrated into modern developpements: https://gitlab.kitware.com/vtk/vtk/-/issues/19246

This is currently being developped and here is a heads up of what is happening.

Refactor of the AMR data model

The AMR data model has been refactored for future proofing.
vtkUniformGridAMR now inherits from vtkPartitionedDataSetCollection instead of vtkCompositeDataSet.

This lets classes interact with AMR data as they would with any data object tree or pdc when accessing data, without requiring specific code. Specific code can and will still be needed in certain cases. Of course, when setting up the AMR, the AMR API should be used.

Indeed, each AMR level is now stored as a vtkPartitionedDataSet,
and the AMR structure itself is described in the vtkAMRMetaData class stored internally.

Another impactful change was the separation of vtkAMRInformation into vtkAMRMetaData and vtkOverlappingAMRMetaData. This allow much simpler handling of the Overlapping vs NonOverlapping case and clear separation of responsibility.

In the process many API were reworked for consistency and stability.
Backward compatibility was kept for many methods but certains became redundant and are just no-op with a deprecation flag.

Here is the exhaustive list.
AMR:: refer to any AMR class, new or already present, for the sake of brevity.
(vtkUniformGridAMR, vtkNonOverlappingAMR, vtkOverlappingAMR, vtkAMRInformation, vtkAMRMetaData, vtkOverlappingAMRMetaData)

Classes:

  • Deprecate vtkAMRInformation and introduce vtkOverlappingAMRMataData and vtkAMRMetaData
  • Deprecate vtkAMRDataInternals which is not used anymore
  • Deprecate vtkUniformGridAMRDataIterator into vtkUniformGirdAMRIterator

Methods:

  • Deprecate AMR::Audit and add AMR::CheckValidity that returns a bool
  • Deprecate AMR::Set/GetData, which are currently no-op.
  • Deprecate AMR::GetInfo and introduce vtkUniformGridAMR::GetMetaData and vtkOverlappingAMR::GetOverlappingAMRMetaData
  • Deprecate AMR::Initialize(nBlock, blocksPerLevel) into AMR::Initialize(const std::vector& blocksPerLevel)
  • Deprecate vtkUniformGridAMR::GetCompositeIndex into vtkUniformGridAMR::GetAbsoluteBlockIndex
  • Deprecate vtkUniformGridAMR::GetLevelAndIndex into vtkUniformGridAMR::ComputeIndexPair
  • Deprecate vtkAMRInformation::GetIndex into vtkAMRMetaData::GetAbsoluteBlockIndex
  • Deprecate vtkAMRInformation::GetTotalNumberOfBlocks into vtkAMRMetaData::GetNumberOfBlocks
  • Deprecate vtkAMRInformation::GetNumberOfDataSets(level) into vtkAMRMetaData::GetNumberOfBlocks(level)

Members:

  • vtkUniformGridAMR::Bounds is now private

Change of behavior:

  • vtkUniformGridAMR now inherits vtkPartitionedDataSetCollection, which means any vtkPartitionedDataSetCollection::SafeDownCast(amr)
    will not return nullptr anymore.

  • vtkUniformGridAMRIterator now inherits vtkDataObjectTreeIterator, which means any vtkDataObjectTreeIterator::SafeDownCast(amrIter)
    will not return nullptr anymore.

  • vtkPlaneCutter now outputs a PDC instead of a MBD with a AMR input.

  • vtkDataObjectTree::CopyStructure(amr) used to reconstruct a data object tree with an simili AMR structure,
    this is not the case anymore and it just copy the partitioned dataset collection structure using the generic implementation.

  • vtkUniformGridAMR::CopyStructure(amr) now copy the bounds as well to ensure retro compatibility
    when dealing with vtkNonOverlappingAMR that do not contains bounds in the vtkAMRMetaData, contrary to vtkOverlappingAMR.

  • vtkExtractBlockUsingDataAssembly now outputs a vtkPartitionedDataSetCollection when input is a vtkNonOverlappingAMR for consistency.

4 Likes

edited

1 Like

Seems very good, Mathieu!

1 Like

The post have been updated, the design was changed to use a PartitionedDataSetCollection after all.

I’ve removed outdated information as well.

All developpements for AMR have been completed. Support for RectilinearGrid has been added to both overlapping amr and non overlapping amr.

Add Support for AMR of vtkRectilinearGrid

The AMR data model now supports creating AMR of vtkRectilinearGrid thanks to the refactoring and the introduction of vtkCartesianGrid.

For vtkNonOverlappingAMR, the usage is pretty straight forward, just use SetDataSet(level, idx, grid) with coherent cartesian grids and it will work out of the box. Type can be mixed too.

For vtkOverlappingAMR, types cannot be mixed. Just add vtkRectilinearGrid but do not use SetSpacing or SetRefinementRatio as they do not make sense for this type. Instead, bounds will be automatically used internally and the API will just work.

See here for more info:

https://gitlab.kitware.com/vtk/vtk/-/blob/master/Documentation/release/dev/refactor-amr-datamodel.md?ref_type=heads

Follow up issues: