Hello,
In my geometry I have a cylinder embedded in a cube. I also have a plane cutting these cylinder in the transverse direction. I would like to give different names for the surfaces in the plane (surface inside the cylinder and surface outside the cylinder)
from ngsolve import *
import netgen.gui
from netgen.csg import *
d_box = 1
r_cyl = 0.3
cube = OrthoBrick(Pnt(-d_box,-d_box,-d_box),Pnt(d_box,d_box,d_box)).bc('outer')
mid = Plane(Pnt(0,0,0), Vec(0,0,1)).bc('plane')
infcyl = Cylinder(Pnt(0,0,0), Pnt(0,0,1), r_cyl).bc('cyl')
corefront = ((cube*infcyl)-mid).mat('core')
coreback = ((cube*infcyl)*mid).mat('core')
cladfront = ((cube-infcyl)-mid).mat('clad')
cladback = ((cube-infcyl)*mid).mat('clad')
geo = CSGeometry()
geo.Add(corefront)
geo.Add(coreback,bcmod=[(corefront,'core_2d')])
geo.Add(cladfront)
geo.Add(cladback,bcmod=[(cladfront,'clad_2d')])
mesh = Mesh(geo.GenerateMesh(maxh=0.1))
print(mesh.GetMaterials())
print(mesh.GetBoundaries())
cf = mesh.BoundaryCF({'core_2d':1,'clad_2d':2,'cyl':3,'outer':4},default=-1)
g = GridFunction(H1(mesh),name='bndry')
g.Set(cf, definedon=~mesh.Boundaries(''))
Draw(g)
That is my resulting code. If I change the lines in which I add coreback and cladback by removing the ,bcmod=…, I do get what I expected: cylinder walls are cyl, plane is plane and the outer boundary is outer. However, with the code as is, bcmod apparently changes all the boundaries of the volume being inserted, and not only the ones between the other volume in the bcmod call.
I would appreciate if you could point me in the direction of understanding what am I missing here.
All the best,
Francisco