# Boundaries of open surfaces

Hi,

I want to do a boundary integral for an open surface, namely a half-cylinder, in order to implement boundary conditions in the Nitsche fashion. Parts of my code now look like

geo = CSGeometry()

``````r = 1/pi
cyl = Cylinder(Pnt(0,0,0), Pnt(1,0,0),r)
top = Plane(Pnt(0,0,0),Vec(0,0,-1))
left = Plane(Pnt(0,0,0),Vec(-1,0,0))
right =Plane(Pnt(1,0,0),Vec(1,0,0))

shell = (cyl * left*right*top)

################

mesh = Mesh(geo.GenerateMesh(maxh=0.3))
bnd_D = mesh.Boundaries("dir")
``````

in order to define the mesh and the boundary. I then perform the integral using e.g.

a += SymbolicBFI(InnerProduct(p*mu, v.Trace()), BND, element_boundary = True, definedon = bnd_D)

However, it seems that NGSolve skips this integral. Does anyone know what I am doing wrong?

Best regards,

Alvar

Hi Alvar,

with

``bnd_D = mesh.Boundaries("dir")``

you only access boundaries labeled with “dir”. But in your presented code no such label appears.

With e.g.

``cyl = Cylinder(Pnt(0,0,0), Pnt(1,0,0),r).bc("dir")``

you can label the surface.

Best,
Michael

Hi Michael,

Thank you for your answer. I have now rewritten the code to be
r = 1/pi
cyl = Cylinder(Pnt(0,0,0), Pnt(1,0,0),r)
top = Plane(Pnt(0,0,0),Vec(0,0,-1)).bc(“dir”)
left = Plane(Pnt(0,0,0),Vec(-1,0,0)).bc(“dir”)
right =Plane(Pnt(1,0,0),Vec(1,0,0)).bc(“dir”)

``````shell = (cyl * left*right*top)

################

ngmesh = geo.GenerateMesh(maxh=0.3)

ngmesh.SetCD2Name(1,"wall")
ngmesh.SetCD2Name(2,"wall")
ngmesh.SetCD2Name(3,"outflow")
ngmesh.SetCD2Name(4,"inflow")
mesh = Mesh(ngmesh)

bnd_D = mesh.Boundaries("inflow|outflow|wall")
``````

with one of the boundary integrals looking like

a += SymbolicBFI(-2InnerProduct(epsumu, v.Trace()), BND, element_boundary = True, definedon = bnd_D)

It still seems like the integral has no effect. Am I missing it completely? How do you do integrals on boundaries of a surfaces, i.e. with Co-dimension 2?

It is worth pointing out that v is in a SurfaceHDiv space and epsu is the symmetric gradient of such a vector. I also need to integrate vectors in SurfaceL2

Hi Alvar,

I somehow got confused with the boundaries and co-dimensional 2 boundaries. In NGSolve co-dimensional 2 boundaries are called BBoundaries and the surface is still a boundary.

In this tutorial you can find how to define BBoundaries without guessing the right index for SetCD2Name.

So to access only the BBoundaries the correct syntax is

``bnd_D = mesh.BBoundaries("inflow|outflow|wall")``

But, I’m afraid that your code

``a += SymbolicBFI(-2*InnerProduct(epsu*mu, v.Trace()), BND, element_boundary = True, definedon = bnd_D)``

won’t work. I guess it will throw an exception concerning the traces. Integrating over edges in three dimensions with a SurfaceHDiv space is not well defined as there is no unique normal vector.

In this example to perform integration over a BBoundary for hyb in SurfaceHDiv the following trick has been used

``bfA += Variation( -IfPos(x-L+1e-6, 1, 0)*(hyb*nel)*ds(element_boundary=True) )``

to loop over all edges with the surface information at hand for the (element)normal vector and being 1 only at the BBoundary.

I hope this helps.

Best,
Michael