X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=doc%2Fexamples%2Fa3DmeshOnModified2Dmesh.py;fp=doc%2Fexamples%2Fa3DmeshOnModified2Dmesh.py;h=fb49f873c8b79525782bc063b1129dd9ec460592;hp=0000000000000000000000000000000000000000;hb=4cf07a14111e98e8889620ee7e6371574c31a50c;hpb=d9f4b53e489dd5857db264ede6acded7b076c9f1 diff --git a/doc/examples/a3DmeshOnModified2Dmesh.py b/doc/examples/a3DmeshOnModified2Dmesh.py new file mode 100644 index 000000000..fb49f873c --- /dev/null +++ b/doc/examples/a3DmeshOnModified2Dmesh.py @@ -0,0 +1,62 @@ +import salome +salome.salome_init_without_session() + +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +# This script demonstrates generation of 3D mesh basing on a modified 2D mesh +# +# Purpose is to get a tetrahedral mesh in a sphere cut by a cube. +# The requirement is to have a surface mesh on the cube comprised of +# triangles of exactly the same size arranged in a grid pattern. +# +# To fulfill this requirement we mesh the box using Quadrangle: Mapping +# meshing algorithm, split quadrangles into triangles and then generate +# tetrahedrons. + + +# Make the geometry + +Box_1 = geompy.MakeBox(-100,-100,-100, 100, 100, 100) +Sphere_1 = geompy.MakeSphereR( 300 ) +Cut_1 = geompy.MakeCut(Sphere_1, Box_1, theName="Cut_1") +# get a spherical face +Sph_Face = geompy.ExtractShapes( Sphere_1, geompy.ShapeType["FACE"] )[0] + +# get the shape Sph_Face turned into during MakeCut() +Sph_Face = geompy.GetInPlace(Cut_1, Sph_Face, isNewImplementation=True, theName="Sphere_1") + + +# 1) Define a mesh with 1D and 2D meshers + +import SMESH +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +Mesh_1 = smesh.Mesh(Cut_1) + +# "global" meshers (assigned to Cut_1) that will be used for the box +Regular_1D = Mesh_1.Segment() +Local_Length_1 = Regular_1D.LocalLength(20) +Quadrangle_2D = Mesh_1.Quadrangle() + +# a "local" mesher (assigned to a sub-mesh on Sphere_1) to mesh the sphere +algo_2D = Mesh_1.Triangle( smeshBuilder.NETGEN_1D2D, Sph_Face ) +algo_2D.SetMaxSize( 70. ) +algo_2D.SetFineness( smeshBuilder.Moderate ) +algo_2D.SetMinSize( 7. ) + +# 2) Compute 2D mesh +isDone = Mesh_1.Compute() + +# 3) Split quadrangles into triangles +isDone = Mesh_1.SplitQuadObject( Mesh_1, Diag13=True ) + +# 4) Define a 3D mesher +Mesh_1.Tetrahedron() + +# 5) Compute 3D mesh +Mesh_1.Compute() + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser()