How to do updated Lagrangian when the displacement lives in a different space to the mesh geometry?

how about the following mwe:

import dolfinx
from mpi4py import MPI
import numpy as np

mesh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 4, 4)
V_coord = dolfinx.fem.FunctionSpace(
    mesh, mesh.ufl_domain().ufl_coordinate_element())

V = dolfinx.fem.VectorFunctionSpace(mesh, ("CG", 2))

u = dolfinx.fem.Function(V)
u.interpolate(lambda x: np.stack((0.1*x[1]**2, 0.1*x[0]**2)))

u_coord = dolfinx.fem.Function(V_coord)
u_coord.interpolate(u)

mesh.geometry.x[:, :mesh.geometry.dim] += u_coord.x.array.reshape(
    (-1, mesh.geometry.dim))

with dolfinx.io.XDMFFile(mesh.comm, "mesh.xdmf", "w") as xdmf:
    xdmf.write_mesh(mesh)

image

1 Like