I agree that splitting the function straight away is more efficient and I normally want to do that. But I am defining a function and thought it's easier to pass one field rather than two. What I tried was the following: V1 = FunctionSpace(mesh, "CG", 3) V2 = FunctionSpace(mesh, "BDM", 2) V3 = FunctionSpace(mesh, "DG", 1) Z = V1 * V2 * V3 # TEST/TRIAL FUNCTIONS Ztrial = TrialFunctions(Z) Ztest = TestFunctions(Z) a,b,c = split(Ztest) and I get the error copied below. Sorry if I am missing something obvious but I can say that if I define a,b,c = TestFunction(Z) that does work. Cheers, Francis --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-7-69c5a9f01474> in <module>() ----> 1 a,b,c = split(Ztest) /home/fpoulin/software/firedrake/src/ufl/ufl/split_functions.pyc in split(v) 64 65 # Special case: simple element, just return function in a tuple ---> 66 element = v.ufl_element() 67 if not isinstance(element, MixedElement): 68 assert end is None AttributeError: 'tuple' object has no attribute 'ufl_element' ------------------ Francis Poulin Associate Professor Department of Applied Mathematics University of Waterloo email: fpoulin@uwaterloo.ca Web: https://uwaterloo.ca/poulin-research-group/ Telephone: +1 519 888 4567 x32637 ________________________________________ From: firedrake-bounces@imperial.ac.uk [firedrake-bounces@imperial.ac.uk] on behalf of Lawrence Mitchell [lawrence.mitchell@imperial.ac.uk] Sent: Friday, March 31, 2017 10:46 AM To: firedrake@imperial.ac.uk Subject: Re: [firedrake] close to fixing my nonlinear QG solver
On 31 Mar 2017, at 15:40, Francis Poulin <fpoulin@uwaterloo.ca> wrote:
Thanks Lawrence.
That sounds very helpful. I update my firedrake and will give it a try.
I thought I understand the difference but I am a bit confused.
Suppose that Z = V1*V2*V3
If I define a trial or test function in Z, say and want to split it, I would have thought i used split(FunctionOnZ). But that does not go over well. What worked in the end is
(a,b,c) = FunctionOnZ
Is this a third way of splitting a function?
Can you show what you tried to do? The following works for me: mesh = ... V = FunctionSpace(mesh, "DG", 0) Q = FunctionSpace(mesh, "DG", 1) W = V*Q w = TestFunction(W) v, q = split(w) In fact, writing v, q = TestFunctions(W) is just a short hand for: v, q = split(TestFunction(W)) Lawrence _______________________________________________ firedrake mailing list firedrake@imperial.ac.uk https://mailman.ic.ac.uk/mailman/listinfo/firedrake