Salome HOME
3140acee8b877f2a6f4dff513713a55224d73591
[modules/smesh.git] / doc / salome / examples / creating_meshes_ex07.py
1 # Building a compound of meshes
2 # Note: it is a copy of 'SMESH_BuildCompound.py' from SMESH_SWIG
3
4 import salome
5 import geompy
6 import smesh
7
8 ## create a bottom box
9 Box_inf = geompy.MakeBox(0., 0., 0., 200., 200., 50.)
10
11 # get a top face
12 Psup1=geompy.MakeVertex(100., 100., 50.)
13 Fsup1=geompy.GetFaceNearPoint(Box_inf, Psup1)
14 # get a bottom face
15 Pinf1=geompy.MakeVertex(100., 100., 0.)
16 Finf1=geompy.GetFaceNearPoint(Box_inf, Pinf1)
17
18 ## create a top box
19 Box_sup = geompy.MakeBox(100., 100., 50., 200., 200., 100.)
20
21 # get a top face
22 Psup2=geompy.MakeVertex(150., 150., 100.)
23 Fsup2=geompy.GetFaceNearPoint(Box_sup, Psup2)
24 # get a bottom face
25 Pinf2=geompy.MakeVertex(150., 150., 50.)
26 Finf2=geompy.GetFaceNearPoint(Box_sup, Pinf2)
27
28 ## Publish in the study
29 geompy.addToStudy(Box_inf, "Box_inf")
30 geompy.addToStudyInFather(Box_inf, Fsup1, "Fsup")
31 geompy.addToStudyInFather(Box_inf, Finf1, "Finf")
32
33 geompy.addToStudy(Box_sup, "Box_sup")
34 geompy.addToStudyInFather(Box_sup, Fsup2, "Fsup")
35 geompy.addToStudyInFather(Box_sup, Finf2, "Finf")
36
37 smesh.SetCurrentStudy(salome.myStudy)
38
39 ## create a bottom mesh
40 Mesh_inf = smesh.Mesh(Box_inf, "Mesh_inf")
41 algo1D_1=Mesh_inf.Segment()
42 algo1D_1.NumberOfSegments(10)
43 algo2D_1=Mesh_inf.Quadrangle()
44 algo3D_1=Mesh_inf.Hexahedron()
45 Mesh_inf.Compute()
46
47 # create a group on the top face
48 Gsup1=Mesh_inf.Group(Fsup1, "Sup")
49 # create a group on the bottom face
50 Ginf1=Mesh_inf.Group(Finf1, "Inf")
51
52 ## create a top mesh
53 Mesh_sup = smesh.Mesh(Box_sup, "Mesh_sup")
54 algo1D_2=Mesh_sup.Segment()
55 algo1D_2.NumberOfSegments(5)
56 algo2D_2=Mesh_sup.Quadrangle()
57 algo3D_2=Mesh_sup.Hexahedron()
58 Mesh_sup.Compute()
59
60 # create a group on the top face
61 Gsup2=Mesh_sup.Group(Fsup2, "Sup")
62 # create a group on the bottom face
63 Ginf2=Mesh_sup.Group(Finf2, "Inf")
64
65 ## create compounds
66 # create a compound of two meshes with renaming groups with the same names and
67 # merging of elements with the given tolerance
68 Compound1 = smesh.smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 0, 1, 1e-05)
69 smesh.SetName(Compound1, 'Compound_with_RenamedGrps_and_MergeElems')
70 # create a compound of two meshes with uniting groups with the same names and
71 # creating groups of all elements
72 Compound2 = smesh.smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 1, 0, 1e-05, True)
73 smesh.SetName(Compound2, 'Compound_with_UniteGrps_and_GrpsOfAllElems')