XDMF checkpoint file of 1D function cannot be read in paraview

Issue #1091 new
Drew Parsons created an issue

There appears to be a bug in the XDMF checkpoint file created for a Function on a 1D FunctionSpace. When reading with paraview 5.7.0, selecting Xdmf3ReaderT, the line of the mesh is shown but the function is empty, no values shown. So Filters/Data Analysis/“Plot Over Line” cannot function. A checkpoint function created in 2D or 3D does view as expected in paraview.

For example, adding

checkpointFile =  XDMFFile("poisson-checkpoint.xdmf")
checkpointFile.write_checkpoint(u, "u")
checkpointFile.close()

to the end of python/demo/documented/poisson/demo_poisson.py generates poisson-checkpoint.xdmf which can be viewed successfully (2D function).

Adapting demo_poisson.py to 1D illustrates the problem:

from dolfin import *

mesh = UnitIntervalMesh(32)
V = FunctionSpace(mesh, "Lagrange", 1)

# Define Dirichlet boundary (x = 0 or x = 1)
def boundary(x):
    return x[0] < DOLFIN_EPS or x[0] > 1.0 - DOLFIN_EPS

u0 = Constant(0.0)
bc = DirichletBC(V, u0, boundary)

# Define variational problem
u = TrialFunction(V)
v = TestFunction(V)
f = Expression("10*exp(-(pow(x[0] - 0.5, 2)) / 0.02)", degree=2)
g = Expression("sin(5*x[0])", degree=2)
a = inner(grad(u), grad(v))*dx
L = f*v*dx + g*v*ds

# Compute solution
u = Function(V)
solve(a == L, u, bc)

# Save solution in VTK format
file = File("poisson1d.pvd")
file << u

# Plot solution
import matplotlib.pyplot as plt
plot(u)
plt.show()

xdmfFile = XDMFFile("poisson1d.xdmf")
xdmfFile.write(u)
xdmfFile.close()

checkpointFile =  XDMFFile("poisson1d-checkpoint.xdmf")
checkpointFile.write_checkpoint(u, "u")
checkpointFile.close()

poisson1d.pvd and poisson1d.xdmf both display as expected in paraview, and Plot Over Line works.

poisson1d-checkpoint.xdmf does not display function values on paraview 5.7.0, and Plot Over Line does not work.

The problem has been discussed at https://fenicsproject.discourse.group/t/cant-view-xdmf-checkpoint-of-function-in-paraview/403

Comments (0)

  1. Log in to comment