Skip to content

Interpolate nonmatching mesh

Mikael Mortensen edited this page Jun 21, 2013 · 16 revisions

The dolfin project function can not handle projection from a FunctionSpace in one mesh to a FunctionSpace using a different mesh, at least not in parallel. Using the project_nonmatching_mesh function this is now possible

mesh1 = UnitCubeMesh(16, 16, 16)
V1 = FunctionSpace(mesh1, 'CG', 2)
u1 = interpolate(Expression("sin(pi*x[0])*cos(pi*x[1])*cos(pi*x[2]/3.)"), V1)
# Create a new _different_ mesh and FunctionSpace
mesh2 = UnitCubeMesh(10, 10, 10)
x = mesh2.coordinates()
x[:, :] = x[:, :] * 0.5 + 0.25
V2 = FunctionSpace(mesh2, 'CG', 1)
u2 = interpolate_nonmatching_mesh(u1, V2)

This works in parallel as well.