How to obtain coordinates of nodes? How to work with dofmap?

The rotation vector is -y, x, i.e.

from mpi4py import MPI
import ufl
import dolfinx

mesh = dolfinx.mesh.create_unit_square(
    MPI.COMM_WORLD, 10, 10, cell_type=dolfinx.mesh.CellType.quadrilateral)
Ve = ufl.VectorElement("S", mesh.ufl_cell(), 2)

V = dolfinx.fem.functionspace(mesh, Ve)
u = dolfinx.fem.Function(V)
u.interpolate(lambda x: (-x[1], x[0]))


V_out = dolfinx.fem.FunctionSpace(
    mesh, ufl.VectorElement("Lagrange", mesh.ufl_cell(), 2))

u_out = dolfinx.fem.Function(V_out)
u_out.interpolate(u)

with dolfinx.io.VTXWriter(mesh.comm, "mwe_rot.bp", [u_out], engine="BP4") as bp:
    bp.write(0.0)

yielding

1 Like