Skip to content

Interpolate nonmatching mesh

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

The dolfin project or interpolate functions can not handle interpolation or projection from a FunctionSpace in one mesh to a FunctionSpace on a different mesh, at least not in parallel. Using the interpolate_nonmatching_mesh function this is now possible

mesh1 = UnitSquareMesh(16, 16)
V1 = FunctionSpace(mesh1, 'CG', 2)
u1 = interpolate(Expression("sin(pi*x[0])*cos(pi*x[1])"), V1)
# Create a new _different_ mesh and FunctionSpace
mesh2 = UnitSquareMesh(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. A ParaView plot of both u1 and u2 is shown below, where the colorscale has been reversed for the smaller mesh projected onto.

Interpolate nonmatching mesh