Quality Controls

Free Borders

import salome

import geompy

 

import smesh

 

# create open shell: a box without one plane

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

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

FaceList.remove(FaceList[5])

box = geompy.MakeShell(FaceList)

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

 

# create a mesh

mesh = smesh.Mesh(box, "Mesh_free_borders")

algo = mesh.Segment()

algo.NumberOfSegments(5)

algo = mesh.Triangle()

algo.MaxElementArea(20.)

mesh.Compute()

 

# criterion : free borders

aFilter = smesh.GetFilter(smesh.EDGE, smesh.FT_FreeBorders)

anIds = mesh.GetIdsFromFilter(aFilter)

 

 

# print the result

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

j = 1

for i in range(len(anIds)):

  if j > 20: j = 1; print ""

  print anIds[i],

  j = j + 1

  pass

print ""

 

# 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 SMESH

 

# create open shell: a box without one plane

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

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

FaceList.remove(FaceList[5])

box = geompy.MakeShell(FaceList)

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

 

# create a mesh

mesh = smesh.Mesh(box, "Mesh_borders_at_multi-connections")

algo = mesh.Segment()

algo.NumberOfSegments(5)

algo = mesh.Triangle()

algo.MaxElementArea(20.)

mesh.Compute()

 

# Criterion : Borders at multi-connection

nb_conn = 2

 

aFilter = smesh.GetFilter(smesh.EDGE, smesh.FT_MultiConnection, smesh.FT_EqualTo, nb_conn)

anIds = mesh.GetIdsFromFilter(aFilter)

 

 

# print the result

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

j = 1

for i in range(len(anIds)):

  if j > 20: j = 1; print ""

  print anIds[i],

  j = j + 1

  pass

print ""

 

# 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

 

# create open shell: a box without one plane

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

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

FaceList.remove(FaceList[5])

box = geompy.MakeShell(FaceList)

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

 

# create a mesh

mesh = smesh.Mesh(box, "Mesh_Length_1D")

algo = mesh.Segment()

algo.NumberOfSegments(5)

algo = mesh.Triangle()

algo.MaxElementArea(20.)

mesh.Compute()

 

# Criterion : Length > 3.

length_margin = 3.

 

aFilter = smesh.GetFilter(smesh.EDGE, smesh.FT_Length, smesh.FT_MoreThan, length_margin)

anIds = mesh.GetIdsFromFilter(aFilter)

 

# print the result

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

j = 1

for i in range(len(anIds)):

  if j > 20: j = 1; print ""

  print anIds[i],

  j = j + 1

  pass

print ""

 

# create a group

aGroup = mesh.CreateGroup(SMESH.EDGE, "Edges with length > " + `length_margin`)

aGroup.Add(anIds)

 

salome.sg.updateObjBrowser(1)

Free Edges

import SMESH_mechanic

 

smesh  = SMESH_mechanic.smesh

mesh   = SMESH_mechanic.mesh

salome = SMESH_mechanic.salome

 

aFilterMgr = smesh.CreateFilterManager()

 

# Remove some elements to obtain free edges

# Criterion : AREA > 95.

area_margin = 95.

 

aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, area_margin)

 

anIds = mesh.GetIdsFromFilter(aFilter)

 

mesh.RemoveElements(anIds)

 

# Criterion : Free Edges

aBorders = mesh.GetFreeBorders()

 

# create groups

aGroupF = mesh.CreateGroup(SMESH.FACE, "Faces with free edges")

aGroupN = mesh.CreateGroup(SMESH.NODE, "Nodes on free edges")

 

# fill groups with elements, corresponding to the criterion

print ""

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

for i in range(len(aBorders)):

  aBorder = aBorders[i]

  print "Face # ", aBorder.myElemId, " : Edge between nodes (",

  print aBorder.myPnt1, ", ", aBorder.myPnt2, ")"

 

  aGroupF.Add([aBorder.myElemId])

  aGroupN.Add([aBorder.myPnt1, aBorder.myPnt2])

 

salome.sg.updateObjBrowser(1)

 

Length 2D

import salome

import geompy

 

import smesh

 

# create open shell: a box without one plane

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

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

FaceList.remove(FaceList[5])

