← Back to team overview

ffc team mailing list archive

Error accessing vectors via indices in mixed elements

 

Hi,

I am new to this list and using ffc for my bachelor thesis.

Hopefully I am not asking something stupid which has already been asked; I tried to look through FFC-dev's archieves, but didn't find an answer.

What I want to do is using a mixed element (with a vector element and a finite element), but then to access the single components of a test or trial function defined on the vector element.

A concrete example would be this modification of the "Mixed formulation of Stokes" from the documentation:

P2 = VectorElement("Lagrange", "triangle", 2)
P1 = FiniteElement("Lagrange", "triangle", 1)
TH = MixedElement([P2, P1])
(v, q) = TestFunctions(TH)
(u, p) = TrialFunctions(TH)
f = Function(P2)
a = (dot(grad(v), grad(u)) - div(v)*p + q*div(u))*dx
L = (v[i] * f[i])*dx

where I only changed the last line (from being "L = dot(v, f) * dx" into its componentwise computation).

I get the following error:
--------
Preprocessing form file: Test.form --> Test.py

Traceback (most recent call last):
  File "/usr/bin/ffc", line 180, in ?
    sys.exit(main(sys.argv[1:]))
  File "/usr/bin/ffc", line 107, in main
    execfile(outname, ns)
  File "Test.py", line 27, in ?
    L = (v[i] * f[i])*dx
TypeError: list indices must be integers
-----

I am afraid that I am not good enough in Python to find a solution to that, therefore I would appreciate any kind of help very much.

Thank you!


By the way, while going through this example (Mixed formulation of Stokes)from the documentation I found some minor errors there:
It should be
"P2 = VectorElement("Lagrange", "triangle", 2)"
instead of
"P2 = FiniteElement("Vector Lagrange", "triangle", 2)",
"a = (dot(grad(v), grad(u)) - div(v)*p + q*div(u))*dx"
instead of
"a = (dot(grad(v), grad(u)) - div(v)*P + q*div(u))*dx";

and finally the sentence about the example file with Heat.form seems to be misplaced; I didn't manage to find this example there.

Thank you very much,

yours sincerely,

Michael Brandl


Follow ups