# # Copyright 2002 (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. # # Create a 2D block for every domain. # Note: Expects a 2D flow solver to already be selected # Existing 2D blocks are not touched. # This script will fail if grid is not topologically 2D # (i.e. if any connector is used more than twice). package require PWI_Glyph 1.4 # See if the flow solver needs to be set to 2D mode set dim [gg::aswSet -dim] if {$dim != 2} { if {[llength [gg::blkGetAll]] > 0} { error "3D blocks are present in the system. Can not proceed." } set fsName [gg::aswSet] # If the current flow solver doesn't support 2D, switch to the GENERIC solver if {[catch {gg::aswSet $fsName -dim 2}]} { gg::aswSet GENERIC -dim 2 } puts "Changed flow solver to [string toupper [gg::aswSet]], dimension [gg::aswSet -dim]" } set Doms [gg::domGetAll] set nDoms [llength $Doms] # check for existing 2D blocks set ExBlks [gg::blkGetAll] set nExBlks [llength $ExBlks] # create a list of doms already used in blocks set UsedDoms [list] for {set mb 0} {$mb < $nExBlks} {incr mb} { foreach domid [lindex [gg::blkGetFace [lindex $ExBlks $mb]] 0] { lappend UsedDoms $domid } } # Create a new 2D block for each unused domain. for {set md 0} {$md < $nDoms} {incr md} { set domid [lindex $Doms $md] if { [lsearch $UsedDoms $domid] == -1 } { gg::blkBegin -type STRUCTURED gg::faceBegin gg::faceAddDom $domid gg::faceEnd if {[catch {gg::blkEnd} msg]} { if {[regexp -- {insufficient number} $msg]} { return -code error "Selected Flow Solver is not 2D" } else { error $msg } } } } set Blks [gg::blkGetAll] set nBlks [llength $Blks] # Align each block's IJ coordinates with either # a) the first Existing Block or # b) the 1st new block. if { $nExBlks > 0 } { set root [lindex $ExBlks 0] } else { set root [lindex $Blks 0] } gg::blkSpecifyIJK [gg::blkGetAll] -align_with $root # Write summary of action to stdout. puts "Created [expr $nBlks - $nExBlks] new 2D blocks." # 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.