Interpolating mesh and boundary mesh should not require extrapolation

Issue #349 new
Nikolaus Rath created an issue

Consider this:

$ cat test.py 
#!/usr/bin/env python

import dolfin
from dolfin import Mesh, BoundaryMesh, FunctionSpace, Function

print(dolfin.__version__)

#dolfin.parameters['allow_extrapolation'] = True
dolfin.parameters["linear_algebra_backend"] = "PETSc"
dolfin.set_log_level(dolfin.WARNING)

mesh = Mesh('mesh.xml.gz')
bmesh = BoundaryMesh(mesh, 'exterior')

V_DG = FunctionSpace(mesh, 'DG', 0)
Vb_DG = FunctionSpace(bmesh, 'DG', 0)

dpsi_dn_b = Function(Vb_DG)
dpsi_dn = Function(V_DG)
dpsi_dn_b.interpolate(dpsi_dn)

$ python test.py 
1.3.0
Traceback (most recent call last):
  File "test.py", line 20, in <module>
    dpsi_dn_b.interpolate(dpsi_dn)
RuntimeError: 

*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
***     fenics@fenicsproject.org
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the 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:  
*** -------------------------------------------------------------------------

It seems to me that setting allow_extrapolation really should not be required - the vertices of bmesh coincide with those of mesh.

Comments (6)

  1. Chris Richardson

    I guess this happens because "DG0" spaces are interpolated at the cell centroid, and the facet centroid (which is the cell centroid in the BoundaryMesh) lies exactly on the surface, which may evaluate to either side of the surface, depending on numerical roundoff.

  2. Chris Richardson

    I'm delaying this to 1.7, as I think this will be cleaned up with MeshView. In the future, BoundaryMesh will be a view into the existing Mesh, and interpolate() will be able to use this knowledge to find the correct cell, purely using topological information.

  3. Log in to comment