Salome HOME
Merge from V5_1_main 14/05/2010
[modules/smesh.git] / src / SMESH_SWIG / SMESH_fixation_hexa.py
1 #  -*- coding: iso-8859-1 -*-
2 #  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
3 #
4 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 #
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.
11 #
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.
16 #
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
20 #
21 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #
23
24 # Hexahedrization of the geometry generated by the Python script
25 # SMESH_fixation.py
26 # Hypothesis and algorithms for the mesh generation are global
27 #
28 import SMESH_fixation
29 import smesh
30
31 compshell = SMESH_fixation.compshell
32 idcomp = SMESH_fixation.idcomp
33 geompy = SMESH_fixation.geompy
34 salome = SMESH_fixation.salome
35
36 print "Analysis of the geometry to be meshed :"
37 subShellList = geompy.SubShapeAll(compshell, geompy.ShapeType["SHELL"])
38 subFaceList  = geompy.SubShapeAll(compshell, geompy.ShapeType["FACE"])
39 subEdgeList  = geompy.SubShapeAll(compshell, geompy.ShapeType["EDGE"])
40
41 print "number of Shells in compshell : ", len(subShellList)
42 print "number of Faces  in compshell : ", len(subFaceList)
43 print "number of Edges  in compshell : ", len(subEdgeList)
44
45 status = geompy.CheckShape(compshell)
46 print " check status ", status
47
48 ### ---------------------------- SMESH --------------------------------------
49 smesh.SetCurrentStudy(salome.myStudy)
50
51 # ---- init a Mesh with the compshell
52 shape_mesh = salome.IDToObject( idcomp  )
53
54 mesh = smesh.Mesh(shape_mesh, "MeshCompShell")
55
56
57 # ---- set Hypothesis and Algorithm
58
59 print "-------------------------- NumberOfSegments"
60
61 numberOfSegments = 5
62
63 regular1D = mesh.Segment()
64 regular1D.SetName("Wire Discretisation")
65 hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
66 print hypNbSeg.GetName()
67 print hypNbSeg.GetId()
68 print hypNbSeg.GetNumberOfSegments()
69 smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
70
71 print "-------------------------- Quadrangle_2D"
72
73 quad2D = mesh.Quadrangle()
74 quad2D.SetName("Quadrangle_2D")
75
76 print "-------------------------- Hexa_3D"
77
78 hexa3D = mesh.Hexahedron()
79 hexa3D.SetName("Hexa_3D")
80
81
82 salome.sg.updateObjBrowser(1)
83
84 print "-------------------------- compute compshell"
85 ret = mesh.Compute()
86 print ret
87 if ret != 0:
88     log = mesh.GetLog(0) # no erase trace
89     for linelog in log:
90         print linelog
91     print "Information about the MeshcompShel:"
92     print "Number of nodes       : ", mesh.NbNodes()
93     print "Number of edges       : ", mesh.NbEdges()
94     print "Number of faces       : ", mesh.NbFaces()
95     print "Number of quadrangles : ", mesh.NbQuadrangles()
96     print "Number of volumes     : ", mesh.NbVolumes()
97     print "Number of hexahedrons : ", mesh.NbHexas()
98 else:
99     print "problem when Computing the mesh"