ffc team mailing list archive
-
ffc team
-
Mailing list archive
-
Message #01871
Re: Error accessing vectors via indices in mixed elements
On Fri, Oct 10, 2008 at 01:27:06AM +0200, Michael Brandl wrote:
> Hi,
>
> thanks to everybody for the help, it works fine with the
> "range"-statement. This will be a little less manageable when treating
> larger expressions with several terms that are indexed in different
> ways, though, so I am looking forward to the mentioned fix in UFL.
>
> However, since I am new to using Dolfin: Is FFC already using UFL?
No.
> Is it reasonable for me to expect a fix to this problem within the
> next weeks, or should I focus on getting my fcc files to work with
> "range"-statements?
No, that's not reasonable... :-) It will take a while longer.
--
Anders
> Thank you, and thanks for the corrections in the manual,
>
> /Michael Brandl
>
>
>
> Anders Logg wrote:
> > On Wed, Oct 08, 2008 at 11:58:23PM +0200, Michael Brandl wrote:
> >> 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!
> >
> > This is expected. FFC handles mixed elements like the one above by
> > first creating a vector-valued element that holds all components of
> > the system. In this case a vector-valued element with three components
> > is created.
> >
> > Then TrialFunctions() etc creates a basis function in this space (with
> > three components) and returns components of this basis function split
> > into the parts that make up the element:
> >
> > w = TrialFunction(TH)
> > u = [w[0], w[1]]
> > p = w[2]
> >
> > So u is just a Python list and it does not know how to handle i which
> > is an FFC object of class Index.
> >
> > This will be fixed in UFL as already noted by Martin.
> >
> >> 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
> >
> > Thanks for reporting this. I see that Kristian has already updated the
> > manual.
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > FFC-dev mailing list
> > FFC-dev@xxxxxxxxxx
> > http://www.fenics.org/mailman/listinfo/ffc-dev
>
> _______________________________________________
> FFC-dev mailing list
> FFC-dev@xxxxxxxxxx
> http://www.fenics.org/mailman/listinfo/ffc-dev
Attachment:
signature.asc
Description: Digital signature
References