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/ or email : webmaster.salome@opencascade.com
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
33 #---------------------------------------------------------------
36 barier_radius = 5.6 / 2 # Rayon de la bariere
37 colis_radius = 1.0 / 2 # Rayon du colis
38 colis_step = 2.0 # Distance s
\89parant deux colis
39 cc_width = 0.11 # Epaisseur du complement de colisage
43 cc_radius = colis_radius + cc_width
44 colis_center = sqrt(2.0)*colis_step/2
55 p0 = geompy.MakeVertex(0.,0.,0.)
56 vz = geompy.MakeVectorDXDYDZ(0.,0.,1.)
60 barier = geompy.MakeCylinder(p0, vz, barier_radius, barier_height)
64 colis = geompy.MakeCylinder(p0, vz, colis_radius, barier_height)
65 cc = geompy.MakeCylinder(p0, vz, cc_radius, barier_height)
67 colis_cc = geompy.MakeCompound([colis, cc])
68 colis_cc = geompy.MakeTranslation(colis_cc, colis_center, 0.0, 0.0)
70 colis_cc_multi = geompy.MultiRotate1D(colis_cc, vz, 4)
74 Compound1 = geompy.MakeCompound([colis_cc_multi, barier])
75 SubShape_theShape = geompy.SubShapeAll(Compound1,geompy.ShapeType["SOLID"])
76 alveole = geompy.MakePartition(SubShape_theShape)
78 print "Analysis of the geometry to mesh (right after the Partition) :"
80 subShellList = geompy.SubShapeAll(alveole, geompy.ShapeType["SHELL"])
81 subFaceList = geompy.SubShapeAll(alveole, geompy.ShapeType["FACE"])
82 subEdgeList = geompy.SubShapeAll(alveole, geompy.ShapeType["EDGE"])
84 print "number of Shells in alveole : ", len(subShellList)
85 print "number of Faces in alveole : ", len(subFaceList)
86 print "number of Edges in alveole : ", len(subEdgeList)
88 subshapes = geompy.SubShapeAll(alveole, geompy.ShapeType["SHAPE"])
90 ## there are 9 subshapes
92 comp1 = geompy.MakeCompound( [ subshapes[0], subshapes[1] ] )
93 comp2 = geompy.MakeCompound( [ subshapes[2], subshapes[3] ] )
94 comp3 = geompy.MakeCompound( [ subshapes[4], subshapes[5] ] )
95 comp4 = geompy.MakeCompound( [ subshapes[6], subshapes[7] ] )
98 compGOs.append( comp1 )
99 compGOs.append( comp2 )
100 compGOs.append( comp3 )
101 compGOs.append( comp4 )
102 comp = geompy.MakeCompound( compGOs )
104 alveole = geompy.MakeCompound( [ comp, subshapes[8] ])
106 idalveole = geompy.addToStudy(alveole, "alveole")
108 print "Analysis of the geometry to mesh (right after the MakeCompound) :"
110 subShellList = geompy.SubShapeAll(alveole, geompy.ShapeType["SHELL"])
111 subFaceList = geompy.SubShapeAll(alveole, geompy.ShapeType["FACE"])
112 subEdgeList = geompy.SubShapeAll(alveole, geompy.ShapeType["EDGE"])
114 print "number of Shells in alveole : ", len(subShellList)
115 print "number of Faces in alveole : ", len(subFaceList)
116 print "number of Edges in alveole : ", len(subEdgeList)
118 status = geompy.CheckShape(alveole)
119 print " check status ", status
123 # ---- init a Mesh with the alveole
124 shape_mesh = salome.IDToObject( idalveole )
126 mesh = smesh.Mesh(shape_mesh, "MeshAlveole")
128 print "-------------------------- create Hypothesis (In this case global hypothesis are used)"
130 print "-------------------------- NumberOfSegments"
132 numberOfSegments = 10
134 regular1D = mesh.Segment()
135 hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
136 print hypNbSeg.GetName()
137 print hypNbSeg.GetId()
138 print hypNbSeg.GetNumberOfSegments()
139 smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
141 print "-------------------------- MaxElementArea"
145 mefisto2D = mesh.Triangle()
146 hypArea = mefisto2D.MaxElementArea(maxElementArea)
147 print hypArea.GetName()
148 print hypArea.GetId()
149 print hypArea.GetMaxElementArea()
150 smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
152 print "-------------------------- MaxElementVolume"
154 maxElementVolume = 0.5
156 netgen3D = mesh.Tetrahedron(smesh.NETGEN)
157 hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
158 print hypVolume.GetName()
159 print hypVolume.GetId()
160 print hypVolume.GetMaxElementVolume()
161 smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume))
163 print "-------------------------- compute the mesh of alveole "
167 log=mesh.GetLog(0) # no erase trace
170 print "Information about the Mesh_mechanic:"
171 print "Number of nodes : ", mesh.NbNodes()
172 print "Number of edges : ", mesh.NbEdges()
173 print "Number of faces : ", mesh.NbFaces()
174 print "Number of triangles : ", mesh.NbTriangles()
175 print "Number of volumes : ", mesh.NbVolumes()
176 print "Number of tetrahedrons: ", mesh.NbTetras()
178 print "problem when computing the mesh"
180 salome.sg.updateObjBrowser(1)