Salome HOME
0023580: [EDF] AsterStudy: more distinct display of selected items in 3D view
[modules/smesh.git] / doc / salome / examples / creating_meshes_ex02.py
1 # Construction of a Sub-mesh
2
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8
9 import SMESH, SALOMEDS
10 from salome.smesh import smeshBuilder
11 smesh =  smeshBuilder.New(salome.myStudy)
12
13 # create a box
14 box = geompy.MakeBoxDXDYDZ(10., 10., 10.)
15 geompy.addToStudy(box, "Box")
16
17 # select one edge of the box for definition of a local hypothesis
18 p5 = geompy.MakeVertex(5., 0., 0.)
19 EdgeX = geompy.GetEdgeNearPoint(box, p5)
20 geompy.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
21
22 # create a hexahedral mesh on the box
23 mesh = smesh.Mesh(box, "Box : hexahedral 3D mesh")
24
25 # create a Regular_1D algorithm for discretization of edges
26 algo1D = mesh.Segment()
27
28 # define "NumberOfSegments" hypothesis to cut
29 # all the edges in a fixed number of segments
30 algo1D.NumberOfSegments(4)
31
32 # create a quadrangle 2D algorithm for the faces
33 mesh.Quadrangle()
34
35 # construct a sub-mesh on the edge with a local Regular_1D algorithm
36 algo_local = mesh.Segment(EdgeX)
37
38 # define "Arithmetic1D" hypothesis to cut EdgeX in several segments with length arithmetically
39 # increasing from 1.0 to 4.0
40 algo_local.Arithmetic1D(1, 4)
41
42 # define "Propagation" hypothesis that propagates algo_local and "Arithmetic1D" hypothesis
43 # from EdgeX to all parallel edges
44 algo_local.Propagation()
45
46 # assign a hexahedral algorithm
47 mesh.Hexahedron()
48
49
50 # any sub-shape can be meshed individually --
51 # compute mesh on two surfaces using different methods
52
53 # get surfaces
54 surfaces = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
55
56 # method 1: no sub-mesh is created
57 mesh.Compute( surfaces[0] )
58
59 # method 2: a sub-mesh is created
60 submesh = mesh.GetSubMesh( surfaces[2], "submesh 2" )
61 submesh.Compute()
62
63
64
65 # compute the whole mesh
66 mesh.Compute()