2 # Tetrahedrization of the geometry generated by the Python script GEOM_Partition1.py
3 # Hypothesis and algorithms for the mesh generation are global
5 #%Make geometry (like CEA script (A1)) using Partition algorithm% from OCC
6 # -- Rayon de la bariere
15 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
16 smesh.SetCurrentStudy(salome.myStudy)
18 smeshgui = salome.ImportComponentGUI("SMESH")
19 smeshgui.Init(salome.myStudyId)
21 #---------------------------------------------------------------
24 barier_radius = 5.6 / 2 # Rayon de la bariere
25 colis_radius = 1.0 / 2 # Rayon du colis
26 colis_step = 2.0 # Distance s
\89parant deux colis
27 cc_width = 0.11 # Epaisseur du complement de colisage
31 cc_radius = colis_radius + cc_width
32 colis_center = sqrt(2.0)*colis_step/2
43 p0 = geompy.MakeVertex(0.,0.,0.)
44 vz = geompy.MakeVectorDXDYDZ(0.,0.,1.)
48 barier = geompy.MakeCylinder(p0, vz, barier_radius, barier_height)
52 colis = geompy.MakeCylinder(p0, vz, colis_radius, barier_height)
53 cc = geompy.MakeCylinder(p0, vz, cc_radius, barier_height)
55 colis_cc = geompy.MakeCompound([colis, cc])
56 colis_cc = geompy.MakeTranslation(colis_cc, colis_center, 0.0, 0.0)
58 colis_cc_multi = geompy.MultiRotate1D(colis_cc, vz, 4)
62 alveole = geompy.MakePartition([colis_cc_multi, barier])
64 print "Analysis of the geometry to mesh (right after the Partition) :"
66 subShellList = geompy.SubShapeAll(alveole, geompy.ShapeType["SHELL"])
67 subFaceList = geompy.SubShapeAll(alveole, geompy.ShapeType["FACE"])
68 subEdgeList = geompy.SubShapeAll(alveole, geompy.ShapeType["EDGE"])
70 print "number of Shells in alveole : ", len(subShellList)
71 print "number of Faces in alveole : ", len(subFaceList)
72 print "number of Edges in alveole : ", len(subEdgeList)
74 subshapes = geompy.SubShapeAll(alveole, geompy.ShapeType["SHAPE"])
76 ## there are 9 subshapes
78 comp1 = geompy.MakeCompound( [ subshapes[0], subshapes[1] ] )
79 comp2 = geompy.MakeCompound( [ subshapes[2], subshapes[3] ] )
80 comp3 = geompy.MakeCompound( [ subshapes[4], subshapes[5] ] )
81 comp4 = geompy.MakeCompound( [ subshapes[6], subshapes[7] ] )
84 compGOs.append( comp1 )
85 compGOs.append( comp2 )
86 compGOs.append( comp3 )
87 compGOs.append( comp4 )
88 comp = geompy.MakeCompound( compGOs )
90 alveole = geompy.MakeCompound( [ comp, subshapes[8] ])
92 idalveole = geompy.addToStudy(alveole, "alveole")
94 print "Analysis of the geometry to mesh (right after the MakeCompound) :"
96 subShellList = geompy.SubShapeAll(alveole, geompy.ShapeType["SHELL"])
97 subFaceList = geompy.SubShapeAll(alveole, geompy.ShapeType["FACE"])
98 subEdgeList = geompy.SubShapeAll(alveole, geompy.ShapeType["EDGE"])
100 print "number of Shells in alveole : ", len(subShellList)
101 print "number of Faces in alveole : ", len(subFaceList)
102 print "number of Edges in alveole : ", len(subEdgeList)
104 status = geompy.CheckShape(alveole)
105 print " check status ", status
109 print "-------------------------- create Hypothesis (In this case global hypothesis are used)"
111 print "-------------------------- NumberOfSegments"
113 numberOfSegments = 10
115 hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
116 hypNbSeg.SetNumberOfSegments(numberOfSegments)
117 print hypNbSeg.GetName()
118 print hypNbSeg.GetId()
119 print hypNbSeg.GetNumberOfSegments()
121 smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
123 print "-------------------------- MaxElementArea"
127 hypArea = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
128 hypArea.SetMaxElementArea(maxElementArea)
129 print hypArea.GetName()
130 print hypArea.GetId()
131 print hypArea.GetMaxElementArea()
133 smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_0.1")
135 print "-------------------------- MaxElementVolume"
137 maxElementVolume = 0.5
139 hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
140 hypVolume.SetMaxElementVolume(maxElementVolume)
141 print hypVolume.GetName()
142 print hypVolume.GetId()
143 print hypVolume.GetMaxElementVolume()
145 smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_0.5")
147 print "-------------------------- create Algorithms"
149 print "-------------------------- Regular_1D"
151 regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
152 smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
154 print "-------------------------- MEFISTO_2D"
156 mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
157 smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
159 print "-------------------------- NETGEN_3D"
161 netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
162 smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
164 # ---- init a Mesh with the alveole
165 shape_mesh = salome.IDToObject( idalveole )
167 mesh = smesh.CreateMesh(shape_mesh)
168 smeshgui.SetName(salome.ObjectToID(mesh), "MeshAlveole")
170 # ---- add hypothesis to alveole
172 print "-------------------------- add hypothesis to alveole"
174 mesh.AddHypothesis(shape_mesh,regular1D)
175 mesh.AddHypothesis(shape_mesh,hypNbSeg)
177 mesh.AddHypothesis(shape_mesh,mefisto2D)
178 mesh.AddHypothesis(shape_mesh,hypArea)
180 mesh.AddHypothesis(shape_mesh,netgen3D)
181 mesh.AddHypothesis(shape_mesh,hypVolume)
183 print "-------------------------- compute the mesh of alveole "
184 ret = smesh.Compute(mesh,shape_mesh)
187 log=mesh.GetLog(0) # no erase trace
190 print "Information about the Mesh_mechanic:"
191 print "Number of nodes : ", mesh.NbNodes()
192 print "Number of edges : ", mesh.NbEdges()
193 print "Number of faces : ", mesh.NbFaces()
194 print "Number of triangles : ", mesh.NbTriangles()
195 print "Number of volumes : ", mesh.NbVolumes()
196 print "Number of tetrahedrons: ", mesh.NbTetras()
198 print "problem when computing the mesh"
200 salome.sg.updateObjBrowser(1)