1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 # Tetrahedrization of the geometry generated by the Python script GEOM_Partition1.py
25 # Hypothesis and algorithms for the mesh generation are global
26 # -- Rayon de la bariere
34 #---------------------------------------------------------------
37 barier_radius = 5.6 / 2 # Rayon de la bariere
38 colis_radius = 1.0 / 2 # Rayon du colis
39 colis_step = 2.0 # Distance s
\89parant deux colis
40 cc_width = 0.11 # Epaisseur du complement de colisage
44 cc_radius = colis_radius + cc_width
45 colis_center = sqrt(2.0)*colis_step/2
56 p0 = geompy.MakeVertex(0.,0.,0.)
57 vz = geompy.MakeVectorDXDYDZ(0.,0.,1.)
61 barier = geompy.MakeCylinder(p0, vz, barier_radius, barier_height)
65 colis = geompy.MakeCylinder(p0, vz, colis_radius, barier_height)
66 cc = geompy.MakeCylinder(p0, vz, cc_radius, barier_height)
68 colis_cc = geompy.MakeCompound([colis, cc])
69 colis_cc = geompy.MakeTranslation(colis_cc, colis_center, 0.0, 0.0)
71 colis_cc_multi = geompy.MultiRotate1D(colis_cc, vz, 4)
75 Compound1 = geompy.MakeCompound([colis_cc_multi, barier])
76 SubShape_theShape = geompy.SubShapeAll(Compound1,geompy.ShapeType["SOLID"])
77 alveole = geompy.MakePartition(SubShape_theShape)
79 print "Analysis of the geometry to mesh (right after the Partition) :"
81 subShellList = geompy.SubShapeAll(alveole, geompy.ShapeType["SHELL"])
82 subFaceList = geompy.SubShapeAll(alveole, geompy.ShapeType["FACE"])
83 subEdgeList = geompy.SubShapeAll(alveole, geompy.ShapeType["EDGE"])
85 print "number of Shells in alveole : ", len(subShellList)
86 print "number of Faces in alveole : ", len(subFaceList)
87 print "number of Edges in alveole : ", len(subEdgeList)
89 subshapes = geompy.SubShapeAll(alveole, geompy.ShapeType["SHAPE"])
91 ## there are 9 sub-shapes
93 comp1 = geompy.MakeCompound( [ subshapes[0], subshapes[1] ] )
94 comp2 = geompy.MakeCompound( [ subshapes[2], subshapes[3] ] )
95 comp3 = geompy.MakeCompound( [ subshapes[4], subshapes[5] ] )
96 comp4 = geompy.MakeCompound( [ subshapes[6], subshapes[7] ] )
99 compGOs.append( comp1 )
100 compGOs.append( comp2 )
101 compGOs.append( comp3 )
102 compGOs.append( comp4 )
103 comp = geompy.MakeCompound( compGOs )
105 alveole = geompy.MakeCompound( [ comp, subshapes[8] ])
107 idalveole = geompy.addToStudy(alveole, "alveole")
109 print "Analysis of the geometry to mesh (right after the MakeCompound) :"
111 subShellList = geompy.SubShapeAll(alveole, geompy.ShapeType["SHELL"])
112 subFaceList = geompy.SubShapeAll(alveole, geompy.ShapeType["FACE"])
113 subEdgeList = geompy.SubShapeAll(alveole, geompy.ShapeType["EDGE"])
115 print "number of Shells in alveole : ", len(subShellList)
116 print "number of Faces in alveole : ", len(subFaceList)
117 print "number of Edges in alveole : ", len(subEdgeList)
119 status = geompy.CheckShape(alveole)
120 print " check status ", status
123 smesh.SetCurrentStudy(salome.myStudy)
125 # ---- init a Mesh with the alveole
126 shape_mesh = salome.IDToObject( idalveole )
128 mesh = smesh.Mesh(shape_mesh, "MeshAlveole")
130 print "-------------------------- create Hypothesis (In this case global hypothesis are used)"
132 print "-------------------------- NumberOfSegments"
134 numberOfSegments = 10
136 regular1D = mesh.Segment()
137 hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
138 print hypNbSeg.GetName()
139 print hypNbSeg.GetId()
140 print hypNbSeg.GetNumberOfSegments()
141 smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
143 print "-------------------------- MaxElementArea"
147 mefisto2D = mesh.Triangle()
148 hypArea = mefisto2D.MaxElementArea(maxElementArea)
149 print hypArea.GetName()
150 print hypArea.GetId()
151 print hypArea.GetMaxElementArea()
152 smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
154 print "-------------------------- MaxElementVolume"
156 maxElementVolume = 0.5
158 netgen3D = mesh.Tetrahedron(smesh.NETGEN)
159 hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
160 print hypVolume.GetName()
161 print hypVolume.GetId()
162 print hypVolume.GetMaxElementVolume()
163 smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume))
165 print "-------------------------- compute the mesh of alveole "
169 log=mesh.GetLog(0) # no erase trace
172 print "Information about the Mesh_mechanic:"
173 print "Number of nodes : ", mesh.NbNodes()
174 print "Number of edges : ", mesh.NbEdges()
175 print "Number of faces : ", mesh.NbFaces()
176 print "Number of triangles : ", mesh.NbTriangles()
177 print "Number of volumes : ", mesh.NbVolumes()
178 print "Number of tetrahedrons: ", mesh.NbTetras()
180 print "problem when computing the mesh"
182 salome.sg.updateObjBrowser(1)