Hello everyone,

I try to use the HDG (or MCS) method to solve the Stokes equations in velocity gradient-velocity-pressure formulation, where non-homogeneous Dirichlet boundary condition is imposed over the whole boundary (say the domain is unit square), and the codes work well for homogeneous Dirichlet boundary condition. However, the solution is not correct for non-homogeneous Dirichlet boundary conditions. I attach the following codes that address the enforcement of non-homogeneous Dirichlet boundary conditions.

def tang(vec):

return vec - (vec*n)*n

uexact = CoefficientFunction((cos(x*pi) sin(ypi),-cos(y*pi)

*sin(x*pi)))

gfu = GridFunction(fes)

#impose non-homogeneous Dirichlet Boundary condition

gfu.components[4].Set((uexact*n)*n,BND). #diri for velocity

gfu.components[5].Set(tang(uexact),BND)#diri for tangential facet

r = f.vec -a.mat * gfu.vec

gfu.vec.data = a.mat.Inverse(fes.FreeDofs()) * r

I do not know which part is wrong, anyone can help? Many thanks.

Best regards,

Lina