firedrakeproject / firedrake

Firedrake is an automated system for the portable solution of partial differential equations using the finite element method (FEM)
https://firedrakeproject.org
Other
509 stars 159 forks source link

BUG: checkpointing produces error #3840

Open colinjcotter opened 3 days ago

colinjcotter commented 3 days ago

Describe the bug

I get an error message when I try to save functions to a checkpoint file.

Steps to Reproduce

from firedrake import *
mesh = IcosahedralSphereMesh(radius=1.0,
                                refinement_level=4,
                                degree=1, name="mesh")
V = FunctionSpace(mesh, "CG", 1)
u = Function(V, name="u").assign(1.0)

with CheckpointFile('test.h5', 'w') as afile:
    afile.save_function(u)

Expected behavior

Error message

(firedrake) journal todo +cjc1@cjc1-HP-Z840-Workstation:~/repositories/sw_timestepping$ python test_chk.py 
Traceback (most recent call last):
  File "/home/cjc1/repositories/sw_timestepping/test_chk.py", line 9, in <module>
    afile.save_mesh(mesh)
  File "petsc4py/PETSc/Log.pyx", line 188, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
  File "petsc4py/PETSc/Log.pyx", line 189, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
  File "/home/cjc1/firedrake/src/firedrake/firedrake/checkpointing.py", line 638, in save_mesh
    self._save_function_topology(mesh._coordinates)
  File "petsc4py/PETSc/Log.pyx", line 188, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
  File "petsc4py/PETSc/Log.pyx", line 189, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
  File "/home/cjc1/firedrake/src/firedrake/firedrake/checkpointing.py", line 971, in _save_function_topology
    self._save_function_space_topology(tV)
  File "petsc4py/PETSc/Log.pyx", line 188, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
  File "petsc4py/PETSc/Log.pyx", line 189, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
  File "/home/cjc1/firedrake/src/firedrake/firedrake/checkpointing.py", line 866, in _save_function_space_topology
    self._save_mesh_topology(tmesh)
  File "petsc4py/PETSc/Log.pyx", line 188, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
  File "petsc4py/PETSc/Log.pyx", line 189, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
  File "/home/cjc1/firedrake/src/firedrake/firedrake/checkpointing.py", line 703, in _save_mesh_topology
    raise ValueError(f"Mesh ({tmesh_name}) already exists in {self.filename}, but the global number of DMPlex points is inconsistent: {order_array_size1} ({self.filename}) != {order_array_size} ({tmesh_name})")
ValueError: Mesh (firedrake_default_topology) already exists in test.h5, but the global number of DMPlex points is inconsistent: 9 (test.h5) != 15362 (firedrake_default_topology)

Environment:

Additional Info

connorjward commented 3 days ago

Are you using an up-to-date Firedrake branch? I think @ksagiyam fixed this a short while ago.

ksagiyam commented 2 days ago

https://github.com/firedrakeproject/firedrake/pull/3792/files

It seems you managed to update your Firedrake after our PETSc fork was updated, but before the matching Firedrake PR went in.