X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=doc%2Fsalome%2Fexamples%2Fcreating_meshes_ex02.py;h=230e67a00f8f9ec9886c5288fc37d5941c5d3677;hb=83b0c984cc12946923dc2640d68ba3a2700faa28;hp=c541b4add7301c5b20bbe025937bdb7126bf3a5b;hpb=9a54694a0ab1e5cbc558a35c4606ceea4f7af2ef;p=modules%2Fsmesh.git diff --git a/doc/salome/examples/creating_meshes_ex02.py b/doc/salome/examples/creating_meshes_ex02.py index c541b4add..230e67a00 100644 --- a/doc/salome/examples/creating_meshes_ex02.py +++ b/doc/salome/examples/creating_meshes_ex02.py @@ -1,39 +1,66 @@ -# Construction of a Submesh +# Construction of a Sub-mesh -from geompy import * -import smesh +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create a box -box = MakeBoxDXDYDZ(10., 10., 10.) -addToStudy(box, "Box") +box = geompy.MakeBoxDXDYDZ(10., 10., 10.) +geompy.addToStudy(box, "Box") # select one edge of the box for definition of a local hypothesis -p5 = MakeVertex(5., 0., 0.) -EdgeX = GetEdgeNearPoint(box, p5) -addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]") +p5 = geompy.MakeVertex(5., 0., 0.) +EdgeX = geompy.GetEdgeNearPoint(box, p5) +geompy.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]") # create a hexahedral mesh on the box -quadra = smesh.Mesh(box, "Box : quadrangle 2D mesh") +mesh = smesh.Mesh(box, "Box : hexahedral 3D mesh") -# create a regular 1D algorithm for the faces -algo1D = quadra.Segment() +# create a Regular_1D algorithm for discretization of edges +algo1D = mesh.Segment() # define "NumberOfSegments" hypothesis to cut # all the edges in a fixed number of segments algo1D.NumberOfSegments(4) # create a quadrangle 2D algorithm for the faces -quadra.Quadrangle() +mesh.Quadrangle() -# construct a submesh on the edge with a local hypothesis -algo_local = quadra.Segment(EdgeX) +# construct a sub-mesh on the edge with a local Regular_1D algorithm +algo_local = mesh.Segment(EdgeX) -# define "Arithmetic1D" hypothesis to cut the edge in several segments with increasing arithmetic length +# define "Arithmetic1D" hypothesis to cut EdgeX in several segments with length arithmetically +# increasing from 1.0 to 4.0 algo_local.Arithmetic1D(1, 4) -# define "Propagation" hypothesis that propagates all other hypotheses -# on all edges of the opposite side in case of quadrangular faces +# define "Propagation" hypothesis that propagates algo_local and "Arithmetic1D" hypothesis +# from EdgeX to all parallel edges algo_local.Propagation() -# compute the mesh -quadra.Compute() +# assign a hexahedral algorithm +mesh.Hexahedron() + + +# any sub-shape can be meshed individually -- +# compute mesh on two surfaces using different methods + +# get surfaces +surfaces = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) + +# method 1: no sub-mesh is created +mesh.Compute( surfaces[0] ) + +# method 2: a sub-mesh is created +submesh = mesh.GetSubMesh( surfaces[2], "submesh 2" ) +submesh.Compute() + + + +# compute the whole mesh +mesh.Compute()