Salome HOME
542fdce4bbb861994c251097dc81e971cd322667
[modules/smesh.git] / src / SMESH_SWIG / SMESH_fixation_netgen.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2015  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, or (at your option) any later version.
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 # The new Netgen algorithm is used that discretizes baoundaries itself
27 #
28 import salome
29 import SMESH_fixation
30
31 import SMESH, SALOMEDS
32 from salome.smesh import smeshBuilder
33 smesh =  smeshBuilder.New(salome.myStudy)
34
35 compshell = SMESH_fixation.compshell
36 idcomp = SMESH_fixation.idcomp
37 geompy = SMESH_fixation.geompy
38 salome = SMESH_fixation.salome
39
40 print "Analysis of the geometry to be meshed :"
41 subShellList = geompy.SubShapeAll(compshell, geompy.ShapeType["SHELL"])
42 subFaceList  = geompy.SubShapeAll(compshell, geompy.ShapeType["FACE"])
43 subEdgeList  = geompy.SubShapeAll(compshell, geompy.ShapeType["EDGE"])
44
45 print "number of Shells in compshell : ", len(subShellList)
46 print "number of Faces  in compshell : ", len(subFaceList)
47 print "number of Edges  in compshell : ", len(subEdgeList)
48
49 status = geompy.CheckShape(compshell)
50 print " check status ", status
51
52 ### ---------------------------- SMESH --------------------------------------
53 smesh.SetCurrentStudy(salome.myStudy)
54
55 print "-------------------------- create Mesh, algorithm, hypothesis"
56
57 mesh = smesh.Mesh(compshell, "MeshcompShel");
58 netgen = mesh.Tetrahedron(smeshBuilder.FULL_NETGEN)
59 netgen.SetMaxSize( 50 )
60 #netgen.SetSecondOrder( 0 )
61 netgen.SetFineness( smeshBuilder.Fine )
62 #netgen.SetOptimize( 1 )
63
64 salome.sg.updateObjBrowser(1)
65
66 print "-------------------------- compute mesh"
67 ret = mesh.Compute()
68 print ret
69 if ret != 0:
70     print "Information about the MeshcompShel:"
71     print "Number of nodes        : ", mesh.GetMesh().NbNodes()
72     print "Number of edges        : ", mesh.GetMesh().NbEdges()
73     print "Number of faces        : ", mesh.GetMesh().NbFaces()
74     print "Number of triangles    : ", mesh.GetMesh().NbTriangles()
75     print "Number of volumes      : ", mesh.GetMesh().NbVolumes()
76     print "Number of tetrahedrons : ", mesh.GetMesh().NbTetras()
77     
78 else:
79     print "problem when computing the mesh"