Salome HOME
23189: EDF 11603 - Dyssymetry in meshing
[modules/smesh.git] / doc / salome / examples / filters_ex01.py
1 # Aspect ratio
2
3 # create mesh
4 from SMESH_mechanic import *
5
6 # get faces with aspect ratio > 1.5
7 filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, SMESH.FT_MoreThan, 1.5)
8 ids = mesh.GetIdsFromFilter(filter)
9 print "Number of faces with aspect ratio > 1.5:", len(ids)
10
11 # copy the faces with aspect ratio > 1.5 to another mesh;
12 # this demostrates that a filter can be used where usually a group or sub-mesh is acceptable
13 filter.SetMesh( mesh.GetMesh() )
14 mesh2 = smesh.CopyMesh( filter, "AR > 1.5" )
15 print "Number of copied faces with aspect ratio > 1.5:", mesh2.NbFaces()
16
17 # create a group (Group on Filter) of faces with Aspect Ratio < 1.5
18 group = mesh.MakeGroup("AR < 1.5", SMESH.FACE, SMESH.FT_AspectRatio, '<', 1.5)
19 print "Number of faces with aspect ratio < 1.5:", group.Size()
20
21 # combine several criteria to Create a Group of only Triangular faces with Aspect Ratio < 1.5;
22 # note that contents of a GroupOnFilter is dynamically updated as the mesh changes
23 crit = [ smesh.GetCriterion( SMESH.FACE, SMESH.FT_AspectRatio, '<', 1.5, BinaryOp=SMESH.FT_LogicalAND ),
24          smesh.GetCriterion( SMESH.FACE, SMESH.FT_ElemGeomType,'=', SMESH.Geom_TRIANGLE ) ]
25 triaGroup = mesh.MakeGroupByCriteria( "Tria AR < 1.5", crit )
26 print "Number of triangles with aspect ratio < 1.5:", triaGroup.Size()
27
28 # get range of values of Aspect Ratio of all faces in the mesh
29 aspects = mesh.GetMinMax( SMESH.FT_AspectRatio )
30 print "MESH: Min aspect = %s, Max aspect = %s" % ( aspects[0], aspects[1] )
31
32 # get max value of Aspect Ratio of faces in triaGroup
33 grAspects = mesh.GetMinMax( SMESH.FT_AspectRatio, triaGroup )
34 print "GROUP: Max aspect = %s" % grAspects[1]