2017-10-12 21:52:03 +05:00
|
|
|
# Deflection 2D
|
|
|
|
|
|
|
|
import salome
|
2021-08-12 14:38:10 +05:00
|
|
|
salome.salome_init_without_session()
|
2017-10-12 21:52:03 +05:00
|
|
|
|
|
|
|
import SMESH
|
2022-04-11 18:28:01 +05:00
|
|
|
from salome.geom import geomBuilder
|
2017-10-12 21:52:03 +05:00
|
|
|
from salome.smesh import smeshBuilder
|
2022-04-11 18:28:01 +05:00
|
|
|
|
|
|
|
geom_builder = geomBuilder.New()
|
|
|
|
smesh_builder = smeshBuilder.New()
|
2017-10-12 21:52:03 +05:00
|
|
|
|
|
|
|
# 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" )
|
2017-10-12 21:52:03 +05:00
|
|
|
|
|
|
|
# create a mesh
|
2022-04-11 18:28:01 +05:00
|
|
|
mesh = smesh_builder.Mesh( Fuse, "Deflection_2D")
|
2017-10-12 21:52:03 +05:00
|
|
|
algo = mesh.Segment()
|
|
|
|
algo.LocalLength(35)
|
|
|
|
algo = mesh.Triangle()
|
2023-02-21 18:59:44 +05:00
|
|
|
if not mesh.Compute(): raise Exception("Error when computing Mesh")
|
2017-10-12 21:52:03 +05:00
|
|
|
|
|
|
|
# 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)
|
2017-10-12 21:52:03 +05:00
|
|
|
|
|
|
|
# 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 ))
|
2017-10-12 21:52:03 +05:00
|
|
|
|
|
|
|
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)
|
2017-10-12 21:52:03 +05:00
|
|
|
anIds = aFilter.GetIDs()
|
2017-12-29 18:20:32 +05:00
|
|
|
print("%s faces have deflection less than %s" %( len(anIds), margin ))
|
2017-10-12 21:52:03 +05:00
|
|
|
|
|
|
|
# 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] ))
|