Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/smesh.git] / doc / salome / gui / SMESH / input / tui_quality_controls.doc
1 /*!
2
3 \page tui_quality_controls_page Quality Controls
4
5 <br>
6 \anchor tui_free_borders
7 <h2>Free Borders</h2>
8
9 \code
10 import salome
11 import geompy
12
13 import smesh
14
15 # create open shell: a box without one plane
16 box = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
17 FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
18 FaceList.remove(FaceList[5])
19 box = geompy.MakeShell(FaceList)
20 idbox = geompy.addToStudy(box, "box")
21
22 # create a mesh
23 mesh = smesh.Mesh(box, "Mesh_free_borders")
24 algo = mesh.Segment()
25 algo.NumberOfSegments(5)
26 algo = mesh.Triangle()
27 algo.MaxElementArea(20.)
28 mesh.Compute() 
29
30 # criterion : free borders
31 aFilter = smesh.GetFilter(smesh.EDGE, smesh.FT_FreeBorders) 
32 anIds = mesh.GetIdsFromFilter(aFilter)
33
34 # print the result
35 print "Criterion: Free borders Nb = ", len(anIds)
36 j = 1
37 for i in range(len(anIds)):
38   if j > 20: j = 1; print ""
39   print anIds[i],
40   j = j + 1
41   pass
42 print ""
43
44 # create a group
45 aGroup = mesh.CreateGroup(SMESH.EDGE, "Free borders")
46 aGroup.Add(anIds)
47
48 salome.sg.updateObjBrowser(1)
49 \endcode
50
51 <br>
52 \anchor tui_borders_at_multiconnection
53 <h2>Borders at Multiconnection</h2>
54
55 \code
56 import salome
57 import geompy
58
59 import smesh
60 import SMESH
61
62 # create open shell: a box without one plane
63 box = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
64 FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
65 FaceList.remove(FaceList[5])
66 box = geompy.MakeShell(FaceList)
67 idbox = geompy.addToStudy(box, "box")
68
69 # create a mesh
70 mesh = smesh.Mesh(box, "Mesh_borders_at_multi-connections")
71 algo = mesh.Segment()
72 algo.NumberOfSegments(5)
73 algo = mesh.Triangle()
74 algo.MaxElementArea(20.)
75 mesh.Compute() 
76
77 # Criterion : Borders at multi-connection
78 nb_conn = 2
79
80 aFilter = smesh.GetFilter(smesh.EDGE, smesh.FT_MultiConnection, smesh.FT_EqualTo, nb_conn)
81 anIds = mesh.GetIdsFromFilter(aFilter)
82
83 # print the result
84 print "Criterion: Borders at multi-connections Nb = ", len(anIds)
85 j = 1
86 for i in range(len(anIds)):
87   if j > 20: j = 1; print ""
88   print anIds[i],
89   j = j + 1
90   pass
91 print ""
92
93 # create a group
94 aGroup = mesh.CreateGroup(SMESH.EDGE, "Borders at multi-connections")
95 aGroup.Add(anIds)
96
97 salome.sg.updateObjBrowser(1)
98 \endcode
99
100 <br>
101 \anchor tui_length_1d
102 <h2>Length 1D</h2>
103
104 \code
105 import salome
106 import geompy
107
108 import smesh
109
110 # create open shell: a box without one plane
111 box = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
112 FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
113 FaceList.remove(FaceList[5])
114 box = geompy.MakeShell(FaceList)
115 idbox = geompy.addToStudy(box, "box")
116
117 # create a mesh
118 mesh = smesh.Mesh(box, "Mesh_Length_1D")
119 algo = mesh.Segment()
120 algo.NumberOfSegments(5)
121 algo = mesh.Triangle()
122 algo.MaxElementArea(20.)
123 mesh.Compute() 
124
125 # Criterion : Length > 3.
126 length_margin = 3.
127
128 aFilter = smesh.GetFilter(smesh.EDGE, smesh.FT_Length, smesh.FT_MoreThan, length_margin)
129 anIds = mesh.GetIdsFromFilter(aFilter) 
130
131 # print the result
132 print "Criterion: Edges length > ", length_margin, " Nb = ", len(anIds)
133 j = 1
134 for i in range(len(anIds)):
135   if j > 20: j = 1; print ""
136   print anIds[i],
137   j = j + 1
138   pass
139 print ""
140
141 # create a group
142 aGroup = mesh.CreateGroup(SMESH.EDGE, "Edges with length > " + `length_margin`)
143 aGroup.Add(anIds)
144
145 salome.sg.updateObjBrowser(1)
146 \endcode
147
148 <br>
149 \anchor tui_free_edges
150 <h2>Free Edges</h2>
151
152 \code
153 import SMESH_mechanic
154
155 smesh  = SMESH_mechanic.smesh
156 mesh   = SMESH_mechanic.mesh
157 salome = SMESH_mechanic.salome
158
159 aFilterMgr = smesh.CreateFilterManager()
160
161 # Remove some elements to obtain free edges
162 # Criterion : AREA > 95.
163 area_margin = 95.
164
165 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, area_margin)
166
167 anIds = mesh.GetIdsFromFilter(aFilter)
168
169 mesh.RemoveElements(anIds)
170
171 # Criterion : Free Edges
172 aBorders = mesh.GetFreeBorders() 
173
174 # create groups
175 aGroupF = mesh.CreateGroup(SMESH.FACE, "Faces with free edges")
176 aGroupN = mesh.CreateGroup(SMESH.NODE, "Nodes on free edges")
177
178 # fill groups with elements, corresponding to the criterion
179 print ""
180 print "Criterion: Free edges Nb = ", len(aBorders)
181 for i in range(len(aBorders)):
182   aBorder = aBorders[i]
183   print "Face # ", aBorder.myElemId, " : Edge between nodes (",
184   print aBorder.myPnt1, ", ", aBorder.myPnt2, ")"
185
186   aGroupF.Add([aBorder.myElemId])
187   aGroupN.Add([aBorder.myPnt1, aBorder.myPnt2])
188
189 salome.sg.updateObjBrowser(1)
190 \endcode
191
192 <br>
193 \anchor tui_length_2d
194 <h2>Length 2D</h2>
195
196 \code
197 import salome
198 import geompy
199
200 import smesh
201
202 # create open shell: a box without one plane
203 box = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
204 FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
205 FaceList.remove(FaceList[5])
206 box = geompy.MakeShell(FaceList)
207 idbox = geompy.addToStudy(box, "box")
208
209 # create a mesh
210 mesh = smesh.Mesh(box, "Mesh_Length_2D")
211 algo = mesh.Segment()
212 algo.NumberOfSegments(5)
213 algo = mesh.Triangle()
214 algo.MaxElementArea(20.)
215 mesh.Compute()
216
217 # Criterion : Length 2D > 5.7
218 length_margin = 5.7
219
220 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Length2D, smesh.FT_MoreThan, length_margin)
221
222 anIds = mesh.GetIdsFromFilter(aFilter)
223
224 # print the result
225 print "Criterion: Edges length 2D > ", length_margin, " Nb = ", len(anIds)
226 j = 1
227 for i in range(len(anIds)):
228   if j > 20: j = 1; print ""
229   print anIds[i],
230   j = j + 1
231   pass
232 print ""
233
234 # create a group
235 aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Faces with length 2D > " + `length_margin`)
236 aGroup.Add(anIds)
237
238 salome.sg.updateObjBrowser(1)
239 \endcode
240
241 <br>
242 \anchor tui_borders_at_multiconnection_2d
243 <h2>Borders at Multiconnection 2D</h2>
244
245 \code
246 import salome
247 import geompy
248
249 import smesh
250
251 # create a compound of two glued boxes
252 box1 = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
253 box2 = geompy.MakeTranslation(box1, 0., 20., 0)
254 comp = geompy.MakeCompound([box1, box2])
255 box = geompy.MakeGlueFaces(comp, 0.000001)
256 idbox = geompy.addToStudy(box, "box")
257
258 # create a mesh
259 mesh = smesh.Mesh(box, "Box compound : 2D triangle mesh")
260 algo = mesh.Segment()
261 algo.NumberOfSegments(5)
262 algo = mesh.Triangle()
263 algo.MaxElementArea(20.)
264 mesh.Compute() 
265
266 # Criterion : MULTI-CONNECTION 2D = 3
267 nb_conn = 3
268
269 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_MultiConnection2D, smesh.FT_EqualTo, nb_conn)
270
271 anIds = mesh.GetIdsFromFilter(aFilter) 
272
273 # print the result
274 print "Criterion: Borders at multi-connection 2D = ", nb_conn, " Nb = ", len(anIds)
275 j = 1
276 for i in range(len(anIds)):
277   if j > 20: j = 1; print ""
278   print anIds[i],
279   j = j + 1
280   pass
281 print ""
282
283 # create a group
284 aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Borders at multi-connection 2D = " + `nb_conn`)
285 aGroup.Add(anIds)
286
287 salome.sg.updateObjBrowser(1)
288 \endcode
289
290 <br>
291 \anchor tui_area
292 <h2>Area</h2>
293
294 \code
295 import SMESH_mechanic
296
297 smesh  = SMESH_mechanic.smesh
298 mesh   = SMESH_mechanic.mesh
299 salome = SMESH_mechanic.salome
300
301 # Criterion : AREA > 100.
302 area_margin = 100.
303
304 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, area_margin)
305
306 anIds = mesh.GetIdsFromFilter(aFilter) 
307
308 # print the result
309 print "Criterion: Area > ", area_margin, " Nb = ", len(anIds)
310 j = 1
311 for i in range(len(anIds)):
312   if j > 20: j = 1; print ""
313   print anIds[i],
314   j = j + 1
315   pass
316 print ""
317
318 # create a group
319 aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Area > " + `area_margin`)
320 aGroup.Add(anIds)
321
322 salome.sg.updateObjBrowser(1)  
323 \endcode
324
325 <br>
326 \anchor tui_taper
327 <h2>Taper</h2>
328
329 \code
330 import SMESH_mechanic
331
332 smesh  = SMESH_mechanic.smesh
333 mesh   = SMESH_mechanic.mesh
334 salome = SMESH_mechanic.salome
335
336 # Criterion : Taper > 3e-20
337 taper_margin = 3e-20
338
339 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Taper, smesh.FT_MoreThan, taper_margin)
340
341 anIds = mesh.GetIdsFromFilter(aFilter) 
342
343 # print the result
344 print "Criterion: Taper > ", taper_margin, " Nb = ", len(anIds)
345 j = 1
346 for i in range(len(anIds)):
347   if j > 20: j = 1; print ""
348   print anIds[i],
349   j = j + 1
350   pass
351 print ""
352
353 # create a group
354 aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Taper > " + `taper_margin`)
355 aGroup.Add(anIds)
356
357 salome.sg.updateObjBrowser(1)
358 \endcode
359
360 <br>
361 \anchor tui_aspect_ratio
362 <h2>Aspect Ratio</h2>
363
364 \code
365 import SMESH_mechanic
366
367 smesh  = SMESH_mechanic.smesh
368 mesh   = SMESH_mechanic.mesh
369 salome = SMESH_mechanic.salome
370
371 # Criterion : ASPECT RATIO > 1.8
372 ar_margin = 1.8
373
374 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_AspectRatio, smesh.FT_MoreThan, ar_margin)
375
376 anIds = mesh.GetIdsFromFilter(aFilter) 
377
378 # print the result
379 print "Criterion: Aspect Ratio > ", ar_margin, " Nb = ", len(anIds)
380 j = 1
381 for i in range(len(anIds)):
382   if j > 20: j = 1; print ""
383   print anIds[i],
384   j = j + 1
385   pass
386 print ""
387
388 # create a group
389 aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Aspect Ratio > " + `ar_margin`)
390 aGroup.Add(anIds)
391
392 salome.sg.updateObjBrowser(1)
393 \endcode
394
395 <br>
396 \anchor tui_minimum_angle
397 <h2>Minimum Angle</h2>
398
399 \code
400 import SMESH_mechanic
401
402 smesh  = SMESH_mechanic.smesh
403 mesh   = SMESH_mechanic.mesh
404 salome = SMESH_mechanic.salome
405
406 # Criterion : MINIMUM ANGLE < 35.
407 min_angle = 35.
408
409 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_MinimumAngle, smesh.FT_LessThan, min_angle)
410
411 anIds = mesh.GetIdsFromFilter(aFilter) 
412
413 # print the result
414 print "Criterion: Minimum Angle < ", min_angle, " Nb = ", len(anIds)
415 j = 1
416 for i in range(len(anIds)):
417   if j > 20: j = 1; print ""
418   print anIds[i],
419   j = j + 1
420   pass
421 print ""
422
423 # create a group
424 aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Minimum Angle < " + `min_angle`)
425
426 aGroup.Add(anIds)
427
428 salome.sg.updateObjBrowser(1)
429 \endcode
430
431 <br>
432 \anchor tui_warping
433 <h2>Warping</h2>
434
435 \code
436 import SMESH_mechanic
437
438 smesh  = SMESH_mechanic.smesh
439 mesh   = SMESH_mechanic.mesh
440 salome = SMESH_mechanic.salome
441
442 # Criterion : WARP ANGLE > 1e-15
443 wa_margin = 1e-15
444
445 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Warping, smesh.FT_MoreThan, wa_margin)
446
447 anIds = mesh.GetIdsFromFilter(aFilter) 
448
449 # print the result
450 print "Criterion: Warp > ", wa_margin, " Nb = ", len(anIds)
451 j = 1
452 for i in range(len(anIds)):
453   if j > 20: j = 1; print ""
454   print anIds[i],
455   j = j + 1
456   pass
457 print ""
458
459 # create a group
460 aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Warp > " + `wa_margin`)
461
462 aGroup.Add(anIds)
463
464 salome.sg.updateObjBrowser(1) 
465 \endcode
466
467 <br>
468 \anchor tui_skew
469 <h2>Skew</h2>
470
471 \code
472 import SMESH_mechanic
473
474 smesh  = SMESH_mechanic.smesh
475 mesh   = SMESH_mechanic.mesh
476 salome = SMESH_mechanic.salome
477
478 # Criterion : Skew > 38.
479 skew_margin = 38.
480
481 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Skew, smesh.FT_MoreThan, skew_margin)
482
483 anIds = mesh.GetIdsFromFilter(aFilter)
484
485 # print the result
486 print "Criterion: Skew > ", skew_margin, " Nb = ", len(anIds)
487 j = 1
488 for i in range(len(anIds)):
489   if j > 20: j = 1; print ""
490   print anIds[i],
491   j = j + 1
492   pass
493 print ""
494
495 # create a group
496 aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Skew > " + `skew_margin`)
497 aGroup.Add(anIds)
498
499 salome.sg.updateObjBrowser(1)
500 \endcode
501
502 <br>
503 \anchor tui_aspect_ratio_3d
504 <h2>Aspect Ratio 3D</h2>
505
506 \code
507 import SMESH_mechanic_tetra 
508
509 smesh  = SMESH_mechanic_tetra.smesh
510 mesh   = SMESH_mechanic_tetra.mesh
511 salome = SMESH_mechanic_tetra.salome
512
513 # Criterion : ASPECT RATIO 3D > 4.5
514 ar_margin = 4.5
515
516 aFilter = smesh.GetFilter(smesh.VOLUME, smesh.FT_AspectRatio3D, smesh.FT_MoreThan, ar_margin)
517
518 anIds = mesh.GetIdsFromFilter(aFilter) 
519
520 # print the result
521 print "Criterion: Aspect Ratio 3D > ", ar_margin, " Nb = ", len(anIds)
522 j = 1
523 for i in range(len(anIds)):
524   if j > 20: j = 1; print ""
525   print anIds[i],
526   j = j + 1
527   pass
528 print ""
529
530 # create a group
531 aGroup = mesh.CreateEmptyGroup(smesh.VOLUME, "Aspect Ratio 3D > " + `ar_margin`)
532
533 aGroup.Add(anIds)
534
535 salome.sg.updateObjBrowser(1)
536 \endcode
537
538 <br>
539 \anchor tui_volume
540 <h2>Volume</h2>
541
542 \code
543 import SMESH_mechanic_tetra
544
545 smesh  = SMESH_mechanic_tetra.smesh
546 mesh   = SMESH_mechanic_tetra.mesh
547 salome = SMESH_mechanic_tetra.salome
548
549 # Criterion : VOLUME < 7.
550 volume_margin = 7.
551
552 aFilter = smesh.GetFilter(smesh.VOLUME, smesh.FT_Volume3D, smesh.FT_LessThan, volume_margin)
553
554 anIds = mesh.GetIdsFromFilter(aFilter) 
555
556 # print the result
557 print ""
558 print "Criterion: Volume < ", volume_margin, " Nb = ", len(anIds)
559 j = 1
560 for i in range(len(anIds)):
561   if j > 20: j = 1; print ""
562   print anIds[i],
563   j = j + 1
564   pass
565 print ""
566
567 # create a group
568 aGroup = mesh.CreateEmptyGroup(smesh.VOLUME, "Volume < " + `volume_margin`)
569
570 aGroup.Add(anIds)
571
572 salome.sg.updateObjBrowser(1) 
573 \endcode
574
575 */