# QMG test 9: an object like a hex nut with a triangular crack. # Make the brep 'from scratch'. # get a 6-segment circle approximation. global PI global gm_brep_type_code gmset {nodes1 scrap} [gm_circ_approx 0 2*$PI 6] set cplist {} # make a list of control points for the object. # Control pts 0-17 are 18 control points for the inner circle # of the bottom surface set nheight .3 for {set i 0} {$i < 18} {incr i} { set ci [lindex $nodes1 $i] lappend cplist [lindex $ci 0] lappend cplist [lindex $ci 1] lappend cplist -$nheight } # Control pts 18-35 are 18 control points for the inner circle # of the top surface for {set i 0} {$i < 18} {incr i} { set ci [lindex $nodes1 $i] lappend cplist [lindex $ci 0] lappend cplist [lindex $ci 1] lappend cplist $nheight } # Control pts 36-53 are 18 control points for the outer hexagon # of the bottom surface for {set i 0} {$i < 6} {incr i} { set sp [list [expr cos(2*$PI*$i/6)] [expr sin(2*$PI*$i/6)]] set ep [list [expr cos(2*$PI*($i+1)/6)] [expr sin(2*$PI*($i+1)/6)]] for {set j 0} {$j < 3} {incr j} { set wt2 [expr 1.7*$j / 3] set wt1 [expr 1.7*(3 - $j)/3] lappend cplist [expr $wt1*[lindex $sp 0] + $wt2*[lindex $ep 0]] lappend cplist [expr $wt1*[lindex $sp 1] + $wt2*[lindex $ep 1]] lappend cplist -$nheight } } # Control pts 54-71 are 18 control points for the outer hexagon # of the top surface for {set i 0} {$i < 6} {incr i} { set sp [list [expr cos(2*$PI*$i/6)] [expr sin(2*$PI*$i/6)]] set ep [list [expr cos(2*$PI*($i+1)/6)] [expr sin(2*$PI*($i+1)/6)]] for {set j 0} {$j < 3} {incr j} { set wt2 [expr 1.7*$j / 3] set wt1 [expr 1.7*(3 - $j)/3] lappend cplist [expr $wt1*[lindex $sp 0] + $wt2*[lindex $ep 0]] lappend cplist [expr $wt1*[lindex $sp 1] + $wt2*[lindex $ep 1]] lappend cplist $nheight } } # Control pts 72-74 are the control points bounding the crack. lappend cplist -1.3 0 0 lappend cplist -1.1 0.05 0 lappend cplist -1.23 .17 .05 # Create the list of topological vertices -- 6 on top and 6 on the bottom # to bound the two hexagons. set vertlist {} for {set j 0} {$j < 6} {incr j} { lappend vertlist vbottom$j {} {} {} [list [list vertex [expr 36+3*$j]]] } for {set j 0} {$j < 6} {incr j} { lappend vertlist vtop$j {} {} {} [list [list vertex [expr 54+3*$j]]] } # Topological vertices bounding the crack lappend vertlist vcrk0 {} {} {} {{vertex 72}} lappend vertlist vcrk1 {} {} {} {{vertex 73}} lappend vertlist vcrk2 {} {} {} {{vertex 74}} # Create the list of topological edges -- 6 on top, 6 on the bottom, # and 6 on the side to bound the two hexagons and side faces, # plus two circular curves and three edges bounding the crack. set edgelist {} # edges for bottom hex for {set j 0} {$j < 6} {incr j} { set nextj [expr ($j+1)%6] lappend edgelist ebottom$j {} [list vbottom$j vbottom$nextj] {} \ [list [list bezier_curve 1 [expr 36+3*$j] [expr 36+3*$nextj]]] } #edges for top hex for {set j 0} {$j < 6} {incr j} { set nextj [expr ($j+1)%6] lappend edgelist etop$j {} [list vtop$j vtop$nextj] {} \ [list [list bezier_curve 1 [expr 54+3*$j] [expr 54+3*$nextj]]] } #edges connecting top and bottom hex for {set j 0} {$j < 6} {incr j} { lappend edgelist eside$j {} [list vbottom$j vtop$j] {} \ [list [list bezier_curve 1 [expr 36+3*$j] [expr 54+3*$j]]] } # three circular edges # bottom circle set curves {} for {set j 0} {$j < 6} {incr j} { set nextj [expr ($j+1)%6] lappend curves \ [list bezier_curve 3 [expr 3*$j] [expr 3*$j+1] \ [expr 3*$j+2] [expr 3*$nextj]] } lappend edgelist ebottomcirc {} {} {} $curves # top circle set curves {} for {set j 0} {$j < 6} {incr j} { set nextj [expr ($j+1)%6] lappend curves \ [list bezier_curve 3 [expr 3*$j+18] [expr 3*$j+19] \ [expr 3*$j+20] [expr 3*$nextj +18]] } lappend edgelist etopcirc {} {} {} $curves # crack lappend edgelist ecrk0 {} {vcrk0 vcrk1} {} {{bezier_curve 1 72 73}} lappend edgelist ecrk1 {} {vcrk1 vcrk2} {} {{bezier_curve 1 73 74}} lappend edgelist ecrk2 {} {vcrk2 vcrk0} {} {{bezier_curve 1 74 72}} # Make the topological surfaces. There is one on bottom, one on top, # on for the inside, six for the outside, and one for the crack. set surflist {} # bottom surface set patches {} for {set j 0} {$j < 6} {incr j} { set nextj [expr ($j+1)%6] lappend patches [list bezier_quad 3 1 [expr 36+3*$j] \ [expr 37+3*$j] [expr 38+3*$j] [expr 36+3*$nextj] \ [expr 3*$j] [expr 3*$j+1] [expr 3*$j+2] [expr 3*$nextj]] } lappend surflist s_bottom {} \ {ebottomcirc ebottom0 ebottom1 ebottom2 ebottom3 ebottom4 ebottom5} \ {} $patches # top surface set patches {} for {set j 0} {$j < 6} {incr j} { set nextj [expr ($j+1)%6] lappend patches [list bezier_quad 3 1 [expr 54+3*$j] \ [expr 55+3*$j] [expr 56+3*$j] [expr 54+3*$nextj] \ [expr 3*$j+18] [expr 3*$j+19] [expr 3*$j+20] [expr 3*$nextj+18]] } lappend surflist s_top {} \ {etopcirc etop0 etop1 etop2 etop3 etop4 etop5} \ {} $patches # inner surface set patches {} for {set j 0} {$j < 6} {incr j} { set nextj [expr ($j+1)%6] lappend patches [list bezier_quad 3 1 [expr 3*$j] \ [expr 3*$j+1] [expr 3*$j+2] [expr 3*$nextj] \ [expr 3*$j+18] [expr 3*$j+19] [expr 3*$j+20] [expr 3*$nextj+18]] } lappend surflist s_inner {} {ebottomcirc etopcirc} {} $patches # six outer surfaces for {set j 0} {$j < 6} {incr j} { set nextj [expr ($j+1)%6] lappend surflist s_outer$j {} [list ebottom$j etop$j eside$j eside$nextj] \ {} [list [list bezier_quad 1 1 [expr 3*$j+36] [expr 3*$nextj+36] \ [expr 3*$j+54] [expr 3*$nextj+54]]] } #crack surface lappend surflist crack {} {ecrk0 ecrk1 ecrk2} {} {{bezier_triangle 1 72 73 74}} set brepl [list $gm_brep_type_code 3 3 {} $cplist $vertlist $edgelist \ $surflist {hexnutcrack {} {s_bottom s_top s_inner \ s_outer0 s_outer1 s_outer2 s_outer3 s_outer4 s_outer5 crack crack} \ {} {}}] gmset hexobj [gmrndcolor [gm_list2obj $brepl]] set show 0 if {[llength [info globals interactive]]} { set show 1 } gmset mesh [gmmeshgen $hexobj show $show] gmset {hexobj2 mesh2} [gmdouble $hexobj 0 $mesh] set asp [gmchecktri $hexobj2 $mesh2] gmset {numvtx numelt} [gmmeshsize $mesh2] if {[llength [info globals meshsizesum]]} { global meshsizesum set meshsizesum [expr $meshsizesum + $numvtx] global aspprod set aspprod [expr $aspprod * asp] } # ------------------------------------------------------------------ # Copyright (c) 1999 by Cornell University. All rights reserved # See the accompanying file 'Copyright' for authorship information, # the terms of the license governing this software, and disclaimers # concerning this software. # ------------------------------------------------------------------ # This file is part of the QMG software. # Version 2.0 of QMG, release date RELDATE. # ------------------------------------------------------------------