Interpolating between different meshes fails

Bug #423154 reported by Harish Narayanan
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
DOLFIN
Fix Released
High
Anders Logg

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.

Johan Hake (johan-hake)
Changed in dolfin:
status: New → Confirmed
Revision history for this message
marc spiegelman (mspieg) wrote :

This is problem exists in the c++ version as well.
It's actually critical for some codes I'm writing where I need to interpolate to a submesh.
Everything worked up to revision 6870, and I suspect it's related to putting ufc_cell into data (as is suggested by the workaround in the original bug report).

Revision history for this message
Anders Logg (logg) wrote :

My fault. I've assigned this to milestone 0.93 so it will be fixed before the release.

Changed in dolfin:
importance: Undecided → High
milestone: none → 0.93
Changed in dolfin:
assignee: nobody → logg (logg)
Revision history for this message
Anders Logg (logg) wrote :

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
Changed in dolfin:
status: Fix Committed → Fix Released
Anders Logg (logg)
Changed in dolfin:
status: Fix Released → Fix Committed
Anders Logg (logg)
Changed in dolfin:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.