← Back to team overview

ffc team mailing list archive

Re: Inverse bug?

 

Quoting "Garth N. Wells" <gnw20@xxxxxxxxx>:

> 
> 
> Garth N. Wells wrote:
> > 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
> >
> 
> 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
 
> Garth
> 
> 
> > 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
> > 
> > _______________________________________________
> > FFC-dev mailing list
> > FFC-dev@xxxxxxxxxx
> > http://www.fenics.org/mailman/listinfo/ffc-dev
> 
> _______________________________________________
> FFC-dev mailing list
> FFC-dev@xxxxxxxxxx
> http://www.fenics.org/mailman/listinfo/ffc-dev
> 




Follow ups

References