Does 'write_checkpoint' ignore the parameter 'rewrite_function_mesh'?

To store my solution, I’m using the write_checkpoint method in XDMFFile(). I really like that I can read the same file easily in both FEniCS and ParaView. However, when I set the parameter rewrite_function_mesh to False it still writes the mesh for each function. Here is a MWE with FEniCs 2018.1.0, installed with conda:

import dolfin as df

mesh = df.UnitCubeMesh(5, 5, 5)
V = FunctionSpace(mesh, "CG", 1)
u = Function(V)

f = XDMFFile(MPI.comm_world, "test.xdmf")
f.parameters["rewrite_function_mesh"] = False

for i in range(2):
    f.write_checkpoint(u, "velocity", i, append=True)

f.close()

Given the above code the content of test.xdmf will be the following:

<?xml version="1.0"?>
<Xdmf Version="3.0">
  <Domain>
    <Grid GridType="Collection" CollectionType="Temporal" Name="velocity">
      <Grid Name="velocity_0" GridType="Uniform">
        <Topology NumberOfElements="750" TopologyType="Tetrahedron" NodesPerElement="4">
          <DataItem Dimensions="750 4" NumberType="UInt" Format="HDF">test.h5:velocity/velocity_0/mesh/topology</DataItem>
        </Topology>
        <Geometry GeometryType="XYZ">
          <DataItem Dimensions="216 3" Format="HDF">test.h5:velocity/velocity_0/mesh/geometry</DataItem>
        </Geometry>
        <Time Value="0.000000" />
        <Attribute ItemType="FiniteElementFunction" ElementFamily="CG" ElementDegree="1" ElementCell="tetrahedron" Name="velocity" Center="Other" AttributeType="Scalar">
          <DataItem Dimensions="3000 1" NumberType="UInt" Format="HDF">test.h5:velocity/velocity_0/cell_dofs</DataItem>
          <DataItem Dimensions="216 1" NumberType="Float" Format="HDF">test.h5:velocity/velocity_0/vector</DataItem>
          <DataItem Dimensions="751 1" NumberType="UInt" Format="HDF">test.h5:velocity/velocity_0/x_cell_dofs</DataItem>
          <DataItem Dimensions="750 1" NumberType="UInt" Format="HDF">test.h5:velocity/velocity_0/cells</DataItem>
        </Attribute>
      </Grid>
      <Grid Name="velocity_1" GridType="Uniform">
        <Topology NumberOfElements="750" TopologyType="Tetrahedron" NodesPerElement="4">
          <DataItem Dimensions="750 4" NumberType="UInt" Format="HDF">test.h5:velocity/velocity_1/mesh/topology</DataItem>
        </Topology>
        <Geometry GeometryType="XYZ">
          <DataItem Dimensions="216 3" Format="HDF">test.h5:velocity/velocity_1/mesh/geometry</DataItem>
        </Geometry>
        <Time Value="1.000000" />
        <Attribute ItemType="FiniteElementFunction" ElementFamily="CG" ElementDegree="1" ElementCell="tetrahedron" Name="velocity" Center="Other" AttributeType="Scalar">
          <DataItem Dimensions="3000 1" NumberType="UInt" Format="HDF">test.h5:velocity/velocity_1/cell_dofs</DataItem>
          <DataItem Dimensions="216 1" NumberType="Float" Format="HDF">test.h5:velocity/velocity_1/vector</DataItem>
          <DataItem Dimensions="751 1" NumberType="UInt" Format="HDF">test.h5:velocity/velocity_1/x_cell_dofs</DataItem>
          <DataItem Dimensions="750 1" NumberType="UInt" Format="HDF">test.h5:velocity/velocity_1/cells</DataItem>
        </Attribute>
      </Grid>
    </Grid>
  </Domain>
</Xdmf>

However, if I change velocity_1 to velocity_0 in the test.xdmf for the mesh, cell_dofs, x_cell_dofs, and cells, it will still be read correctly into both ParaView and FEniCS.

I’m wondering if there is something I’m missing here, or if this is a bug?

1 Like

To answer my own question: Yes, write_checkpoint does not take into account rewrite_function_mesh.

2 Likes