You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I want to merge/combine some cylinders in netgen.csg, where 1 big cylinder is the domain to be investigated and two small cylinders are electrodes (voltage/current boundaries). I specify the bcs on the top surface of a cylinder primitive. However, the bc will be erroneous merged. Here is a minimal example that recreates this problem. Moreover, the material properties of the small cylinders (electrodes) are also merged, which can be seen in mesh.GetMaterials().
Can I preserve the bc and mat of the small shapes when using + in netgen.csg?
At line 78, if you comment this line p0[0] += 0.01, the bc="e1" will be removed, if uncomment this line, bc="e1" will be visible. The material properties of electrodes (which should be 'agcl') is gone, where only 'g0' is preserved.
importnumpyasnpfromnetgenimportcsgfromngsolve.compimportMeshdefcylinder(p0, p1, unit_vec, r, bc="bc"):
""" a pointed cylinder (numpy interface) """# generate CSG primitivescsg_p0=csg.Pnt(p0[0], p0[1], p0[2])
csg_p1=csg.Pnt(p1[0], p1[1], p1[2])
csg_vec=csg.Vec(unit_vec[0], unit_vec[1], unit_vec[2])
# generate cylinder shapebot=csg.Plane(csg_p0, -csg_vec)
top=csg.Plane(csg_p1, csg_vec)
cy_surface=csg.Cylinder(csg_p0, csg_p1, r)
# specify bc on toptop.bc(bc)
# geocy=top*cy_surface*botreturncydefunit_cylinder(h=1.0, r=0.5, bc="cyl"):
""" scaled unit z-axis cylinder """p0= [0, 0, 0]
p1= [0, 0, h]
unit_vec= [0, 0, 1]
returncylinder(p0, p1, unit_vec, r, bc)
defelectrode_cylinder(p0=[0, 0, 0], unit_vec=[1, 0, 0], shape=[0.1, 0.1],
bc="e0"):
""" cylinder electrode (numpy interface) shape: NDArray [radius, thickness] """r, thick=shape# calculate the center of the other facep1=np.asarray(p0) +thick*np.asarray(unit_vec)
# generate cylinder electrode with annotationele=cylinder(p0, p1, unit_vec, r, bc)
ele.mat('agcl')
returneledefcylinder_with_electrodes():
""" [test only, will be deleted] """h=1.0r=0.5g0=unit_cylinder(h=h, r=r)
g0.mat('g0')
# generate cylinder electrodeele_shape= [0.1, 0.1] # radius, thickthick=ele_shape[1]
ele_pos= [30, h/2.0] # angle (degree), z# infer locationsrad=ele_pos[0] *2*np.pi/360.0unit_vec=np.array([np.cos(rad), np.sin(rad), 0])
# warning: a thin contact of electrode with domain will cause# netgen failed to generate proper meshp0= (r-thick/2.0)*unit_vecp0[2] =ele_pos[1]
# place 1st electrodeele=electrode_cylinder(p0, unit_vec, shape=ele_shape, bc="e0")
geo=g0+ele# place 2nd electrodep0[2] +=0.25p0[0] +=0.01# <-- https://github.com/NGSolve/netgen/issues/49ele2=electrode_cylinder(p0, unit_vec, shape=ele_shape, bc="e1")
geo=geo+ele2returngeoif__name__=="__main__":
g=cylinder_with_electrodes()
geo=csg.CSGeometry()
geo.Add(g)
ngmesh=geo.GenerateMesh(maxh=0.1)
mesh=Mesh(ngmesh)
# mesh.Curve(3)print(mesh.GetBoundaries())
print(mesh.GetMaterials())
The text was updated successfully, but these errors were encountered:
liubenyuan
changed the title
bc will be automatically merged in CSG mode
bc will be automatically merged in netgen.csg
Dec 5, 2019
liubenyuan
changed the title
bc will be automatically merged in netgen.csg
bc and mat will be erroneous merged in netgen.csg
Dec 5, 2019
Hi, I want to merge/combine some cylinders in
netgen.csg
, where 1 big cylinder is the domain to be investigated and two small cylinders are electrodes (voltage/current boundaries). I specify the bcs on the top surface of a cylinder primitive. However, the bc will be erroneous merged. Here is a minimal example that recreates this problem. Moreover, the material properties of the small cylinders (electrodes) are also merged, which can be seen inmesh.GetMaterials()
.Can I preserve the
bc
andmat
of the small shapes when using+
innetgen.csg
?https://github.com/liubenyuan/netgen-note/blob/master/examples/csg_issue_bc_cyl.py
At line 78, if you comment this line
p0[0] += 0.01
, thebc="e1"
will be removed, if uncomment this line,bc="e1"
will be visible. The material properties of electrodes (which should be 'agcl') is gone, where only 'g0' is preserved.The text was updated successfully, but these errors were encountered: