1 #==============================================================================
3 # Bug (from script, bug) : SMESH_demo_hexa2_upd.py, PAL6781
4 # Modified : 25/11/2004
5 # Author : Kovaltchuk Alexey
7 #==============================================================================
8 # Tetrahedrization of a geometry (box minus a inner cylinder).
9 # Hypothesis and algorithms for the mesh generation are not global:
10 # the mesh of some edges is thinner
19 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
20 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
22 smeshgui = salome.ImportComponentGUI("SMESH")
23 smeshgui.Init(salome.myStudyId);
27 # -----------------------------------------------------------------------------
40 Orig = geompy.MakeVertex(zero,zero,zero)
41 P0 = geompy.MakeVertex(a,a,zero)
42 P1 = geompy.MakeVertex(zero,demi,zero)
43 P2 = geompy.MakeVertex(ma,a,zero)
44 P3 = geompy.MakeVertex(mun,un,zero)
45 P4 = geompy.MakeVertex(un,un,zero)
46 P5 = geompy.MakeVertex(zero,zero,un)
48 arc = geompy.MakeArc(P0,P1,P2)
49 e1 = geompy.MakeEdge(P2,P3)
50 e2 = geompy.MakeEdge(P3,P4)
51 e3 = geompy.MakeEdge(P4,P0)
59 wire = geompy.MakeWire(list)
60 face = geompy.MakeFace(wire,1)
62 dir = geompy.MakeVector(Orig,P5)
63 vol1 = geompy.MakePipe(face,dir)
66 #dir = geom.MakeVector(Orig,P5)
67 vol2 = geompy.MakeRotation(vol1,dir,angle)
69 vol3 = geompy.MakeRotation(vol2,dir,angle)
71 vol4 = geompy.MakeRotation(vol3,dir,angle)
79 volComp = geompy.MakeCompound(list)
82 vol = geompy.MakeGlueFaces(volComp,tol3d)
83 idVol = geompy.addToStudy(vol,"volume")
85 print "Analysis of the final volume:"
86 subShellList = geompy.SubShapeAllSorted(vol,ShapeTypeShell)
87 subFaceList = geompy.SubShapeAllSorted(vol,ShapeTypeFace)
88 subEdgeList = geompy.SubShapeAllSorted(vol,ShapeTypeEdge)
90 print "number of Shells in the volume : ",len(subShellList)
91 print "number of Faces in the volume : ",len(subFaceList)
92 print "number of Edges in the volume : ",len(subEdgeList)
95 for k in range(len(subEdgeList)):
96 idSubEdge.append(geompy.addToStudyInFather(vol,subEdgeList[k],"SubEdge"+str(k)))
99 edgeZ.append(subEdgeList[0])
100 edgeZ.append(subEdgeList[3])
101 edgeZ.append(subEdgeList[10])
102 edgeZ.append(subEdgeList[11])
103 edgeZ.append(subEdgeList[20])
104 edgeZ.append(subEdgeList[21])
105 edgeZ.append(subEdgeList[28])
106 edgeZ.append(subEdgeList[31])
110 idEdgeZ.append(geompy.addToStudyInFather(vol,edgeZ[i],"EdgeZ"+str(i+1)))
112 ### ---------------------------- SMESH --------------------------------------
114 # ---- create Hypothesis
116 print "-------------------------- create Hypothesis"
118 print "-------------------------- NumberOfSegments the global one"
120 numberOfSegments = 10
122 hypNbSeg=smesh.CreateHypothesis("NumberOfSegments","libStdMeshersEngine.so")
123 hypNbSeg.SetNumberOfSegments(numberOfSegments)
124 hypNbSegID = hypNbSeg.GetId()
125 print hypNbSeg.GetName()
127 print hypNbSeg.GetNumberOfSegments()
129 smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments")
131 print "-------------------------- NumberOfSegments in the Z direction"
133 numberOfSegmentsZ = 40
135 hypNbSegZ=smesh.CreateHypothesis("NumberOfSegments","libStdMeshersEngine.so")
136 hypNbSegZ.SetNumberOfSegments(numberOfSegmentsZ)
137 hypNbSegZID = hypNbSegZ.GetId()
138 print hypNbSegZ.GetName()
140 print hypNbSegZ.GetNumberOfSegments()
142 smeshgui.SetName(salome.ObjectToID(hypNbSegZ), "NumberOfSegmentsZ")
144 # ---- create Algorithms
146 print "-------------------------- create Algorithms"
148 print "-------------------------- Regular_1D"
150 regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
151 smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
153 print "-------------------------- Quadrangle_2D"
155 quad2D=smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so")
156 smeshgui.SetName(salome.ObjectToID(quad2D), "Quadrangle_2D")
158 print "-------------------------- Hexa_3D"
160 hexa3D=smesh.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so")
161 smeshgui.SetName(salome.ObjectToID(hexa3D), "Hexa_3D")
163 # ---- init a Mesh with the volume
165 mesh = smesh.CreateMesh(vol)
166 smeshgui.SetName(salome.ObjectToID(mesh), "meshVolume")
168 # ---- add hypothesis to the volume
170 print "-------------------------- add hypothesis to the volume"
172 ret=mesh.AddHypothesis(vol,regular1D)
174 ret=mesh.AddHypothesis(vol,hypNbSeg)
176 ret=mesh.AddHypothesis(vol,quad2D)
178 ret=mesh.AddHypothesis(vol,hexa3D)
182 print "-------------------------- add hypothesis to edge in the Z directions", (i+1)
184 subMeshEdgeZ = mesh.GetSubMesh(edgeZ[i],"SubMeshEdgeZ_"+str(i+1))
186 retZ = mesh.AddHypothesis(edgeZ[i],hypNbSegZ)
187 print " add hyp Z ", retZ
189 salome.sg.updateObjBrowser(1)
191 print "-------------------------- compute the mesh of the volume"
193 ret=smesh.Compute(mesh,vol)
197 ## log=mesh.GetLog(0) # no erase trace
198 ## for linelog in log:
200 print "Information about the MeshBox :"
201 print "Number of nodes : ", mesh.NbNodes()
202 print "Number of edges : ", mesh.NbEdges()
203 print "Number of faces : ", mesh.NbFaces()
204 print "Number of triangles : ", mesh.NbTriangles()
205 print "Number of volumes : ", mesh.NbVolumes()
206 print "Number of tetrahedrons: ", mesh.NbTetras()
208 print "problem when Computing the mesh"
210 salome.sg.updateObjBrowser(1)