Quality Controls

Free Borders

import salome

import geompy

import SMESH

import StdMeshers

 

smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")

smesh.SetCurrentStudy(salome.myStudy)

 

# create a box without one plane

box = geompy.MakeBox(0., 0., 0., 20., 20., 15.)

subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])

 

FaceList  = []

for i in range( 5 ):

  FaceList.append( subShapeList[ i ] )

 

aComp = geompy.MakeCompound( FaceList )

aBox = geompy.Sew( aComp, 1. )

idbox = geompy.addToStudy( aBox, "box" )

  

aBox  = salome.IDToObject( idbox )

 

# create a mesh

hyp1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")

hyp1.SetNumberOfSegments(5)

hyp2 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")

hyp2.SetMaxElementArea(20)

 

algo1 = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")

algo2 = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")

 

mesh = smesh.CreateMesh(aBox)

mesh.AddHypothesis(aBox,hyp1)

mesh.AddHypothesis(aBox,hyp2)

mesh.AddHypothesis(aBox,algo1)

mesh.AddHypothesis(aBox,algo2)

 

smesh.Compute(mesh,aBox)

 

smeshgui = salome.ImportComponentGUI("SMESH")

smeshgui.Init(salome.myStudyId);

smeshgui.SetName( salome.ObjectToID( mesh ), "Mesh_freebord" );

 

# criterion : free borders

aFilterMgr = smesh.CreateFilterManager()

aPredicate = aFilterMgr.CreateFreeBorders()

aFilter = aFilterMgr.CreateFilter()

aFilter.SetPredicate( aPredicate )

anIds = aFilter.GetElementsId( mesh )

 

# print the result

print "Criterion: Free borders Nb = ", len( anIds )

for i in range( len( anIds ) ):

  print anIds[ i ]

 

# create a group

aGroup = mesh.CreateGroup( SMESH.EDGE, "Free borders" )

aGroup.Add( anIds )

salome.sg.updateObjBrowser(1)

 

Borders at Multiconnection

import salome

import geompy

import SMESH

import StdMeshers

 

smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")

smesh.SetCurrentStudy(salome.myStudy)

 

# create a box without one plane

 

box = geompy.MakeBox(0., 0., 0., 20., 20., 15.)

subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])

 

FaceList  = []

for i in range( 5 ):

  FaceList.append( subShapeList[ i ] )

 

aComp = geompy.MakeCompound( FaceList )

aBox = geompy.Sew( aComp, 1. )

idbox = geompy.addToStudy( aBox, "box" )

  

aBox  = salome.IDToObject( idbox )

 

# create a mesh

 

hyp1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")

hyp1.SetNumberOfSegments(5)

hyp2 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")

hyp2.SetMaxElementArea(20)

 

algo1 = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")

algo2 = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")

 

mesh = smesh.CreateMesh(aBox)

mesh.AddHypothesis(aBox,hyp1)

mesh.AddHypothesis(aBox,hyp2)

mesh.AddHypothesis(aBox,algo1)

mesh.AddHypothesis(aBox,algo2)

 

smesh.Compute(mesh,aBox)

 

smeshgui = salome.ImportComponentGUI("SMESH")

smeshgui.Init(salome.myStudyId);

smeshgui.SetName( salome.ObjectToID( mesh ), "Mesh_borders_at_multi-connections" );

 

# Criterion : Borders at multi-connection

aFilterMgr = smesh.CreateFilterManager()

aFunctor = aFilterMgr.CreateMultiConnection()

 

aPredicate = aFilterMgr.CreateEqualTo()

aPredicate.SetNumFunctor( aFunctor )

aPredicate.SetMargin( 2 )

 

aFilter = aFilterMgr.CreateFilter()

aFilter.SetPredicate( aPredicate )

 

anIds = aFilter.GetElementsId( mesh )

 

# print the result

print "Criterion: Borders at multi-connections Nb = ", len( anIds )

