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