Salome HOME
PR: merged from V5_1_4rc1
[modules/smesh.git] / src / SMESH_SWIG / SMESH_fixation_tetra.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 # Tetrahedrization 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
53 mesh = smesh.Mesh(compshell, "MeshcompShell")
54
55
56 # ---- set Hypothesis and Algorithm
57
58 print "-------------------------- NumberOfSegments"
59
60 numberOfSegments = 5
61
62 regular1D = mesh.Segment()
63 regular1D.SetName("Wire Discretisation")
64 hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
65 print hypNbSeg.GetName()
66 print hypNbSeg.GetId()
67 print hypNbSeg.GetNumberOfSegments()
68 smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
69
70 ## print "-------------------------- MaxElementArea"
71
72 ## maxElementArea = 80
73
74 ## mefisto2D = mesh.Triangle()
75 ## mefisto2D.SetName("MEFISTO_2D")
76 ## hypArea = mefisto2D.MaxElementArea(maxElementArea)
77 ## print hypArea.GetName()
78 ## print hypArea.GetId()
79 ## print hypArea.GetMaxElementArea()
80 ## smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
81
82 print "-------------------------- LengthFromEdges"
83
84 mefisto2D = mesh.Triangle()
85 mefisto2D.SetName("MEFISTO_2D")
86 hypLengthFromEdges = mefisto2D.LengthFromEdges()
87 print hypLengthFromEdges.GetName()
88 print hypLengthFromEdges.GetId()
89 smesh.SetName(hypLengthFromEdges, "LengthFromEdges")
90
91
92 print "-------------------------- MaxElementVolume"
93
94 maxElementVolume = 1000
95
96 netgen3D = mesh.Tetrahedron(smesh.NETGEN)
97 netgen3D.SetName("NETGEN_3D")
98 hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
99 print hypVolume.GetName()
100 print hypVolume.GetId()
101 print hypVolume.GetMaxElementVolume()
102 smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume))
103
104
105 salome.sg.updateObjBrowser(1)
106
107 print "-------------------------- compute compshell"
108 ret = mesh.Compute(mesh)
109 print ret
110 if ret != 0:
111     log = mesh.GetLog(0) # no erase trace
112     for linelog in log:
113         print linelog
114     print "Information about the MeshcompShel:"
115     print "Number of nodes        : ", mesh.NbNodes()
116     print "Number of edges        : ", mesh.NbEdges()
117     print "Number of faces        : ", mesh.NbFaces()
118     print "Number of triangles    : ", mesh.NbTriangles()
119     print "Number of volumes      : ", mesh.NbVolumes()
120     print "Number of tetrahedrons : ", mesh.NbTetras()
121     
122 else:
123     print "problem when computing the mesh"