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

Error: "Expecting equal argument rank terms among summands."

0 votes

I'm getting an error "Expecting equal argument rank terms among summands." when JIT comes across the following. This is the MWE that I was able to reproduce the error although if it is the global 'M'.

    from fenics import *

mesh = IntervalMesh(10, 0, 1)

Pi = VectorElement("Lagrange",mesh.ufl_cell(),1,dim=2)
PS = MixedElement([Pi,Pi])
V = FunctionSpace(mesh,PS)

U = Function(V)
u1,u2 = split(U) 

test_u1, test_u2 = TestFunctions(V)
dU = TrialFunction(V)

a = inner(u1,u1)*conditional(gt(1,0),u2[0],u2[0]) #error
#a = inner(u1,u1)*u2[0] # works

b = derivative(a,u1,test_u1)

F = b*dx

problem = NonlinearVariationalProblem(F, U, [], derivative(F, U, dU))

As far as I can tell, the error comes from the 'conditional' function.
Thanks!

asked Jun 16, 2017 by mwelland FEniCS User (8,410 points)

As a workaround, the following works:

a = conditional(gt(1,0),inner(u1,u1)*u2[0],inner(u1,u1)*u2[0])

but this is not very satisfactory.

...