What is the best way to create a 3D mesh from a parametric description of its coordinates? I am trying to morph a UnitSquareMesh mesh using an Expression that maps the parametric to the spatial coordinates. This should be simple, however, UnitSquareMesh doesn’t have z-coordinates to assign to. Is it possible to embed UnitSquareMesh into 3D? (In the code below, I am trying to form a semicylinder.)
from dolfin import * gamma = Expression(('cos(pi*(-x + 1))', 'x', 'sin(pi*(-x + 1))'), pi=pi, degree=4) mesh = UnitSquareMesh(20, 20, 'crossed') Ve = VectorElement("CG", mesh.ufl_cell(), degree=2, dim=3) V = FunctionSpace(mesh, Ve) spatial_coordinates = interpolate(gamma , V) spatial_mesh = Mesh(mesh) # create a copy of mesh ALE.move(spatial_mesh, spatial_coordinates)
For my application, I need both the parametric mesh (2D), and the mesh with spatial coordinates (3D).