for i in range( len( anIds ) ):

  print anIds[ i ]

 

# create a group

aGroup = mesh.CreateGroup( SMESH.EDGE, "Borders at multi-connections" )

aGroup.Add( anIds )

salome.sg.updateObjBrowser(1)

 

Length 1D

 

import salome

import geompy

import SMESH

import StdMeshers

 

smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")

smesh.SetCurrentStudy(salome.myStudy)

 

# create a box without one plane

box = geompy.MakeBox(0., 0., 0., 20., 20., 15.)

subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])

 

FaceList  = []

for i in range( 5 ):

  FaceList.append( subShapeList[ i ] )

 

aComp = geompy.MakeCompound( FaceList )

aBox = geompy.Sew( aComp, 1. )

idbox = geompy.addToStudy( aBox, "box" )

  

aBox  = salome.IDToObject( idbox )

 

# create a mesh

hyp1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")

hyp1.SetNumberOfSegments(5)

hyp2 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")

hyp2.SetMaxElementArea(20)

 

algo1 = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")

algo2 = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")

 

mesh = smesh.CreateMesh(aBox)

mesh.AddHypothesis(aBox,hyp1)

mesh.AddHypothesis(aBox,hyp2)

mesh.AddHypothesis(aBox,algo1)

mesh.AddHypothesis(aBox,algo2)

 

smesh.Compute(mesh,aBox)

 

smeshgui = salome.ImportComponentGUI("SMESH")

smeshgui.Init(salome.myStudyId);

smeshgui.SetName( salome.ObjectToID( mesh ), "Mesh" );

 

# Criterion : Length > 3

aFilterMgr = smesh.CreateFilterManager()

aFunctor = aFilterMgr.CreateLength()

 

aPredicate = aFilterMgr.CreateMoreThan()

aPredicate.SetNumFunctor( aFunctor )

aPredicate.SetMargin( 3 )

 

aFilter = aFilterMgr.CreateFilter()

aFilter.SetPredicate( aPredicate )

 

anIds = aFilter.GetElementsId( mesh )

 

# print the result

print "Criterion: Edges length > 3 Nb = ", len( anIds )

for i in range( len( anIds ) ):

  print anIds[ i ]

 

# create a group

aGroup = mesh.CreateGroup( SMESH.EDGE, "Edges with legth > 3" )

aGroup.Add( anIds )

salome.sg.updateObjBrowser(1)

 

Free Edges

import SMESH

import SMESH_mechanic

 

smesh  = SMESH_mechanic.smesh

mesh   = SMESH_mechanic.mesh

salome = SMESH_mechanic.salome

 

aFilterMgr = smesh.CreateFilterManager()

 

# Criterion : AREA > 30

 

aFunctor = aFilterMgr.CreateArea()

aPredicate = aFilterMgr.CreateMoreThan()

aPredicate.SetNumFunctor( aFunctor )

aPredicate.SetMargin( 30 )

 

aFilter = aFilterMgr.CreateFilter()

aFilter.SetPredicate( aPredicate )

 

anIds = aFilter.GetElementsId( mesh )

anEditor = mesh.GetMeshEditor()

anEditor.RemoveElements(anIds)

 

# Criterion : FREE EDGES

 

aPredicate = aFilterMgr.CreateFreeEdges()

aFilter = aFilterMgr.CreateFilter()

aFilter.SetPredicate( aPredicate )

 

anIds = aFilter.GetElementsId( mesh )

 

# print the result

print "Criterion: Free edges Nb = ", len( anIds )

for i in range( len( anIds ) ):

  print anIds[ i ]

 

# create a group

aGroup = mesh.CreateGroup( SMESH.EDGE, "Free edges" )

aGroup.Add( anIds )

salome.sg.updateObjBrowser(1)

 

Length 2D

import salome

import geompy

import SMESH

import StdMeshers

 

smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")

smesh.SetCurrentStudy(salome.myStudy)

 

