Skip to content

Incorrect behaviour when moving parent mesh of VertexOnlyMesh #4540

@leo-collins

Description

@leo-collins

Suppose we have a VertexOnlyMesh immersed in a parent mesh. Changing mesh.coordinates doesn't reimmerse the VOM as expected. For example,

from firedrake import *

points = [[0.5, 0.5]]
mesh = UnitSquareMesh(10, 10)
V = FunctionSpace(mesh, "CG", 1)
x, y = SpatialCoordinate(mesh)
f = Function(V).interpolate(x + y)

vom = VertexOnlyMesh(mesh, points)
P0DG = FunctionSpace(vom, "DG", 0)
f_at_points = assemble(interpolate(f, P0DG))

assert np.allclose(f_at_points.dat.data, [1.0])

mesh.coordinates.dat.data_wo[:, 0] += 1.0
f = Function(V).interpolate(x + y)

f_at_points_after_move = assemble(interpolate(f, P0DG))

assert np.allclose(f_at_points_after_move.dat.data, [2.0])

coord = vom.topology_dm.getField("DMSwarmPIC_coor")
assert np.allclose(coord[0], [0.5, 0.5])
vom.topology_dm.restoreField("DMSwarmPIC_coor")

f_at_points_after_move contains f evaluated at the point [0.5,0.5] which isn't in the mesh. I think this is because the value at the point is calculated from the global number of the cell and the local reference coordinates of the point, neither of which are affected by changing the mesh coordinates. But clearly this calculation makes no sense.

Moving the mesh is equivalent to moving the points in the opposite way, so a fix for this would require implementing moving particles.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions