Week - 11 - Element quality check
OBJECTIVE:
- To create element quality check macro for 2D and 3D elements
- To create a button for each criteria. On pressing the button the elements should be highlighted using temp nodes. Entry boxes next to the buttons will accept the quality criteria value
PROCEDURE:
- Firstly, create a GUI for element quality check with all the necessary buttons for the check.
- Also, create a text entry field for each button to get the value for the specific quality criteria.
- Display the failed elements, and then create temp nodes for the same.
- At the end create a button to clear all the temp nodes.
CODE:
*createmark elems 1 "displayed"
if {[hm_marklength elems 1]!=0} {
*clearmarkall 1;
*clearmarkall 2;
set a .window
catch {destroy $a}
toplevel $a -class TopLevel
wm title $a "Element Quality Check"
wm geometry $a 300x550+1000+100; update
wm resizable $a 0 0
wm deiconify $a
#labels
label $a.01 -text "2D ELEMENTS QUALITY CHECK" -bg yellow -font {times 10 bold}; place $a.01 -x 0 -y 0 -width 300 -height 20
label $a.02 -text "3D ELEMENTS QUALITY CHECK" -bg yellow -font {times 10 bold}; place $a.02 -x 0 -y 340 -width 300 -height 20
label $a.03 -text "ELEMENTS QUALITY CHECK" -bg yellow -font {times 12 bold}; place $a.03 -x 0 -y 500 -width 300 -height 50
#buttons
button $a.11 -text "Min Length" -command {min_leng $min_l} -bg grey -font {times 10 bold}; place $a.11 -x 25 -y 30 -width 100 -height 20
button $a.12 -text "Max Length" -command {max_leng $max_l} -bg grey -font {times 10 bold}; place $a.12 -x 25 -y 60 -width 100 -height 20
button $a.13 -text "Warpage" -command {warpage $w} -bg grey -font {times 10 bold}; place $a.13 -x 25 -y 90 -width 100 -height 20
button $a.14 -text "Skew" -command {skew $s} -bg grey -font {times 10 bold}; place $a.14 -x 25 -y 120 -width 100 -height 20
button $a.15 -text "Aspect" -command {aspect $asp} -bg grey -font {times 10 bold}; place $a.15 -x 25 -y 150 -width 100 -height 20
button $a.16 -text "Jacobian" -command {jacobian $j} -bg grey -font {times 10 bold}; place $a.16 -x 25 -y 180 -width 100 -height 20
button $a.17 -text "Min Quad Angle" -command {min_quad_angle $min_qa_ang} -bg grey -font {times 10 bold}; place $a.17 -x 25 -y 210 -width 100 -height 20
button $a.18 -text "Max Quad Angle" -command {max_quad_angle $max_qa_ang} -bg grey -font {times 10 bold}; place $a.18 -x 25 -y 240 -width 100 -height 20
button $a.19 -text "Min tria Angle" -command {min_tria_angle $min_ta_ang} -bg grey -font {times 10 bold}; place $a.19 -x 25 -y 270 -width 100 -height 20
button $a.101 -text "Max tria Angle" -command {max_tria_angle $max_ta_ang} -bg grey -font {times 10 bold}; place $a.101 -x 25 -y 300 -width 100 -height 20
button $a.102 -text "Warpage" -command {warpage_3d $warp} -bg grey -font {times 10 bold}; place $a.102 -x 25 -y 370 -width 100 -height 20
button $a.103 -text "Tetra Collapse" -command {tetcollapse $tet} -bg grey -font {times 10 bold}; place $a.103 -x 25 -y 400 -width 100 -height 20
button $a.104 -text "Volume Skew " -command {vskew $v_skew} -bg grey -font {times 10 bold}; place $a.104 -x 25 -y 430 -width 100 -height 20
button $a.105 -text "Clear Nodes" -command {clear} -bg blue -font {times 10 bold}; place $a.105 -x 20 -y 470 -width 100 -height 20
button $a.106 -text "Close" -command "destroy $a" -bg red -font {times 12 bold}; place $a.106 -x 150 -y 470 -width 100 -height 20
#textfields
entry $a.21 -textvariable min_l -bg white -font {times 10}; place $a.21 -x 165 -y 30 -width 100 -height 20
entry $a.22 -textvariable max_l -bg white -font {times 10}; place $a.22 -x 165 -y 60 -width 100 -height 20
entry $a.23 -textvariable w -bg white -font {times 10}; place $a.23 -x 165 -y 90 -width 100 -height 20
entry $a.24 -textvariable s -bg white -font {times 10}; place $a.24 -x 165 -y 120 -width 100 -height 20
entry $a.25 -textvariable asp -bg white -font {times 10}; place $a.25 -x 165 -y 150 -width 100 -height 20
entry $a.26 -textvariable j -bg white -font {times 10}; place $a.26 -x 165 -y 180 -width 100 -height 20
entry $a.27 -textvariable min_qa_ang -bg white -font {times 10}; place $a.27 -x 165 -y 210 -width 100 -height 20
entry $a.28 -textvariable max_qa_ang -bg white -font {times 10}; place $a.28 -x 165 -y 240 -width 100 -height 20
entry $a.29 -textvariable min_ta_ang -bg white -font {times 10}; place $a.29 -x 165 -y 270 -width 100 -height 20
entry $a.201 -textvariable max_ta_ang -bg white -font {times 10}; place $a.201 -x 165 -y 300 -width 100 -height 20
entry $a.202 -textvariable warp -bg white -font {times 10}; place $a.202 -x 165 -y 370 -width 100 -height 20
entry $a.203 -textvariable tet -bg white -font {times 10}; place $a.203 -x 165 -y 400 -width 100 -height 20
entry $a.204 -textvariable v_skew -bg white -font {times 10}; place $a.204 -x 165 -y 430 -width 100 -height 20
proc min_leng {min_l} {
if {$min_l==""} {tk_messageBox -message "Enter the minimum length and click again!" -icon warning -type ok -title Message
} else {
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestlength elements 1 $min_l 2 1 2 0 " 2D Min Length "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
}
proc max_leng {max_l} {
if {$max_l==""} {tk_messageBox -message "Enter the maximum length and click again!" -icon warning -type ok -title Message
} else {
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestlength elements 1 $max_l 2 0 2 0 " 2D Max Length "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
}
proc warpage {w} {
if {$w==""} {tk_messageBox -message "Enter the warpage and click again!" -icon warning -type ok -title Message
} else {
*nodecleartempmark
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestwarpage elements 1 $w 2 2 0 " 2D Warpage "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
}
proc skew {s} {
if {$s==""} {tk_messageBox -message "Enter the skewness and click again!" -icon warning -type ok -title Message
} else {
*nodecleartempmark
*nodecleartempmark
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestskew elements 1 $s 2 2 0 " 2D Skew "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
}
proc aspect {asp} {
if {$asp==""} {tk_messageBox -message "Enter the 2D Aspect Ratio and click again!" -icon warning -type ok -title Message
} else {
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestaspect elements 1 $asp 2 2 0 " 2D Aspect Ratio "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
}
proc jacobian {j} {
if {$j==""} {tk_messageBox -message "Enter the 2D Jacobian and click again!" -icon warning -type ok -title Message
} else {
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestjacobian elements 1 $j 2 2 0 " 2D Jacobian "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
}
proc min_quad_angle {min_qa_ang} {
if {$min_qa_ang==""} {tk_messageBox -message "Enter the 2D Quad Min Angle and click again!" -icon warning -type ok -title Message
} else {
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestinterangle elements 1 $min_qa_ang 0 2 1 2 0 " 2D Quad Min Angle "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
}
proc max_quad_angle {max_qa_ang} {
if {$max_qa_ang==""} {tk_messageBox -message "Enter the 2D Quad Max Angle and click again!" -icon warning -type ok -title Message
} else {
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestinterangle elements 1 $max_qa_ang 0 2 0 2 0 " 2D Quad Max Angle "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
}
proc min_tria_angle {min_ta_ang} {
if {$min_ta_ang==""} {tk_messageBox -message "Enter the 2D Tria Min Angle and click again!" -icon warning -type ok -title Message
} else {
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestinterangle elements 1 $min_ta_ang 1 2 1 2 0 " 2D Tria Min Angle "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
}
proc max_tria_angle {max_ta_ang} {
if {$max_ta_ang==""} {tk_messageBox -message "Enter the 2D Tria Max Angle and click again!" -icon warning -type ok -title Message
} else {
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestinterangle elements 1 $max_ta_ang 1 2 0 2 0 " 2D Tria Max Angle "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
}
proc warpage_3d {warp} {
if {$warp==""} {tk_messageBox -message "Enter the 3D warpage and click again!" -icon warning -type ok -title Message
} else {
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestwarpage elements 1 $warp 2 4 0 " 3D Warpage "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
}
proc tetcollapse {tet} {
if {$tet==""} {tk_messageBox -message "Enter the 3D Tetra collapse and click again!" -icon warning -type ok -title Message
} else {
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtesttetracollapse elements 1 $tet 2 0 " 3D Tetra Collapse "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
}
proc vskew {v_skew} {
if {$v_skew==""} {tk_messageBox -message "Enter the 3D skewness and click again!" -icon warning -type ok -title Message
} else {
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestvolumetricskew elements 1 $v_skew 2 0 " 3D Volumetric Skew "
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
}
proc clear {} {
*nodecleartempmark
}
} else {tk_messageBox -message "There are no displayed elements" -icon warning -type ok -title Message}
GRAPHICAL USER INTERFACE:

CONCLUSION:
- Learned to create a GUI to help the user to speed up the element quality checks.