# create a box without one plane

 

box = geompy.MakeBox(0., 0., 0., 20., 20., 15.)

subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])

 

FaceList  = []

for i in range( 5 ):

  FaceList.append( subShapeList[ i ] )

 

aComp = geompy.MakeCompound( FaceList )

aBox = geompy.Sew( aComp, 1. )

idbox = geompy.addToStudy( aBox, "box" )

  

aBox  = salome.IDToObject( idbox )

 

# create a mesh

 

hyp1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")

hyp1.SetNumberOfSegments(5)

hyp2 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")

hyp2.SetMaxElementArea(20)

 

algo1 = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")

algo2 = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")

 

mesh = smesh.CreateMesh(aBox)

mesh.AddHypothesis(aBox,hyp1)

mesh.AddHypothesis(aBox,hyp2)

mesh.AddHypothesis(aBox,algo1)

mesh.AddHypothesis(aBox,algo2)

 

smesh.Compute(mesh,aBox)

 

smeshgui = salome.ImportComponentGUI("SMESH")

smeshgui.Init(salome.myStudyId);

smeshgui.SetName( salome.ObjectToID( mesh ), "Mesh" );

 

# Criterion : Length 2D > 5

aFilterMgr = smesh.CreateFilterManager()

aFunctor = aFilterMgr.CreateLength2D()

 

aPredicate = aFilterMgr.CreateMoreThan()

aPredicate.SetNumFunctor( aFunctor )

aPredicate.SetMargin( 5 )

 

aFilter = aFilterMgr.CreateFilter()

aFilter.SetPredicate( aPredicate )

 

anIds = aFilter.GetElementsId( mesh )

 

# print the result

print "Criterion: Edges length 2D > 5 Nb = ", len( anIds )

for i in range( len( anIds ) ):

  print anIds[ i ]

 

# create a group

aGroup = mesh.CreateGroup( SMESH.FACE, "Edges with legth 2D > 5" )

aGroup.Add( anIds )

salome.sg.updateObjBrowser(1)  

 

Borders at Multiconnection 2D

import salome

import geompy

import SMESH

import StdMeshers

 

smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")

smesh.SetCurrentStudy(salome.myStudy)

 

# create a box without one plane

box = geompy.MakeBox(0., 0., 0., 20., 20., 15.)

subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])

 

FaceList  = []

for i in range( 5 ):

  FaceList.append( subShapeList[ i ] )

 

aComp = geompy.MakeCompound( FaceList )

aBox = geompy.Sew( aComp, 1. )

idbox = geompy.addToStudy( aBox, "box" )

  

aBox  = salome.IDToObject( idbox )

 

# create a mesh

hyp1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")

hyp1.SetNumberOfSegments(5)

hyp2 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")

hyp2.SetMaxElementArea(20)

 

algo1 = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")

algo2 = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")

 

mesh = smesh.CreateMesh(aBox)

mesh.AddHypothesis(aBox,hyp1)

mesh.AddHypothesis(aBox,hyp2)

mesh.AddHypothesis(aBox,algo1)

mesh.AddHypothesis(aBox,algo2)

 

smesh.Compute(mesh,aBox)

smeshgui = salome.ImportComponentGUI("SMESH")

smeshgui.Init(salome.myStudyId);

smeshgui.SetName( salome.ObjectToID( mesh ), "Mesh" );

 

# Criterion : MULTI-CONNECTION 2D = 2

aFilterMgr = smesh.CreateFilterManager()

aFunctor = aFilterMgr.CreateMultiConnection2D()

 

aPredicate = aFilterMgr.CreateEqualTo()

aPredicate.SetNumFunctor( aFunctor )

aPredicate.SetMargin( 2 )

 

aFilter = aFilterMgr.CreateFilter()

aFilter.SetPredicate( aPredicate )

anIds = aFilter.GetElementsId( mesh )

 

# print the result

