Scheme file for scaling cell zones through journal file

There might be a need for scaling all the zones with same scaling factors in TGrid. If there are many zones then it becomes cumbersome to invoke the necessary TUI command for all of them individually in the Journal file. The following scheme file can then be used to scale all the zones in the geometry by similar scaling factors.

The input required for this is (input 3 2 1) (parenthesis should be included in the command)
where 3 is the scaling factor for x direction
2 is the scaling factor for y direction
1 is the scaling factor for z direction
;; scale.scm
;; Rename all zones with similar scaling factors
;; Give the scale parameters along x y and z direction as '(input x y z)'
;; Do not alter below this line
(define input
(lambda ( xs ys zs)
(set! xs (number->string xs))
(set! ys (number->string ys))
(set! zs (number->string zs))
(define imin 0)
(define i 0)
(define zstr)
(set! zstr (get-threads Entity-Cell))
(set! zstr (format #f "~a" zstr))
(define str " ")
(define slen)
(set! slen (string-length zstr))
(define tcount 0)
(define testchar)
(define blankchar " ")
(define t1 " ")
(define t2 " ")
(define t4)
(define t5)
(define tc 0)
(define k 1)
(define m)
(define n)
(do (( i imin (+ i 1)))
((= i slen))
(set! testchar (string-ref zstr i))
(set! testchar (format #f "~a" testchar))
(if (equal? testchar blankchar)
(set! tcount (+ tcount 1)))
(if (equal? tcount 1)
(if (equal? tc 0)
(set! tc 1)
(set! k (+ i 1))
(set! m (+ k 1))
(set! t1 (string-ref zstr k))
(set! t4 (string-ref zstr m))
(set! t4 (format #f "~a" t4))
(set! t2 (format #f "~a" t1))
(cond ((equal? t4 blankchar)
(display ""))
(set! t2 (string-append t2 t4))
(set! n (+ m 1))
(set! t5 (string-ref zstr n))
(set! t5 (format #f "~a" t5))
(cond ((equal? t5 blankchar)
(display " "))
(set! t2 (string-append t2 t5))))))
(set! str (string-append " " t2 str )))))
(if(equal? tcount 5)
(set! tcount 0)
(set! tc 0))))
(define cmd "Z")
(set! cmd (string-append "/mesh/zones/scale "))
(ti-menu-load-string (string-append cmd str " , " xs " " ys " " zs " , "))

Show Form
No comments yet. Be the first to add a comment!