Salome HOME
Merge from BR_plugins_pbyacs 03/04/2013
[modules/smesh.git] / src / SMESH_SWIG / SMESH_fixation_hexa.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2013  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
30 import SMESH, SALOMEDS
31 from salome.smesh import smeshBuilder
32 smesh =  smeshBuilder.New(salome.myStudy)
33
34 compshell = SMESH_fixation.compshell
35 idcomp = SMESH_fixation.idcomp
36 geompy = SMESH_fixation.geompy
37 salome = SMESH_fixation.salome
38
39 print "Analysis of the geometry to be meshed :"
40 subShellList = geompy.SubShapeAll(compshell, geompy.ShapeType["SHELL"])
41 subFaceList  = geompy.SubShapeAll(compshell, geompy.ShapeType["FACE"])
42 subEdgeList  = geompy.SubShapeAll(compshell, geompy.ShapeType["EDGE"])
43
44 print "number of Shells in compshell : ", len(subShellList)
45 print "number of Faces  in compshell : ", len(subFaceList)
46 print "number of Edges  in compshell : ", len(subEdgeList)
47
48 status = geompy.CheckShape(compshell)
49 print " check status ", status
50
51 ### ---------------------------- SMESH --------------------------------------
52 smesh.SetCurrentStudy(salome.myStudy)
53
54 # ---- init a Mesh with the compshell
55 shape_mesh = salome.IDToObject( idcomp  )
56
57 mesh = smesh.Mesh(shape_mesh, "MeshCompShell")
58
59
60 # ---- set Hypothesis and Algorithm
61
62 print "-------------------------- NumberOfSegments"
63
64 numberOfSegments = 5
65
66 regular1D = mesh.Segment()
67 regular1D.SetName("Wire Discretisation")
68 hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
69 print hypNbSeg.GetName()
70 print hypNbSeg.GetId()
71 print hypNbSeg.GetNumberOfSegments()
72 smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
73
74 print "-------------------------- Quadrangle_2D"
75
76 quad2D = mesh.Quadrangle()
77 quad2D.SetName("Quadrangle_2D")
78
79 print "-------------------------- Hexa_3D"
80
81 hexa3D = mesh.Hexahedron()
82 hexa3D.SetName("Hexa_3D")
83
84
85 salome.sg.updateObjBrowser(1)
86
87 print "-------------------------- compute compshell"
88 ret = mesh.Compute()
89 print ret
90 if ret != 0:
91     log = mesh.GetLog(0) # no erase trace
92     for linelog in log:
93         print linelog
94     print "Information about the MeshcompShel:"
95     print "Number of nodes       : ", mesh.NbNodes()
96     print "Number of edges       : ", mesh.NbEdges()
97     print "Number of faces       : ", mesh.NbFaces()
98     print "Number of quadrangles : ", mesh.NbQuadrangles()
99     print "Number of volumes     : ", mesh.NbVolumes()
100     print "Number of hexahedrons : ", mesh.NbHexas()
101 else:
102     print "problem when Computing the mesh"