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

DOLFIN can't find point inside mesh

0 votes

Hi,
I'm trying to solve Poisson's equation with a variable conductivity, sigma, and I'm overriding the "eval" function of Expression to do so. For some reason the interpolated "sigma" can't return values at seemingly random points inside the domain.
A minimal working script is given bellow as well as the error messages I get with and without extrapolation.

I did not encounter these problems when I wrote my code some time
earlier this fall. I'm now using FEniCS version 1.2.0., but I'm not
entirely sure when my code stopped working.

Is there any way around this problem?

Error with "parameters['allow_extrapolation'] = False":

Evaluating at x =
Traceback (most recent call last):
File "minimal_debug.py", line 26, in
print sigma(0.233, 0.638, 0.039)
File "/usr/lib/python2.7/dist-packages/dolfin/functions/function.py", line 382, in call
self.eval(values, x)
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


*** https://answers.launchpad.net/dolfin


*** 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
*** -------------------------------------------------------------------------

Error with "parameters['allow_extrapolation'] = True":

Traceback (most recent call last):
File "minimal_debug.py", line 27, in
print sigma(0.233, 0.638, 0.039)
File "/usr/lib/python2.7/dist-packages/dolfin/functions/function.py", line 382, in call
self.eval(values, x)
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


*** https://answers.launchpad.net/dolfin


*** Remember to include the error message listed below and, if possible,
*** include a minimal running example to reproduce the error.


*** -------------------------------------------------------------------------
*** Error: Unable to perform call to DOLFIN function.
*** Reason: The function compute has not been implemented (in /build/buildd/dolfin-1.2.0+dfsg/dolfin/intersection/IntersectionOperatorImplementation.h line 302).
*** Where: This error was encountered inside log.h.
*** Process: 0
*** -------------------------------------------------------------------------

from dolfin import *

class DebugConductivity(Expression):
""" This inherits from ConductivityClass and contains the specific
conductivity of the control set-up"""

def eval(self, value, x):
    """ This function is written like this so I can use return_conductivity() outside the class for
    debugging reasons """
    value[0] = 1

parameters['allow_extrapolation'] = True
N = 25
mesh = BoxMesh(0, 1, 0, 1, 0, 1, N, N, N)

V = FunctionSpace(mesh, "CG", 2)
Vs = FunctionSpace(mesh, "DG", 0) # For conductivity tensor
sigma = Function(Vs)

Cond = DebugConductivity()
sigma.interpolate(Cond)
print sigma(0.233, 0.638, 0.039)

I would be very thankful for any help,
Torbjørn

asked Dec 17, 2013 by torbness FEniCS Novice (150 points)
closed Dec 17, 2013 by torbness

1 Answer

+1 vote
 
Best answer

Hi,

You probably have the same problem as reported here http://fenicsproject.org/qa/1792/interpolation-problem-with-current-development-version and fixed here https://bitbucket.org/fenics-project/dolfin/issue/168/evaluation-of-function-at-specific-point. Not quite sure about the second error, but it is not really relevant since allow_extrapolation should be False anyway for the fixed dolfin. For better help you should post a code snippet that is possible to copy-paste and run.

answered Dec 17, 2013 by mikael-mortensen FEniCS Expert (29,340 points)
selected Dec 17, 2013 by torbness

Ah, thanks. Sorry about that, I had seen the other solution, but I thought I had the development version, and that it still didn't work.

In detail:
I had previously installed the Ubuntu PPA with the commands listed here:
http://fenicsproject.org/download/ubuntu_details.html
but it worked when I installed using the commands from here instead:
https://launchpad.net/~fenics-packages/+archive/fenics-dev

...