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