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