smesh/doc/examples/quality_controls_ex05.py

50 lines
1.1 KiB
Python
Raw Normal View History

2013-02-12 20:37:44 +06:00
# Free Nodes
import salome
salome.salome_init_without_session()
2013-02-12 20:37:44 +06:00
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 box
2022-04-11 18:28:01 +05:00
box = geom_builder.MakeBox(0., 0., 0., 100., 200., 300.)
idbox = geom_builder.addToStudy(box, "box")
2013-02-12 20:37:44 +06:00
# create a mesh
2022-04-11 18:28:01 +05:00
mesh = smesh_builder.Mesh(box, "Mesh_free_nodes")
2022-04-15 20:49:22 +05:00
mesh.Segment().NumberOfSegments(10)
mesh.Triangle().MaxElementArea(150.)
2013-02-12 20:37:44 +06:00
mesh.Compute()
# Remove some elements to obtain free nodes
# Criterion : AREA < 80.
area_margin = 80.
2022-04-11 18:28:01 +05:00
aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, area_margin)
2013-02-12 20:37:44 +06:00
anIds = mesh.GetIdsFromFilter(aFilter)
mesh.RemoveElements(anIds)
# criterion : free nodes
2022-04-11 18:28:01 +05:00
aFilter = smesh_builder.GetFilter(SMESH.NODE, SMESH.FT_FreeNodes)
2013-02-12 20:37:44 +06:00
anNodeIds = mesh.GetIdsFromFilter(aFilter)
# create a group
aGroup = mesh.CreateEmptyGroup(SMESH.NODE, "Free_nodes")
2013-02-12 20:37:44 +06:00
aGroup.Add(anNodeIds)
# print the result
2017-03-20 17:27:30 +05:00
print("Criterion: Free nodes Nb = ", len(anNodeIds))
2013-02-12 20:37:44 +06:00
j = 1
for i in range(len(anNodeIds)):
2017-03-20 17:27:30 +05:00
if j > 20: j = 1; print("")
print(anNodeIds[i], end=' ')
2013-02-12 20:37:44 +06:00
j = j + 1
pass
2017-03-20 17:27:30 +05:00
print("")