box = geompy.MakeShell(FaceList)

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

 

# create a mesh

mesh = smesh.Mesh(box, "Mesh_Length_2D")

algo = mesh.Segment()

algo.NumberOfSegments(5)

algo = mesh.Triangle()

algo.MaxElementArea(20.)

mesh.Compute()

 

# Criterion : Length 2D > 5.7

length_margin = 5.7

 

aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Length2D, smesh.FT_MoreThan, length_margin)

 

anIds = mesh.GetIdsFromFilter(aFilter)

 

# print the result

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

j = 1

for i in range(len(anIds)):

  if j > 20: j = 1; print ""

  print anIds[i],

  j = j + 1

  pass

print ""

 

# create a group

aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Faces with length 2D > " + `length_margin`)

aGroup.Add(anIds)

 

salome.sg.updateObjBrowser(1)

 

Borders at Multiconnection 2D

import salome

import geompy

 

import smesh

 

# create a compound of two glued boxes

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

box2 = geompy.MakeTranslation(box1, 0., 20., 0)

comp = geompy.MakeCompound([box1, box2])

box = geompy.MakeGlueFaces(comp, 0.000001)

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

 

# create a mesh

mesh = smesh.Mesh(box, "Box compound : 2D triangle mesh")

algo = mesh.Segment()

algo.NumberOfSegments(5)

algo = mesh.Triangle()

algo.MaxElementArea(20.)

mesh.Compute()

 

# Criterion : MULTI-CONNECTION 2D = 3

nb_conn = 3

 

aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_MultiConnection2D, smesh.FT_EqualTo, nb_conn)

 

anIds = mesh.GetIdsFromFilter(aFilter)

 

# print the result

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

j = 1

for i in range(len(anIds)):

  if j > 20: j = 1; print ""

  print anIds[i],

  j = j + 1

  pass

print ""

 

# create a group

aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Borders at multi-connection 2D = " + `nb_conn`)

aGroup.Add(anIds)

 

salome.sg.updateObjBrowser(1)

 

Area

import SMESH_mechanic

 

smesh  = SMESH_mechanic.smesh

mesh   = SMESH_mechanic.mesh

salome = SMESH_mechanic.salome

 

# Criterion : AREA > 100.

area_margin = 100.

 

aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, area_margin)

 

anIds = mesh.GetIdsFromFilter(aFilter)

 

# print the result

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

j = 1

for i in range(len(anIds)):

  if j > 20: j = 1; print ""

  print anIds[i],

  j = j + 1

  pass

print ""

 

# create a group

aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Area > " + `area_margin`)

aGroup.Add(anIds)

 

salome.sg.updateObjBrowser(1)  

Taper

import SMESH_mechanic

 

smesh  = SMESH_mechanic.smesh

mesh   = SMESH_mechanic.mesh

salome = SMESH_mechanic.salome

 

# Criterion : Taper > 3e-20

taper_margin = 3e-20

 

aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Taper, smesh.FT_MoreThan, taper_margin)

 

anIds = mesh.GetIdsFromFilter(aFilter)

 

# print the result

print "Criterion: Taper > ", taper_margin, " Nb = ", len(anIds)

j = 1

for i in range(len(anIds)):

  if j > 20: j = 1; print ""

  print anIds[i],

  j = j + 1

  pass

print ""

 

# create a group

aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Taper > " + `taper_margin`)

aGroup.Add(anIds)

 

salome.sg.updateObjBrowser(1)  

Aspect Ratio

import SMESH_mechanic

 

smesh  = SMESH_mechanic.smesh

mesh   = SMESH_mechanic.mesh

salome = SMESH_mechanic.salome

 

# Criterion : ASPECT RATIO > 1.8

ar_margin = 1.8

 

aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_AspectRatio, smesh.FT_MoreThan, ar_margin)

 

anIds = mesh.GetIdsFromFilter(aFilter)

 

# print the result

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

j = 1

for i in range(len(anIds)):

  if j > 20: j = 1; print ""

  print anIds[i],

  j = j + 1

  pass

print ""

 

# create a group

aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Aspect Ratio > " + `ar_margin`)

aGroup.Add(anIds)

 

salome.sg.updateObjBrowser(1)

 

Minimum Angle

