1 # Usage of Body Fitting algorithm
7 from salome.geom import geomBuilder
8 geompy = geomBuilder.New()
10 import SMESH, SALOMEDS
11 from salome.smesh import smeshBuilder
12 smesh = smeshBuilder.New()
16 sphere = geompy.MakeSphereR( 50 )
17 geompy.addToStudy( sphere, "sphere" )
19 # create a mesh and assign a "Body Fitting" algo
20 mesh = smesh.Mesh( sphere )
21 cartAlgo = mesh.BodyFitted()
23 # define a cartesian grid using Coordinates
24 coords = list(range(-100,100,10))
25 cartHyp = cartAlgo.SetGrid( coords,coords,coords, 1000000)
29 print("nb hexahedra",mesh.NbHexas())
30 print("nb tetrahedra",mesh.NbTetras())
31 print("nb polyhedra",mesh.NbPolyhedrons())
34 # define the grid by setting constant spacing
35 cartHyp = cartAlgo.SetGrid( "10","10","10", 1000000)
38 print("nb hexahedra",mesh.NbHexas())
39 print("nb tetrahedra",mesh.NbTetras())
40 print("nb polyhedra",mesh.NbPolyhedrons())
43 # define the grid by setting different spacing in 2 sub-ranges of geometry
44 spaceFuns = ["5","10+10*t"]
45 cartAlgo.SetGrid( [spaceFuns, [0.5]], [spaceFuns, [0.5]], [spaceFuns, [0.25]], 10 )
48 print("nb hexahedra",mesh.NbHexas())
49 print("nb tetrahedra",mesh.NbTetras())
50 print("nb polyhedra",mesh.NbPolyhedrons())
53 # Example of customization of dirtections of the grid axes
55 # make a box with non-orthogonal edges
56 xDir = geompy.MakeVectorDXDYDZ( 1.0, 0.1, 0.0, "xDir" )
57 yDir = geompy.MakeVectorDXDYDZ(-0.1, 1.0, 0.0, "yDir" )
58 zDir = geompy.MakeVectorDXDYDZ( 0.2, 0.3, 1.0, "zDir" )
59 face = geompy.MakePrismVecH( xDir, yDir, 1.0 )
60 box = geompy.MakePrismVecH( face, zDir, 1.0, theName="box" )
65 mesh = smesh.Mesh( box, "custom axes")
66 algo = mesh.BodyFitted()
67 algo.SetGrid( spc, spc, spc, 10000 )
70 print(" nb hex:",mesh.NbHexas())
72 # set axes using edges of the box
73 algo.SetAxesDirs( xDir, [-0.1,1,0], zDir )
76 print(" nb hex:",mesh.NbHexas())
78 # set optimal orthogonal axes
79 algo.SetOptimalAxesDirs( isOrthogonal=True )
81 print("Optimal orthogonal axes")
82 print(" nb hex:",mesh.NbHexas())
84 # set optimal non-orthogonal axes
85 algo.SetOptimalAxesDirs( isOrthogonal=False )
87 print("Optimal non-orthogonal axes")
88 print(" nb hex:",mesh.NbHexas())