1 # Duplicate nodes or/and elements
8 from salome.geom import geomBuilder
9 geompy = geomBuilder.New()
12 from salome.smesh import smeshBuilder
13 smesh = smeshBuilder.New()
17 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
19 # Define hexa mesh on a box
20 mesh = smesh.Mesh(box, "Mesh")
21 mesh.Segment().NumberOfSegments(7)
28 # Duplicate nodes only
31 nodes1 = mesh.CreateEmptyGroup( SMESH.NODE, 'nodes1' )
32 nodes1.Add( [ 119, 125, 131, 137 ] )
34 # Group of faces to replace nodes with new ones
35 faces1 = mesh.CreateEmptyGroup( SMESH.FACE, 'faces1' )
36 faces1.Add( [ 144, 151, 158 ] )
39 print("\nMesh before the first nodes duplication:")
40 print("Nodes : ", mesh.NbNodes())
41 print("Edges : ", mesh.NbEdges())
42 print("Quadrangles : ", mesh.NbQuadrangles())
44 groupOfCreatedNodes = mesh.DoubleNodeGroup(nodes1, faces1, theMakeGroup=True)
45 print("New nodes:", groupOfCreatedNodes.GetIDs())
47 print("\nMesh after the first nodes duplication:")
48 print("Nodes : ", mesh.NbNodes())
49 print("Edges : ", mesh.NbEdges())
50 print("Quadrangles : ", mesh.NbQuadrangles())
52 # Duplicate nodes and border elements
55 edges = mesh.CreateEmptyGroup( SMESH.EDGE, 'edges' )
56 edges.Add( [ 32, 33, 34 ] )
58 # Nodes not to duplicate
59 nodes2 = mesh.CreateEmptyGroup( SMESH.NODE, 'nodes2' )
60 nodes2.Add( [ 35, 38 ] )
62 # Group of faces to replace nodes with new ones
63 faces2 = mesh.CreateEmptyGroup( SMESH.FACE, 'faces2' )
64 faces2.Add( [ 141, 148, 155 ] )
67 print("\nMesh before the second nodes duplication:")
68 print("Nodes : ", mesh.NbNodes())
69 print("Edges : ", mesh.NbEdges())
70 print("Quadrangles : ", mesh.NbQuadrangles())
72 groupOfNewEdges = mesh.DoubleNodeElemGroup( edges, nodes2, faces2, theMakeGroup=True )
73 print("New edges:", groupOfNewEdges.GetIDs())
75 print("\nMesh after the second nodes duplication:")
76 print("Nodes : ", mesh.NbNodes())
77 print("Edges : ", mesh.NbEdges())
78 print("Quadrangles : ", mesh.NbQuadrangles())
81 # Duplicate elements only
83 # Duplicate all faces and make a group of new faces.
84 # If a mesh is given to DoubleElements(), all elements of the greatest dimension are duplicated
85 newFacesGroup = mesh.DoubleElements( mesh, "newFacesGroup" )
87 # Duplicate edges contained in the group "edges" and add new edges to this group
88 mesh.DoubleElements( edges, edges.GetName() )
90 # Duplicate two first edges of the mesh
91 mesh.DoubleElements([ 1, 2 ])
93 # Update object browser
94 if salome.sg.hasDesktop():
95 salome.sg.updateObjBrowser()