Boundary Finite Element Spaces

I’m having some trouble. I would like to have a finite element space defined on the boundary mesh of a bulk mesh. Fore example, piecewise linear on the boundary of a square. So I did this:

bdy_H1 = H1(mesh, order=1, definedon=“top|left|right|bottom”)

Is this right? If so, I now create a GridFunction:

bdy_u = GridFunction(bdy_H1, “bdy_func”)

Here I set it to 1, but it could be anything. In fact, bdy_u could end up being the solution of some boundary PDE.

Anyway, I now want to plot bdy_u. From what I have read, I have to create a bulk GridFunction, and somehow transfer the bdy_u values to the bulk GridFunction. But I don’t know how to do that.


Hi Shawn,

The Set(…) sets values on specified domains. If nothing is specified it will set on the whole volume mesh (where your GridFunction is not defined). You need to specify the part of the boundary you want to prescribe a function. If it’s on the whole boundary simply use .Set(…, BND) otherwise use .Set(…, mesh.Boundaries(“…”)).


Ok, so I do this:

mesh = Mesh (unit_square.GenerateMesh(maxh=0.02))

standard FE space

V = H1(mesh, order=1, dirichlet=[])

my boundary FE space

bdy_H1 = H1(mesh, order=1, definedon=“top|left|right|bottom”)
bdy_u = GridFunction(bdy_H1, “bdy_func”)

bdy_u_ext = GridFunction(V)
bdy_u_ext.Set(bdy_u, BND)

But the plot just shows zero everywhere.

If I made a CoefficientFunction defined to be 1 (on the boundary), then there is a way to plot that. But that is not an option. I need to be able to plot a finite element function that is only defined on the boundary.

Ok, I found this explanation, which definitely helps!

Just to confirm, I did get this figured out.
BTW: ngsolve does “complain” about


not being documented. I suppose it is safe.