Solving multiple equations in a mixed formulation in dolfinx

Hey,

I need to solve a set of 3 scalar equations and 1 vector equation using a mixed formulation in a monolithic solver. My approach works fine if I have one scalar equation and one vector equation (basically following the tutorials). I am using dolfinx version ‘0.6.0’, and extending the tutorial from the Poisson problem using a mixed formulation to my case through:

msh = create_unit_square(MPI.COMM_WORLD, 96, 96, CellType.quadrilateral)
U1 = ufl.FiniteElement("Lagrange", msh.ufl_cell(), 2)
R1 = ufl.FiniteElement("Lagrange", msh.ufl_cell(), 1)
ME = FunctionSpace(msh, R1 * U1 * R1 * R1)

Next, I define the trial and test functions as

u, r, th, phi = ufl.TrialFunctions(ME)
w, q, et, psi = ufl.TestFunctions(ME)

However I get the error:

ValueError: not enough values to unpack (expected 4, got 2)

Is this the appropriate approach to use a mixed formulation for a system of multiple equations? My full problem consists on the solution of 8 coupled equations, so I need to define a clear rationale for the implementation. Maybe the mixed form is not suitable for these problems? Are there any references I can learn from?

Thank you very much in advance.

I would recommend using the syntax:

U1 = ufl.FiniteElement("Lagrange", msh.ufl_cell(), 2)
R1 = ufl.FiniteElement("Lagrange", msh.ufl_cell(), 1)
ME = FunctionSpace(msh, ufl.MixedElement([R1, U1,  R1, R1]))

as multiplication of elements is confusing and misleading (as shown in your example), and is deprecated: Remove `*` overload in `FiniteElementBase` for creating `MixedElement` · Issue #60 · FEniCS/ufl · GitHub