Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/smesh.git] / src / SMESH_SWIG / SMESH_fixation_hexa.py
1 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
6 #  This library is free software; you can redistribute it and/or
7 #  modify it under the terms of the GNU Lesser General Public
8 #  License as published by the Free Software Foundation; either
9 #  version 2.1 of the License.
10 #
11 #  This library is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 #  Lesser General Public License for more details.
15 #
16 #  You should have received a copy of the GNU Lesser General Public
17 #  License along with this library; if not, write to the Free Software
18 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22 # Hexahedrization of the geometry generated by the Python script
23 # SMESH_fixation.py
24 # Hypothesis and algorithms for the mesh generation are global
25 #
26 import SMESH_fixation
27 import smesh
28
29 compshell = SMESH_fixation.compshell
30 idcomp = SMESH_fixation.idcomp
31 geompy = SMESH_fixation.geompy
32 salome = SMESH_fixation.salome
33
34 print "Analysis of the geometry to be meshed :"
35 subShellList = geompy.SubShapeAll(compshell, geompy.ShapeType["SHELL"])
36 subFaceList  = geompy.SubShapeAll(compshell, geompy.ShapeType["FACE"])
37 subEdgeList  = geompy.SubShapeAll(compshell, geompy.ShapeType["EDGE"])
38
39 print "number of Shells in compshell : ", len(subShellList)
40 print "number of Faces  in compshell : ", len(subFaceList)
41 print "number of Edges  in compshell : ", len(subEdgeList)
42
43 status = geompy.CheckShape(compshell)
44 print " check status ", status
45
46 ### ---------------------------- SMESH --------------------------------------
47
48 # ---- init a Mesh with the compshell
49 shape_mesh = salome.IDToObject( idcomp  )
50
51 mesh = smesh.Mesh(shape_mesh, "MeshCompShell")
52
53
54 # ---- set Hypothesis and Algorithm
55
56 print "-------------------------- NumberOfSegments"
57
58 numberOfSegments = 5
59
60 regular1D = mesh.Segment()
61 regular1D.SetName("Wire Discretisation")
62 hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
63 print hypNbSeg.GetName()
64 print hypNbSeg.GetId()
65 print hypNbSeg.GetNumberOfSegments()
66 smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
67
68 print "-------------------------- Quadrangle_2D"
69
70 quad2D = mesh.Quadrangle()
71 quad2D.SetName("Quadrangle_2D")
72
73 print "-------------------------- Hexa_3D"
74
75 hexa3D = mesh.Hexahedron()
76 hexa3D.SetName("Hexa_3D")
77
78
79 salome.sg.updateObjBrowser(1)
80
81 print "-------------------------- compute compshell"
82 ret = mesh.Compute()
83 print ret
84 if ret != 0:
85     log = mesh.GetLog(0) # no erase trace
86     for linelog in log:
87         print linelog
88     print "Information about the MeshcompShel:"
89     print "Number of nodes       : ", mesh.NbNodes()
90     print "Number of edges       : ", mesh.NbEdges()
91     print "Number of faces       : ", mesh.NbFaces()
92     print "Number of quadrangles : ", mesh.NbQuadrangles()
93     print "Number of volumes     : ", mesh.NbVolumes()
94     print "Number of hexahedrons : ", mesh.NbHexas()
95 else:
96     print "problem when Computing the mesh"