automate post processing
It is required many times to create a series of iso-surfaces, postprocess some variables on these iso-surfaces and write the data into a file for further use. Following scheme file can be used for the purpose. ;scheme file to automate the postprocessing ;The scheme file will create iso surfaces based on x cordinate and will ;report total temperature, total pressure, mach number and custom field ;function (which is equal to axial velocity * density) and writes the ;data into a file (define extract_value (lambda (str) (set! str (with-output-to-string (lambda () (ti-menu-load-string str) ))) (let ((lis)(len)(value ())) (set! lis (reverse (string->list str))) (set! len (length lis)) (do ( (i 1 (+ i 1)) ) ((char=? (list-ref lis i) #space)) (set! value (append value (list (list-ref lis i)))) ) (set! value (string->number (list->string (reverse value)))) (+ 0 value) ) ) ) ; the above section is only to extract the information from a string. In general, there ; is no need to modify this section. (define total_press) (define total_temp) (define mach) (define custom) ; output file where data will be written (define outputport (open-output-file "result.dat")) (format outputport "~a " "(x-cord total_pressure total_temperature mach_number density*axial_vel)" ) (newline outputport) (newline outputport) (newline outputport) (do ( (i 1 (+ i 1)) ) ( ; the number 10 shows that the loop will be executed 10 times (> i 10) ) (define new_value) ; new value is the iso value of some variable, currently it is 0.1, 0.2 ,0.3 ....etc upto 1 ; change this value accordingly (set! new_value (/ i 10)) (define str) ; create iso surface for a given iso value which is given by variable new_value, eg., in following section ; iso-surface based on x cordinate are created. (ti-menu-load-string (format #f "surface iso-surface x-coordinate x=~d , ~d , " new_value new_value )) ; following section will report the mass weighted average of different variables on newly ; created surfacese based on iso value of x coordinate and will give the output to variable "str". (set! str (string-append "rep surface-mass-avg " (string-append "x=" (number->string new_value ) ) " , total-pressure")) ; extract the value from variable str (set! total_press (extract_value str ) ) (set! str (string-append "rep surface-mass-avg " (string-append "x=" (number->string new_value ) ) " , total-temperature")) (set! total_temp (extract_value str ) ) (set! str (string-append "rep surface-mass-avg " (string-append "x=" (number->string new_value ) ) " , mach-number")) (set! mach (extract_value str ) ) (set! str (string-append "rep surface-mass-avg " (string-append "x=" (number->string new_value ) ) " , custom-1")) (set! custom (extract_value str ) ) (format outputport "~a ~a ~a ~a ~a" new_value total_press total_temp mach custom ) (newline outputport) ) (close-output-port outputport) |
||
|