← Back to team overview

ufl team mailing list archive

Re: [FFC-dev] Problems with lhs/rhs and mixed elements

 

Unless my memory fails me, expand_indices converts

v[i]*u[i] -> v[0]*u[0] + v[1]*u[1]
etc.

I don't have time to understand and fix the issue.
Removing the experimental feature "something scalar"
as I suggested should lead to a better error message.

Martin



On Wed, Sep 9, 2009 at 7:52 PM, Anders Logg<logg@xxxxxxxxx> wrote:
> It seemed to be a simple fix and it worked. The resulting code was
> also the same (except for a minor difference in the quadrature code).
>
> Which is the proper way to fix it?
>
> --
> Anders
>
>
> On Wed, Sep 09, 2009 at 07:28:26PM +0200, Martin Sandve Alnæs wrote:
>> Calling expand_indices is not a good idea.
>> This removes all free indices from the expression,
>> leaving the compiler with less information.
>> This function is intended for use in the compilation
>> step, _if_ it is needed by the form compiler.
>>
>> Martin
>>
>>
>>
>> On Tue, Sep 1, 2009 at 10:59 AM, Anders Logg<logg@xxxxxxxxx> wrote:
>> > Should be fixed now. I added a missing expand_indices.
>> >
>> >
>> > On Wed, Aug 12, 2009 at 03:08:24PM +0200, Harish Narayanan wrote:
>> >> I'm running into an error when I attempt to use lhs() and rhs() with
>> >> mixed elements. I have attached two small .ufl files, one for the
>> >> Poisson equation (which works) and the other for the Stokes equations
>> >> (which fails with the following error).
>> >>
>> >> Preprocessing form file: stokes-broken.ufl --> stokes-broken.py
>> >>
>> >> Wrapping non-UFL expression. This is experimental and will likely break
>> >> many algorithms!
>> >> Expecting Python scalar, not
>> >> set([BasisFunction(MixedElement(*[VectorElement('Lagrange',
>> >> Cell('triangle', 1, Space(2)), 2, 2), FiniteElement('Lagrange',
>> >> Cell('triangle', 1, Space(2)), 1)], **{'value_shape': (3,) }), -2)]).
>> >>
>> >>
>> >>
>> >> FAILURE in reuse_if_possible:
>> >> type(o) = <class 'ufl.tensors.ListTensor'>
>> >> operands =
>> >>
>> >> (Indexed(BasisFunction(MixedElement(*[VectorElement('Lagrange',
>> >> Cell('triangle', 1, Space(2)), 2, 2), FiniteElement('Lagrange',
>> >> Cell('triangle', 1, Space(2)), 1)], **{'value_shape': (3,) }), -2),
>> >> MultiIndex((FixedIndex(0),), {FixedIndex(0): 3})),
>> >> set([BasisFunction(MixedElement(*[VectorElement('Lagrange',
>> >> Cell('triangle', 1, Space(2)), 2, 2), FiniteElement('Lagrange',
>> >> Cell('triangle', 1, Space(2)), 1)], **{'value_shape': (3,) }), -2)]))
>> >>
>> >> (Indexed(BasisFunction(MixedElement(*[VectorElement('Lagrange',
>> >> Cell('triangle', 1, Space(2)), 2, 2), FiniteElement('Lagrange',
>> >> Cell('triangle', 1, Space(2)), 1)], **{'value_shape': (3,) }), -2),
>> >> MultiIndex((FixedIndex(1),), {FixedIndex(1): 3})),
>> >> set([BasisFunction(MixedElement(*[VectorElement('Lagrange',
>> >> Cell('triangle', 1, Space(2)), 2, 2), FiniteElement('Lagrange',
>> >> Cell('triangle', 1, Space(2)), 1)], **{'value_shape': (3,) }), -2)]))
>> >>
>> >> stack =
>> >> ////////////////////////////////////////////////////////////////////////////////
>> >> Visit stack in Transformer:
>> >> <class 'ufl.algebra.Sum'> ; -1 * (sum_{i_8} ((w_0)[i_8]) * (([[
>> >> (v_{-2})[0], (v_
>> >> <class 'ufl.algebra.Product'> ; -1 * (sum_{i_8} ((w_0)[i_8]) * (([[
>> >> (v_{-2})[0],
>> >> <class 'ufl.indexsum.IndexSum'> ; sum_{i_8} ((w_0)[i_8]) * (([[
>> >> (v_{-2})[0], (v_
>> >> <class 'ufl.algebra.Product'> ; ((w_0)[i_8]) * (([[ (v_{-2})[0],
>> >> (v_{-2})[1] ]])
>> >> <class 'ufl.indexed.Indexed'> ; ([[ (v_{-2})[0], (v_{-2})[1] ]])[i_8]
>> >> <class 'ufl.tensors.ListTensor'> ; [[ (v_{-2})[0], (v_{-2})[1] ]]
>> >> \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
>> >>
>> >>
>> >> *** FFC: Expecting Python scalar, not
>> >> set([BasisFunction(MixedElement(*[VectorElement('Lagrange',
>> >> Cell('triangle', 1, Space(2)), 2, 2), FiniteElement('Lagrange',
>> >> Cell('triangle', 1, Space(2)), 1)], **{'value_shape': (3,) }), -2)]).
>> >> *** FFC: To get more information about this error, rerun FFC with --debug.
>> >>
>> >> Harish
>> >
>> >> cell = triangle
>> >> vector = VectorElement("Lagrange", cell, 2)
>> >> scalar = FiniteElement("Lagrange", cell, 1)
>> >> system = vector + scalar
>> >>
>> >> v = TestFunction(vector)
>> >> u = TrialFunction(vector)
>> >>
>> >> f = Function(vector)
>> >>
>> >> F = (inner(grad(v), grad(u)) - inner(v, f))*dx
>> >>
>> >> a = lhs(F)
>> >> L = rhs(F)
>> >>
>> >
>> >> cell = triangle
>> >> vector = VectorElement("Lagrange", cell, 2)
>> >> scalar = FiniteElement("Lagrange", cell, 1)
>> >> system = vector + scalar
>> >>
>> >> (v, q) = TestFunctions(system)
>> >> (u, p) = TrialFunctions(system)
>> >>
>> >> f = Function(vector)
>> >>
>> >> F = (inner(grad(v), grad(u)) - div(v)*p + q*div(u))*dx - inner(v, f)*dx
>> >>
>> >> a = lhs(F)
>> >> L = rhs(F)
>> >>
>> >
>> >> _______________________________________________
>> >> UFL-dev mailing list
>> >> UFL-dev@xxxxxxxxxx
>> >> http://fenics.org/mailman/listinfo/ufl-dev
>> >
>> >
>> > -----BEGIN PGP SIGNATURE-----
>> > Version: GnuPG v1.4.9 (GNU/Linux)
>> >
>> > iEYEARECAAYFAkqc4n4ACgkQTuwUCDsYZdE/6gCfXreDc/Oe97fHvZqTR3zl4QLR
>> > h9oAn3CQ12bh5r2y0uvDUMjI2otoGNN0
>> > =mQ3f
>> > -----END PGP SIGNATURE-----
>> >
>> > _______________________________________________
>> > UFL-dev mailing list
>> > UFL-dev@xxxxxxxxxx
>> > http://fenics.org/mailman/listinfo/ufl-dev
>> >
>> >
>> _______________________________________________
>> FFC-dev mailing list
>> FFC-dev@xxxxxxxxxx
>> http://www.fenics.org/mailman/listinfo/ffc-dev
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iEYEARECAAYFAkqn62QACgkQTuwUCDsYZdGZpwCfS1yVc0iBTmuD+e2Oyf6FlyBg
> PGAAn0mAnYA7ZAtadnXHo7U7yFaQXGPx
> =E2ve
> -----END PGP SIGNATURE-----
>
>


References