1 # Create boundary elements
4 salome.salome_init_without_session()
7 from salome.geom import geomBuilder
8 from salome.smesh import smeshBuilder
10 geom_builder = geomBuilder.New()
11 smesh_builder = smeshBuilder.New()
13 box = geom_builder.MakeBoxDXDYDZ(100, 100, 100)
14 gFaces = geom_builder.SubShapeAllSorted(box, geom_builder.ShapeType["FACE"])
15 f1,f2 = gFaces[0],gFaces[1]
16 geom_builder.addToStudy(box,"box")
17 geom_builder.addToStudyInFather(box,f1,"face1")
18 geom_builder.addToStudyInFather(box,f2,"face2")
20 twoFaces = geom_builder.MakeCompound([f1,f2])
27 dim = SMESH.BND_2DFROM3D
29 init_mesh = smesh_builder.Mesh(box, "box")
30 init_mesh.AutomaticHexahedralization() # it makes 3 x 3 x 3 hexahedrons
33 faces = init_mesh.GetElementsByType( SMESH.FACE )
34 nb_faces = len( faces )
35 rm_face = faces[ : nb_faces // 2]
36 init_mesh.RemoveElements( rm_face )
38 # restore boundary in this mesh
39 mesh = smesh_builder.CopyMesh( init_mesh, "2D from 3D")
41 nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName)
43 # restore boundary (only) in other mesh
44 meshName = "2D boundary of " + init_mesh.GetName()
45 nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName)
47 # restore boundary in mesh copy
48 meshName = init_mesh.GetName() + " + boundary"
49 nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName, toCopyAll=True)
56 dim = SMESH.BND_1DFROM2D
58 init_mesh = smesh_builder.Mesh(f1, "2D mesh")
59 init_mesh.AutomaticHexahedralization()
62 edges = init_mesh.GetElementsByType( SMESH.EDGE )
63 nb_edges = len( edges )
64 rm_edge = edges[ : nb_edges // 2]
65 init_mesh.RemoveElements( rm_edge )
68 # restore boundary edges in this mesh
69 mesh = smesh_builder.CopyMesh( init_mesh, "1D from 2D")
71 nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName)
73 # restore boundary edges (only) in other mesh
74 meshName = "1D boundary of " + init_mesh.GetName()
75 nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName)
77 # restore boundary edges in mesh copy
78 meshName = init_mesh.GetName() + " + boundary"
79 nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName, toCopyAll=True)
86 dim = SMESH.BND_1DFROM3D
88 init_mesh = smesh_builder.Mesh(box, "box")
89 init_mesh.AutomaticHexahedralization() # it makes 3 x 3 x 3 hexahedrons
91 rm_edges = init_mesh.GetElementsByType( SMESH.EDGE )
92 init_mesh.RemoveElements( rm_edges )
94 # make groups of faces
95 fGroup1 = init_mesh.Group( f1, "f1" )
96 fGroup2 = init_mesh.Group( f2, "f2" )
98 # make 1D boundary around groups in this mesh
99 mesh = smesh_builder.CopyMesh( init_mesh, "1D from 2D groups", toCopyGroups=True)
100 groups = mesh.GetGroups()
101 nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName,groups=groups)
103 # make 1D boundary (only) in other mesh
104 meshName = "boundary from groups of " + init_mesh.GetName()
105 groups = init_mesh.GetGroups()
106 nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName,groups=groups)
108 # make 1D boundary in mesh copy
109 meshName = init_mesh.GetName() + " + boundary from groups"
110 nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName,
111 groups=groups, toCopyAll=True)