-# Duplicate nodes
+# Duplicate nodes or/and elements
+
import salome
-import geompy
-import smesh
+salome.salome_init()
+
+import GEOM
+from salome.geom import geomBuilder
+geompy = geomBuilder.New()
+
+import SMESH
+from salome.smesh import smeshBuilder
+smesh = smeshBuilder.New()
# Create a box
# Compute mesh
mesh.Compute()
-# Without the duplication of border elements
+# Duplicate nodes only
# Nodes to duplicate
-nodes1 = mesh.CreateEmptyGroup( smesh.NODE, 'nodes1' )
+nodes1 = mesh.CreateEmptyGroup( SMESH.NODE, 'nodes1' )
nodes1.Add( [ 119, 125, 131, 137 ] )
# Group of faces to replace nodes with new ones
-faces1 = mesh.CreateEmptyGroup( smesh.FACE, 'faces1' )
+faces1 = mesh.CreateEmptyGroup( SMESH.FACE, 'faces1' )
faces1.Add( [ 144, 151, 158 ] )
# Duplicate nodes
print "Edges : ", mesh.NbEdges()
print "Quadrangles : ", mesh.NbQuadrangles()
-# With the duplication of border elements
+# Duplicate nodes and border elements
# Edges to duplicate
-edges = mesh.CreateEmptyGroup( smesh.EDGE, 'edges' )
+edges = mesh.CreateEmptyGroup( SMESH.EDGE, 'edges' )
edges.Add( [ 32, 33, 34 ] )
# Nodes not to duplicate
-nodes2 = mesh.CreateEmptyGroup( smesh.NODE, 'nodes2' )
+nodes2 = mesh.CreateEmptyGroup( SMESH.NODE, 'nodes2' )
nodes2.Add( [ 35, 38 ] )
# Group of faces to replace nodes with new ones
-faces2 = mesh.CreateEmptyGroup( smesh.FACE, 'faces2' )
+faces2 = mesh.CreateEmptyGroup( SMESH.FACE, 'faces2' )
faces2.Add( [ 141, 148, 155 ] )
# Duplicate nodes
print "Edges : ", mesh.NbEdges()
print "Quadrangles : ", mesh.NbQuadrangles()
+
+# Duplicate elements only
+
+# Duplicate all faces and make a group of new faces.
+# If a mesh is given to DoubleElements(), all elements of the greatest dimension are duplicated
+newFacesGroup = mesh.DoubleElements( mesh, "newFacesGroup" )
+
+# Duplicate edges contained in the group "edges" and add new edges to this group
+mesh.DoubleElements( edges, edges.GetName() )
+
+# Duplicate two first edges of the mesh
+mesh.DoubleElements([ 1, 2 ])
+
# Update object browser
if salome.sg.hasDesktop():
- salome.sg.updateObjBrowser(0)
+ salome.sg.updateObjBrowser()