← Back to team overview

ffc team mailing list archive

Re: bug in MixedElement.tabulate()

 

The error was related to the following type of code:

table_shape = (self.space_dimension(), self.num_components(), len(points))
zeros = numpy.zeros(table_shape)
for element in self._elements:
 table = element.tabulate(order, points)
 for dtuple in table.keys():
     if not dtuple in mixed_table:
         mixed_table[dtuple] = zeros
             # Insert non-zero values
             if (crange[1] - crange[0]) > 1:
                 mixed_table[dtuple][irange[0]:irange[1], crange[0]:crange[1]] = table[dtuple]

This would cause the zeros array to be update every time we assigned to it because the mixed_element[dtuple] holds a reference
to zeros, not the values.

Changing the line:
         mixed_table[dtuple] = zeros
to

         mixed_table[dtuple] = numpy.zeros(table_shape)

fixed the problem.

Kristian

2010/1/26  <k.b.oelgaard@xxxxxxxxx>:
MixedElement.tabulate() produces some mysterious results. Try the following
in a ufl file:

from ffc.fiatinterface import create_element
elem = FiniteElement("Lagrange", triangle, 1)
print create_element(elem).tabulate(1, [(0.333, 0.333)])

This gives:

{(0, 1): array([[-1.0],
     [0.0],
     [1.0]], dtype=object), (1, 0): array([[-1.0],
     [1.0],
     [0.0]], dtype=object), (0, 0): array([[0.334],
     [0.333],
     [0.333]], dtype=object)}

which is correct.

For a vector (mixed) element

elem = VectorElement("Lagrange", triangle, 1)

the result is

{(0, 1): array([[[ 0.334],                                 [ 0.   ]],      
                           
     [[ 0.333],
      [ 0.   ]],

     [[ 0.333],
      [ 0.   ]],

     [[ 0.   ],
      [ 0.334]],

     [[ 0.   ],
      [ 0.333]],

     [[ 0.   ],
      [ 0.333]]]), (1, 0): array([[[ 0.334],
      [ 0.   ]],                            
     [[ 0.333],
      [ 0.   ]],

     [[ 0.333],
      [ 0.   ]],

     [[ 0.   ],
      [ 0.334]],

     [[ 0.   ],
      [ 0.333]],

     [[ 0.   ],
      [ 0.333]]]), (0, 0): array([[[ 0.334],
      [ 0.   ]],

     [[ 0.333],
      [ 0.   ]],

     [[ 0.333],
      [ 0.   ]],

     [[ 0.   ],
      [ 0.334]],

     [[ 0.   ],
      [ 0.333]],

     [[ 0.   ],
      [ 0.333]]])}

which is very wrong. I had a look at the code in MixedElement.tabulate(),
but couldn't figure out what was going on.

Kristian



Attachment: signature.asc
Description: OpenPGP digital signature


Follow ups

References