smesh/doc/examples/modifying_meshes_ex03.py

51 lines
1.7 KiB
Python
Raw Normal View History

2013-02-12 20:37:44 +06:00
# Add 0D Element on Element Nodes
import salome
salome.salome_init_without_session()
2022-04-11 18:28:01 +05:00
import SMESH
from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
2022-04-11 18:28:01 +05:00
geom_builder = geomBuilder.New()
smesh_builder = smeshBuilder.New()
2013-02-12 20:37:44 +06:00
# create a geometry
2022-04-11 18:28:01 +05:00
box = geom_builder.MakeBoxDXDYDZ( 10, 10, 10 )
face = geom_builder.SubShapeAll( box, geom_builder.ShapeType["FACE"])[0]
2013-02-12 20:37:44 +06:00
# make 3D mesh
2022-04-11 18:28:01 +05:00
mesh = smesh_builder.Mesh( box )
2013-02-12 20:37:44 +06:00
mesh.AutomaticHexahedralization(0)
# create 0D elements on all nodes of the mesh
res = mesh.Add0DElementsToAllNodes( mesh )
# find 0D elements on all nodes of the mesh, all found nodes are added to a new group
groupName = "0Dmesh"
res = mesh.Add0DElementsToAllNodes( mesh, groupName )
mesh.RemoveGroupWithContents( res ) # remove all found 0D elements
# create 0D elements on all nodes of a sub-mesh, with group creation
groupName = "0Dsubmesh"
submesh = mesh.GetSubMesh( face, "faceSM")
res = mesh.Add0DElementsToAllNodes( submesh, groupName )
# create 0D elements on all nodes of a group
group = mesh.Group( face, "faceGroup" )
res = mesh.Add0DElementsToAllNodes( group )
# remove all 0D elements
2022-04-11 18:28:01 +05:00
mesh.RemoveElements( mesh.GetIdsFromFilter( smesh_builder.GetFilter( SMESH.ELEM0D,
SMESH.FT_ElemGeomType,
"=",SMESH.Geom_POINT )))
2013-02-12 20:37:44 +06:00
# create 0D elements on all nodes of some elements
res = mesh.Add0DElementsToAllNodes( mesh.GetElementsId() )
mesh.RemoveElements( mesh.GetElementsByType( SMESH.ELEM0D ))
# create 0D elements on some nodes
2017-03-20 17:27:30 +05:00
nodes = list(range(1,10))
2013-02-12 20:37:44 +06:00
res = mesh.Add0DElementsToAllNodes( mesh.GetIDSource( nodes, SMESH.NODE ))