HDF5File and PETSc object in wrong state
Issue #171
resolved
from dolfin import *
mesh = UnitSquareMesh(4, 4)
V = FunctionSpace(mesh, "CG", 1)
u = interpolate(Constant(1.0), V)
osol = HDF5File("solution.h5", "w")
osol.write(u, "solution_000")
u_read = Function(V)
osol.read(u_read, "solution_000")
#u_read.vector().apply("insert") # <- uncomment to avoid the error
u.assign(u_read)
info("%f" % assemble(u*dx))
info("%f" % assemble(u_read*dx))
On the other hand, dumping the function into an XML file yields the correct behaviour. By comparing HDF5File.cpp and XMLFunctionData.cpp it seems that a
// Finalise vector
vector.apply("insert");
is missing.
Comments (6)
-
-
We should have a check that the file is in the write state for reading or writing.
-
reporter @chris_richardson it doesn't help. The reading process is fine, but when you try to use the vector, PETSc says that the object is in the wrong state (error code: 73). Which makes sense since Vec is not finalised.
-
-
- changed status to resolved
Fixed in cd77cfe.
-
- removed milestone
Removing milestone: 1.4 (automated comment)
- Log in to comment
It's possibly caused by not closing the HDF5 file between writing and reading. Have you tried:
between writing and reading?