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

journal file with variable in a while loop?

Register Blogs Community New Posts Updated Threads Search

Like Tree8Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 19, 2006, 12:41
Default journal file with variable in a while loop?
  #1
Ralf Schmidt
Guest
 
Posts: n/a
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
  Reply With Quote

Old   April 19, 2006, 12:53
Default Re: journal file with variable in a while loop?
  #2
Aidan
Guest
 
Posts: n/a
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.

  Reply With Quote

Old   April 19, 2006, 12:56
Default Re: journal file with variable in a while loop?
  #3
Ralf Schmidt
Guest
 
Posts: n/a
That would be nice!

send to RSchmidt @ IWT-bremen.de

(without the space before/behind the @)
  Reply With Quote

Old   April 19, 2006, 18:51
Default Re: journal file with variable in a while loop?
  #4
jasond
Guest
 
Posts: n/a
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
  Reply With Quote

Old   April 20, 2006, 02:23
Default Re: journal file with variable in a while loop?
  #5
mAx
Guest
 
Posts: n/a
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
mrenergy likes this.
  Reply With Quote

Old   April 25, 2006, 13:46
Default Re: journal file with variable in a while loop?
  #6
David Osborn
Guest
 
Posts: n/a
mAx,

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

Thanks.

Dave
  Reply With Quote

Old   May 4, 2006, 09:10
Default Re: journal file with variable in a while loop?
  #7
Kerem
Guest
 
Posts: n/a
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
  Reply With Quote

Old   August 13, 2009, 02:40
Default Hi, mAx, nice meeting you
  #8
New Member
 
Oliver
Join Date: Aug 2009
Posts: 1
Rep Power: 0
kiger is on a distinguished road
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
kiger is offline   Reply With Quote

Old   September 8, 2009, 12:57
Smile Hi mAx!
  #9
New Member
 
Chris Turner
Join Date: Jun 2009
Location: Belfast
Posts: 12
Rep Power: 17
chrisoturner is on a distinguished road
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
chrisoturner is offline   Reply With Quote

Old   September 8, 2009, 17:52
Default
  #10
Member
 
Ivan
Join Date: May 2009
Posts: 85
Rep Power: 17
ivanbuz is on a distinguished road
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!
ivanbuz is offline   Reply With Quote

Old   September 9, 2009, 02:41
Default
  #11
Super Moderator
 
-mAx-'s Avatar
 
Maxime Perelli
Join Date: Mar 2009
Location: Switzerland
Posts: 3,297
Rep Power: 41
-mAx- will become famous soon enough
I send you both the file
__________________
In memory of my friend Hervé: CFD engineer & freerider
-mAx- is offline   Reply With Quote

Old   October 23, 2009, 07:26
Default
  #12
New Member
 
Fabio
Join Date: May 2009
Posts: 11
Rep Power: 17
Fabio_77 is on a distinguished road
Hi, is it possible to have that file??

Thank you so much

demian_77@hotmail.it
Fabio_77 is offline   Reply With Quote

Old   October 23, 2009, 23:46
Default
  #13
New Member
 
alven
Join Date: Mar 2009
Location: Malaysia
Posts: 25
Blog Entries: 1
Rep Power: 17
alven299 is on a distinguished road
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.
alven299 is offline   Reply With Quote

Old   October 25, 2009, 18:43
Default
  #14
New Member
 
Join Date: Apr 2009
Posts: 19
Rep Power: 0
audrich is on a distinguished road
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:applerange: 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:applerange: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.
audrich is offline   Reply With Quote

Old   October 26, 2009, 02:50
Default
  #15
Super Moderator
 
-mAx-'s Avatar
 
Maxime Perelli
Join Date: Mar 2009
Location: Switzerland
Posts: 3,297
Rep Power: 41
-mAx- will become famous soon enough
Quote:
Originally Posted by alven299 View Post
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
__________________
In memory of my friend Hervé: CFD engineer & freerider
-mAx- is offline   Reply With Quote

Old   October 26, 2009, 06:56
Default
  #16
New Member
 
Fabio
Join Date: May 2009
Posts: 11
Rep Power: 17
Fabio_77 is on a distinguished road
Thanks -MAX-
Fabio_77 is offline   Reply With Quote

Old   November 11, 2009, 04:16
Default
  #17
New Member
 
azahari
Join Date: Apr 2009
Posts: 2
Rep Power: 0
albab is on a distinguished road
Max

can I have your file please.

TQ
albab
albab is offline   Reply With Quote

Old   November 11, 2009, 04:17
Default
  #18
New Member
 
azahari
Join Date: Apr 2009
Posts: 2
Rep Power: 0
albab is on a distinguished road
Max

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

tq
albab is offline   Reply With Quote

Old   November 11, 2009, 07:00
Default
  #19
Super Moderator
 
-mAx-'s Avatar
 
Maxime Perelli
Join Date: Mar 2009
Location: Switzerland
Posts: 3,297
Rep Power: 41
-mAx- will become famous soon enough
I send it to you right now
__________________
In memory of my friend Hervé: CFD engineer & freerider
-mAx- is offline   Reply With Quote

Old   November 11, 2009, 10:00
Default simple scheme loop for FLUENT
  #20
New Member
 
Volker Pawlik
Join Date: Mar 2009
Location: Germany
Posts: 25
Rep Power: 17
Volker P. is on a distinguished road
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!!).
3DmaniacSLDWRKS likes this.
Volker P. 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
do loop in Fluent journal file. caterchen FLUENT 12 November 14, 2016 23:57
Working directory via command line Luiz CFX 4 March 6, 2011 21:02
OpenFOAM 1.7.1 installation problem on OpenSUSE 11.3 flakid OpenFOAM Installation 16 December 28, 2010 09:48
Version 15 on Mac OS X gschaider OpenFOAM Installation 113 December 2, 2009 11:23
[OpenFOAM] ParaView 33 canbt open OpenFoam file hariya03 ParaView 7 September 25, 2008 18:33


All times are GMT -4. The time now is 17:18.