There are usually two ways of locating degrees of freedom for setting boundary conditions:
- geometrical (Check if a dof coordinate fulfills a certain condition)
- topological (check if a facet fullfill a certain condition, then find all degrees of freedom related to the facet).
A big difference between CG and DG spaces is that DG degrees of freedom has no relation to global facets (as they only relate to a given cell).
To set such conditions for meshes from Gmsh, i suggest using a MeshFunction (imported through a mesh value collection) as described in for instance: Need help converting GMSH to FEniCS - #17 by dokken