CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   do loop in Fluent journal file. (https://www.cfd-online.com/Forums/fluent/34432-do-loop-fluent-journal-file.html)

caterchen August 17, 2004 13:10

do loop in Fluent journal file.
 
Hi,

Is there anybody know how to use a do loop in fluent journal file? I need it to convert lots of result files for fieldview.

Thanks.

caterchen

mateus August 18, 2004 01:54

Re: do loop in Fluent journal file.
 
Hi!

You're in trouble. I think there is no way to do loop in journal file...I can tell you that posprocessing of the reslts can be preety frustrating because of that:((

MATEUS

Markus August 18, 2004 02:18

Re: do loop in Fluent journal file.
 
Hello,

Fluent's command language is scheme, quite strange in its syntax but loops are possible. A do-loop will look like:

(let loop ((i 5)) // start value for i = 5 // (begin ( .... your code) (loop (+ i 5)) // increment of i = 5 // )

Maybe you should also refer to some scheme-examples at fluentusers.com

best regards Markus

chandrasekhar April 8, 2014 23:49

Hi
i know its a very old post but if u can help i would be thankful. i would like to know if i can open a case-data file using scheme file(i know how to do it in a journal file, i want to do it in scheme because i want to make use of the do loop). Many thanks for replying.

with regards

Quote:

Originally Posted by Markus
;114444
Hello,

Fluent's command language is scheme, quite strange in its syntax but loops are possible. A do-loop will look like:

(let loop ((i 5)) // start value for i = 5 // (begin ( .... your code) (loop (+ i 5)) // increment of i = 5 // )

Maybe you should also refer to some scheme-examples at fluentusers.com

best regards Markus


macfly April 9, 2014 09:42

1 Attachment(s)
Hi chandrasekhar,

I don't know how to insert strings in a scheme loop, but I'll suggest another approach: generate a journal file with another software. For example, I'm on Windows and I use AutoHotkey, a wonderful intuitive open-source utility with which you can script and automate a whole bunch of things (http://www.autohotkey.com/). Moreover, the Help of AutoHotkey is very detailed with a lot of examples (like the Matlab's Help).

Here's an AutoHotkey script that generates a journal file (jou.jou) and would satisfy your needs, easy to understand:

Code:

FileDelete, jou.jou  ; delete the file before writing a new one

filenumber := ["1","2","3"]
max := filenumber.MaxIndex()  ; length of "filenumber"

Loop, %max%  ; loop until "max" is reached
    {
    string := filenumber[A_Index]  ; The built-in variable A_Index contains the number of the current loop iteration.
    FileAppend,
    (
    file read-case-data file_%string%.cas.gz`n
    ), jou.jou
    }


sanketdange2007 April 9, 2014 11:32

Hi Chandrasekhar,

To automate post processing it is very useful to use scheme file in ANSYS Fluent.

Here is an example of how to read case file, similarly you can do for case and data file using appropriate TUI commands.

Code:


(do ((x 1 (+ x 1))) ((> x 10))

(ti-menu-load-string (format #f "/file/read-case \"case-file-~a.cas.gz\"" x))

)

Just make sure that you file name are in some fixed format so that you can use the do loop to read them. Simple way to do this is number them serially or with equal difference like: case-file-1.cas.gz , case-file-2.cas.gz , case-file-3.cas.gz, ......

Or

case-file-10.cas.gz , case-file-20.cas.gz , case-file-30.cas.gz ,.......

chandrasekhar April 9, 2014 12:00

wow thanks guys for the immediate response, was not really expecting it so soon. thank you

chandrasekhar April 10, 2014 14:27

Hi
i tried using the scheme file with the code which gave, there was an error "Error: WorkBench Error: Could not handle command
Error Object: #f". do you by any chance know what this means. Many thanks for replying.

with regards

Quote:

Originally Posted by sanketdange2007 (Post 484989)
Hi Chandrasekhar,

To automate post processing it is very useful to use scheme file in ANSYS Fluent.

Here is an example of how to read case file, similarly you can do for case and data file using appropriate TUI commands.

Code:


(do ((x 1 (+ x 1))) ((> x 10))

(ti-menu-load-string (format #f "/file/read-case \"case-file-~a.cas.gz\"" x))

)

Just make sure that you file name are in some fixed format so that you can use the do loop to read them. Simple way to do this is number them serially or with equal difference like: case-file-1.cas.gz , case-file-2.cas.gz , case-file-3.cas.gz, ......

Or

case-file-10.cas.gz , case-file-20.cas.gz , case-file-30.cas.gz ,.......


For more detailed explanation you can visit our blog : http://www.learncax.com/index.php/en...and-automation

This blog explains how to use do loop for automation and it also explains the syntax of the do loop. I would recommend you to go through this blog.


macfly April 10, 2014 19:30

For example, the following scheme loads the 3 following files:
fluent_1.cas.gz
fluent_2.cas.gz
fluent_3.cas.gz

Code:

(do ((x 1 (+ x 1))) ((> x 3))
    (ti-menu-load-string (format #f "file read-case fluent_~a.cas.gz" x))
)

There is a \ that seems to be outside its "" in Sanket's example.

sanketdange2007 April 11, 2014 05:12

Hi,

The scheme program which I have given in my previous comment works in both the cases, With the slash (\) and with out the slash.

If you want to write file name in " " (quote) then you have to give a \ before the use of quote sign (if you are using format # f, if format # f is not used then you should not give a \ ).

The error might have occurred because there might not be case file in existence with the specified name in your working directory.

And in my script I have specified that do loop will run until x<10, when x becomes equal to 11 it will stop. You may specify the number equal to your number of case files.

Chandrasekhar could you pl. post a snap shot of your error, it might be helpful to understand your error.

Peng Zhong June 27, 2016 14:24

Quote:

Originally Posted by caterchen
;114432
Hi,

Is there anybody know how to use a do loop in fluent journal file? I need it to convert lots of result files for fieldview.

Thanks.

caterchen

You can use recursive functions to do any looping. For example:

(define (recursion i j) (if (>= i j) (display i) (begin (display i) (recursion (+ 1 i) j))))

output: 12345

Katja November 14, 2016 13:19

Error: CAR: invalid argument [1]: wrong type [not a pair]
 
Found the solution: there should be a an additional "i" at the end of the code (i i) to match the number of ~a's

Hi!

I'm trying to create surface monitors along the height of a pipe and save them. I want to create many of them. So, I have successfully created the surfaces using a Do-loop, but somehow the almost same code does not seem to work for making of the monitors. Can you please tell me what's the error in the following code?

(Do ((i 0 (+ i 1000))) ((> i 50))
(Ti-menu-load-string (format #f "/solve/monitors/surface/set-monitor h-~a "Vertex Average" air vof (h-~a) no no yes "h~a" 1 yes flow-time"i i))
)

But I'm not really that good at scheme programming!
Thank You :)

sanketdange2007 November 14, 2016 22:57

Hi Katja,
The condition (> i 50 ) which you are using is the culprit here. If you want to create 50 monitors then make the condition as (> i 50000) because your increment of i is 1000.
Also you are using i inside ti-menu-load-string for three times so at the end of bracket you will have to write i three times. Like this -


(Do ((i 0 (+ i 1000))) ((> i 50000))
(Ti-menu-load-string (format #f "/solve/monitors/surface/set-monitor h-~a "Vertex Average" air vof (h-~a) no no yes "h~a" 1 yes flow-time"i i i))
)

Thanks,
Sanket


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