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

Modeling discontinuity

0 votes

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

asked Jan 14, 2014 by christianv FEniCS User (2,460 points)
edited Jan 14, 2014 by christianv

1 Answer

+3 votes
 
Best answer

Yes, you need ffc-pum compiler. Moreover, I don't think it works with python interface. Nevertheless, dolfin-pum and ffc-pum are not maintained anymore. You can probably use it with FEniCS 1.0 or some development version between 1.0 and 1.1.

There is a newly started effort https://bitbucket.org/terafrac/terafrac.

answered Jan 14, 2014 by Jan Blechta FEniCS Expert (51,420 points)
selected Feb 12, 2015 by christianv

Hi Blechta

I am unable to find this link. Is there any new start for the FEniCS PUM ?

Thanks

I'm note aware of any.

Thanks for the reply

...