Salome HOME
Merge from BR_V5_DEV 16Feb09
[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_free_nodes
194 <h2>Free Nodes</h2>
195
196 \code
197 import salome
198 import geompy
199
200 import smesh
201
202 # create box
203 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
204 idbox = geompy.addToStudy(box, "box")
205
206 # create a mesh
207 mesh = smesh.Mesh(box, "Mesh_free_nodes")
208 algo = mesh.Segment()
209 algo.NumberOfSegments(10)
210 algo = mesh.Triangle(smesh.MEFISTO)
211 algo.MaxElementArea(150.)
212 mesh.Compute() 
213
214 # Remove some elements to obtain free nodes
215 # Criterion : AREA < 80.
216 area_margin = 80.
217
218 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, area_margin)
219
220 anIds = mesh.GetIdsFromFilter(aFilter)
221
222 mesh.RemoveElements(anIds)
223
224 # criterion : free nodes
225 aFilter = smesh.GetFilter(smesh.NODE, smesh.FT_FreeNodes) 
226 anNodeIds = mesh.GetIdsFromFilter(aFilter)
227
228 # create a group
229 aGroup = mesh.CreateEmptyGroup(smesh.NODE, "Free_nodes")
230 aGroup.Add(anNodeIds)
231
232 # print the result
233 print "Criterion: Free nodes Nb = ", len(anNodeIds)
234 j = 1
235 for i in range(len(anNodeIds)):
236   if j > 20: j = 1; print ""
237   print anNodeIds[i],
238   j = j + 1
239   pass
240 print ""
241
242 salome.sg.updateObjBrowser(1)
243 \endcode
244
245
246 <br>
247 \anchor tui_free_faces
248 <h2>Free Faces</h2>
249
250 \code
251 import salome
252 import geompy
253
254 ####### GEOM part ########
255
256 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
257 Box_1_vertex_6 = geompy.GetSubShape(Box_1, [6])
258 Box_1 = geompy.GetMainShape(Box_1_vertex_6)
259 Box_1_vertex_16 = geompy.GetSubShape(Box_1, [16])
260 Box_1 = geompy.GetMainShape(Box_1_vertex_16)
261 Box_1_vertex_11 = geompy.GetSubShape(Box_1, [11])
262 Box_1 = geompy.GetMainShape(Box_1_vertex_11)
263 Plane_1 = geompy.MakePlaneThreePnt(Box_1_vertex_6, Box_1_vertex_16, Box_1_vertex_11, 2000)
264 Partition_1 = geompy.MakePartition([Box_1], [Plane_1], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
265
266 Box_1_vertex_19 = geompy.GetSubShape(Box_1, [19])
267 Box_1_vertex_21 = geompy.GetSubShape(Box_1, [21])
268 Plane_2 = geompy.MakePlaneThreePnt(Box_1_vertex_16, Box_1_vertex_19, Box_1_vertex_21, 2000)
269
270 geompy.addToStudy( Box_1, "Box_1" )
271 geompy.addToStudyInFather( Box_1, Box_1_vertex_6, "Box_1:vertex_6" )
272 geompy.addToStudyInFather( Box_1, Box_1_vertex_16, "Box_1:vertex_16" )
273 geompy.addToStudyInFather( Box_1, Box_1_vertex_11, "Box_1:vertex_11" )
274 geompy.addToStudy( Plane_1, "Plane_1" )
275 geompy.addToStudy( Partition_1, "Partition_1" )
276 geompy.addToStudyInFather( Box_1, Box_1_vertex_19, "Box_1:vertex_19" )
277 geompy.addToStudyInFather( Box_1, Box_1_vertex_21, "Box_1:vertex_21" )
278 geompy.addToStudy( Plane_2, "Plane_2" )
279
280 ###### SMESH part ######
281 import smesh
282
283 import StdMeshers
284 import NETGENPlugin
285
286 Mesh_1 = smesh.Mesh(Partition_1)
287 Regular_1D = Mesh_1.Segment()
288 Max_Size_1 = Regular_1D.MaxSize(34.641)
289 MEFISTO_2D = Mesh_1.Triangle()
290 Tetrahedron_Netgen = Mesh_1.Tetrahedron(algo=smesh.NETGEN)
291 isDone = Mesh_1.Compute()
292
293 # create a group of free faces
294 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_FreeFaces )
295 aFaceIds = Mesh_1.GetIdsFromFilter(aFilter)
296
297 aGroup = Mesh_1.CreateEmptyGroup(smesh.FACE, "Free_faces")
298 aGroup.Add(aFaceIds)
299
300 # print the result
301 print "Criterion: Free nodes Nb = ", len(anNodeIds)
302 j = 1
303 for i in range(len(aFaceIds)):
304   if j > 20: j = 1; print ""
305   print anNodeIds[i],
306   j = j + 1
307   pass
308 print ""
309
310 #filter faces from plane 2
311 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_BelongToPlane, Plane_2)
312 aFaceIds = Mesh_1.GetIdsFromFilter(aFilter)
313 aGroup.Remove(aFaceIds)
314
315 # create a group of shared faces (located on partition boundary inside box)
316 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_BelongToPlane, Plane_1)
317 aFaceIds = Mesh_1.GetIdsFromFilter(aFilter)
318
319 aGroup = Mesh_1.CreateEmptyGroup(smesh.FACE, "Shared_faces")
320 aGroup.Add(aFaceIds)
321
322 salome.sg.updateObjBrowser(1)
323 \endcode
324
325
326 <br>
327 \anchor tui_length_2d
328 <h2>Length 2D</h2>
329
330 \code
331 import salome
332 import geompy
333
334 import smesh
335
336 # create open shell: a box without one plane
337 box = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
338 FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
339 FaceList.remove(FaceList[5])
340 box = geompy.MakeShell(FaceList)
341 idbox = geompy.addToStudy(box, "box")
342
343 # create a mesh
344 mesh = smesh.Mesh(box, "Mesh_Length_2D")
345 algo = mesh.Segment()
346 algo.NumberOfSegments(5)
347 algo = mesh.Triangle()
348 algo.MaxElementArea(20.)
349 mesh.Compute()
350
351 # Criterion : Length 2D > 5.7
352 length_margin = 5.7
353
354 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Length2D, smesh.FT_MoreThan, length_margin)
355
356 anIds = mesh.GetIdsFromFilter(aFilter)
357
358 # print the result
359 print "Criterion: Edges length 2D > ", length_margin, " Nb = ", len(anIds)
360 j = 1
361 for i in range(len(anIds)):
362   if j > 20: j = 1; print ""
363   print anIds[i],
364   j = j + 1
365   pass
366 print ""
367
368 # create a group
369 aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Faces with length 2D > " + `length_margin`)
370 aGroup.Add(anIds)
371
372 salome.sg.updateObjBrowser(1)
373 \endcode
374
375 <br>
376 \anchor tui_borders_at_multiconnection_2d
377 <h2>Borders at Multiconnection 2D</h2>
378
379 \code
380 import salome
381 import geompy
382
383 import smesh
384
385 # create a compound of two glued boxes
386 box1 = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
387 box2 = geompy.MakeTranslation(box1, 0., 20., 0)
388 comp = geompy.MakeCompound([box1, box2])
389 box = geompy.MakeGlueFaces(comp, 0.000001)
390 idbox = geompy.addToStudy(box, "box")
391
392 # create a mesh
393 mesh = smesh.Mesh(box, "Box compound : 2D triangle mesh")
394 algo = mesh.Segment()
395 algo.NumberOfSegments(5)
396 algo = mesh.Triangle()
397 algo.MaxElementArea(20.)
398 mesh.Compute() 
399
400 # Criterion : MULTI-CONNECTION 2D = 3
401 nb_conn = 3
402
403 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_MultiConnection2D, smesh.FT_EqualTo, nb_conn)
404
405 anIds = mesh.GetIdsFromFilter(aFilter) 
406
407 # print the result
408 print "Criterion: Borders at multi-connection 2D = ", nb_conn, " Nb = ", len(anIds)
409 j = 1
410 for i in range(len(anIds)):
411   if j > 20: j = 1; print ""
412   print anIds[i],
413   j = j + 1
414   pass
415 print ""
416
417 # create a group
418 aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Borders at multi-connection 2D = " + `nb_conn`)
419 aGroup.Add(anIds)
420
421 salome.sg.updateObjBrowser(1)
422 \endcode
423
424 <br>
425 \anchor tui_area
426 <h2>Area</h2>
427
428 \code
429 import SMESH_mechanic
430
431 smesh  = SMESH_mechanic.smesh
432 mesh   = SMESH_mechanic.mesh
433 salome = SMESH_mechanic.salome
434
435 # Criterion : AREA > 100.
436 area_margin = 100.
437
438 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, area_margin)
439
440 anIds = mesh.GetIdsFromFilter(aFilter) 
441
442 # print the result
443 print "Criterion: Area > ", area_margin, " Nb = ", len(anIds)
444 j = 1
445 for i in range(len(anIds)):
446   if j > 20: j = 1; print ""
447   print anIds[i],
448   j = j + 1
449   pass
450 print ""
451
452 # create a group
453 aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Area > " + `area_margin`)
454 aGroup.Add(anIds)
455
456 salome.sg.updateObjBrowser(1)  
457 \endcode
458
459 <br>
460 \anchor tui_taper
461 <h2>Taper</h2>
462
463 \code
464 import SMESH_mechanic
465
466 smesh  = SMESH_mechanic.smesh
467 mesh   = SMESH_mechanic.mesh
468 salome = SMESH_mechanic.salome
469
470 # Criterion : Taper > 3e-20
471 taper_margin = 3e-20
472
473 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Taper, smesh.FT_MoreThan, taper_margin)
474
475 anIds = mesh.GetIdsFromFilter(aFilter) 
476
477 # print the result
478 print "Criterion: Taper > ", taper_margin, " Nb = ", len(anIds)
479 j = 1
480 for i in range(len(anIds)):
481   if j > 20: j = 1; print ""
482   print anIds[i],
483   j = j + 1
484   pass
485 print ""
486
487 # create a group
488 aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Taper > " + `taper_margin`)
489 aGroup.Add(anIds)
490
491 salome.sg.updateObjBrowser(1)
492 \endcode
493
494 <br>
495 \anchor tui_aspect_ratio
496 <h2>Aspect Ratio</h2>
497
498 \code
499 import SMESH_mechanic
500
501 smesh  = SMESH_mechanic.smesh
502 mesh   = SMESH_mechanic.mesh
503 salome = SMESH_mechanic.salome
504
505 # Criterion : ASPECT RATIO > 1.8
506 ar_margin = 1.8
507
508 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_AspectRatio, smesh.FT_MoreThan, ar_margin)
509
510 anIds = mesh.GetIdsFromFilter(aFilter) 
511
512 # print the result
513 print "Criterion: Aspect Ratio > ", ar_margin, " Nb = ", len(anIds)
514 j = 1
515 for i in range(len(anIds)):
516   if j > 20: j = 1; print ""
517   print anIds[i],
518   j = j + 1
519   pass
520 print ""
521
522 # create a group
523 aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Aspect Ratio > " + `ar_margin`)
524 aGroup.Add(anIds)
525
526 salome.sg.updateObjBrowser(1)
527 \endcode
528
529 <br>
530 \anchor tui_minimum_angle
531 <h2>Minimum Angle</h2>
532
533 \code
534 import SMESH_mechanic
535
536 smesh  = SMESH_mechanic.smesh
537 mesh   = SMESH_mechanic.mesh
538 salome = SMESH_mechanic.salome
539
540 # Criterion : MINIMUM ANGLE < 35.
541 min_angle = 35.
542
543 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_MinimumAngle, smesh.FT_LessThan, min_angle)
544
545 anIds = mesh.GetIdsFromFilter(aFilter) 
546
547 # print the result
548 print "Criterion: Minimum Angle < ", min_angle, " Nb = ", len(anIds)
549 j = 1
550 for i in range(len(anIds)):
551   if j > 20: j = 1; print ""
552   print anIds[i],
553   j = j + 1
554   pass
555 print ""
556
557 # create a group
558 aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Minimum Angle < " + `min_angle`)
559
560 aGroup.Add(anIds)
561
562 salome.sg.updateObjBrowser(1)
563 \endcode
564
565 <br>
566 \anchor tui_warping
567 <h2>Warping</h2>
568
569 \code
570 import SMESH_mechanic
571
572 smesh  = SMESH_mechanic.smesh
573 mesh   = SMESH_mechanic.mesh
574 salome = SMESH_mechanic.salome
575
576 # Criterion : WARP ANGLE > 1e-15
577 wa_margin = 1e-15
578
579 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Warping, smesh.FT_MoreThan, wa_margin)
580
581 anIds = mesh.GetIdsFromFilter(aFilter) 
582
583 # print the result
584 print "Criterion: Warp > ", wa_margin, " Nb = ", len(anIds)
585 j = 1
586 for i in range(len(anIds)):
587   if j > 20: j = 1; print ""
588   print anIds[i],
589   j = j + 1
590   pass
591 print ""
592
593 # create a group
594 aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Warp > " + `wa_margin`)
595
596 aGroup.Add(anIds)
597
598 salome.sg.updateObjBrowser(1) 
599 \endcode
600
601 <br>
602 \anchor tui_skew
603 <h2>Skew</h2>
604
605 \code
606 import SMESH_mechanic
607
608 smesh  = SMESH_mechanic.smesh
609 mesh   = SMESH_mechanic.mesh
610 salome = SMESH_mechanic.salome
611
612 # Criterion : Skew > 38.
613 skew_margin = 38.
614
615 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Skew, smesh.FT_MoreThan, skew_margin)
616
617 anIds = mesh.GetIdsFromFilter(aFilter)
618
619 # print the result
620 print "Criterion: Skew > ", skew_margin, " Nb = ", len(anIds)
621 j = 1
622 for i in range(len(anIds)):
623   if j > 20: j = 1; print ""
624   print anIds[i],
625   j = j + 1
626   pass
627 print ""
628
629 # create a group
630 aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Skew > " + `skew_margin`)
631 aGroup.Add(anIds)
632
633 salome.sg.updateObjBrowser(1)
634 \endcode
635
636 <br>
637 \anchor tui_aspect_ratio_3d
638 <h2>Aspect Ratio 3D</h2>
639
640 \code
641 import SMESH_mechanic_tetra 
642
643 smesh  = SMESH_mechanic_tetra.smesh
644 mesh   = SMESH_mechanic_tetra.mesh
645 salome = SMESH_mechanic_tetra.salome
646
647 # Criterion : ASPECT RATIO 3D > 4.5
648 ar_margin = 4.5
649
650 aFilter = smesh.GetFilter(smesh.VOLUME, smesh.FT_AspectRatio3D, smesh.FT_MoreThan, ar_margin)
651
652 anIds = mesh.GetIdsFromFilter(aFilter) 
653
654 # print the result
655 print "Criterion: Aspect Ratio 3D > ", ar_margin, " Nb = ", len(anIds)
656 j = 1
657 for i in range(len(anIds)):
658   if j > 20: j = 1; print ""
659   print anIds[i],
660   j = j + 1
661   pass
662 print ""
663
664 # create a group
665 aGroup = mesh.CreateEmptyGroup(smesh.VOLUME, "Aspect Ratio 3D > " + `ar_margin`)
666
667 aGroup.Add(anIds)
668
669 salome.sg.updateObjBrowser(1)
670 \endcode
671
672 <br>
673 \anchor tui_volume
674 <h2>Volume</h2>
675
676 \code
677 import SMESH_mechanic_tetra
678
679 smesh  = SMESH_mechanic_tetra.smesh
680 mesh   = SMESH_mechanic_tetra.mesh
681 salome = SMESH_mechanic_tetra.salome
682
683 # Criterion : VOLUME < 7.
684 volume_margin = 7.
685
686 aFilter = smesh.GetFilter(smesh.VOLUME, smesh.FT_Volume3D, smesh.FT_LessThan, volume_margin)
687
688 anIds = mesh.GetIdsFromFilter(aFilter) 
689
690 # print the result
691 print ""
692 print "Criterion: Volume < ", volume_margin, " Nb = ", len(anIds)
693 j = 1
694 for i in range(len(anIds)):
695   if j > 20: j = 1; print ""
696   print anIds[i],
697   j = j + 1
698   pass
699 print ""
700
701 # create a group
702 aGroup = mesh.CreateEmptyGroup(smesh.VOLUME, "Volume < " + `volume_margin`)
703
704 aGroup.Add(anIds)
705
706 salome.sg.updateObjBrowser(1) 
707 \endcode
708
709 */