X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=doc%2Fsalome%2Fexamples%2Fcartesian_algo.py;h=d7d64b8b7617bfbb8e813f812b52ea0509b3cb1e;hb=13e344b8720248d920a39505004bb9a889a0b2d7;hp=6472c053ec403c4918cd04ae5496e6639a9611b6;hpb=264eeb2edd6977ccf2d2bd88cbb210353f63f7c9;p=modules%2Fsmesh.git diff --git a/doc/salome/examples/cartesian_algo.py b/doc/salome/examples/cartesian_algo.py index 6472c053e..d7d64b8b7 100644 --- a/doc/salome/examples/cartesian_algo.py +++ b/doc/salome/examples/cartesian_algo.py @@ -10,46 +10,68 @@ geompy = geomBuilder.New() import SMESH, SALOMEDS from salome.smesh import smeshBuilder smesh = smeshBuilder.New() -import salome_notebook # create a sphere sphere = geompy.MakeSphereR( 50 ) -geompy.addToStudy( sphere, "sphere" ) + +# cut the sphere by a box +box = geompy.MakeBoxDXDYDZ( 100, 100, 100 ) +partition = geompy.MakePartition([ sphere ], [ box ], theName="partition") # create a mesh and assign a "Body Fitting" algo -mesh = smesh.Mesh( sphere ) +mesh = smesh.Mesh( partition ) cartAlgo = mesh.BodyFitted() # define a cartesian grid using Coordinates -coords = range(-100,100,10) +coords = list(range(-100,100,10)) cartHyp = cartAlgo.SetGrid( coords,coords,coords, 1000000) # compute the mesh mesh.Compute() -print "nb hexahedra",mesh.NbHexas() -print "nb tetrahedra",mesh.NbTetras() -print "nb polyhedra",mesh.NbPolyhedrons() -print +print("nb hexahedra",mesh.NbHexas()) +print("nb tetrahedra",mesh.NbTetras()) +print("nb polyhedra",mesh.NbPolyhedrons()) +print() # define the grid by setting constant spacing cartHyp = cartAlgo.SetGrid( "10","10","10", 1000000) mesh.Compute() -print "nb hexahedra",mesh.NbHexas() -print "nb tetrahedra",mesh.NbTetras() -print "nb polyhedra",mesh.NbPolyhedrons() +print("nb hexahedra",mesh.NbHexas()) +print("nb tetrahedra",mesh.NbTetras()) +print("nb polyhedra",mesh.NbPolyhedrons()) +print("nb faces",mesh.NbFaces()) +print() + +# activate creation of faces +cartHyp.SetToCreateFaces( True ) +mesh.Compute() +print("nb hexahedra",mesh.NbHexas()) +print("nb tetrahedra",mesh.NbTetras()) +print("nb polyhedra",mesh.NbPolyhedrons()) +print("nb faces",mesh.NbFaces()) +print() + +# enable consideration of shared faces +cartHyp.SetToConsiderInternalFaces( True ) +mesh.Compute() +print("nb hexahedra",mesh.NbHexas()) +print("nb tetrahedra",mesh.NbTetras()) +print("nb polyhedra",mesh.NbPolyhedrons()) +print("nb faces",mesh.NbFaces()) +print() # define the grid by setting different spacing in 2 sub-ranges of geometry spaceFuns = ["5","10+10*t"] cartAlgo.SetGrid( [spaceFuns, [0.5]], [spaceFuns, [0.5]], [spaceFuns, [0.25]], 10 ) mesh.Compute() -print "nb hexahedra",mesh.NbHexas() -print "nb tetrahedra",mesh.NbTetras() -print "nb polyhedra",mesh.NbPolyhedrons() -print +print("nb hexahedra",mesh.NbHexas()) +print("nb tetrahedra",mesh.NbTetras()) +print("nb polyhedra",mesh.NbPolyhedrons()) +print() # Example of customization of dirtections of the grid axes @@ -67,23 +89,23 @@ mesh = smesh.Mesh( box, "custom axes") algo = mesh.BodyFitted() algo.SetGrid( spc, spc, spc, 10000 ) mesh.Compute() -print "Default axes" -print " nb hex:",mesh.NbHexas() +print("Default axes") +print(" nb hex:",mesh.NbHexas()) # set axes using edges of the box algo.SetAxesDirs( xDir, [-0.1,1,0], zDir ) mesh.Compute() -print "Manual axes" -print " nb hex:",mesh.NbHexas() +print("Manual axes") +print(" nb hex:",mesh.NbHexas()) # set optimal orthogonal axes algo.SetOptimalAxesDirs( isOrthogonal=True ) mesh.Compute() -print "Optimal orthogonal axes" -print " nb hex:",mesh.NbHexas() +print("Optimal orthogonal axes") +print(" nb hex:",mesh.NbHexas()) # set optimal non-orthogonal axes algo.SetOptimalAxesDirs( isOrthogonal=False ) mesh.Compute() -print "Optimal non-orthogonal axes" -print " nb hex:",mesh.NbHexas() +print("Optimal non-orthogonal axes") +print(" nb hex:",mesh.NbHexas())