Salome HOME
Merge from V6_main 01/04/2013
[modules/smesh.git] / src / SMESH_SWIG / SMESH_hexaedre.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2013  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 import salome
24 import geompy
25 import smesh
26
27 # -----------------------------------------------------------------------------
28
29 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
30
31 p0 = geompy.MakeVertex(0., 0., 0.)
32 px = geompy.MakeVertex(100., 0., 0.)
33 py = geompy.MakeVertex(0., 100., 0.)
34 pz = geompy.MakeVertex(0., 0., 100.)
35 vx = geompy.MakeVector(p0, px)
36 vy = geompy.MakeVector(p0, py)
37 vz = geompy.MakeVector(p0, pz)
38
39 sphereExt = geompy.MakeSphere(    0.,  0.,  0., 400.)
40 sphereInt = geompy.MakeSphere(    0.,-50.,  0., 350.)
41 sphereA   = geompy.MakeSphere( -400., 50., 50., 400.)
42 sphereB   = geompy.MakeSphere(  350.,-50.,-50., 350.)
43 ptcyle    = geompy.MakeVertex(0., -300., -450.)
44 cylindre  = geompy.MakeCylinder(ptcyle,vz,500.,900.)
45
46 vol1=geompy.MakeCut(sphereExt,sphereA)
47 vol2=geompy.MakeCut(vol1,sphereB)
48 vol3=geompy.MakeCut(vol2,cylindre)
49 blob=geompy.MakeCut(vol3,sphereInt)
50
51 idblob = geompy.addToStudy(blob,"blob")
52
53 edgeGroups = geompy.Propagate( blob )
54 assert len( edgeGroups ) == 3
55
56 salome.sg.updateObjBrowser(1)
57
58 # -----------------------------------------------------------------------------
59
60 print "-------------------------- mesh"
61 smesh.SetCurrentStudy(salome.myStudy)
62
63 # ---- define a mesh on the geom shape 'blob'
64 mesh=smesh.Mesh(blob, "MeshBlob")
65
66 # ---- assign global hypothesis and algorithms to mesh
67 print "-------------------------- add hypothesis to mesh"
68 algo1 = mesh.Segment()
69 algo2 = mesh.Quadrangle()
70 algo3 = mesh.Hexahedron()
71
72 # ---- assign local hypothesis and algorithms to mesh
73 for edges in edgeGroups: # loop on groups of logically parallel edges
74     length = geompy.BasicProperties( edges )[0]
75     if   length < 500:  nbSeg = 4
76     elif length < 2000: nbSeg = 10
77     else:               nbSeg = 15
78     algo = mesh.Segment( edges )
79     algo.NumberOfSegments( nbSeg )
80     pass
81
82 # ---- compute mesh
83 print "-------------------------- compute mesh"
84 ok = mesh.Compute()
85 if ok:
86     print "Information about the Mesh:"
87     print "Number of nodes       : ", mesh.NbNodes()
88     print "Number of edges       : ", mesh.NbEdges()
89     print "Number of faces       : ", mesh.NbFaces()
90     print "Number of quadrangles : ", mesh.NbQuadrangles()
91     print "Number of volumes     : ", mesh.NbVolumes()
92     print "Number of hexahedrons : ", mesh.NbHexas()
93 else:
94     print "problem when Computing the mesh"
95
96 salome.sg.updateObjBrowser(1)