print "Criterion: Borders at multi-connection 2D = 2 Nb = ", len( anIds )

for i in range( len( anIds ) ):

  print anIds[ i ]

 

# create a group

aGroup = mesh.CreateGroup( SMESH.FACE, "Borders at multi-connection 2D = 2" )

aGroup.Add( anIds )

salome.sg.updateObjBrowser(1)

 

Area

import SMESH

import SMESH_mechanic

 

smesh  = SMESH_mechanic.smesh

mesh   = SMESH_mechanic.mesh

salome = SMESH_mechanic.salome

 

aFilterMgr = smesh.CreateFilterManager()

 

# Criterion : AREA > 100

 

aFunctor = aFilterMgr.CreateArea()

aPredicate = aFilterMgr.CreateMoreThan()

aPredicate.SetNumFunctor( aFunctor )

aPredicate.SetMargin( 100 )

 

aFilter = aFilterMgr.CreateFilter()

aFilter.SetPredicate( aPredicate )

 

anIds = aFilter.GetElementsId( mesh )

 

# print the result

print "Criterion: Area > 100 Nb = ", len( anIds )

for i in range( len( anIds ) ):

  print anIds[ i ]

 

# create a group

aGroup = mesh.CreateGroup( SMESH.FACE, "Area > 100" )

aGroup.Add( anIds )

 

salome.sg.updateObjBrowser(1)

 

Taper

import SMESH

import SMESH_mechanic

 

smesh  = SMESH_mechanic.smesh

mesh   = SMESH_mechanic.mesh

salome = SMESH_mechanic.salome

 

aFilterMgr = smesh.CreateFilterManager()

 

# Criterion : Taper > 3e-20

 

aFunctor = aFilterMgr.CreateTaper()

aPredicate = aFilterMgr.CreateMoreThan()

aPredicate.SetNumFunctor( aFunctor )

aPredicate.SetMargin( 3e-20 )

 

aFilter = aFilterMgr.CreateFilter()

aFilter.SetPredicate( aPredicate )

 

anIds = aFilter.GetElementsId( mesh )

 

# print the result

print "Criterion: Taper > 3e-20 Nb = ", len( anIds )

for i in range( len( anIds ) ):

  print anIds[ i ]

 

# create a group

aGroup = mesh.CreateGroup( SMESH.FACE, "Taper > 3e-20" )

aGroup.Add( anIds )

 

salome.sg.updateObjBrowser(1)

 

Aspect Ratio

import SMESH

import SMESH_mechanic

 

smesh  = SMESH_mechanic.smesh

mesh   = SMESH_mechanic.mesh

salome = SMESH_mechanic.salome

 

aFilterMgr = smesh.CreateFilterManager()

 

# Criterion : ASPECT RATIO > 1.4

 

aFunctor = aFilterMgr.CreateAspectRatio()

aPredicate = aFilterMgr.CreateMoreThan()

aPredicate.SetNumFunctor( aFunctor )

aPredicate.SetMargin( 1.4 )

 

aFilter = aFilterMgr.CreateFilter()

aFilter.SetPredicate( aPredicate )

 

anIds = aFilter.GetElementsId( mesh )

 

# print the result

print "Criterion: Aspect Ratio > 1.4 Nb = ", len( anIds )

for i in range( len( anIds ) ):

  print anIds[ i ]

 

# create a group

aGroup = mesh.CreateGroup( SMESH.FACE, "Aspect Ratio > 1.4" )

aGroup.Add( anIds )

 

salome.sg.updateObjBrowser(1)

 

Minimum Angle

 

import SMESH

import SMESH_mechanic

 

smesh  = SMESH_mechanic.smesh

mesh   = SMESH_mechanic.mesh

salome = SMESH_mechanic.salome

 

aFilterMgr = smesh.CreateFilterManager()

 

# Criterion : MINIMUM ANGLE < 70

 

aFunctor = aFilterMgr.CreateMinimumAngle()

