Subject: [FFC-dev] Inverse bug?

From: "Garth N. Wells" <[email-masked]>
Date: Fri, 27 Jun 2008 18:37:24 +0100

I'm observing some strange behaviour when using the inverse of a scalar. 
Running FFC on

   P1   = FiniteElement("Lagrange", "triangle", 1)
   v    = TestFunction(P1)
   temp = Constant("triangle")
   Tp   = 10
   L    = v*temp*(1*Tp)*dx

is fine, but running

   P1   = FiniteElement("Lagrange", "triangle", 1)
   v    = TestFunction(P1)
   temp = Constant("triangle")
   Tp   = 10
   L    = v*temp*(1/Tp)*dx

leads to the below error. For complex forms, I don't get an error when 
using 1/a, but the forms expect the wrong number of arguments.

Garth

Traceback (most recent call last):
   File "/usr/bin/ffc", line 180, in <module>
     sys.exit(main(sys.argv[1:]))
   File "/usr/bin/ffc", line 107, in main
     execfile(outname, ns)
   File "Test.py", line 18, in <module>
     compile([a, L, M, element], "Test", "tensor", "dolfin", 
{'quadrature_points=': False, 'blas': False, 'precision=': '15', 
'optimize': False})
   File "/usr/lib/python2.5/site-packages/ffc/compiler/compiler.py", 
line 67, in compile
     (form_data, form_representation) = __compile_forms(forms, prefix, 
representation, language, options)
   File "/usr/lib/python2.5/site-packages/ffc/compiler/compiler.py", 
line 94, in __compile_forms
     form_data = analyze_form(form)
   File "/usr/lib/python2.5/site-packages/ffc/compiler/compiler.py", 
line 186, in analyze_form
     form_data = analyze(form)
   File 
"/usr/lib/python2.5/site-packages/ffc/compiler/analysis/analyze.py", 
line 51, in analyze
     form_data = FormData(form)
   File 
"/usr/lib/python2.5/site-packages/ffc/compiler/analysis/formdata.py", 
line 60, in __init__
     self.elements                     = self.__extract_elements(form, 
self.rank, self.num_coefficients)
   File 
"/usr/lib/python2.5/site-packages/ffc/compiler/analysis/formdata.py", 
line 111, in __extract_elements
     monomial = form.monomials[0]
IndexError: list index out of range

---

From: "Garth N. Wells" <[email-masked]>
Date: Fri, 27 Jun 2008 19:31:00 +0100

>    temp = Constant("triangle")

It looks like 1/Tp is a problem, and 1.0/Tp is OK.

Garth

> _______________________________________________
> FFC-dev mailing list
> [email-masked]
> http://www.fenics.org/mailman/listinfo/ffc-dev

---

From: Kristian Oelgaard <[email-masked]>
Date: Fri, 27 Jun 2008 23:45:01 +0200

> It looks like 1/Tp is a problem, and 1.0/Tp is OK.

It's because 1/10 = 0 and 1.0/10 or 1/10.0 = 0.1 in Python...

Kristian

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Mon, 30 Jun 2008 12:38:03 +0200

> It's because 1/10 = 0 and 1.0/10 or 1/10.0 = 0.1 in Python...

Yes. Note that this will change in python 3.0, with // meaning integer
division and / always meaning float division.

-- 
Martin