Hi folks,
Just a quick question about MeshFunction. I am trying to have three different sub-meshes (mesha, meshs and meshc in the code)and function spaces (V_a, V_s, V_c).
I use the following code to generate these. But when I want to print out ca(Lxa), I get the following error. I absolutely have no idea why this is happening! Lxa is inside the domain, not outside.
Any help is deeply appreciated.
Thanks,
Mo
My code is:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
import time
from dolfin import *
import numpy as np
import scipy.io as sciio
from math import tanh, sinh, cosh, log
from numpy import linalg as LA
import scipy.io
set_log_active(False)
from sys import exit
Lxa = 100.0E-6
Lxs = 25.0E-6
Lxc = 100.0E-6
Lx = Lxa + Lxs + Lxc
nxa = 20
nxs = 5
nxc = 20
nx = nxa + nxs + nxc
dxa = Lxa/nxa
dxs = Lxs/nxs
dxc = Lxc/nxc
print 'dxa ===', dxa
print 'dxs ===', dxs
print 'dxc ===', dxc
mesh = IntervalMesh(nx,0,Lx)
subdomains = MeshFunction('uint', mesh, 0)
class a(SubDomain):
def inside(self, x, on_boundary):
return True if 0 <= x[0] <= (Lxa) else False
class s(SubDomain):
def inside(self, x, on_boundary):
return True if (Lxa) <= x[0] <= (Lxa + Lxs ) else False
class c(SubDomain):
def inside(self, x, on_boundary):
return True if (Lxa + Lxs) <= x[0] <= (Lx) else False
subdomain0 = a()
subdomain0.mark(subdomains, 0)
subdomain1 = s()
subdomain1.mark(subdomains, 1)
subdomain2 = c()
subdomain2.mark(subdomains, 2)
mesha = SubMesh(mesh, subdomain0)
meshs = SubMesh(mesh, subdomain1)
meshc = SubMesh(mesh, subdomain2)
V = FunctionSpace(mesh, 'CG', 1)
V_a = FunctionSpace(mesha, 'CG', 1)
V_s = FunctionSpace(meshs, 'CG', 1)
V_c = FunctionSpace(meshc, 'CG', 1)
c = Function(V)
ca = Function(V_a)
cc = Function(V_c)
print ca(0)
print ca(Lxa)
print cc(Lxa+Lxs)
print cc(Lx)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
And the error:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Traceback (most recent call last):
File "test_mesh.py", line 71, in
print ca(Lxa)
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
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!