smesh/doc/salome/gui/SMESH/input/tui_quality_controls.doc

710 lines
15 KiB
Plaintext
Raw Normal View History

/*!
\page tui_quality_controls_page Quality Controls
<br>
\anchor tui_free_borders
<h2>Free Borders</h2>
\code
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)
\endcode
<br>
\anchor tui_borders_at_multiconnection
<h2>Borders at Multiconnection</h2>
\code
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)
\endcode
<br>
\anchor tui_length_1d
<h2>Length 1D</h2>
\code
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)
\endcode
<br>
\anchor tui_free_edges
<h2>Free Edges</h2>
\code
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)
\endcode
2009-02-17 10:27:49 +05:00
<br>
\anchor tui_free_nodes
<h2>Free Nodes</h2>
\code
import salome
import geompy
import smesh
# create box
box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
idbox = geompy.addToStudy(box, "box")
# create a mesh
mesh = smesh.Mesh(box, "Mesh_free_nodes")
algo = mesh.Segment()
algo.NumberOfSegments(10)
algo = mesh.Triangle(smesh.MEFISTO)
algo.MaxElementArea(150.)
mesh.Compute()
# Remove some elements to obtain free nodes
# Criterion : AREA < 80.
area_margin = 80.
aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, area_margin)
anIds = mesh.GetIdsFromFilter(aFilter)
mesh.RemoveElements(anIds)
# criterion : free nodes
aFilter = smesh.GetFilter(smesh.NODE, smesh.FT_FreeNodes)
anNodeIds = mesh.GetIdsFromFilter(aFilter)
# create a group
aGroup = mesh.CreateEmptyGroup(smesh.NODE, "Free_nodes")
aGroup.Add(anNodeIds)
# print the result
print "Criterion: Free nodes Nb = ", len(anNodeIds)
j = 1
for i in range(len(anNodeIds)):
if j > 20: j = 1; print ""
print anNodeIds[i],
j = j + 1
pass
print ""
salome.sg.updateObjBrowser(1)
\endcode
<br>
\anchor tui_free_faces
<h2>Free Faces</h2>
\code
import salome
import geompy
####### GEOM part ########
Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
Box_1_vertex_6 = geompy.GetSubShape(Box_1, [6])
Box_1 = geompy.GetMainShape(Box_1_vertex_6)
Box_1_vertex_16 = geompy.GetSubShape(Box_1, [16])
Box_1 = geompy.GetMainShape(Box_1_vertex_16)
Box_1_vertex_11 = geompy.GetSubShape(Box_1, [11])
Box_1 = geompy.GetMainShape(Box_1_vertex_11)
Plane_1 = geompy.MakePlaneThreePnt(Box_1_vertex_6, Box_1_vertex_16, Box_1_vertex_11, 2000)
Partition_1 = geompy.MakePartition([Box_1], [Plane_1], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
Box_1_vertex_19 = geompy.GetSubShape(Box_1, [19])
Box_1_vertex_21 = geompy.GetSubShape(Box_1, [21])
Plane_2 = geompy.MakePlaneThreePnt(Box_1_vertex_16, Box_1_vertex_19, Box_1_vertex_21, 2000)
geompy.addToStudy( Box_1, "Box_1" )
geompy.addToStudyInFather( Box_1, Box_1_vertex_6, "Box_1:vertex_6" )
geompy.addToStudyInFather( Box_1, Box_1_vertex_16, "Box_1:vertex_16" )
geompy.addToStudyInFather( Box_1, Box_1_vertex_11, "Box_1:vertex_11" )
geompy.addToStudy( Plane_1, "Plane_1" )
geompy.addToStudy( Partition_1, "Partition_1" )
geompy.addToStudyInFather( Box_1, Box_1_vertex_19, "Box_1:vertex_19" )
geompy.addToStudyInFather( Box_1, Box_1_vertex_21, "Box_1:vertex_21" )
geompy.addToStudy( Plane_2, "Plane_2" )
###### SMESH part ######
import smesh
import StdMeshers
import NETGENPlugin
Mesh_1 = smesh.Mesh(Partition_1)
Regular_1D = Mesh_1.Segment()
Max_Size_1 = Regular_1D.MaxSize(34.641)
MEFISTO_2D = Mesh_1.Triangle()
Tetrahedron_Netgen = Mesh_1.Tetrahedron(algo=smesh.NETGEN)
isDone = Mesh_1.Compute()
# create a group of free faces
aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_FreeFaces )
aFaceIds = Mesh_1.GetIdsFromFilter(aFilter)
aGroup = Mesh_1.CreateEmptyGroup(smesh.FACE, "Free_faces")
aGroup.Add(aFaceIds)
# print the result
print "Criterion: Free nodes Nb = ", len(anNodeIds)
j = 1
for i in range(len(aFaceIds)):
if j > 20: j = 1; print ""
print anNodeIds[i],
j = j + 1
pass
print ""
#filter faces from plane 2
aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_BelongToPlane, Plane_2)
aFaceIds = Mesh_1.GetIdsFromFilter(aFilter)
aGroup.Remove(aFaceIds)
# create a group of shared faces (located on partition boundary inside box)
aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_BelongToPlane, Plane_1)
aFaceIds = Mesh_1.GetIdsFromFilter(aFilter)
aGroup = Mesh_1.CreateEmptyGroup(smesh.FACE, "Shared_faces")
aGroup.Add(aFaceIds)
salome.sg.updateObjBrowser(1)
\endcode
<br>
\anchor tui_length_2d
<h2>Length 2D</h2>
\code
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)
\endcode
<br>
\anchor tui_borders_at_multiconnection_2d
<h2>Borders at Multiconnection 2D</h2>
\code
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)
\endcode
<br>
\anchor tui_area
<h2>Area</h2>
\code
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)
\endcode
<br>
\anchor tui_taper
<h2>Taper</h2>
\code
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)
\endcode
<br>
\anchor tui_aspect_ratio
<h2>Aspect Ratio</h2>
\code
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)
\endcode
<br>
\anchor tui_minimum_angle
<h2>Minimum Angle</h2>
\code
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)
\endcode
<br>
\anchor tui_warping
<h2>Warping</h2>
\code
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)
\endcode
<br>
\anchor tui_skew
<h2>Skew</h2>
\code
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)
\endcode
<br>
\anchor tui_aspect_ratio_3d
<h2>Aspect Ratio 3D</h2>
\code
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)
\endcode
<br>
\anchor tui_volume
<h2>Volume</h2>
\code
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)
\endcode
2009-02-17 10:27:49 +05:00
*/