How to set two or more different boundary conditions in HDG

Dear all,

Recently, I have applied the HDG method to fluid problems. However, I cannot sure the following methods to set two or more different boundary conditions is correct. Please help revise.

V = L2(mesh, order=k)
M = FacetFESpace(mesh, order=k, dirichlet="left|bottom|right|top")
fes = FESpace([V,M])
gfu = GridFunction(fes)
a = BilinearForm(fes, condense=True)
l = LinearForm(fes)


gfu.components[1].Set(2, definedon=mesh.Boundaries("left"))
gfu.components[1].Set(1, definedon=mesh.Boundaries("bottom"))
gfu.components[1].Set(-1, definedon=mesh.Boundaries("right"))
# add Dirichlet BC = -a.mat * gfu.vec


Di Yang

You need to set all boundary conditions at once, since the .Set method sets it to 0 everywhere else:

gfu.components[1].Set(mesh.BoundaryCF({ "left" : 2, "bottom" : 1, "right" : -1}), definedon=mesh.Boundaries("left|bottom|right"))


Dear Christopher,

Thank you for your revision. This helps me very much.


Di Yang