Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/smesh.git] / src / SMESH_SWIG / SMESH_box_tetra.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 # Tetrahedrization of a simple box. Hypothesis and algorithms for
23 # the mesh generation are global
24 #
25 import salome
26 import geompy
27 import smesh
28
29
30 # ---- define a boxe
31
32 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
33
34 idbox = geompy.addToStudy(box, "box")
35
36 print "Analysis of the geometry box :"
37 subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"])
38 subFaceList  = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
39 subEdgeList  = geompy.SubShapeAll(box, geompy.ShapeType["EDGE"])
40
41 print "number of Shells in box : ", len(subShellList)
42 print "number of Faces  in box : ", len(subFaceList)
43 print "number of Edges  in box : ", len(subEdgeList)
44
45
46 ### ---------------------------- SMESH --------------------------------------
47
48 # ---- init a Mesh with the boxe
49
50 mesh = smesh.Mesh(box, "MeshBox")
51
52 # ---- set Hypothesis and Algorithm
53
54 print "-------------------------- NumberOfSegments"
55 numberOfSegments = 10
56
57 regular1D = mesh.Segment()
58 hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
59 print hypNbSeg.GetName()
60 print hypNbSeg.GetId()
61 print hypNbSeg.GetNumberOfSegments()
62 smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
63
64 print "-------------------------- MaxElementArea"
65
66 maxElementArea = 500
67
68 mefisto2D = mesh.Triangle()
69 hypArea = mefisto2D.MaxElementArea(maxElementArea)
70 print hypArea.GetName()
71 print hypArea.GetId()
72 print hypArea.GetMaxElementArea()
73 smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
74
75 print "-------------------------- MaxElementVolume"
76
77 maxElementVolume = 500
78
79 netgen3D = mesh.Tetrahedron(smesh.NETGEN)
80 hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
81 print hypVolume.GetName()
82 print hypVolume.GetId()
83 print hypVolume.GetMaxElementVolume()
84 smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume))
85
86 salome.sg.updateObjBrowser(1)
87
88 print "-------------------------- compute the mesh of the boxe"
89 ret = mesh.Compute()
90 print ret
91 if ret != 0:
92     log = mesh.GetLog(0) # no erase trace
93     for linelog in log:
94         print linelog
95     print "Information about the MeshBox:"
96     print "Number of nodes       : ", mesh.NbNodes()
97     print "Number of edges       : ", mesh.NbEdges()
98     print "Number of faces       : ", mesh.NbFaces()
99     print "Number of triangles   : ", mesh.NbTriangles()
100     print "Number of volumes     : ", mesh.NbVolumes()
101     print "Number of tetrahedrons: ", mesh.NbTetras()
102 else:
103     print "probleme when computing the mesh"