1 # Create boundary elements
7 from salome.geom import geomBuilder
8 geompy = geomBuilder.New()
10 import SMESH, SALOMEDS
11 from salome.smesh import smeshBuilder
12 smesh = smeshBuilder.New()
13 import salome_notebook
16 box = geompy.MakeBoxDXDYDZ(100, 100, 100)
17 gFaces = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"])
18 f1,f2 = gFaces[0],gFaces[1]
19 geompy.addToStudy(box,"box")
20 geompy.addToStudyInFather(box,f1,"face1")
21 geompy.addToStudyInFather(box,f2,"face2")
23 twoFaces = geompy.MakeCompound([f1,f2])
30 dim = SMESH.BND_2DFROM3D
32 init_mesh = smesh.Mesh(box, "box")
33 init_mesh.AutomaticHexahedralization() # it makes 3 x 3 x 3 hexahedrons
36 faces = init_mesh.GetElementsByType( SMESH.FACE )
37 nb_faces = len( faces )
38 rm_face = faces[ : nb_faces // 2]
39 init_mesh.RemoveElements( rm_face )
41 # restore boundary in this mesh
42 mesh = smesh.CopyMesh( init_mesh, "2D from 3D")
44 nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName)
46 # restore boundary (only) in other mesh
47 meshName = "2D boundary of " + init_mesh.GetName()
48 nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName)
50 # restore boundary in mesh copy
51 meshName = init_mesh.GetName() + " + boundary"
52 nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName, toCopyAll=True)
60 dim = SMESH.BND_1DFROM2D
62 init_mesh = smesh.Mesh(f1, "2D mesh")
63 init_mesh.AutomaticHexahedralization()
66 edges = init_mesh.GetElementsByType( SMESH.EDGE )
67 nb_edges = len( edges )
68 rm_edge = edges[ : nb_edges // 2]
69 init_mesh.RemoveElements( rm_edge )
72 # restore boundary edges in this mesh
73 mesh = smesh.CopyMesh( init_mesh, "1D from 2D")
75 nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName)
77 # restore boundary edges (only) in other mesh
78 meshName = "1D boundary of " + init_mesh.GetName()
79 nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName)
81 # restore boundary edges in mesh copy
82 meshName = init_mesh.GetName() + " + boundary"
83 nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName, toCopyAll=True)
92 dim = SMESH.BND_1DFROM3D
94 init_mesh = smesh.Mesh(box, "box")
95 init_mesh.AutomaticHexahedralization() # it makes 3 x 3 x 3 hexahedrons
97 rm_edges = init_mesh.GetElementsByType( SMESH.EDGE )
98 init_mesh.RemoveElements( rm_edges )
100 # make groups of faces
101 fGroup1 = init_mesh.Group( f1, "f1" )
102 fGroup2 = init_mesh.Group( f2, "f2" )
104 # make 1D boundary around groups in this mesh
105 mesh = smesh.CopyMesh( init_mesh, "1D from 2D groups", toCopyGroups=True)
106 groups = mesh.GetGroups()
107 nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName,groups=groups)
109 # make 1D boundary (only) in other mesh
110 meshName = "boundary from groups of " + init_mesh.GetName()
111 groups = init_mesh.GetGroups()
112 nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName,groups=groups)
114 # make 1D boundary in mesh copy
115 meshName = init_mesh.GetName() + " + boundary from groups"
116 nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName,
117 groups=groups, toCopyAll=True)