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