-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: Checkpointing Hdiv elements on higher order meshes is not correct. #3781
Comments
That is indeed expected. We currently project functions on HDiv/HCurl spaces to ones on appropriate DG spaces before saving and project them back after loading. Those are projection errors. |
Hi, thanks - I see - I was investigating this since we see much bigger difference with higher order mesh. from firedrake import *
from firedrake.__future__ import interpolate
def report(z):
l2_norm=sqrt(assemble(inner(z, z)*dx))
h1_norm=sqrt(assemble(inner(grad(z), grad(z))*dx))
div_norm=sqrt(assemble(inner(div(z), div(z))*dx))
print(f"{l2_norm=} {h1_norm=} {div_norm=}")
mesh = UnitDiskMesh(refinement_level=2, name='disk')
l=2 # mesh order
R=1.0
V1 = mesh.coordinates.function_space()
V2 = VectorFunctionSpace(mesh, "CG", l)
x = SpatialCoordinate(mesh)
f = Function(V2).interpolate(mesh.coordinates)
ur=R*as_vector([x[0]/sqrt(x[0]**2+x[1]**2), x[1]/sqrt(x[0]**2+x[1]**2)])
bc=DirichletBC(V2, ur, 1)
bc.apply(f) # correct the boundary to conform to circle
mesh = Mesh(f, name='disk')
mesh.init()
print(mesh.coordinates.ufl_element())
k=1
V = FunctionSpace(mesh, "BDM", k)
#V = VectorFunctionSpace(mesh, "CG", k)
x=SpatialCoordinate(mesh)
z=assemble(interpolate(as_vector((x[1],x[0])), V))
report(z)
with CheckpointFile(f"temp_test.h5", 'w') as chp:
chp.save_function(z, name='z')
report(z)
with CheckpointFile(f"temp_test.h5", 'r') as chp:
mesh=chp.load_mesh(name='disk')
z=chp.load_function(mesh, name='z')
report(z) then i see this:
But maybe I am constructing the higher order mesh in wrong way? |
That indeed looks like a bug. Probably, it is caused by that projection onto the DG spaces are not exact if the mappings are non-affine. I will have a closer look when I am back from holiday. Are you only interested in simplex meshes for now? |
Yes, we use simplex meshes for now. I will modified the bug title to reflect the problem. |
When trying to restore checkpointed function, it seems not to be identical for some elements.
Steps to Reproduce
Expected behavior
When run for CG element the restored function seems to be identical
While for RT/BDM element, there is a small difference:
Is this to be expected?
The text was updated successfully, but these errors were encountered: