This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

To specify more than two trial and test functions

0 votes

Hi,

How do I specify more than two trial and test functions in Fenics. Am new to Fenics.

For example I have U=(U,V), u=(u,v) are vectors functions and p1, p2 are scalar functions. So I choose 2 vector functions m, n and 2 scalar functions q,r for the variational formulation all in 2d and I tried

V1= VectorFunctionSpace(mesh, 'Lagrange', degree=2)
Q = FunctionSpace(mesh, 'Lagrange', degree=1)
VQ = V1 * Q

(U,u, p1,p2)= TrialFunctions(VQ)
(m,n,q,r) = TestFunctions(VQ)

But this is not working. Any hint is appreciated. Thanks

asked Nov 9, 2015 by Vivian FEniCS Novice (550 points)

Does it work if you replace VQ = V1 * Q with VQ = V1 * V1 * Q * Q ? All four trial- and testfunctions should be mapped to their respective Functionspace as defined in VQ that way.

Hi, No it doesn't work. It says

(U,u, p1,p2)= TrialFunctions(VQ)
VallueError: need more than 2 values to unpack

1 Answer

+1 vote
 
Best answer

Oh, probably V1 * V1 * Q * Q is interpreted as V1 * (V1 * (Q * Q)), hence always returning two values. You should replace that line by VQ = MixedFunctionSpace([V1, V1, Q, Q]) instead.

answered Nov 9, 2015 by maartent FEniCS User (3,910 points)
selected Nov 9, 2015 by Vivian

Thanks Maartent, That works!

...