Too many values to unpack error due to discontinuous trace spaces

The following is the minimal code of HDG method for Stokes equation where i am having discontinuous trace spaces (for facets) for both velocity and pressure variables. I am getting ‘‘too many values to unpack error’’ for these trace spaces. But if i have conforming trace spaces, then there is no such problem. Is there any alternative way possible to define the discontinuous facets spaces in Fenics ?.What is the reason for getting this error and how to correct this.

Thanks Alot.

Mesh

mesh = UnitSquareMesh(8,8)
k = 1 # degree of polynomials

Function Spaces

U = VectorElement(‘DG’, mesh.ufl_cell(), k) # vector element on K of polynomials of degree k
P = FiniteElement(‘DG’, mesh.ufl_cell(), k-1) # scalar element on K of polynomials of degree k
R = FiniteElement(‘Real’, mesh.ufl_cell(), 0) # scalar element on K of polynomials of degree k

Trace spaces for velocity and pressure

T_U = VectorElement(‘Discontinuous Lagrange Trace’, mesh.ufl_cell(), k)
T_P = FiniteElement(‘Discontinuous Lagrange Trace’, mesh.ufl_cell(), k)

Mixed_element = MixedElement([U,P,R,T_U,T_P])
W = FunctionSpace(mesh, Mixed_element) # mixed element space

Boundary condition

def boundary(x, on_boundary):
return on_boundary

bc = [DirichletBC(W.sub(0),(‘0’,‘0’),boundary), DirichletBC(W.sub(3),(‘0’,‘0’),boundary)]

x = SpatialCoordinate(mesh)
dx = Measure(“dx”, domain=mesh)

Parameters

nu = 1 # viscosity coefficient
alpha = 4 * k * k # penalty
gamma = alpha * nu
f = Expression((‘1’,‘1’),degree=0) # source function
n = FacetNormal(mesh)
h = CellDiameter(mesh)

Test / trial functions

y, p, c, yt, pt, we = [Function(W) for _ in range(6)]
y,p,c,yt,pt = split(we)
(v1,v2,d,vt,vp) = TestFunctions(W)

HDG scheme formulation

F1 = nu * inner(grad(y),grad(v1)) * dx + 2 * gamma/avg(h) * avg(dot(y-yt,v1-vt)) * dS + gamma/h * dot(y,v1) * ds - 2 * nu * avg(dot(y-yt,grad(v1) * n)) * dS - nu * dot(y,grad(v1) * n) * ds - 2 * nu * avg(dot(v1-vt,grad(y) * n)) * dS - nu * dot(v1,grad(y) * n) * ds # diffusion term

F2 = - p * div(v1) * dx + 2 * avg(dot(v1,n) * pt) * dS + dot(v1,n) * pt * ds # pressure term

F3 = v2 * div(y) * dx - 2 * avg(dot(y,n) * vp) * dS - dot(y,n) * vp * ds # divergence zero conditon

F4 = - p * d * dx - c * v2 * dx # presssure mean-zero condition
L = dot(f,v1) * dx

computing solution

F = F1 + F2 + F3 + F4 - L
solve(F == 0, we, bc, solver_parameters = {‘newton_solver’: {‘linear_solver’: ‘mumps’, ‘maximum_iterations’: 50}})

y_h , p_h , c_h, yt_h, pt_h = we.split()

Hello,

I’m not sure where you have your error ? is it the very last line ? If so, try to use ‘print(len(we.split()))’, just to check if you really have 5 outputs

@pierremrtt Yeah it gives 5 outputs. Error is in the solver line and specifically it gives the following error:
Calling FFC just-in-time (JIT) compiler, this may take some time.
Traceback (most recent call last):
solve(F == 0, we, bc, solver_parameters = {‘newton_solver’: {‘linear_solver’: ‘mumps’, ‘maximum_iterations’: 50}})
nonzerovals, = element.tabulate(order, new_points).values()
ValueError: too many values to unpack (expected 1)

It really looks like an error I had this week… I did not use MixedElement, but the idea remains the same. In my problem I use a mesh and a submesh. And if I create 2 different Measures such as :

ds = Measure("ds", domain=mesh, subdomain_data=mesh_bc_tags)
dx1 = Measure("dx", domain=submesh)

And the I use both of them in the same form:

dq  = inner(grad(q), n) # dq/dn = grad(q) * n
e0  = inner(dq, u)*ds(3)
e1  = inner(q, u)*dx1 # The submesh is exactly the boundary tagged with the number 3

a = form(e0 + e1)

Then I got the same error as you had. Basically I would say when Measures are mixed, the compiler dislike it… I just used ds(3) everywhere to solve it. In your case, as you use MixedElement and you use some dS, some ds and some dx, it might be the same problem…

It’s a bit confused because you do not have my whole code (2k lines…), but I’m pretty sure that people will help you more Monday !