# # Copyright 2006 (c) Pointwise, Inc. # All rights reserved. # # This sample Gridgen script is not supported by Pointwise, Inc. # It is provided freely for demonstration purposes only. # SEE THE WARRANTY DISCLAIMER AT THE BOTTOM OF THIS FILE. # # This script will calculate maximum deviation of unstructured domain # cell center points from their underlying database surface. # The cell center point deviation is only calculated if all three # cell vertices lie on the same database surface. # # package require PWI_Glyph 1.5.1 gg::updatePolicy DELAYED ############################################################ # PROC: UnsDomMaxDev # Calculates the maximum deviation of cell center points # from the underlying db surface. # Returns a list consisting of the maximum deviation # and a boolean of whether any of the cells were determined # to be db constrained (all three vertices lying on a surf). # proc UnsDomMaxDev {dom} { gg::domReport $dom diag "STRUCTURE REFERENCE" if { $diag(type) != "UNSTRUCTURED" } { error "Unstructured domains only!" } set numCells $diag(cellsTotal) set maxDev -99.0 for {set cell 1} {$cell <= $numCells} {incr cell} { set inds [gg::domGetCell $dom $cell] #-- calculate cell center point set Ctr [list 0.0 0.0 0.0] catch {unset cellDb} set dbs_match 1 for {set i 0} {$i < 3} {incr i} { set pind [lindex $inds $i] set pt [gg::domGetPt $dom $pind] for {set n 0} {$n < 3} {incr n} { set v [expr [lindex $Ctr $n] + [lindex $pt $n]/3.0] set Ctr [lreplace $Ctr $n $n $v] } if ![catch {gg::domGetPt $dom -db $pind} dbPt] { set db [lindex $dbPt 2] if [info exists cellDb] { if { $db == $cellDb && $dbs_match } { set dbs_match 1 } else { set dbs_match 0 } } else { set cellDb $db } } else { set dbs_match 0 } } #-- project cell center onto db and compute distance #-- from original position if {$dbs_match} { catch {unset minDs} foreach db $cellDb { if ![catch {gg::dbSurfClosestPt $db $Ctr} newPt] { set newPt [gg::dbUVToXYZ $newPt] set Ds [ggu::vec3Length [ggu::vec3Sub $Ctr $newPt]] if [info exists minDs] { if { $Ds < $minDs } { set minDs $Ds } } else { set minDs $Ds } } } if [info exists minDs] { if {$minDs > $maxDev} { set maxDev $minDs } } } } if { $maxDev < 0.0 } { set maxDev 0.0 set dbConstrained 0 } else { set dbConstrained 1 } return "$maxDev $dbConstrained" } set title "UnsDom MaxDev" set msg "Maximum surface deviation will be calculated for the selected unstructured domains." set doms [gg::dispPick DOMAIN -type UNSTRUCTURED -title $title -message $msg ] if {[llength $doms] > 0 } { puts " Domain Max Deviation" puts " ------ -------------" foreach dom $doms { set result [UnsDomMaxDev $dom] set maxDev [lindex $result 0] set dbConstrained [lindex $result 1] set dn [lindex [gg::domIdToNum $dom] 0] if {$dbConstrained} { puts [format " %5d %12.5e" $dn $maxDev] } else { puts [format " %5d Not on DB" $dn] } } } # # DISCLAIMER: # TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, POINTWISE DISCLAIMS # ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED # TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE, WITH REGARD TO THIS SCRIPT. TO THE MAXIMUM EXTENT PERMITTED # BY APPLICABLE LAW, IN NO EVENT SHALL POINTWISE BE LIABLE TO ANY PARTY # FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES # WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF # BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE # USE OF OR INABILITY TO USE THIS SCRIPT EVEN IF POINTWISE HAS BEEN # ADVISED OF THE POSSIBILITY OF SUCH DAMAGES AND REGARDLESS OF THE # FAULT OR NEGLIGENCE OF POINTWISE. #