Salome HOME
bos #29171 Refactor testing procedure
[modules/smesh.git] / doc / examples / creating_meshes_ex07.py
1 # Building a compound of meshes
2
3 import salome
4 salome.salome_init_without_session()
5
6 from salome.geom import geomBuilder
7 from salome.smesh import smeshBuilder
8
9 geom_builder = geomBuilder.New()
10 smesh_builder = smeshBuilder.New()
11
12 ## create a bottom box
13 Box_inf = geom_builder.MakeBox(0., 0., 0., 200., 200., 50.)
14
15 # get a top face
16 Psup1=geom_builder.MakeVertex(100., 100., 50.)
17 Fsup1=geom_builder.GetFaceNearPoint(Box_inf, Psup1)
18 # get a bottom face
19 Pinf1=geom_builder.MakeVertex(100., 100., 0.)
20 Finf1=geom_builder.GetFaceNearPoint(Box_inf, Pinf1)
21
22 ## create a top box
23 Box_sup = geom_builder.MakeBox(100., 100., 50., 200., 200., 100.)
24
25 # get a top face
26 Psup2=geom_builder.MakeVertex(150., 150., 100.)
27 Fsup2=geom_builder.GetFaceNearPoint(Box_sup, Psup2)
28 # get a bottom face
29 Pinf2=geom_builder.MakeVertex(150., 150., 50.)
30 Finf2=geom_builder.GetFaceNearPoint(Box_sup, Pinf2)
31
32 ## Publish in the study
33 geom_builder.addToStudy(Box_inf, "Box_inf")
34 geom_builder.addToStudyInFather(Box_inf, Fsup1, "Fsup")
35 geom_builder.addToStudyInFather(Box_inf, Finf1, "Finf")
36
37 geom_builder.addToStudy(Box_sup, "Box_sup")
38 geom_builder.addToStudyInFather(Box_sup, Fsup2, "Fsup")
39 geom_builder.addToStudyInFather(Box_sup, Finf2, "Finf")
40
41 smesh_builder.UpdateStudy()
42
43 ## create a bottom mesh
44 Mesh_inf = smesh_builder.Mesh(Box_inf, "Mesh_inf")
45 algo1D_1=Mesh_inf.Segment()
46 algo1D_1.NumberOfSegments(10)
47 algo2D_1=Mesh_inf.Quadrangle()
48 algo3D_1=Mesh_inf.Hexahedron()
49 Mesh_inf.Compute()
50
51 # create a group on the top face
52 Gsup1=Mesh_inf.Group(Fsup1, "Sup")
53 # create a group on the bottom face
54 Ginf1=Mesh_inf.Group(Finf1, "Inf")
55
56 ## create a top mesh
57 Mesh_sup = smesh_builder.Mesh(Box_sup, "Mesh_sup")
58 algo1D_2=Mesh_sup.Segment()
59 algo1D_2.NumberOfSegments(5)
60 algo2D_2=Mesh_sup.Quadrangle()
61 algo3D_2=Mesh_sup.Hexahedron()
62 Mesh_sup.Compute()
63
64 # create a group on the top face
65 Gsup2=Mesh_sup.Group(Fsup2, "Sup")
66 # create a group on the bottom face
67 Ginf2=Mesh_sup.Group(Finf2, "Inf")
68
69 ## create compounds
70 # create a compound of two meshes with renaming namesake groups and
71 # merging elements with the given tolerance
72 Compound1 = smesh_builder.Concatenate([Mesh_inf, Mesh_sup], 0, 1, 1e-05,
73                                       name='Compound with RenamedGrps and MergeElems')
74 # create a compound of two meshes with uniting namesake groups and
75 # creating groups of all elements
76 Compound2 = smesh_builder.Concatenate([Mesh_inf, Mesh_sup], 1, 0, 1e-05, True,
77                                       name='Compound with UniteGrps and GrpsOfAllElems')
78
79 # copy Gsup1 into a separate mesh and translate it
80 groupMesh = Mesh_inf.TranslateObjectMakeMesh( Gsup1, [300,0,0] )
81
82 # add Ginf2 to groupMesh
83 smesh_builder.Concatenate([Ginf2], False, meshToAppendTo = groupMesh )
84
85 if salome.sg.hasDesktop():
86     salome.sg.updateObjBrowser()