ornladios / ADIOS2

Next generation of ADIOS developed in the Exascale Computing Program
https://adios2.readthedocs.io/en/latest/index.html
Apache License 2.0
267 stars 125 forks source link

Time dependent VTX CellData not rendered correctly in Paraview #4179

Open jorgensd opened 4 months ago

jorgensd commented 4 months ago

I do apologize if this issue is more appropriate to open at VTK. Let me know and I will move it.

With: https://gitlab.kitware.com/vtk/vtk/-/merge_requests/7401/diffs one can render CellData with the VTX bp format.

However, time dependency is not supported. Below is a dump of a minimal bp file that has CellData written in two steps:

root@dokken-XPS-9320:~/shared/debug# bpls result.bp/ -a -l
  uint32_t  NumberOfCells        2*{1} = 8 / 8
  uint32_t  NumberOfNodes        2*{1} = 9 / 9
  int64_t   connectivity         2*[1]*{8, 4} = 0 / 8
  double    f                    2*[1]*{8, 1} = 0 / 8
  double    geometry             2*[1]*{9, 3} = 0 / 1
  double    step                 2*scalar = 0 / 1
  uint32_t  types                2*scalar = 69 / 69
  string    vtk.xml              attr   = 
<VTKFile type="UnstructuredGrid" version="0.1">
  <UnstructuredGrid>
    <Piece NumberOfPoints="NumberOfNodes" NumberOfCells="NumberOfCells">
      <Points>
        <DataArray Name="geometry" />
      </Points>
      <Cells>
        <DataArray Name="connectivity" />
        <DataArray Name="types" />
      </Cells>
      <PointData>
        <DataArray Name="vtkOriginalPointIds" />
        <DataArray Name="vtkGhostType" />
      </PointData>
      <CellData>
        <DataArray Name="TIME">step</DataArray>
        <DataArray Name="f" />
      </CellData>
    </Piece>
  </UnstructuredGrid>
</VTKFile>

  uint8_t   vtkGhostType         2*[1]*{9} = 0 / 0
  int64_t   vtkOriginalPointIds  2*[1]*{9} = 0 / 8
root@dokken-XPS-9320:~/shared/debug# bpls result.bp/ -a -l f -d
  double    f                    2*[1]*{8, 1} = 0 / 8
        step 0: 
          block 0: [0:7, 0:0] = 0 / 0
    (0,0)    0 0 0 0 0 0
    (6,0)    0 0 
        step 1: 
          block 0: [0:7, 0:0] = 1 / 8
    (0,0)    1 2 3 4 5 6
    (6,0)    7 8 

However, opening this bp file in Paraview does not render the time dependent cell data (even if the time steps are recognized). Screenshot from Paraview 5.12.0-R3 image This issue was originally reported at: https://fenicsproject.discourse.group/t/cant-write-dg0-time-data-to-vtx/14786

kmorel commented 4 months ago

@williamfgc, can you look to see if this feature is missing from the VTK reader?

@jorgensd, can you post result.bp? It would help a lot to address this issue.

jorgensd commented 4 months ago

result.bp.zip Here is a zip file of an even smaller mesh that exhibits the same behavior. Here the mesh is only 1x1 unit square with two triangles, with

bpls result.bp/ -a -l   
  uint32_t  NumberOfCells        2*{1} = 2 / 2
  uint32_t  NumberOfNodes        2*{1} = 4 / 4
  int64_t   connectivity         2*[1]*{2, 4} = 0 / 3
  double    f                    2*[1]*{2, 1} = 0 / 2
  double    geometry             2*[1]*{4, 3} = 0 / 1
  double    step                 2*scalar = 0 / 1
  uint32_t  types                2*scalar = 69 / 69
  string    vtk.xml              attr   = 
<VTKFile type="UnstructuredGrid" version="0.1">
  <UnstructuredGrid>
    <Piece NumberOfPoints="NumberOfNodes" NumberOfCells="NumberOfCells">
      <Points>
        <DataArray Name="geometry" />
      </Points>
      <Cells>
        <DataArray Name="connectivity" />
        <DataArray Name="types" />
      </Cells>
      <PointData>
        <DataArray Name="vtkOriginalPointIds" />
        <DataArray Name="vtkGhostType" />
      </PointData>
      <CellData>
        <DataArray Name="TIME">step</DataArray>
        <DataArray Name="f" />
      </CellData>
    </Piece>
  </UnstructuredGrid>
</VTKFile>

  uint8_t   vtkGhostType         2*[1]*{4} = 0 / 0
  int64_t   vtkOriginalPointIds  2*[1]*{4} = 0 / 3

