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