CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   journal file with variable in a while loop? (http://www.cfd-online.com/Forums/fluent/40648-journal-file-variable-while-loop.html)

Ralf Schmidt April 19, 2006 11:41

journal file with variable in a while loop?
 
Hi!

Is it possible, do write a journal file, that has a variable (lets say the filename) that can be altered in a while (or if, or for)loop??

I have a lot of case files, and I want to read, write and display data from every case file.

Now, i wrote a journal, that is doing all the neccessary operations with one case file. But I want the journal to do it for all of them!

Is there a convenient way? (instead of writing a journal, in that all the case files are written in - thats a lot of work, and one have to take care, that every file name is written correctly)

Any Idea??

Ralf

Aidan April 19, 2006 11:53

Re: journal file with variable in a while loop?
 
Hi Ralf,

I had a similar problem and I wrote some Matlab code to create a journal file with all relevant case/data filenames and commands to execute. I can send you the Matlab code by email if you would like.

I dont know if a while or for loop can be used explicitly in the journal file.


Ralf Schmidt April 19, 2006 11:56

Re: journal file with variable in a while loop?
 
That would be nice!

send to RSchmidt @ IWT-bremen.de

(without the space before/behind the @)

jasond April 19, 2006 17:51

Re: journal file with variable in a while loop?
 
Hello,

I too had a similar problem, but I got around it using the Scheme interface (basically looping over the various files and executing the same set of steps). It is probably not the easiest thing due to the lack of documentation, but it has worked for me.

Jason

mAx April 20, 2006 01:23

Re: journal file with variable in a while loop?
 
hi guys, I have such a file. It is pretty good for large unsteady calculations. If you want this file, please write me a mail, I will mail it you back. Regards mAx

David Osborn April 25, 2006 12:46

Re: journal file with variable in a while loop?
 
mAx,

I would be interested in seeing your file. Please send to david.osborn@pw.utc.com.

Thanks.

Dave

Kerem May 4, 2006 08:10

Re: journal file with variable in a while loop?
 
hi mAx,

i am trying to perform a similar operation, so i am interested in your file.

would be glad if you can mail it to kerem.guenbulut@tu-harburg.de

thanks.

kerem

kiger August 13, 2009 01:40

Hi, mAx, nice meeting you
 
Quote:

Originally Posted by mAx
;131434
hi guys, I have such a file. It is pretty good for large unsteady calculations. If you want this file, please write me a mail, I will mail it you back. Regards mAx

Hi, mAx,

Would you please share me the file? My mail is "marinbrooke@gmail.com". I need it and your help. Thanks a lot.

Best Wishes,

Kiger

chrisoturner September 8, 2009 11:57

Hi mAx!
 
Quote:

Originally Posted by mAx
;131434
hi guys, I have such a file. It is pretty good for large unsteady calculations. If you want this file, please write me a mail, I will mail it you back. Regards mAx


Hi mAx,

I know this is a fairly old post and you might not check it anymore, but I too would be very interested in this file! I am currently trying to work out how to do it and have got to the stage where I have a journal file that does what I want for one data set, but not all the other ones!

My email is cturner03@qub.ac.uk, if you could contact me I would be much obliged!

Chris

ivanbuz September 8, 2009 16:52

Quote:

Originally Posted by mAx
;131434
hi guys, I have such a file. It is pretty good for large unsteady calculations. If you want this file, please write me a mail, I will mail it you back. Regards mAx



mAx, can I also have a copy of the file? hope you still have it, this is a very old thread. Please send to ivanbuz@yahoo.com Thanks!

-mAx- September 9, 2009 01:41

I send you both the file
;)

Fabio_77 October 23, 2009 06:26

Hi, is it possible to have that file??

Thank you so much

demian_77@hotmail.it

alven299 October 23, 2009 22:46

Hi max, I am really interested in this journal file and anxious to learn bout it. Could you please send a copy to my email: aldo_malvin@yahoo.com, thanks a million.

audrich October 25, 2009 18:43

The quick way to achieve this is to use one of the gnu/unix string editing tools such as awk, grep, or sed to replace the variable in the journal file with the actual value. This can be done in a shell script or a MATLAB m-file.

Here's an example: I have a Fluent journal file with many lines of code, but all I'd like to do is to vary the speed at an inlet called ENTRANCE_1 and simulate for each speed. First, I set up my journal file to have the inlet speed as a variable name, I call it V_1_VAL. In my journal the particular line of code looks like this:

Code:

