Can't write DG0 time data to VTX

At first I thought this was just an issue in DOLFINx, so I modified the writer to add the time step counter into CellData, ref: Comparing main...dokken/time-dependent-celldata · FEniCS/dolfinx · GitHub
Inspecting the results.bp file, with the following MWE i get:

from dolfinx import mesh, fem, io, default_scalar_type
from mpi4py import MPI
import numpy as np

domain = mesh.create_unit_square(MPI.COMM_WORLD, 2, 2)
V = fem.functionspace(domain, ("DG", 0))
v = fem.Function(V)

vtx = io.VTXWriter(domain.comm, "result.bp", v)
vtx.write(0.0)

v.interpolate(lambda x: np.arange(1,1+x.shape[1], dtype=default_scalar_type))
vtx.write(1.0)
vtx.close()
 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

which seems correct.
Next, I checked if the data is correctly written to f with

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 

which looks correct. However opening it in paraview, I cannot step between the two time steps:


As you can see in data statistics, it realizes that there are two time steps,l but in data arrays we can observe that f is always 0. This seems to be an issue with Paraview’s VTXWriter.
I’ve made an issue at: Time dependent VTX CellData not rendered correctly in Paraview · Issue #4179 · ornladios/ADIOS2 · GitHub which might be transferred to VTK depending on what the developers says.

1 Like