Add option to switch between xdmf2 and xdmf3 output

Issue #791 resolved
rambausek created an issue

After installing FEniCS 2016.2.0 I noticed that I couldn't visualize my results with Paraview. A closer look at my xdmf-files showed that 2016.1.0 produced xdmf2 files, while FEniCS 2016.2.0 writes in xdmf3 format. Unfortunately, on my workstation (Linux Mint 18, Paraview binary 5.2.0 from paraview.org), Paraview crashes when trying to read the xdmf3 file.

I do not know, whether this is a Paraview/vtk or some other bug, but at least I found another report probably the same issue: https://public.kitware.com/Bug/view.php?id=16080

Since this issue might not get fixed soon, I suggest to support both xdmf2 and xdmf3 output.

Comments (23)

  1. rambausek reporter

    Has there been some testing on the new format? If yes, with which Paraview version/configuration or with which examples?

  2. Prof Garth Wells

    We don't want to add an option for XDMF 2 or 3 - it creates unnecessary work and complexity. We should support just XDMF 3 and aim to make it bug-free.

  3. rambausek reporter

    Many thanks for the fast response! Okay, if the bug is on dolfin side, I would also prefer this to be fixed. I can provide a minimal example in case the crash is not so easy to reproduce. Just tell me, whether it's worth to create another issue...

    regards

  4. Chris Richardson

    I will investigate. Paraview has some variations in behaviour with different versions. Can you confirm if the problem exists on the latest download version from paraview.org?

  5. Chris Richardson

    @rambausek - Can you give me a MWE XDMF which fails? Maybe use the ascii encoding to keep it simple.

  6. rambausek reporter

    Okay, the issue only occurs if I use XDMFFile.write(Function, time [, encoding])...

    from dolfin import *
    
    mesh = UnitSquareMesh(3, 3)
    
    expr = Expression("x[0]*x[0] + x[1]", degree=2)
    
    V = FunctionSpace(mesh, "P", 1)
    u = Function(V, name="u")
    u.interpolate(expr)
    
    xf = XDMFFile("u_without_time.xdmf")
    xf.write(u, xf.Encoding_ASCII)
    
    xf2 = XDMFFile("u_with_time.xdmf")
    xf2.write(u, 0.0, xf2.Encoding_ASCII)
    

    u_without_time.xdmf

    <?xml version="1.0"?>
    <Xdmf Version="3.0">
      <Domain>
        <Grid Name="mesh" GridType="Uniform">
          <Topology NumberOfElements="18" TopologyType="Triangle" NodesPerElement="3">
            <DataItem Dimensions="18 3" NumberType="UInt" Format="XML">0 1 5
    0 4 5
    1 2 6
    1 5 6
    2 3 7
    2 6 7
    4 5 9
    4 8 9
    5 6 10
    5 9 10
    6 7 11
    6 10 11
    8 9 13
    8 12 13
    9 10 14
    9 13 14
    10 11 15
    10 14 15
    </DataItem>
          </Topology>
          <Geometry GeometryType="XY">
            <DataItem Dimensions="16 2" Format="XML">0 0
    0.3333333333333333 0
    0.6666666666666666 0
    1 0
    0 0.3333333333333333
    0.3333333333333333 0.3333333333333333
    0.6666666666666666 0.3333333333333333
    1 0.3333333333333333
    0 0.6666666666666666
    0.3333333333333333 0.6666666666666666
    0.6666666666666666 0.6666666666666666
    1 0.6666666666666666
    0 1
    0.3333333333333333 1
    0.6666666666666666 1
    1 1
    </DataItem>
          </Geometry>
          <Attribute Name="u" AttributeType="Scalar" Center="Node">
            <DataItem Dimensions="16 1" Format="XML">0
    0.1111111111111111
    0.4444444444444444
    1
    0.3333333333333333
    0.4444444444444444
    0.7777777777777777
    1.333333333333333
    0.6666666666666666
    0.7777777777777777
    1.111111111111111
    1.666666666666667
    1
    1.111111111111111
    1.444444444444444
    2
    </DataItem>
          </Attribute>
        </Grid>
      </Domain>
    </Xdmf>
    

    u_with_time.xdmf

    <?xml version="1.0"?>
    <!DOCTYPE Xdmf SYSTEM "Xdmf.dtd" []>
    <Xdmf Version="3.0" xmlns:xi="http://www.w3.org/2001/XInclude">
      <Domain>
        <Grid Name="TimeSeries" GridType="Collection" CollectionType="Temporal">
          <Time TimeType="List">
            <DataItem Format="XML" Dimensions="1"> 0</DataItem>
          </Time>
          <Grid Name="mesh" GridType="Uniform">
            <Topology NumberOfElements="18" TopologyType="Triangle" NodesPerElement="3">
              <DataItem Dimensions="18 3" NumberType="UInt" Format="XML">0 1 5
    0 4 5
    1 2 6
    1 5 6
    2 3 7
    2 6 7
    4 5 9
    4 8 9
    5 6 10
    5 9 10
    6 7 11
    6 10 11
    8 9 13
    8 12 13
    9 10 14
    9 13 14
    10 11 15
    10 14 15
    </DataItem>
            </Topology>
            <Geometry GeometryType="XY">
              <DataItem Dimensions="16 2" Format="XML">0 0
    0.3333333333333333 0
    0.6666666666666666 0
    1 0
    0 0.3333333333333333
    0.3333333333333333 0.3333333333333333
    0.6666666666666666 0.3333333333333333
    1 0.3333333333333333
    0 0.6666666666666666
    0.3333333333333333 0.6666666666666666
    0.6666666666666666 0.6666666666666666
    1 0.6666666666666666
    0 1
    0.3333333333333333 1
    0.6666666666666666 1
    1 1
    </DataItem>
            </Geometry>
            <Attribute Name="u" AttributeType="Scalar" Center="Node">
              <DataItem Dimensions="16 1" Format="XML">0
    0.1111111111111111
    0.4444444444444444
    1
    0.3333333333333333
    0.4444444444444444
    0.7777777777777777
    1.333333333333333
    0.6666666666666666
    0.7777777777777777
    1.111111111111111
    1.666666666666667
    1
    1.111111111111111
    1.444444444444444
    2
    </DataItem>
            </Attribute>
          </Grid>
        </Grid>
      </Domain>
    </Xdmf>
    
  7. rambausek reporter

    that's my error message from Paraview:

    """ 'Value' not in itemProperties in XdmfTime::populateItem Qt has caught an exception thrown from an event handler. Throwing exceptions from an event handler is not supported in Qt. You must reimplement QApplication::notify() and catch all exceptions there.

    terminate called after throwing an instance of 'XdmfError' what(): 'Value' not in itemProperties in XdmfTime::populateItem Aborted """

  8. Chris Richardson

    @rambausek - Yes, I am getting the same error. It seems that Xdmf3 has redefined how to list the timesteps (without updating the documentation). I will try to figure out what is the new way to do it. Meanwhile, note that you can still read the file by using the Xdmf reader in Paraview instead of the Xdmf3 reader.

  9. rambausek reporter

    @chris_richardson - Actually, before I recognized that dolfin now generates Xdmf3 output, I tried to open my files with the Xdmf(2) reader, which did not work properly for files containing multiple fields (e.g. u ["CG", 1] and grad(u) ["DG", 0]) per time step.

  10. Chris Richardson

    As far as I am aware, saving multiple fields in one file has never worked properly. This is not recommended - the main reason being that it is difficult to separate the different fields into separate blocks in the XML. I would definitely recommend using separate files.

  11. rambausek reporter

    Okay, then I'll try to get back to "one field per file", although until now it worked quite well for me. However, if there is a convenient way to update the mesh according to a displacement field, I am also fine with the "one field per file" recommendation. I'll have a look at the ALE routines... Anyway, thank you again for the fast response and advices!

  12. rambausek reporter

    For those who didn't know (like me...): In Paraview, there exists a filter "AppendAttributes" that aggregates multiple datasets (e.g. xdmf-files) into one.

  13. Chris Richardson

    There are several inconsistencies/omissions in the Xdmf3 documentation. I have made a simple fix for Xdmf3 time series in a branch. There are other issues, to do with XPath syntax, which remain to be resolved. The main issues are upstream.

  14. Tormod Landet

    Is the fix merged? I get the same problems on master ( 'Value' not in itemProperties in XdmfTime::populateItem) with Paraview 5.3.0

    By the way, I have depended on saving many different fields to XDMF for a long time now. Never had any issues. I have many output fields and switch between them all the time so I need to have multiple fields in one file working with Paraview in some format or another, otherwise it will just be too big of a hassle.

    Can I help with this somehow?

  15. Log in to comment