Subject: Re: [Ffc] [Branch ~ffc-core/ffc/dev] Rev 1506: Bug fix in MixedElement. Quite a few more cases compile now.

From: Kristian Oelgaard <[email-masked]>
Date: Thu, 21 Jan 2010 17:41:38 +0100 (CET)

Did you rearrange some axis in the table the element.tabulate() returns for mixed elements?
It looks like it is now: (derivative tuples, components) instead of (components, derivative tuples)

Kristian

2010/1/21  <[email-masked]>:
> ------------------------------------------------------------
> revno: 1506
> committer: Anders Logg <[email-masked]>
> branch nick: ffc-dev
> timestamp: Thu 2010-01-21 17:15:59 +0100
> message:
>  Bug fix in MixedElement. Quite a few more cases compile now.
>  Needed to comment out evaluate_basis_derivatives to avoid error
>  message when compiling Stokes.ufl.
> modified:
>  ffc/analysis.py
>  ffc/codegeneration.py
>  ffc/mixedelement.py
>
>
> --
> lp:~ffc-core/ffc/dev
> https://code.launchpad.net/~ffc-core/ffc/dev
>
> You are subscribed to branch lp:~ffc-core/ffc/dev.
> To unsubscribe from this branch go to https://code.launchpad.net/~ffc-core/ffc/dev/+edit-subscription.
>
> === modified file 'ffc/analysis.py'
> --- ffc/analysis.py     2010-01-21 10:25:42 +0000
> +++ ffc/analysis.py     2010-01-21 16:15:59 +0000
> @@ -12,7 +12,7 @@
>  __copyright__ = "Copyright (C) 2007-2010 " + __author__
>  __license__  = "GNU GPL version 3 or any later version"
>
> -# Last changed: 2009-01-21
> +# Last changed: 2010-01-21
>
>  # UFL modules
>  from ufl.common import istr
> @@ -44,7 +44,7 @@
>     unique_elements = []
>     element_map = {}
>     for (form, form_data) in form_and_data:
> -        for element in form_data.unique_elements + form_data.unique_sub_elements:
> +        for element in form_data.unique_sub_elements:
>             if not element in element_map:
>                 element_map[element] = len(unique_elements)
>                 unique_elements.append(element)
> @@ -58,6 +58,8 @@
>     # Empty form and data
>     form_and_data = []
>
> +    # FIXME: This looks unecessarily complex
> +
>     # Extract unique elements
>     unique_elements = []
>     element_map = {}
>
> === modified file 'ffc/codegeneration.py'
> --- ffc/codegeneration.py       2010-01-20 21:27:24 +0000
> +++ ffc/codegeneration.py       2010-01-21 16:15:59 +0000
> @@ -11,7 +11,7 @@
>  __copyright__ = "Copyright (C) 2009 " + __author__
>  __license__  = "GNU GPL version 3 or any later version"
>
> -# Last changed: 2010-01-19
> +# Last changed: 2010-01-21
>
>  # FFC modules
>  from ffc.log import info, begin, end, debug_code
> @@ -83,7 +83,7 @@
>     code["value_dimension"] = _value_dimension(ir["value_dimension"])
>     code["evaluate_basis"] = _evaluate_basis(ir["evaluate_basis"])
>     code["evaluate_basis_all"] = _evaluate_basis_all(ir["evaluate_basis"])
> -    code["evaluate_basis_derivatives"] = _evaluate_basis_derivatives(ir["evaluate_basis"])
> +    code["evaluate_basis_derivatives"] = not_implemented #_evaluate_basis_derivatives(ir["evaluate_basis"])
>     code["evaluate_basis_derivatives_all"] = _evaluate_basis_derivatives_all(ir["evaluate_basis"])
>     code["evaluate_dof"] = evaluate_dof(ir["evaluate_dof"])
>     code["evaluate_dofs"] = evaluate_dofs(ir["evaluate_dofs"])
>
> === modified file 'ffc/mixedelement.py'
> --- ffc/mixedelement.py 2010-01-14 20:01:40 +0000
> +++ ffc/mixedelement.py 2010-01-21 16:15:59 +0000
> @@ -6,7 +6,7 @@
>  # Modified by Marie E. Rognes ([email-masked]) 2007--2010
>  # Modified by Kristian B. Oelgaard 2009
>
> -# Last changed: 2010-01-14
> +# Last changed: 2010-01-21
>
>  # Python modules
>  import numpy
> @@ -70,12 +70,17 @@
>         table_shape = (self.space_dimension(), self.num_components(), len(points))
>         zeros = numpy.zeros(table_shape)
>
> +        print "shape =", table_shape
> +
>         # Iterate over elements and fill in non-zero values
>         irange = (0, 0)
>         crange = (0, 0)
>         mixed_table = {}
>         for element in self._elements:
>
> +            print element
> +            print order
> +
>             # Tabulate element
>             table = element.tabulate(order, points)
>
> @@ -83,15 +88,23 @@
>             irange = (irange[1], irange[1] + element.space_dimension())
>             crange = (crange[1], crange[1] + _num_components(element))
>
> +            print "irange =", irange
> +            print "crange =", crange
> +
>             # Insert table into mixed table
>             for dtuple in table.keys():
>
> +                print "shape  =", numpy.shape(table[dtuple])
> +
>                 # Insert zeros if necessary (should only happen first time)
>                 if not dtuple in mixed_table:
>                     mixed_table[dtuple] = zeros
>
>                 # Insert non-zero values
> -                mixed_table[dtuple][irange[0]:irange[1], crange[0]:crange[1]] = table[dtuple]
> +                if (crange[1] - crange[0]) > 1:
> +                    mixed_table[dtuple][irange[0]:irange[1], crange[0]:crange[1]] = table[dtuple]
> +                else:
> +                    mixed_table[dtuple][irange[0]:irange[1], crange[0]] = table[dtuple]
>
>         return mixed_table
>
>
>
>

---

From: Anders Logg <[email-masked]>
Date: Thu, 21 Jan 2010 17:56:24 +0100

> It looks like it is now: (derivative tuples, components) instead of (components, derivative tuples)

The table should be the same as the table returned by FIAT:

  D^a v_i[j](x_k) = table[a][i][j][k]

where a is the derivative tuple.

Is this not correct?

--
Anders

> _______________________________________________
> Mailing list: https://launchpad.net/~ffc
> Post to     : [email-masked]
> Unsubscribe : https://launchpad.net/~ffc
> More help   : https://help.launchpad.net/ListHelp

---

From: Kristian Oelgaard <[email-masked]>
Date: Thu, 21 Jan 2010 18:17:04 +0100 (CET)

> where a is the derivative tuple.

What is correct depends on how we use the tables. If it stays the way it is now I'll just modify my code to loop derivatives before components. I just wanted to be sure that it doesn't change in five minutes again :)

Kristian

> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iEYEARECAAYFAktYhzgACgkQTuwUCDsYZdHbBQCfS2kyzmA8+tCVMdwl1DjQkQdY
> 2fQAn3b9NcQqh9dixN24Iu5GyTEdb1a/
> =w9OO
> -----END PGP SIGNATURE-----
>
>

---

From: Anders Logg <[email-masked]>
Date: Thu, 21 Jan 2010 18:40:52 +0100

> What is correct depends on how we use the tables. If it stays the way it is now I'll just modify my code to loop derivatives before components. I just wanted to be sure that it doesn't change in fi…

It won't. I never want to touch it again. :-)

--
Anders