ffc team mailing list archive
-
ffc team
-
Mailing list archive
-
Message #00569
Re: bug in mixed elements
On Wed, Apr 05, 2006 at 05:37:43PM +0200, Mehdi Nikbakht wrote:
> Hello,
>
> I am trying to solve consolidation problem with Dolphin. The following is my
> simplified form file.
>
> > u_elem=FiniteElement("Vector Lagrange", "triangle", 2)
> > P_elem=FiniteElement("Lagrange", "triangle", 1)
>
> > Element = u_elem + P_elem
>
> > (u0, p0) = Functions(Element)
> > (u1, p1)= Functions(Element)
>
> > u1test = Function(u_elem)
> > u0test = Function(u_elem)
>
>
> > dpdt= p1 - p0
>
> > dudt_mixed = u1 - u0
>
> > #dudt = u1test - u0test
>
> When I wanted to do operation on u1 and u0, I received this error.(I
> didn't recieve any error when I did same thing for p1 and p0)
>
> > TypeError: unsupported operand type(s) for -: 'list' and 'list'
>
> But If I do same operation on variable which are defined based on ordianry
> element, I don't receive such error.
>
> Cheers,
The problem is that subtraction is not defined for Python lists. A
vector in FFC is represented as a Python list of scalars so when you
do u1 - u0, Python does not know what to do.
I should probably use Numeric.array instead of list. I'll add this to
the TODO list and get to it as soon as I can (or someone send me
patch).
In the meantime, you can do
dudt_mixed = [u1[i] - u0[i] for i in range(len(u1))]
or
dudt_mixed = list(array(u1) - array(u0))
/Anders
References