Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[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 SMESH_fixation
27 import smesh
28
29 compshell = SMESH_fixation.compshell
30 idcomp = SMESH_fixation.idcomp
31 geompy = SMESH_fixation.geompy
32 salome = SMESH_fixation.salome
33
34 print "Analysis of the geometry to be meshed :"
35 subShellList = geompy.SubShapeAll(compshell, geompy.ShapeType["SHELL"])
36 subFaceList  = geompy.SubShapeAll(compshell, geompy.ShapeType["FACE"])
37 subEdgeList  = geompy.SubShapeAll(compshell, geompy.ShapeType["EDGE"])
38
39 print "number of Shells in compshell : ", len(subShellList)
40 print "number of Faces  in compshell : ", len(subFaceList)
41 print "number of Edges  in compshell : ", len(subEdgeList)
42
43 status = geompy.CheckShape(compshell)
44 print " check status ", status
45
46 ### ---------------------------- SMESH --------------------------------------
47
48 # ---- init a Mesh with the compshell
49
50 mesh = smesh.Mesh(compshell, "MeshcompShell")
51
52
53 # ---- set Hypothesis and Algorithm
54
55 print "-------------------------- NumberOfSegments"
56
57 numberOfSegments = 5
58
59 regular1D = mesh.Segment()
60 regular1D.SetName("Wire Discretisation")
61 hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
62 print hypNbSeg.GetName()
63 print hypNbSeg.GetId()
64 print hypNbSeg.GetNumberOfSegments()
65 smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
66
67 ## print "-------------------------- MaxElementArea"
68
69 ## maxElementArea = 80
70
71 ## mefisto2D = mesh.Triangle()
72 ## mefisto2D.SetName("MEFISTO_2D")
73 ## hypArea = mefisto2D.MaxElementArea(maxElementArea)
74 ## print hypArea.GetName()
75 ## print hypArea.GetId()
76 ## print hypArea.GetMaxElementArea()
77 ## smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
78
79 print "-------------------------- LengthFromEdges"
80
81 mefisto2D = mesh.Triangle()
82 mefisto2D.SetName("MEFISTO_2D")
83 hypLengthFromEdges = mefisto2D.LengthFromEdges()
84 print hypLengthFromEdges.GetName()
85 print hypLengthFromEdges.GetId()
86 smesh.SetName(hypLengthFromEdges, "LengthFromEdges")
87
88
89 print "-------------------------- MaxElementVolume"
90
91 maxElementVolume = 1000
92
93 netgen3D = mesh.Tetrahedron(smesh.NETGEN)
94 netgen3D.SetName("NETGEN_3D")
95 hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
96 print hypVolume.GetName()
97 print hypVolume.GetId()
98 print hypVolume.GetMaxElementVolume()
99 smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume))
100
101
102 salome.sg.updateObjBrowser(1)
103
104 print "-------------------------- compute compshell"
105 ret = mesh.Compute(mesh)
106 print ret
107 if ret != 0:
108     log = mesh.GetLog(0) # no erase trace
109     for linelog in log:
110         print linelog
111     print "Information about the MeshcompShel:"
112     print "Number of nodes        : ", mesh.NbNodes()
113     print "Number of edges        : ", mesh.NbEdges()
114     print "Number of faces        : ", mesh.NbFaces()
115     print "Number of triangles    : ", mesh.NbTriangles()
116     print "Number of volumes      : ", mesh.NbVolumes()
117     print "Number of tetrahedrons : ", mesh.NbTetras()
118     
119 else:
120     print "problem when computing the mesh"