This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

How to interpolate function on boundary?

0 votes

I have two functions f and f_b, defined on a mesh and its boundary mesh:

mesh = Mesh('somemesh.xml')
bmesh = BoundaryMesh(mesh, 'exterior')
V = FunctionSpace(mesh, 'CG', 2)
V_b = FunctionSpace(bmesh, 'CG', 2)
f = Function(V)
f_b = Function(V_b)

On the boundary mesh, I would like the two functions to have the same values, so I do (after computing the dofs of f):

f_b.interpolate(f)

Now, for simple meshes like mesh = SphereMesh(Point(0.0, 0.0, 0.0), 1, 0.08) this works just fine. But for some more complicated meshes, I'm getting this error:

*** Error:   Unable to evaluate function at point.
*** Reason:  The point is not inside the domain. Consider setting "allow_extrapolation" to allow extrapolation.
*** Where:   This error was encountered inside Function.cpp.
*** Process: 0
*** 
*** DOLFIN version: 1.3.0
*** Git changeset:  

However, even setting dolfin.parameters['allow_extrapolation'] = True does not change anything. Moreover, I believe there should be no need to extrapolate in the first mesh. Aren't the degrees of freedom of f_b a subset of the degrees of freedom of f?

asked Jul 11, 2014 by Nikolaus Rath FEniCS User (2,100 points)
...