Salome HOME
Fix bug 12796: Warning missed for the bad file 'test18.med'
[modules/smesh.git] / src / SMESH_SWIG / SMESH_fixation_hexa.py
1 #  Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 #
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.
8 #
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.
13 #
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
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20 #
21 # Hexahedrization of the geometry generated by the Python script
22 # SMESH_fixation.py
23 # Hypothesis and algorithms for the mesh generation are global
24 #
25
26 import SMESH_fixation
27
28 import StdMeshers
29
30 compshell = SMESH_fixation.compshell
31 idcomp = SMESH_fixation.idcomp
32 geompy = SMESH_fixation.geompy
33 salome = SMESH_fixation.salome
34
35 print "Analysis of the geometry to be meshed :"
36 subShellList = geompy.SubShapeAll(compshell, geompy.ShapeType["SHELL"])
37 subFaceList  = geompy.SubShapeAll(compshell, geompy.ShapeType["FACE"])
38 subEdgeList  = geompy.SubShapeAll(compshell, geompy.ShapeType["EDGE"])
39
40 print "number of Shells in compshell : ", len(subShellList)
41 print "number of Faces  in compshell : ", len(subFaceList)
42 print "number of Edges  in compshell : ", len(subEdgeList)
43
44 status = geompy.CheckShape(compshell)
45 print " check status ", status
46
47 ### ---------------------------- SMESH --------------------------------------
48 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
49
50 smeshgui = salome.ImportComponentGUI("SMESH")
51 smeshgui.Init(salome.myStudyId)
52
53 print "-------------------------- create Hypothesis"
54
55 print "-------------------------- NumberOfSegments"
56
57 numberOfSegments = 5
58
59 hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
60 hypNbSeg.SetNumberOfSegments(numberOfSegments)
61
62 print hypNbSeg.GetName()
63 print hypNbSeg.GetId()
64 print hypNbSeg.GetNumberOfSegments()
65
66 smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_5")
67
68 print "-------------------------- create Algorithms"
69
70 print "-------------------------- Regular_1D"
71
72 regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
73
74 smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
75
76 print "-------------------------- Quadrangle_2D"
77
78 quad2D = smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so")
79
80 smeshgui.SetName(salome.ObjectToID(quad2D), "Quadrangle_2D")
81
82 print "-------------------------- Hexa_3D"
83
84 hexa3D = smesh.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so")
85
86 smeshgui.SetName(salome.ObjectToID(hexa3D), "Hexa_3D")
87
88 # ---- init a Mesh with the compshell
89 shape_mesh = salome.IDToObject( idcomp  )
90
91 mesh = smesh.CreateMesh(shape_mesh)
92 smeshgui.SetName(salome.ObjectToID(mesh), "MeshCompShell")
93
94
95 print "-------------------------- add hypothesis to compshell"
96
97 mesh.AddHypothesis(shape_mesh,regular1D)
98 mesh.AddHypothesis(shape_mesh,hypNbSeg)
99
100 mesh.AddHypothesis(shape_mesh,quad2D)
101 mesh.AddHypothesis(shape_mesh,hexa3D)
102
103 salome.sg.updateObjBrowser(1)
104
105 print "-------------------------- compute compshell"
106 ret = smesh.Compute(mesh, shape_mesh)
107 print ret
108 if ret != 0:
109     log = mesh.GetLog(0) # no erase trace
110     for linelog in log:
111         print linelog
112     print "Information about the MeshcompShel:"
113     print "Number of nodes       : ", mesh.NbNodes()
114     print "Number of edges       : ", mesh.NbEdges()
115     print "Number of faces       : ", mesh.NbFaces()
116     print "Number of quadrangles : ", mesh.NbQuadrangles()
117     print "Number of volumes     : ", mesh.NbVolumes()
118     print "Number of hexahedrons : ", mesh.NbHexas()
119 else:
120     print "problem when Computing the mesh"