CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   Two conditions in Fluent journal files (http://www.cfd-online.com/Forums/fluent/94224-two-conditions-fluent-journal-files.html)

bobmalaria November 9, 2011 14:42

Two conditions in Fluent journal files
 
hi,

I have an FLUENT journal file I use for post-processing.

The journal reads in cas and dat files I auto-saved and performs a certain action.
the files are in the format

bla-bla-bla-0050.cas
.
.
.
bla-bla-bla-0120.cas

so basically a number increasing in increments of 10. This causes probelms when I read the file.

Code:

(define (my-post-proc);;name of the journal-function
;;
(define nstart 50);; time-step # for the 1st data set
(define nsave 10) ;; auto-save frequency
(define ndata 100) ;; # of data-sets
(do ((i nstart (+ nsave i)))((= i (+ nstart (* ndata nsave))))
(if (< i 100)
(define basename "file-00") ;;Filename prefixfor the data files
((if (< i 100)(define basename "file-0")(define basename "file-")))
)
(begin
(ti-menu-load-string(format #f "f rcd ~a~d.cas" basename i))
)))

As you can see the variable i holds the current file number. What I was trying to do is

Code:

If filenumber <100
then
file name = file-00 i
else
if file number < 1000
file name = file-0 i
else
file name = file-

while this works fine with the < 100 condition only, the second if loop causes an error.

Any ideas? Thanks

Amir November 9, 2011 16:24

Hi Martin,

why didn't you use another program (journal generator) for this purpose? (Any other languages which can generate expanded journal file; I usually use FORTRAN)

Bests,

bobmalaria November 9, 2011 17:09

hi amir,

the problem ist not the generation of the journal file itself.
it needs to be in the scheme language for fluent to understand, doesn't it?

my problem is basically in the syntax of scheme in fluent. usually scheme understands (case) as well but fluent does not.

cheers

fox000002 November 10, 2011 00:07

Paste the error message.

or just use casename as following:

Code:

(define casename "file-~04d.cas" i) ;;

bobmalaria November 10, 2011 03:55

thanks fox,

actually i know this notation from other tools like ffmpg in linux. did not know this works in scheme. I will try it later today.

Cheers

bobmalaria November 10, 2011 06:31

Hi,

it finally worked. i had to define the basename outside of the loop and then construct the filename inside of the loop

(define (po);;name of the journal-function
(define basename "file-")
(define nstart 50);; time-step # for the 1st data set
(define nsave 10) ;; auto-save frequency
(define ndata 1) ;; # of data-sets
(do ((i nstart (+ nsave i)))((= i (+ nstart (* ndata nsave))))
(begin
(ti-menu-load-string(format #f "f rcd ~a~04d" basename i))
;;other things
;;more other things
)))


All times are GMT -4. The time now is 15:23.