← Back to team overview

dolfin team mailing list archive

Re: Crouzeix-Raviart error

 

Anders Logg wrote:
On Mon, Apr 28, 2008 at 02:24:38PM +0200, Anders Logg wrote:
On Mon, Apr 28, 2008 at 03:00:26PM +0200, Marie Rognes wrote:
Error:

    Traceback (most recent call last):
      File "test.py", line 33, in ?
        u0.assign(w)
      File
    "/home/meg/src/dolfin/dolfin/local/lib/python2.4/site-packages/dolfin/dolfin.py",
    line 3172, in assign
        return _dolfin.cpp_Function_assign(*args)
    RuntimeError: *** Error: Unable to find finite element in library:
    "Mixed finite element: [Crouzeix-Raviart finite element of degree 1
    on a triangle, Crouzeix-Raviart finite element of degree 1 on a
    triangle]".
    Segmentation fault


Code:

    from dolfin import *

    # Geometry of the domain and mesh
    shape = "triangle"
    mesh = UnitSquare(16, 16)

    # Setting up the elements
    V = VectorElement("CR", shape, 1)

    u0 = Function(V, mesh, 0.0)

    v = TestFunction(V)
    u = TrialFunction(V)
    a = dot(grad(u), grad(v))*dx
    L = dot(u0, v)*dx

    pde = LinearPDE(a, L, mesh)
    w = pde.solve()
    u0.assign(w)

Easy fix?
Probably not. The message comes from the copy constructor (in C++) of
DiscreteFunction, which looks in the list of precompiled elements and
that list does not include vector-valued CR elements.

I'll see if I can find the problem. You are doing this from Python so
it should be possible to get around this problem and not need to
create the element from precompiled code.

ok, I found a solution (temporary).

If you change the line

  u0 = Function(V, mesh, 0.0)

to

  u0 = Function(V, mesh, Vector())

it should work.


Perfect. Thanks!

Then both w and u0 will be discrete functions (i.e. storing their
values in a vector). They will also be defined on the same space so
then just the values in the vector need to get copied and that works
nicely (in operator= in DiscreteFunction).

The problem with your code is that u0 was not a discrete function, but
instead a "constant function" which does not store its values in a
vector. So then what happens is that a new discrete function must be
created (including a new finite element) and then DOLFIN must (in C++)
look in its library of precompiled elements (which is limited to
reduce compile times).

We can fix this and related issues when we rework/cleanup the function
classes (now that the linear algebra seems to be ok).


Good.

--
Marie E. Rognes
Ph.D Fellow, Centre of Mathematics for Applications, University of Oslo
http://folk.uio.no/meg



References