1 # Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/
21 # Tetrahedrization of the geometry generated by the Python script GEOM_Partition1.py
22 # Hypothesis and algorithms for the mesh generation are global
24 #%Make geometry (like CEA script (A1)) using Partition algorithm% from OCC
25 # -- Rayon de la bariere
34 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
35 smesh.SetCurrentStudy(salome.myStudy)
37 smeshgui = salome.ImportComponentGUI("SMESH")
38 smeshgui.Init(salome.myStudyId)
40 #---------------------------------------------------------------
43 barier_radius = 5.6 / 2 # Rayon de la bariere
44 colis_radius = 1.0 / 2 # Rayon du colis
45 colis_step = 2.0 # Distance s
\89parant deux colis
46 cc_width = 0.11 # Epaisseur du complement de colisage
50 cc_radius = colis_radius + cc_width
51 colis_center = sqrt(2.0)*colis_step/2
62 p0 = geompy.MakeVertex(0.,0.,0.)
63 vz = geompy.MakeVectorDXDYDZ(0.,0.,1.)
67 barier = geompy.MakeCylinder(p0, vz, barier_radius, barier_height)
71 colis = geompy.MakeCylinder(p0, vz, colis_radius, barier_height)
72 cc = geompy.MakeCylinder(p0, vz, cc_radius, barier_height)
74 colis_cc = geompy.MakeCompound([colis, cc])
75 colis_cc = geompy.MakeTranslation(colis_cc, colis_center, 0.0, 0.0)
77 colis_cc_multi = geompy.MultiRotate1D(colis_cc, vz, 4)
81 alveole = geompy.MakePartition([colis_cc_multi, barier])
83 print "Analysis of the geometry to mesh (right after the Partition) :"
85 subShellList = geompy.SubShapeAll(alveole, geompy.ShapeType["SHELL"])
86 subFaceList = geompy.SubShapeAll(alveole, geompy.ShapeType["FACE"])
87 subEdgeList = geompy.SubShapeAll(alveole, geompy.ShapeType["EDGE"])
89 print "number of Shells in alveole : ", len(subShellList)
90 print "number of Faces in alveole : ", len(subFaceList)
91 print "number of Edges in alveole : ", len(subEdgeList)
93 subshapes = geompy.SubShapeAll(alveole, geompy.ShapeType["SHAPE"])
95 ## there are 9 subshapes
97 comp1 = geompy.MakeCompound( [ subshapes[0], subshapes[1] ] )
98 comp2 = geompy.MakeCompound( [ subshapes[2], subshapes[3] ] )
99 comp3 = geompy.MakeCompound( [ subshapes[4], subshapes[5] ] )
100 comp4 = geompy.MakeCompound( [ subshapes[6], subshapes[7] ] )
103 compGOs.append( comp1 )
104 compGOs.append( comp2 )
105 compGOs.append( comp3 )
106 compGOs.append( comp4 )
107 comp = geompy.MakeCompound( compGOs )
109 alveole = geompy.MakeCompound( [ comp, subshapes[8] ])
111 idalveole = geompy.addToStudy(alveole, "alveole")
113 print "Analysis of the geometry to mesh (right after the MakeCompound) :"
115 subShellList = geompy.SubShapeAll(alveole, geompy.ShapeType["SHELL"])
116 subFaceList = geompy.SubShapeAll(alveole, geompy.ShapeType["FACE"])
117 subEdgeList = geompy.SubShapeAll(alveole, geompy.ShapeType["EDGE"])
119 print "number of Shells in alveole : ", len(subShellList)
120 print "number of Faces in alveole : ", len(subFaceList)
121 print "number of Edges in alveole : ", len(subEdgeList)
123 status = geompy.CheckShape(alveole)
124 print " check status ", status
128 print "-------------------------- create Hypothesis (In this case global hypothesis are used)"
130 print "-------------------------- NumberOfSegments"
132 numberOfSegments = 10
134 hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
135 hypNbSeg.SetNumberOfSegments(numberOfSegments)
136 print hypNbSeg.GetName()
137 print hypNbSeg.GetId()
138 print hypNbSeg.GetNumberOfSegments()
140 smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
142 print "-------------------------- MaxElementArea"
146 hypArea = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
147 hypArea.SetMaxElementArea(maxElementArea)
148 print hypArea.GetName()
149 print hypArea.GetId()
150 print hypArea.GetMaxElementArea()
152 smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_0.1")
154 print "-------------------------- MaxElementVolume"
156 maxElementVolume = 0.5
158 hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
159 hypVolume.SetMaxElementVolume(maxElementVolume)
160 print hypVolume.GetName()
161 print hypVolume.GetId()
162 print hypVolume.GetMaxElementVolume()
164 smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_0.5")
166 print "-------------------------- create Algorithms"
168 print "-------------------------- Regular_1D"
170 regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
171 smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
173 print "-------------------------- MEFISTO_2D"
175 mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
176 smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
178 print "-------------------------- NETGEN_3D"
180 netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
181 smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
183 # ---- init a Mesh with the alveole
184 shape_mesh = salome.IDToObject( idalveole )
186 mesh = smesh.CreateMesh(shape_mesh)
187 smeshgui.SetName(salome.ObjectToID(mesh), "MeshAlveole")
189 # ---- add hypothesis to alveole
191 print "-------------------------- add hypothesis to alveole"
193 mesh.AddHypothesis(shape_mesh,regular1D)
194 mesh.AddHypothesis(shape_mesh,hypNbSeg)
196 mesh.AddHypothesis(shape_mesh,mefisto2D)
197 mesh.AddHypothesis(shape_mesh,hypArea)
199 mesh.AddHypothesis(shape_mesh,netgen3D)
200 mesh.AddHypothesis(shape_mesh,hypVolume)
202 print "-------------------------- compute the mesh of alveole "
203 ret = smesh.Compute(mesh,shape_mesh)
206 log=mesh.GetLog(0) # no erase trace
209 print "Information about the Mesh_mechanic:"
210 print "Number of nodes : ", mesh.NbNodes()
211 print "Number of edges : ", mesh.NbEdges()
212 print "Number of faces : ", mesh.NbFaces()
213 print "Number of triangles : ", mesh.NbTriangles()
214 print "Number of volumes : ", mesh.NbVolumes()
215 print "Number of tetrahedrons: ", mesh.NbTetras()
217 print "problem when computing the mesh"
219 salome.sg.updateObjBrowser(1)