and

 bpls result.bp/ -a -l f -d
  double    f                    2*[1]*{2, 1} = 0 / 2
        step 0: 
          block 0: [0:1, 0:0] = 0 / 0
    (0,0)    0 0 
        step 1: 
          block 0: [0:1, 0:0] = 1 / 2
    (0,0)    1 2 
williamfgc commented 3 months ago

Sorry for the late response. I try to find time to look at it, but a first glance show that types uint32_t types 2*scalar = 69 / 69 need to be compatible with VTK cells (11). I'll try to find working examples, but those in the VTX tests should be a good starting point.

jorgensd commented 3 months ago

The 69 cell tag is the arbitrary order Lagrange cells. We use them to write our meshes to file, as we support arbitrary order geometry. Ref:

// Arbitrary order Lagrange elements (formulated separated from generic higher order cells)
  [VTK_LAGRANGE_CURVE](https://vtk.org/doc/nightly/html/vtkCellType_8h.html#ab1d6fd1f3177b8a2a32bb018807151f8a1da073afca887c20193799e90f219d21) = 68,
  [VTK_LAGRANGE_TRIANGLE](https://vtk.org/doc/nightly/html/vtkCellType_8h.html#ab1d6fd1f3177b8a2a32bb018807151f8ab3627e9c9f832c99cfaf776aa59446e6) = 69,
  [VTK_LAGRANGE_QUADRILATERAL](https://vtk.org/doc/nightly/html/vtkCellType_8h.html#ab1d6fd1f3177b8a2a32bb018807151f8a3d7c84e01a9a7c15b39893752960fb1a) = 70,
  [VTK_LAGRANGE_TETRAHEDRON](https://vtk.org/doc/nightly/html/vtkCellType_8h.html#ab1d6fd1f3177b8a2a32bb018807151f8a7d1053447ab42f8346ffdeae8f74384d) = 71,
  [VTK_LAGRANGE_HEXAHEDRON](https://vtk.org/doc/nightly/html/vtkCellType_8h.html#ab1d6fd1f3177b8a2a32bb018807151f8a6532a57392d4ff6cb6bd7b29d16f7611) = 72,
  [VTK_LAGRANGE_WEDGE](https://vtk.org/doc/nightly/html/vtkCellType_8h.html#ab1d6fd1f3177b8a2a32bb018807151f8a6295bf3c196ce73b89fe3501c71b93e1) = 73,
  [VTK_LAGRANGE_PYRAMID](https://vtk.org/doc/nightly/html/vtkCellType_8h.html#ab1d6fd1f3177b8a2a32bb018807151f8ad7bb93e1731d876e427c0f6fb7d3b8c4) = 74,

Taken from: https://vtk.org/doc/nightly/html/vtkCellType_8h_source.html

Also do note that time dependent node data does work with the given types and connectivity.

kmorel commented 3 months ago

I dove into the code for the reader. It looks like there is indeed an issue with reading cell data that changes over time. For some reason, it is hard coded to "persist," meaning it only loads data on the first timestep.

I made a PR that should fix the issue: https://gitlab.kitware.com/vtk/vtk/-/merge_requests/11243. @williamfgc, can you review these changes?

That said, I think it will take at least until ParaView 5.14 for these changes to be seen. (I'm pretty sure the features for 5.13 are already set.) So, it will be a while before this will be available without a special build.

I don't have a great workaround. Obviously you could use point data instead of cell data, but that would distort your data. You could alternately use the FIDES format, which also uses ADIOS2 to store the data but uses JSON to specify the schema rather than HTML. However, FIDES does not support Lagrange elements; they would have to be tessellated to linear elements.

jorgensd commented 3 months ago

I dove into the code for the reader. It looks like there is indeed an issue with reading cell data that changes over time. For some reason, it is hard coded to "persist," meaning it only loads data on the first timestep.

I made a PR that should fix the issue: https://gitlab.kitware.com/vtk/vtk/-/merge_requests/11243. @williamfgc, can you review these changes?

That said, I think it will take at least until ParaView 5.14 for these changes to be seen. (I'm pretty sure the features for 5.13 are already set.) So, it will be a while before this will be available without a special build.

I don't have a great workaround. Obviously you could use point data instead of cell data, but that would distort your data. You could alternately use the FIDES format, which also uses ADIOS2 to store the data but uses JSON to specify the schema rather than HTML. However, FIDES does not support Lagrange elements; they would have to be tessellated to linear elements.

It’s unfortunate that there isn’t a quickfix (as we were quite excited with the CellData feature in VTX). A temporary (expensive) workaround on my end is to create a DG-1 mesh based of the connected mesh, and represent my data on the nodes there to avoid distortion.