import SMESH_mechanic

 

smesh  = SMESH_mechanic.smesh

mesh   = SMESH_mechanic.mesh

salome = SMESH_mechanic.salome

 

# Criterion : MINIMUM ANGLE < 35.

min_angle = 35.

 

aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_MinimumAngle, smesh.FT_LessThan, min_angle)

 

anIds = mesh.GetIdsFromFilter(aFilter)

 

# print the result

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

j = 1

for i in range(len(anIds)):

  if j > 20: j = 1; print ""

  print anIds[i],

  j = j + 1

  pass

print ""

 

# create a group

aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Minimum Angle < " + `min_angle`)

 

aGroup.Add(anIds)

 

salome.sg.updateObjBrowser(1)

 

Warping

import SMESH_mechanic

 

smesh  = SMESH_mechanic.smesh

mesh   = SMESH_mechanic.mesh

salome = SMESH_mechanic.salome

 

# Criterion : WARP ANGLE > 1e-15

wa_margin = 1e-15

 

aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Warping, smesh.FT_MoreThan, wa_margin)

 

anIds = mesh.GetIdsFromFilter(aFilter)

 

# print the result

print "Criterion: Warp > ", wa_margin, " Nb = ", len(anIds)

j = 1

for i in range(len(anIds)):

  if j > 20: j = 1; print ""

  print anIds[i],

  j = j + 1

  pass

print ""

 

# create a group

aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Warp > " + `wa_margin`)

 

aGroup.Add(anIds)

 

salome.sg.updateObjBrowser(1)

 

Skew

import SMESH_mechanic

 

smesh  = SMESH_mechanic.smesh

mesh   = SMESH_mechanic.mesh

salome = SMESH_mechanic.salome

 

# Criterion : Skew > 38.

skew_margin = 38.

 

aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Skew, smesh.FT_MoreThan, skew_margin)

 

anIds = mesh.GetIdsFromFilter(aFilter)

 

# print the result

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

j = 1

for i in range(len(anIds)):

  if j > 20: j = 1; print ""

  print anIds[i],

  j = j + 1

  pass

print ""

 

# create a group

aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Skew > " + `skew_margin`)

aGroup.Add(anIds)

 

salome.sg.updateObjBrowser(1)

 

Aspect Ratio 3D

import SMESH_mechanic_tetra

 

smesh  = SMESH_mechanic_tetra.smesh

mesh   = SMESH_mechanic_tetra.mesh

salome = SMESH_mechanic_tetra.salome

 

# Criterion : ASPECT RATIO 3D > 4.5

ar_margin = 4.5

 

aFilter = smesh.GetFilter(smesh.VOLUME, smesh.FT_AspectRatio3D, smesh.FT_MoreThan, ar_margin)

 

anIds = mesh.GetIdsFromFilter(aFilter)

 

# print the result

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

j = 1

for i in range(len(anIds)):

  if j > 20: j = 1; print ""

  print anIds[i],

  j = j + 1

  pass

print ""

 

# create a group

aGroup = mesh.CreateEmptyGroup(smesh.VOLUME, "Aspect Ratio 3D > " + `ar_margin`)

 

aGroup.Add(anIds)

 

salome.sg.updateObjBrowser(1)

Volume

import SMESH_mechanic_tetra

 

smesh  = SMESH_mechanic_tetra.smesh

mesh   = SMESH_mechanic_tetra.mesh

salome = SMESH_mechanic_tetra.salome

 

# Criterion : VOLUME < 7.

volume_margin = 7.

 

aFilter = smesh.GetFilter(smesh.VOLUME, smesh.FT_Volume3D, smesh.FT_LessThan, volume_margin)

 

anIds = mesh.GetIdsFromFilter(aFilter)

 

# print the result

print ""

print "Criterion: Volume < ", volume_margin, " Nb = ", len(anIds)

j = 1

for i in range(len(anIds)):

  if j > 20: j = 1; print ""

  print anIds[i],

  j = j + 1

  pass

print ""

 

# create a group

aGroup = mesh.CreateEmptyGroup(smesh.VOLUME, "Volume < " + `volume_margin`)

 

aGroup.Add(anIds)

 

salome.sg.updateObjBrowser(1)