smesh/doc/examples/quality_controls_defl.py

44 lines
1.4 KiB
Python
Raw Normal View History

# Deflection 2D
import salome
salome.salome_init_without_session()
import SMESH
2022-04-11 18:28:01 +05:00
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()
# fuse a box and a sphere
2022-04-11 18:28:01 +05:00
Sphere_1 = geom_builder.MakeSphereR(100)
Box_1 = geom_builder.MakeBoxDXDYDZ(200, 200, 200)
Fuse = geom_builder.MakeFuse( Sphere_1, Box_1, theName="box + sphere" )
# create a mesh
2022-04-11 18:28:01 +05:00
mesh = smesh_builder.Mesh( Fuse, "Deflection_2D")
algo = mesh.Segment()
algo.LocalLength(35)
algo = mesh.Triangle()
mesh.Compute()
# get min and max deflection
minMax = mesh.GetMinMax( SMESH.FT_Deflection2D )
2017-12-29 18:20:32 +05:00
print("min and max deflection: ", minMax)
# get deflection of a certain face
faceID = mesh.NbEdges() + mesh.NbFaces()
defl = mesh.FunctorValue( SMESH.FT_Deflection2D, faceID )
2017-12-29 18:20:32 +05:00
print("deflection of face %s = %s" % ( faceID, defl ))
margin = minMax[1] / 2
# get all faces with deflection LESS than the margin
2022-04-11 18:28:01 +05:00
aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Deflection2D, '<', margin, mesh=mesh)
anIds = aFilter.GetIDs()
2017-12-29 18:20:32 +05:00
print("%s faces have deflection less than %s" %( len(anIds), margin ))
# create a group of faces with deflection MORE than the margin
2017-12-29 18:20:32 +05:00
aGroup = mesh.MakeGroup("Deflection > " + repr(margin), SMESH.FACE, SMESH.FT_Deflection2D,'>',margin)
print("%s faces have deflection more than %s: %s ..." %( aGroup.Size(), margin, aGroup.GetIDs()[:10] ))