← Back to team overview

ffc team mailing list archive

Re: FFC

 

if this is a "set" in the mathematical sense, Python 2.3 supports them

from sets import Set, ImmutableSet

I haven't looked at sets in 2.4 -- is there a built-in set that isn't part of a module?

Anders, little things like this change from time to time in Python -- it's best to be backward compatible a little ways...


Robert C. Kirby
Assistant Professor
Department of Computer Science
The University of Chicago
http://people.cs.uchicago.edu/~kirby
On May 3, 2005, at 4:53 PM, Anders Logg wrote:

I think this is a Python 2.3 problem. Can you update to Python 2.4?

The built-in data type set was added in Python 2.4. If you are unable
to upgrade to Python 2.4, I can change to use the class Set from the
module sets which should work with both 2.3 and 2.4.

Also note that you need the latest CVS version of FFC to run the test
problems (0.1.7 was released before the bug fix).

/Anders

	On Tue, May 03, 2005 at 11:35:35PM +0200, Garth N. Wells wrote:
Anders,

I can't try the forms that you gave, because I can't get FFC 0.1.7 + FIAT 0.2.1 to run. The output from 'ffc Poisson.form' (using the Poisson.form demo in
ffc-0.1.7/src/demo) is

mech136/<4>ffc-0.1.7/src/demo>ffc Poisson.form
This is FFC, the FEniCS Form Compiler, version 0.1.7.
For further information, go to http://www/fenics.org/ffc/.

Parsing Poisson.form
Output written to Poisson.py

Compiling form: (dXa0/dxb0)(dXa1/dxb0) | ((d/dXa0)vi1)*((d/dXa1)vi0)*dX Finite element of test space: Lagrange finite element of degree 1 on a Triangle Finite element of trial space: Lagrange finite element of degree 1 on a Triangle
Computing 36 integrals, this may take some time
...................................................................... .........
Traceback (most recent call last):
  File "/usr/bin/ffc", line 80, in ?
    main(sys.argv[1:])
  File "/usr/bin/ffc", line 58, in main
    execfile(outname)
  File "Poisson.py", line 38, in ?
    compile([a, L], name, "0.1.7", "C++", "GNU GPL Version 2")
File "/usr/lib/python2.3/site-packages/ffc/compiler/compiler.py", line 75, in
compile
    form.AKi = ElementTensor(form.sum, "interior", format)
File "/usr/lib/python2.3/site-packages/ffc/compiler/elementtensor.py", line
41, in __init__
    gK_used = set()
NameError: global name 'set' is not defined

Garth


Quoting Anders Logg <logg@xxxxxxxxx>:

You were right, there was a (serious) bug in FFC for handling constant
indices. Thanks for pointing this out.

It has been fixed in the latest CVS version of FFC. However, the new
version of FFC uses FIAT directly to generate vector-valued elements
(previously handled in FFC), and FIAT assumes that a vector-valued
Lagrange element on a triangle has two components. I think Rob will
fix this shortly. Until then, try the following forms and see that you
get the expected results:

element = FiniteElement("Vector Lagrange", "triangle", 1)

v  = BasisFunction(element)
u1 = BasisFunction(element)

# Form 1
#a = v[1] *(u1[0].dx(0) + u1[1].dx(1)) * dx

#Form 2
#a = v[1] *(u1[0] + u1[1]) * dx

#Form 3
a = v[1] *(u1[0].dx(0) + u1[1].dx(1)) * dx

#Form 4
#a = v[1] *(u1[i].dx(i) ) * dx

/Anders

On Mon, May 02, 2005 at 05:19:37PM +0200, Garth N. Wells wrote:
Dear Anders,

I've been trying to use FFC for some forms which cannot be written using
summation convention, so I've been writing out the forms explicitly.
However, I have a problem with terms that involve a derivative, e.g.
u1[0].dx(0). Terms like u1[i].dx(i) (using indices) work fine.

Below is the code from an FFC file. What I've labelled Form 1 is basically
the
continuity equation for 2D Navier-Stokes. Form 1 and Form 2 produce
erroneously
exactly the same header file. In the case of Form 1, the resulting header
file
does not involve any terms from the Jacobian (g00, g10, etc.) which it
should
do. I would expect Form 3 and Form 4 to produce the same result. However,
Form 4
produces the expected result, and Form 3 does not. Is there something wrong
with
the synatax that I'm using? Notably, terms like u1[0].dx() do produce the
expected result (no index between the round brackets).

We're having some trouble with our mail server here, so I'd be grateful if
you
could send a cc of any response to gnwells@xxxxxxxxxxx.

Regards,
Garth

name = "Test"
vector = FiniteElement("Lagrange", "triangle", 1, 3)

v    = BasisFunction(vector)
u1   = BasisFunction(vector)

# Form 1
a = v[2] *(u1[0].dx(0) + u1[1].dx(1)) * dx

#Form 2
#a = v[2] *(u1[0] + u1[1]) * dx

#Form 3
#a = v[2] *(u1[0].dx(0) + u1[1].dx(1) + u1[2].dx(2)) * dx

#Form 4
#a = v[2] *(u1[i].dx(i) ) * dx





--
Anders Logg
Research Assistant Professor
Toyota Technological Institute at Chicago
http://www.tti-c.org/logg/




Follow ups

References