← Back to team overview

dolfin team mailing list archive

[Bug 423154] Re: Interpolating between different meshes fails

 

Reverted optimization to UFCFunction.cpp (not storing _ufc_cell). The problem was
that the cell might originate from another mesh and so was not valid. We could
consider storing the mesh also and check that as well but the Function class is
up for redesign (simplification) anyway so it can wait until then.

Closing this bug.

** Changed in: dolfin
       Status: Confirmed => Fix Committed

-- 
Interpolating between different meshes fails
https://bugs.launchpad.net/bugs/423154
You received this bug notification because you are subscribed to DOLFIN.

Status in DOLFIN: Fix Committed

Bug description:
When I attempt to interpolate between different meshes, I get completely erroneous results. The following example demonstrates this:

from dolfin import *

mesh1 = UnitSquare(8, 8)
mesh2 = UnitSquare(16, 16)

V1 = FunctionSpace(mesh1, "CG", 1)
V2 = FunctionSpace(mesh2, "CG", 1)

f1 = Function(V1, "500.0 * exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)")
f1.interpolate()

f2 = interpolate(f1, V2)

plot(f1, title="Original function")
plot(f2, title="Interpolated function")
interactive()

Furthermore, when I comment out f1.interpolate(), i.e. keep it defined as an expression, I do not run into this problem. A workaround (as suggested by Anders) for this seems to be to comment out data._ufc_cell = &cell; from dolfin/function/UFCFunction.cpp.