I have a simple question that I have been struggling with for the past two days. I want to solve a simple laplace equation with non-homogenous boundary using both DG and HDG scheme. I got the proble working with the standard FEM spaces but I dont understand how to set the dirichlet boundary conditions in DG and HDG.

The DG code is attached. It would be great if you can point out my mistake in this simple code.

your problem was in the way you attempted to set the boundary condition:

Anything added to a BilinearForm needs to contain a trial and a test function. i.e., the uin * v is only a linear form and needs to be added to the right hand side.

Boundary and internal facet terms need to be treated slightly differently (as there is no .Other()), or see how to: DG

All in all, this is how you need to define the Bilinear and LinearForms: