Renaming of zones which start with a specified string


There might be a need for changing the name of a zone which starts with a particular string for eg to control zone names generated automatically by Fluent when executing some commands such as "Fuse face zones" or "extrude-face-zone" or to control names of the zones created while growing prisms in Tgrid.

The following scheme files serve the purpose.Please note that the two scheme files are different and work only in their respective
softwares.


*************************************************************
FLUENT Scheme File
*************************************************************

;rename.scm
;Rename all zones whose names begin with a specified string
;Usage: (rename-zones-* "inlet" "myname")
;All the names starting with inlet* would be changed to myname*

(define (rename-zones-* old-begin new-begin)
(let ((old-begin-length (string-length old-begin)))
(let loop ((threads (get-all-threads )))
(if (pair? threads)
(let ((old-name (symbol->string (thread-name (car threads)))))
(if (and (>= (string-length old-name) old-begin-length)
(string=? old-begin
(substring old-name 0 old-begin-length)))
(begin
(let (
(new-name (string-append new-begin
(substring old-name
old-begin-length
(string-length old-name)))))
(send (car threads) set-var! 'name (string->symbol new-name))
(format "nZone ~a renamed to ~a" old-name new-name))))
(loop
(cdr threads))))
(display "n"))))

**********************************************************************


************************************************************************
TGRID Scheme File
************************************************************************

;rename.scm
;Rename all zones whose names begin with a specified string
;Usage: (rename-zones-* "prism-cells" "myname")
;All the names starting with prism-cells* would be changed to myname*

(define (rename-zones-* old-begin new-begin)
(let ((old-begin-length (string-length old-begin)))
(let loop ((threads (get-threads)))
(if (pair? threads)
(loop
(let ((old-name (thread-name (car threads))))
(if (and (>= (string-length old-name) old-begin-length)
(string=? old-begin
(substring old-name 0 old-begin-length)))
(let (
(new-name (string-append new-begin
(substring old-name
old-begin-length
(string-length old-name)))))
(set-thread-name (car threads) new-name)
(format "nZone ~a renamed to ~a" old-name new-name)))
(cdr threads))))))
(display "n"))

*******************************************************************************





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