define b velocity-inlet ENTRANCE_1 yes yes no V_1_VAL no 1 no 0 no 300 no yes 1 1
Now I'm going to vary the speed from 1 m/s to 10 m/s by increments of 1 m/s and simulate each time. I'm going to do this with MATLAB. My entire m-file looks like this:

Code:

for v1=1:10
setenv('VELOCITY_VALUE',v1);
!sed -e 's:V_1_VAL:'$VELOCITY_VALUE':g' my_little_fluent_journal.jou>temp.jou
!fluent 2d -r6.3.26 -g <temp.jou
end

The first and last lines are obvious, they are the basics of an iteration loop in MATLAB. The second line passes your MATLAB variable (v1) out to the shell environment as a new shell variable called VELOCITY_VALUE. The third line replaces any text matching "V_1_VAL" with the value the shell variable VELOCITY_VALUE. So the first time, the text "V_1_VALUE" is replaced with "1", the second loop iteration it is replaced with "2" and so on. This is saved as a new journal called temp.jou. The fourth line runs Fluent in batch mode (no graphics) using the new journal.

Notes:

-The "!" character at the beginning of a MATLAB command escapes you temporarily to your DOS or UNIX shell. It lets you can do all your command-line/terminal stuff from within MATLAB. For example if you're running Linux/UNIX and you wanted to view your current directory from within MATLAB, you can just type !ls and it'll list the directory's files and folders just as it would if you were in a terminal.

-sed is the stream editor, a versatile unix tool for editing text by command-line. The most common use is to substitute one piece of text with another. You do this with the s-command, which follows the form s:apple:orange: my_file >new_file which replaces the first instance of the world apple with the word orange in my_file and dumps it into new_file. To replace all instances of apple with orange, add a 'g' so it says s:apple:orange:g. See a SED tutorial for more info if you'd like to do even more text editing.

-notice the use of quotation marks that wrap the shell/environmental variable within the sed substitution. All shell variables begin with a dollar sign.

Well I hope this helps get you started in doing loops with journal files. As far as I know, there is no simpler way of automating Fluent from within itself, i.e. doing loops within Fluent's journal scripts. You have to do all your loops outside of Fluent, and you need to bridge the world of MATLAB/C++/Shell to the world of Fluent through environmental variables and text editing.

-mAx- October 26, 2009 02:50

Quote:

Originally Posted by alven299 (Post 233867)
Hi max, I am really interested in this journal file and anxious to learn bout it. Could you please send a copy to my email: aldo_malvin@yahoo.com, thanks a million.

I sent you both the file

Fabio_77 October 26, 2009 06:56

Thanks -MAX-

albab November 11, 2009 04:16

Max

can I have your file please.

TQ
albab

albab November 11, 2009 04:17

Max

Can I have ypur file please. my email add is ir_azahari@yahoo.com

tq

-mAx- November 11, 2009 07:00

I send it to you right now

Volker P. November 11, 2009 10:00

simple scheme loop for FLUENT
 
Hi,

the task is to do some postprocessing with a number of files whose names might not contain sequences of numbers, hence a "for to"- loop with an intenger as a counter is not possible.
One easy way ist to use a scheme "for each" loop. Scheme is a programming language. Fluent 's GUI is written in scheme. Here comes a simple example for reading a list of case+dat files, displaying a contour-plot of temperature on the zones wall, inlet, and outlet, finally generating a hard-copy with the case-filename included in the imagefile-name.

Example:
--------------------------------------------------------------
; Start of the loop (this is a comment!)
(for-each
(lambda (filename)
(ti-menu-load-string (format #f "file read-case-data ~a.cas yes" filename))
(ti-menu-load-string (format #f " /display/set/contours/surfaces (wall inlet outlet)
/display/contour temperature 25 2000
/display/hc ~a-temp.ps " filename ))
)
; list of the filenames here: without extension but one is not obliged to do so
'(
filename_A
filename02
file_XYA
hidden_tank
lost_water
)
; closing the loop:
)

--------------------------------------------------------------

The "~a" is a variable which is replaced by the content of the loop variable "filename". "filename" takes the values from the list at the bottom of the example above: filename_A, filename02, file_XYA as input. You are free to use any fiilname you like without the need to number them in a correct way.

The scheme file can be red into fluent via /file/read/scheme (GUI) or /file/read-macro (TUI).

In contrast to a script-loop the scheme-loop is carried out here inside one Fluent session.

For more details for the use of scheme together with fluent have a look to http://fluid.jku.at/personen/javurek/pdf/scheme.pdf (in German!!).


All times are GMT -4. The time now is 05:22.