Subject: [FIAT-dev] Bug in discontinuous vector Lagrange

From: Anders Logg <[email-masked]>
Date: Tue, 28 Nov 2006 10:49:58 +0100

Rob, vector-valued DG(0) is broken:

>> from FIAT.DiscontinuousLagrange import *
>> from FIAT.shapes import *
>> P0 = DiscontinuousVectorLagrange(TRIANGLE, 0, 2)
---------------------------------------------------------------------------
exceptions.TypeError

/usr/lib/python2.4/site-packages/FIAT/DiscontinuousLagrange.py in
DiscontinuousVectorLagrange(shape, n, nc)
     89     else:      return DiscLagrange( shape , n )
     90 
     91 def DiscontinuousVectorLagrange( shape , n , nc ):
---> 92     if n == 0: return P0.VecP0( shape , nc )
     93     else:      return DiscVecLagrange( shape , n ,nc )

/usr/lib/python2.4/site-packages/FIAT/P0.py in __init__(self, shape, nc)
     61     def __init__( self , shape , nc ):
     62         U = polynomial.OrthogonalPolynomialArraySet( shape , 0
     , nc )
---> 63         Udual = VecP0Dual( shape , U )
     64         polynomial.FiniteElement.__init__( self , Udual , U )
     65 

/usr/lib/python2.4/site-packages/FIAT/P0.py in __init__(self, shape, U)
     44         bary = numpy.average( numpy.array( map( numpy.array ,
     \
     45
     vs.values() ) ) )
---> 46         self.pts = ( tuple(bary) , )
     47         ls = [ functional.ComponentPointEvaluation( U , c ,
     bary ) \
     48                for c in range( nc ) ]

TypeError: iteration over non-sequence

/Anders

---

From: "Garth N. Wells" <[email-masked]>
Date: Tue, 28 Nov 2006 11:01:23 +0100

This is related to numpy (making me responsible for introducing the
bug). In P0.py, on line 44,

    bary = numpy.average( numpy.array( map( numpy.array , \
                                                    vs.values() ) ) )

should be replaced by

    bary = numpy.average( numpy.array( map( numpy.array , \
                                                   vs.values() ) ) , 0 )

Some basic verification tests in FIAT would be really useful.

Garth

Anders Logg wrote:
> _______________________________________________
> FIAT-dev mailing list
> [email-masked]
> http://www.fenics.org/mailman/listinfo/fiat-dev
>

---

From: "Garth N. Wells" <[email-masked]>
Date: Tue, 28 Nov 2006 16:13:24 +0100

You could tabulate the functions for a collection of elements and write
them to a benchmark file, and then add a script to verify FIAT output
against these files. FFC does something like this which is really useful
for testing after making changes.

Garth

Robert C. Kirby wrote:
> Fixed.
> Any thoughts on how to verify?
> I could just write a script that would instantiate every element for the
> first three orders and make sure no exceptions happen.  This doesn't
> check for correctness, just for these kinds of errors.
> 
> Rob
> 
> On Tue, 2006-11-28 at 11:01 +0100, Garth N. Wells wrote: