1 # Building a compound of meshes
4 salome.salome_init_without_session()
5 from salome.geom import geomBuilder
6 geompy = geomBuilder.New()
7 from salome.smesh import smeshBuilder
8 smesh = smeshBuilder.New()
10 ## create a bottom box
11 Box_inf = geompy.MakeBox(0., 0., 0., 200., 200., 50.)
14 Psup1=geompy.MakeVertex(100., 100., 50.)
15 Fsup1=geompy.GetFaceNearPoint(Box_inf, Psup1)
17 Pinf1=geompy.MakeVertex(100., 100., 0.)
18 Finf1=geompy.GetFaceNearPoint(Box_inf, Pinf1)
21 Box_sup = geompy.MakeBox(100., 100., 50., 200., 200., 100.)
24 Psup2=geompy.MakeVertex(150., 150., 100.)
25 Fsup2=geompy.GetFaceNearPoint(Box_sup, Psup2)
27 Pinf2=geompy.MakeVertex(150., 150., 50.)
28 Finf2=geompy.GetFaceNearPoint(Box_sup, Pinf2)
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")
35 geompy.addToStudy(Box_sup, "Box_sup")
36 geompy.addToStudyInFather(Box_sup, Fsup2, "Fsup")
37 geompy.addToStudyInFather(Box_sup, Finf2, "Finf")
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()
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")
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()
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")
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')
77 # copy Gsup1 into a separate mesh and translate it
78 groupMesh = Mesh_inf.TranslateObjectMakeMesh( Gsup1, [300,0,0] )
80 # add Ginf2 to groupMesh
81 smesh.Concatenate([Ginf2], False, meshToAppendTo = groupMesh )
84 if salome.sg.hasDesktop():
85 salome.sg.updateObjBrowser()