SetDeformation does not work properly with L2 space gfu

Hi,

I have the following code-snippet, that seems to not deform the mesh as expected:

cf = CoefficientFunction([(0,0,1) if mat== "MovingTarget" else (0,0,0) for mat in mesh.GetMaterials()])
    
fes = L2(mesh, order = 1, dim=3)
u = GridFunction(fes)
u.Set(cf)

mesh.SetDeformation(u)

I also tried with H1 fes, but that had the disadvantage, that the interpolation of the cf was very useless.
Perhaps there is a fundamentally better way to achieve this moving target?

I don’t think you want a discontinuous deformation… What do you mean with ‘useless’? I guess you want a smooth extension of (0,0,1) into the outer domain, best would probably be computing an harmonic extension by solving a poisson equation on the exterior with dirichlet boundaries (0,0,1) on the interior and then setting all vertex dofs to (0,0,1) in the interior. That would give you a function deforms the mesh smoothly and is (0,0,1) in the domain… But a bit expensive to compute.
Best
Christopher