CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

do loop in Fluent journal file.

Register Blogs Community New Posts Updated Threads Search

Like Tree7Likes
  • 4 Post By Markus
  • 1 Post By macfly
  • 2 Post By sanketdange2007

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 17, 2004, 14:10
Default do loop in Fluent journal file.
  #1
caterchen
Guest
 
Posts: n/a
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
  Reply With Quote

Old   August 18, 2004, 02:54
Default Re: do loop in Fluent journal file.
  #2
mateus
Guest
 
Posts: n/a
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
  Reply With Quote

Old   August 18, 2004, 03:18
Default Re: do loop in Fluent journal file.
  #3
Markus
Guest
 
Posts: n/a
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
  Reply With Quote

Old   April 9, 2014, 00:49
Default
  #4
New Member
 
Chandrasekhar
Join Date: Oct 2013
Location: new jersey
Posts: 24
Rep Power: 13
chandrasekhar is on a distinguished road
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
chandrasekhar is offline   Reply With Quote

Old   April 9, 2014, 10:42
Default
  #5
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
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
     }
Attached Files
File Type: zip read-case-data.zip (405 Bytes, 75 views)
chandrasekhar likes this.

Last edited by macfly; April 9, 2014 at 12:27.
macfly is offline   Reply With Quote

Old   April 9, 2014, 12:32
Default
  #6
New Member
 
Sanket Dange
Join Date: Jul 2013
Posts: 9
Rep Power: 13
sanketdange2007 is on a distinguished road
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 ,.......
macfly and chandrasekhar like this.
sanketdange2007 is offline   Reply With Quote

Old   April 9, 2014, 13:00
Default
  #7
New Member
 
Chandrasekhar
Join Date: Oct 2013
Location: new jersey
Posts: 24
Rep Power: 13
chandrasekhar is on a distinguished road
wow thanks guys for the immediate response, was not really expecting it so soon. thank you
chandrasekhar is offline   Reply With Quote

Old   April 10, 2014, 15:27
Default
  #8
New Member
 
Chandrasekhar
Join Date: Oct 2013
Location: new jersey
Posts: 24
Rep Power: 13
chandrasekhar is on a distinguished road
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 View Post
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.
chandrasekhar is offline   Reply With Quote

Old   April 10, 2014, 20:30
Default
  #9
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
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.

Last edited by macfly; April 11, 2014 at 02:05.
macfly is offline   Reply With Quote

Old   April 11, 2014, 06:12
Default
  #10
New Member
 
Sanket Dange
Join Date: Jul 2013
Posts: 9
Rep Power: 13
sanketdange2007 is on a distinguished road
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.
sanketdange2007 is offline   Reply With Quote

Old   June 27, 2016, 15:24
Default
  #11
New Member
 
Peng Zhong
Join Date: Mar 2016
Posts: 2
Rep Power: 0
Peng Zhong is on a distinguished road
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
Peng Zhong is offline   Reply With Quote

Old   November 14, 2016, 14:19
Smile Error: CAR: invalid argument [1]: wrong type [not a pair]
  #12
New Member
 
Katja N.
Join Date: May 2014
Location: Sweden
Posts: 13
Rep Power: 12
Katja is on a distinguished road
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
__________________

Last edited by Katja; November 14, 2016 at 14:47. Reason: Found solution
Katja is offline   Reply With Quote

Old   November 14, 2016, 23:57
Default
  #13
New Member
 
Sanket Dange
Join Date: Jul 2013
Posts: 9
Rep Power: 13
sanketdange2007 is on a distinguished road
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
sanketdange2007 is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
2.0.x on Mac OSX niklas OpenFOAM Installation 74 March 28, 2012 17:46
paraview installation woes vex OpenFOAM Installation 15 January 30, 2011 08:11
Fluent 12 Journal File Problem Krish FLUENT 2 July 16, 2010 07:10
OpenFOAM Install Script ljsh OpenFOAM Installation 82 October 12, 2009 12:47
Problem with rhoSimpleFoam matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 07:51


All times are GMT -4. The time now is 19:50.