1 # Usage of Body Fitting algorithm
7 from salome.geom import geomBuilder
8 geompy = geomBuilder.New(salome.myStudy)
10 import SMESH, SALOMEDS
11 from salome.smesh import smeshBuilder
12 smesh = smeshBuilder.New(salome.myStudy)
13 import salome_notebook
17 sphere = geompy.MakeSphereR( 50 )
18 geompy.addToStudy( sphere, "sphere" )
20 # create a mesh and assign a "Body Fitting" algo
21 mesh = smesh.Mesh( sphere )
22 cartAlgo = mesh.BodyFitted()
24 # define a cartesian grid using Coordinates
25 coords = list(range(-100,100,10))
26 cartHyp = cartAlgo.SetGrid( coords,coords,coords, 1000000)
30 print("nb hexahedra",mesh.NbHexas())
31 print("nb tetrahedra",mesh.NbTetras())
32 print("nb polyhedra",mesh.NbPolyhedrons())
35 # define the grid by setting constant spacing
36 cartHyp = cartAlgo.SetGrid( "10","10","10", 1000000)
39 print("nb hexahedra",mesh.NbHexas())
40 print("nb tetrahedra",mesh.NbTetras())
41 print("nb polyhedra",mesh.NbPolyhedrons())
44 # define the grid by setting different spacing in 2 sub-ranges of geometry
45 spaceFuns = ["5","10+10*t"]
46 cartAlgo.SetGrid( [spaceFuns, [0.5]], [spaceFuns, [0.5]], [spaceFuns, [0.25]], 10 )
49 print("nb hexahedra",mesh.NbHexas())
50 print("nb tetrahedra",mesh.NbTetras())
51 print("nb polyhedra",mesh.NbPolyhedrons())
54 # Example of customization of dirtections of the grid axes
56 # make a box with non-orthogonal edges
57 xDir = geompy.MakeVectorDXDYDZ( 1.0, 0.1, 0.0, "xDir" )
58 yDir = geompy.MakeVectorDXDYDZ(-0.1, 1.0, 0.0, "yDir" )
59 zDir = geompy.MakeVectorDXDYDZ( 0.2, 0.3, 1.0, "zDir" )
60 face = geompy.MakePrismVecH( xDir, yDir, 1.0 )
61 box = geompy.MakePrismVecH( face, zDir, 1.0, theName="box" )
66 mesh = smesh.Mesh( box, "custom axes")
67 algo = mesh.BodyFitted()
68 algo.SetGrid( spc, spc, spc, 10000 )
71 print(" nb hex:",mesh.NbHexas())
73 # set axes using edges of the box
74 algo.SetAxesDirs( xDir, [-0.1,1,0], zDir )
77 print(" nb hex:",mesh.NbHexas())
79 # set optimal orthogonal axes
80 algo.SetOptimalAxesDirs( isOrthogonal=True )
82 print("Optimal orthogonal axes")
83 print(" nb hex:",mesh.NbHexas())
85 # set optimal non-orthogonal axes
86 algo.SetOptimalAxesDirs( isOrthogonal=False )
88 print("Optimal non-orthogonal axes")
89 print(" nb hex:",mesh.NbHexas())