Salome HOME
Merge from V6_main 28/02/2013
[modules/smesh.git] / doc / salome / examples / cartesian_algo.py
1 # Usage of Body Fitting algorithm
2
3 from smesh import *
4 SetCurrentStudy(salome.myStudy)
5
6 # create a sphere
7 sphere = geompy.MakeSphereR( 50 )
8 geompy.addToStudy( sphere, "sphere" )
9
10 # create a mesh and assign a "Body Fitting" algo
11 mesh = Mesh( sphere )
12 cartAlgo = mesh.BodyFitted()
13
14 # define a cartesian grid using Coordinates
15 coords = range(-100,100,10)
16 cartHyp = cartAlgo.SetGrid( coords,coords,coords, 1000000)
17
18 # compute the mesh
19 mesh.Compute()
20 print "nb hexahedra",mesh.NbHexas()
21 print "nb tetrahedra",mesh.NbTetras()
22 print "nb polyhedra",mesh.NbPolyhedrons()
23 print
24
25 # define the grid by setting constant spacing
26 cartHyp = cartAlgo.SetGrid( "10","10","10", 1000000)
27
28 mesh.Compute()
29 print "nb hexahedra",mesh.NbHexas()
30 print "nb tetrahedra",mesh.NbTetras()
31 print "nb polyhedra",mesh.NbPolyhedrons()
32
33
34 # define the grid by setting different spacing in 2 sub-ranges of geometry
35 spaceFuns = ["5","10+10*t"]
36 cartAlgo.SetGrid( [spaceFuns, [0.5]], [spaceFuns, [0.5]], [spaceFuns, [0.25]], 10 )
37
38 mesh.Compute()
39 print "nb hexahedra",mesh.NbHexas()
40 print "nb tetrahedra",mesh.NbTetras()
41 print "nb polyhedra",mesh.NbPolyhedrons()
42 print