← Back to team overview

ufl team mailing list archive

Re: Problems with lhs/rhs and mixed elements

 

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.
>
> --
> Anders
>
> 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
>
>


Follow ups

References