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()