Hi.
Thank you all for a nice and good q/a forum.
I'm new to FEniCS, so please bear with me.
I'm reading chapter 30 in the Fenics book about discontinuities in the solution.
And to understand it I tried to implement the code from figure 30.2, as follows:
from dolfin import *
import sys, math, numpy
nx = 40; ny = 60
mesh = UnitSquareMesh(nx, ny)
h = mesh.hmax()
# Define a MeshFunction over two subdomains
dcdomain = MeshFunction("size_t", mesh, mesh.topology().dim())
class OmegaHat(SubDomain):
def inside(self, x, on_boundary):
return True if x[1] >= 0.5-h and x[1] <= 0.5+h else False
# Mark subdomains with numbers 0 and 1
omegaHat = OmegaHat()
dcdomain.set_all(0)
omegaHat.mark(dcdomain, 1)
dc = Measure("dx")[dcdomain]
# Code below is from figure 30.2
# Define contionous and discontiuous spaces
Ec = FiniteElement("Lagrange", triangle, 1)
Ed = RestrictedElement(Ec, dc)
# Create enriched space
E = Ec + Ed
# Create test and tria functions
v, u = TestFunction(E), TrialFunction(E)
# Interface flux parameter and source term
k = Constant(triangle)
f = Coefficient(Ec)
# Create linear and bilinear forms
a = inner(grad(u), grad(v))*dx + k*jump(u)*jump(v)*dc
L = f*v*dx
So dc is a measure as text tells. But FEniCS throws the following error:
Expecting a Cell instance, or the string 'facet'. Traceback (most
recent call last): File "demo.py", line 27, in
Ed = RestrictedElement(Ec, dc) File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/ufl/finiteelement/restrictedelement.py",
line 42, in init
"Expecting a Cell instance, or the string 'facet'.") File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/ufl/assertions.py",
line 37, in ufl_assert
if not condition: error(message) File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/ufl/log.py",
line 154, in error
raise self._exception_type(self._format_raw(message)) ufl.log.UFLException: Expecting a Cell instance, or the string
'facet'.
So it will not accept dc as a measure. Does anyone know what to do to get it right?
Do I need the form compiler from http://launchpad.net/ffc-pum before I can do this?
That one is not available for FEniCS V 1.2?
If so, is there any other ways to deal with discontinuities in FEniCS?
Greeting Christian