Forum Message



We have moved the forum to . This is an archived version of the topics until 05/05/23. All the topics were moved to the new forum and conversations can be continued there. This forum is just kept as legacy to not invalidate old links. If you want to continue a conversation just look for the topic in the new forum.


The forum is in read only mode.

Boundary Finite Element Spaces

2 years 1 month ago #4143 by walker_tr9
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.

2 years 1 month ago #4144 by schruste
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("...")).

2 years 1 month ago #4145 by walker_tr9
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.
2 years 1 month ago #4146 by walker_tr9
Ok, I found this explanation, which definitely helps!
2 years 1 month ago #4150 by walker_tr9
Just to confirm, I did get this figured out.
BTW: ngsolve does "complain" about


not being documented. I suppose it is safe.
Time to create page: 0.120 seconds