1 # Creating a hexahedral mesh on a cylinder.
2 # Note: it is a copy of 'ex24_cylinder.py' from SMESH_SWIG
20 base = geo.MakeVertex(0, 0, 0)
21 direction = geo.MakeVectorDXDYDZ(0, 0, 1)
23 cylinder = geo.MakeCylinder(base, direction, radius, height)
25 geo.addToStudy(cylinder, "cylinder")
32 box_rot = geo.MakeBox(-size, -size, 0, +size, +size, height)
33 box_axis = geo.MakeLine(base, direction)
34 box = geo.MakeRotation(box_rot, box_axis, math.pi/4)
36 hole = geo.MakeCut(cylinder, box)
40 plane_a = geo.MakePlane(base, geo.MakeVectorDXDYDZ(1, 0, 0), plane_trim)
41 plane_b = geo.MakePlane(base, geo.MakeVectorDXDYDZ(0, 1, 0), plane_trim)
43 blocks_part = geo.MakePartition([hole], [plane_a, plane_b], [], [], geo.ShapeType["SOLID"])
44 blocks_list = [box] + geo.SubShapeAll(blocks_part, geo.ShapeType["SOLID"])
45 blocks_all = geo.MakeCompound(blocks_list)
46 blocks = geo.MakeGlueFaces(blocks_all, 0.0001)
48 geo.addToStudy(blocks, "cylinder:blocks")
50 # Build geometric groups
51 # ----------------------
53 def group(name, shape, type, base=None, direction=None):
54 t = geo.ShapeType[type]
55 g = geo.CreateGroup(shape, t)
57 geo.addToStudy(g, name)
61 l = geo.GetShapesOnPlaneWithLocationIDs(shape, t, direction, base, geo.GEOM.ST_ON)
66 group_a = group("baseA", blocks, "FACE", base, direction)
68 base_b = geo.MakeVertex(0, 0, height)
69 group_b = group("baseB", blocks, "FACE", base_b, direction)
71 group_1 = group("limit", blocks, "SOLID")
72 group_1_all = geo.SubShapeAllIDs(blocks, geo.ShapeType["SOLID"])
73 geo.UnionIDs(group_1, group_1_all)
74 group_1_box = geo.GetBlockNearPoint(blocks, base)
75 geo.DifferenceList(group_1, [group_1_box])
77 # Mesh the blocks with hexahedral
78 # -------------------------------
80 smesh.SetCurrentStudy(salome.myStudy)
82 def discretize(x, y, z, n, s=blocks):
83 p = geo.MakeVertex(x, y, z)
84 e = geo.GetEdgeNearPoint(s, p)
89 hexa = smesh.Mesh(blocks)
91 hexa_1d = hexa.Segment()
92 hexa_1d.NumberOfSegments(1)
94 discretize(+radius , +radius, 0, 5)
95 discretize(-radius , +radius, 0, 8)
96 discretize((radius+size)/2, 0, 0, 10)
97 discretize( +radius, 0, height/2, 20)