Salome HOME
Fix bug 12796: Warning missed for the bad file 'test18.med'
[modules/smesh.git] / src / SMESH_SWIG / SMESH_fixation_tetra.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 # Tetrahedrization 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 StdMeshers
27 import NETGENPlugin
28 import SMESH_fixation
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 "-------------------------- MaxElementArea"
69
70 ## maxElementArea = 80
71
72 ## hypArea=smesh.CreateHypothesis("MaxElementArea")
73 ## hypArea.SetMaxElementArea(maxElementArea)
74 ## print hypArea.GetName()
75 ## print hypArea.GetId()
76 ## print hypArea.GetMaxElementArea()
77 ## smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_160")
78
79 hypLengthFromEdges = smesh.CreateHypothesis("LengthFromEdges", "libStdMeshersEngine.so")
80 smeshgui.SetName(salome.ObjectToID(hypLengthFromEdges), "LengthFromEdges")
81
82
83 print "-------------------------- MaxElementVolume"
84
85 maxElementVolume = 1000
86
87 hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
88 hypVolume.SetMaxElementVolume(maxElementVolume)
89
90 print hypVolume.GetName()
91 print hypVolume.GetId()
92 print hypVolume.GetMaxElementVolume()
93
94 smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_1000")
95
96 print "-------------------------- create Algorithms"
97
98 print "-------------------------- Regular_1D"
99
100 regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
101
102 smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
103
104 print "-------------------------- MEFISTO_2D"
105
106 mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
107
108 smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
109
110 print "-------------------------- NETGEN_3D"
111
112 netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
113
114 smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
115
116 # ---- init a Mesh with the compshell
117
118 mesh = smesh.CreateMesh(compshell)
119 smeshgui.SetName(salome.ObjectToID(mesh), "MeshcompShel")
120
121 print "-------------------------- add hypothesis to compshell"
122
123 mesh.AddHypothesis(compshell,regular1D)
124 mesh.AddHypothesis(compshell,hypNbSeg)
125
126 mesh.AddHypothesis(compshell,mefisto2D)
127 mesh.AddHypothesis(compshell,hypLengthFromEdges)
128
129 mesh.AddHypothesis(compshell,netgen3D)
130 mesh.AddHypothesis(compshell,hypVolume)
131
132 salome.sg.updateObjBrowser(1)
133
134 print "-------------------------- compute compshell"
135 ret = smesh.Compute(mesh,compshell)
136 print ret
137 if ret != 0:
138     log = mesh.GetLog(0) # no erase trace
139     for linelog in log:
140         print linelog
141     print "Information about the MeshcompShel:"
142     print "Number of nodes        : ", mesh.NbNodes()
143     print "Number of edges        : ", mesh.NbEdges()
144     print "Number of faces        : ", mesh.NbFaces()
145     print "Number of triangles    : ", mesh.NbTriangles()
146     print "Number of volumes      : ", mesh.NbVolumes()
147     print "Number of tetrahedrons : ", mesh.NbTetras()
148     
149 else:
150     print "problem when computing the mesh"