New `vtkCellGrid` Functionality

Hi all,

vtkCellGrid and its related source/filter classes have had some significant changes committed recently. These changes are summarized below. They are in VTK master and will be in VTK 9.4.0 (branching October 5th). There is also a ParaView merge request to expose the functionality in ParaView; it will be present in ParaView 5.14.0.

Introduction

If you are not familiar with vtkCellGrid, you may wish to read this post before continuing.

TL;DR: vtkDataSet and its subclasses make many assumptions that are irreconcilable with novel finite element (and finite difference and finite volume) formulations such as Nédélec, Thomas-Raviart, CW-complexes, and X-FEM. So we created a new extensible subclass of vtkDataObject.

IOSS Reader Support

The most significant feature is support for reading data from the Exodus file format via vtkIOSSCellGridReader; if you have an existing Exodus file named foo.exo, simply rename it to foo.exdg and the new reader will load it as a partitioned dataset collection of vtkCellGrid instances. But unlike the “plain” vtkIOSSReader, this reader will properly present discontinuous HGRAD, HCURL, and HDIV data.

The next steps for the IOSS reader are to

  • take advantage of its enhanced field metadata to ensure the basis functions and quadrature points of elements match those in VTK; and
  • support continuous attributes (that share degrees-of-freedom (DOFs) on their boundaries as a way of enforcing continuity).

Hardware Picking

The first steps for supporting interactive selection of cells in a vtkCellGrid have also been added. The hardware selector in VTK will now produce vtkSelectionNode instances for cell-grids that identify the type of cell selected with a CELLGRID_CELL_TYPE_INDEX information key set. Nodes of this type will include a list of IDs of selected cells.

The next steps include

  • adding support to vtkExtractSelection to extract just the selected cells;
  • adding software selection support (particularly ray-intersection) in order to support ParaView’s “Pick Center” toolbar button (for choosing the center of rotation).
  • adding support to render a selection directly in the cell-grid mapper with a different style than the mapper’s default (which will prevent z-fighting of selected cells with coincident geometry that is not selected).

CPU and GPU Interpolation

The vtkDGCell class VTK provides now does both CPU and GPU interpolation from the same basis function source code. See Filters/CellGrid/Basis for the set of basis functions defined over the range of cell shapes, function spaces, and basis-function orders supported. This makes it easy to add new interpolation schemes to the fixed set of cell shapes the vtkDGCell supports. (And you can always implement a new cell type if you want other shapes.)

New Filter and Source Algorithms

A vtkCellGridCellCenters filter has been added that generates vertex cells at the parametric center of each input cell.

A vtkCellGridCellSource algorithm has been added that creates a single cell of the specified type. A new example application named “CellGridSource” (in Examples/GUISupport/Qt/CellGridSource) takes advantage of this to show how the HCURL, HDIV, and HGRAD function spaces work. It also demonstrates how cell-grid data is structured in memory and allows people to edit coefficients to change the definition of an vector attribute interactively.

A vtkCellGridToUnstructuredGrid filter has been added to convert a cell-grid into an approximating vtkUnstructuredGrid dataset. The output unstructured grid will always have linear geometry even if the source uses quadratic or higher order interpolation; any discontinuities at shared cell boundaries will be averaged. All the data represented in the input cell-grid as a vtkCellAttribute will be converted into vtkPointData arrays.

A vtkCellGridTransform filter has been added that will apply a (linear) vtkTransform to a cell-grid’s shape attribute. This is useful for translating/scaling/rotating cell grids.

A vtkCellGridWarp filter has been added that, given an HGRAD cell-attribute defined on a cell-grid, will add a scaled version of it to the cell-grid’s shape attribute. The responder for vtkDGCell instances currently requires the attribute and the shape to have the same basis function and order. In the future, it will be expanded to support features such as degree elevation.

The existing vtkPassSelectedArrays filter now accepts and processes vtkCellGrid instances. If you request cell-data “arrays” to be passed or excluded, this is treated as a request to pass or exclude a vtkCellAttribute of the same name. For now, passing/excluding vtkCellAttribute instances is only allowed by name and not by type (scalar/vector/tensor/texture) or by index.

Improvements to vtkCellGridAlgorithm

We’ve added vtkCellGridAlgorithm::GetInputCellAttributeToProcess() to mirror
vtkAlgorithm::GetInputAbstractArrayToProcess(), but for cell-grids. Similarly, vtkCellGridAlgorithm::SetInputAttributeToProcess() mirrors vtkAlgorithm::SetInputArrayToProcess(). Use these to indicate which cell-attributes an algorithm should use for processing.

Note that cell-attributes may currently only be referenced by name. Eventually, we should allow them to be referenced in other ways (not by “type” or field association, but by vtkCellAttribute::GetSpace()).

Legacy File Format

Since ParaView uses VTK’s “legacy” file format to transfer data between a render-server and the client when datasets are small, we’ve implemented a reader and writer for the legacy format that simply packages up cell grids using the existing JSON format (encoded as MessagePack binary data).

JSON File Format Improvements

The vtkCellGridReader and vtkCellGridWriter can now write either JSON or MessagePack (a binary equivalent to JSON).

The reader and writer now also include attribute range information if it has been computed. This accelerates loading data – especially for HDIV and HCURL cell-attributes which must be interpolated at points across each cell to determine their range.

vtkCellGrid Improvements

When copying cell-grid instances (either shallow-copying, deep-copying, or copying via the vtkCellGridCopyQuery), the range information of cell-attributes is copied in some cases (when cell attributes and cells are both being copied without modifications and the range information has been cached).

Range computation for HDIV and HCURL function spaces is now properly estimated by evaluating cell-attributes at corner points to find minimal and maximal values. The exact range is not computed as this would involve solving an expensive optimization problem on each cell; that may be implemented in the future once basis conversion is supported.

3 Likes