Salome HOME
IPAL21363 Compute hangs up on Hypothesis Distribution of Layers.
[modules/smesh.git] / src / SMESH_SWIG / SMESH_fixation_tetra.py
1 #! /usr/bin/python
2 #  -*- coding: iso-8859-1 -*-
3 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
4 #
5 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
6 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 #
8 #  This library is free software; you can redistribute it and/or
9 #  modify it under the terms of the GNU Lesser General Public
10 #  License as published by the Free Software Foundation; either
11 #  version 2.1 of the License.
12 #
13 #  This library is distributed in the hope that it will be useful,
14 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 #  Lesser General Public License for more details.
17 #
18 #  You should have received a copy of the GNU Lesser General Public
19 #  License along with this library; if not, write to the Free Software
20 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21 #
22 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
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
50 # ---- init a Mesh with the compshell
51
52 mesh = smesh.Mesh(compshell, "MeshcompShell")
53
54
55 # ---- set Hypothesis and Algorithm
56
57 print "-------------------------- NumberOfSegments"
58
59 numberOfSegments = 5
60
61 regular1D = mesh.Segment()
62 regular1D.SetName("Wire Discretisation")
63 hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
64 print hypNbSeg.GetName()
65 print hypNbSeg.GetId()
66 print hypNbSeg.GetNumberOfSegments()
67 smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
68
69 ## print "-------------------------- MaxElementArea"
70
71 ## maxElementArea = 80
72
73 ## mefisto2D = mesh.Triangle()
74 ## mefisto2D.SetName("MEFISTO_2D")
75 ## hypArea = mefisto2D.MaxElementArea(maxElementArea)
76 ## print hypArea.GetName()
77 ## print hypArea.GetId()
78 ## print hypArea.GetMaxElementArea()
79 ## smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
80
81 print "-------------------------- LengthFromEdges"
82
83 mefisto2D = mesh.Triangle()
84 mefisto2D.SetName("MEFISTO_2D")
85 hypLengthFromEdges = mefisto2D.LengthFromEdges()
86 print hypLengthFromEdges.GetName()
87 print hypLengthFromEdges.GetId()
88 smesh.SetName(hypLengthFromEdges, "LengthFromEdges")
89
90
91 print "-------------------------- MaxElementVolume"
92
93 maxElementVolume = 1000
94
95 netgen3D = mesh.Tetrahedron(smesh.NETGEN)
96 netgen3D.SetName("NETGEN_3D")
97 hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
98 print hypVolume.GetName()
99 print hypVolume.GetId()
100 print hypVolume.GetMaxElementVolume()
101 smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume))
102
103
104 salome.sg.updateObjBrowser(1)
105
106 print "-------------------------- compute compshell"
107 ret = mesh.Compute(mesh)
108 print ret
109 if ret != 0:
110     log = mesh.GetLog(0) # no erase trace
111     for linelog in log:
112         print linelog
113     print "Information about the MeshcompShel:"
114     print "Number of nodes        : ", mesh.NbNodes()
115     print "Number of edges        : ", mesh.NbEdges()
116     print "Number of faces        : ", mesh.NbFaces()
117     print "Number of triangles    : ", mesh.NbTriangles()
118     print "Number of volumes      : ", mesh.NbVolumes()
119     print "Number of tetrahedrons : ", mesh.NbTetras()
120     
121 else:
122     print "problem when computing the mesh"