How to create spherical surfaces with occ.addSurfaceFilling
Hello there,
I'm trying to create surfaces with occ.addSurfaceFilling based on the previously generated curve loop on a spherical shell, however the created surfaces are not spherical but some other surface functions, see Fig.1. Meanwhile, the same code with geo.addSurfaceFilling could generate a spherical surface as expected, see Fig.2. Therefore I was wondering if I can accomplish the same surface generation in the occ module. The script is also attached below, which is used in the geo module from the tutorial "t5.py".
I appreciate any help and advice!
import gmsh
import math
import sys
gmsh.initialize()
gmsh.model.add("partitioned_sphere")
def cheeseHole(x, y, z, r, lc, shells):
# This function will create a spherical hole in a volume. We don't specify
# tags manually, and let the functions return them automatically:
p1 = gmsh.model.occ.addPoint(x, y, z, lc)
p2 = gmsh.model.occ.addPoint(x + r, y, z, lc)
p3 = gmsh.model.occ.addPoint(x, y + r, z, lc)
p4 = gmsh.model.occ.addPoint(x, y, z + r, lc)
p5 = gmsh.model.occ.addPoint(x - r, y, z, lc)
p6 = gmsh.model.occ.addPoint(x, y - r, z, lc)
p7 = gmsh.model.occ.addPoint(x, y, z - r, lc)
c1 = gmsh.model.occ.addCircleArc(p2, p1, p7)
c2 = gmsh.model.occ.addCircleArc(p7, p1, p5)
c3 = gmsh.model.occ.addCircleArc(p5, p1, p4)
c4 = gmsh.model.occ.addCircleArc(p4, p1, p2)
c5 = gmsh.model.occ.addCircleArc(p2, p1, p3)
c6 = gmsh.model.occ.addCircleArc(p3, p1, p5)
c7 = gmsh.model.occ.addCircleArc(p5, p1, p6)
c8 = gmsh.model.occ.addCircleArc(p6, p1, p2)
c9 = gmsh.model.occ.addCircleArc(p7, p1, p3)
c10 = gmsh.model.occ.addCircleArc(p3, p1, p4)
c11 = gmsh.model.occ.addCircleArc(p4, p1, p6)
c12 = gmsh.model.occ.addCircleArc(p6, p1, p7)
l1 = gmsh.model.occ.addCurveLoop([c5, c10, c4])
l2 = gmsh.model.occ.addCurveLoop([c9, -c5, c1])
l3 = gmsh.model.occ.addCurveLoop([c12, -c8, -c1])
l4 = gmsh.model.occ.addCurveLoop([c8, -c4, c11])
l5 = gmsh.model.occ.addCurveLoop([-c10, c6, c3])
l6 = gmsh.model.occ.addCurveLoop([-c11, -c3, c7])
l7 = gmsh.model.occ.addCurveLoop([-c2, -c7, -c12])
l8 = gmsh.model.occ.addCurveLoop([-c6, -c9, c2])
s1 = gmsh.model.occ.addSurfaceFilling(l1)
s2 = gmsh.model.occ.addSurfaceFilling(l2)
s3 = gmsh.model.occ.addSurfaceFilling(l3)
s4 = gmsh.model.occ.addSurfaceFilling(l4)
s5 = gmsh.model.occ.addSurfaceFilling(l5)
s6 = gmsh.model.occ.addSurfaceFilling(l6)
s7 = gmsh.model.occ.addSurfaceFilling(l7)
s8 = gmsh.model.occ.addSurfaceFilling(l8)
sl = gmsh.model.occ.addSurfaceLoop([s1, s2, s3, s4, s5, s6, s7, s8])
v = gmsh.model.occ.addVolume([sl])
gmsh.model.occ.synchronize()
shells.append(sl)
return v
# We create five holes in the cube:
shells = []
v = cheeseHole(0, 0, 0, 1, 0.1, shells)
gmsh.model.occ.synchronize()
gmsh.write("partitioned_sphere.step")
gmsh.finalize()
Edited by Jinlong Guo