1 # Construction of a Sub-mesh
4 salome.salome_init_without_session()
6 from salome.geom import geomBuilder
7 from salome.smesh import smeshBuilder
9 geom_builder = geomBuilder.New()
10 smesh_builder = smeshBuilder.New()
13 box = geom_builder.MakeBoxDXDYDZ(10., 10., 10.)
14 geom_builder.addToStudy(box, "Box")
16 # select one edge of the box for definition of a local hypothesis
17 p5 = geom_builder.MakeVertex(5., 0., 0.)
18 EdgeX = geom_builder.GetEdgeNearPoint(box, p5)
19 geom_builder.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
21 # create a hexahedral mesh on the box
22 mesh = smesh_builder.Mesh(box, "Box : hexahedral 3D mesh")
24 # create a Regular_1D algorithm for discretization of edges
25 algo1D = mesh.Segment()
27 # define "NumberOfSegments" hypothesis to cut
28 # all the edges in a fixed number of segments
29 algo1D.NumberOfSegments(4)
31 # create a quadrangle 2D algorithm for the faces
34 # construct a sub-mesh on the edge with a local Regular_1D algorithm
35 algo_local = mesh.Segment(EdgeX)
37 # define "Arithmetic1D" hypothesis to cut EdgeX in several segments with length arithmetically
38 # increasing from 1.0 to 4.0
39 algo_local.Arithmetic1D(1, 4)
41 # define "Propagation" hypothesis that propagates algo_local and "Arithmetic1D" hypothesis
42 # from EdgeX to all parallel edges
43 algo_local.Propagation()
45 # assign a hexahedral algorithm
48 # any sub-shape can be meshed individually --
49 # compute mesh on two surfaces using different methods
52 surfaces = geom_builder.SubShapeAll(box, geom_builder.ShapeType["FACE"])
54 # method 1: no sub-mesh is created
55 if not mesh.Compute( surfaces[0] ): raise Exception("Error when computing Mesh")
57 # method 2: a sub-mesh is created
58 submesh = mesh.GetSubMesh( surfaces[2], "submesh 2" )
59 if not submesh.Compute(): raise Exception("Error when computing Mesh")
61 # compute the whole mesh
62 if not mesh.Compute(): raise Exception("Error when computing Mesh")