aPredicate = aFilterMgr.CreateLessThan()

aPredicate.SetNumFunctor( aFunctor )

aPredicate.SetMargin( 70 )

 

aFilter = aFilterMgr.CreateFilter()

aFilter.SetPredicate( aPredicate )

 

anIds = aFilter.GetElementsId( mesh )

 

# print the result

print "Criterion: Minimum Angle < 70 Nb = ", len( anIds )

for i in range( len( anIds ) ):

  print anIds[ i ]

 

# create a group

aGroup = mesh.CreateGroup( SMESH.FACE, "Minimum Angle < 70" )

aGroup.Add( anIds )

 

salome.sg.updateObjBrowser(1)

 

Warping

import SMESH

import SMESH_mechanic

 

smesh  = SMESH_mechanic.smesh

mesh   = SMESH_mechanic.mesh

salome = SMESH_mechanic.salome

 

aFilterMgr = smesh.CreateFilterManager()

 

# Criterion : WARP ANGLE > 1e-15

 

aFunctor = aFilterMgr.CreateWarping()

aPredicate = aFilterMgr.CreateMoreThan()

aPredicate.SetNumFunctor( aFunctor )

aPredicate.SetMargin( 1e-15 )

 

aFilter = aFilterMgr.CreateFilter()

aFilter.SetPredicate( aPredicate )

 

anIds = aFilter.GetElementsId( mesh )

 

# print the result

print "Criterion: Warp > 1e-15 Nb = ", len( anIds )

for i in range( len( anIds ) ):

  print anIds[ i ]

 

# create a group

aGroup = mesh.CreateGroup( SMESH.FACE, "Warp > 1e-15" )

aGroup.Add( anIds )

salome.sg.updateObjBrowser(1)

 

Skew

import SMESH

import SMESH_mechanic

 

smesh  = SMESH_mechanic.smesh

mesh   = SMESH_mechanic.mesh

salome = SMESH_mechanic.salome

 

aFilterMgr = smesh.CreateFilterManager()

 

# Criterion : Skew > 18

 

aFunctor = aFilterMgr.CreateSkew()

aPredicate = aFilterMgr.CreateMoreThan()

aPredicate.SetNumFunctor( aFunctor )

aPredicate.SetMargin( 18 )

 

aFilter = aFilterMgr.CreateFilter()

aFilter.SetPredicate( aPredicate )

 

anIds = aFilter.GetElementsId( mesh )

 

# print the result

print "Criterion: Skew > 18 Nb = ", len( anIds )

for i in range( len( anIds ) ):

  print anIds[ i ]

 

# create a group

aGroup = mesh.CreateGroup( SMESH.FACE, "Skew > 18" )

aGroup.Add( anIds )

 

salome.sg.updateObjBrowser(1)

 

Aspect Ratio 3D

import SMESH

import SMESH_mechanic_tetra

 

smesh  = SMESH_mechanic_tetra.smesh

mesh   = SMESH_mechanic_tetra.mesh

salome = SMESH_mechanic_tetra.salome

 

aFilterMgr = smesh.CreateFilterManager()

 

# Criterion : ASPECT RATIO 3D > 2.2

 

aFunctor = aFilterMgr.CreateAspectRatio3D()

aPredicate = aFilterMgr.CreateMoreThan()

aPredicate.SetNumFunctor( aFunctor )

aPredicate.SetMargin( 2.2 )

 

aFilter = aFilterMgr.CreateFilter()

aFilter.SetPredicate( aPredicate )

 

anIds = aFilter.GetElementsId( mesh )

 

# print the result

print "Criterion: Aspect Ratio 3D > 2.2 Nb = ", len( anIds )

for i in range( len( anIds ) ):

  print anIds[ i ]

 

# create a group

aGroup = mesh.CreateGroup( SMESH.VOLUME, "Aspect Ratio 3D > 2.2" )

aGroup.Add( anIds )

 

salome.sg.updateObjBrowser(1)