CFD Online Discussion Forums

CFD Online Discussion Forums (
-   ANSYS Meshing & Geometry (
-   -   [GAMBIT] Looping in journal file (

luuk.thielen October 2, 2009 08:13

Looping in journal file
Hello all,

is it possible to loop over parts of a group in the DO loop functionality of the Gambit journal file?

My goal is to loop over all volumes in a group and create a separate physics for each group. So the loop should look something like:

DO i = 1, volume_in_groups of <groupname>
physics create <physicsname> ctype "FLUID" volume i

When reading the manuals I have the feeling this is not possible, but I want to make sure.

Thanks in advance, Luuk

mystic_cfd October 3, 2009 17:15

Hi Luuk,

Your mail is a bit confusing. It might require some discussion to resolve your issues.

It is possible in Gambit to loop over all the volumes in a group. You need to look at the LISTENTITY command in the manual.

The bit that confuses me is your stated goal: "My goal is to loop over all volumes in a group and create a separate physics for each group." Why loop over the volumes if you want to define a region for the group?

If you already have groups of volumes defined and need to assign continuum types to each group, you can simply assign the the continuum type directly to the group - either in the GUI, or with a command like:
physics create "cell-zone-name" ctype "FLUID" group "name-of-group"

i.e. you do not need to loop over all volumes in a group to assign a continuum type to the group. if you have a lot of groups that require naming, you can, with some effort, construct a gambit macro to do the naming by looping over the groups. if you are lazy like me, you can also use linux to do this. the method goes something like this (only in Linux!):
- you start with all your regions (continuums) defined as separate groups of volumes
- in gambit, go to the group menu and summarize all groups (press "i", select all groups and enter)
- the listing with the summary of all groups now scroll by in the output window, but is also available in the GAMBIT.nnnn/trn file in your work directory
- cut out all the text output from the group summary and paste into a dummy file e.g. dummy.txt.
- the command 'grep "Group:" dummy.txt' will now give a list of all the groups in your database (the output is "Group: groupname".
- pipe the output through awk to create a journal file that generates continuums from the groups.
- e.g.
grep "Group:" dummy.txt | awk '{print "physics create \"fluid-"$2"\" ctype \"FLUID\" group \""$2"\""}' > make-continuums.jou
- you need to edit the journal file to assign FLUID and SOLID states as required, but that is usually quite fast.
- read the journal file into the gambit session and you are done.

if zone creation fails, it is often because you have used the same volume in more than one group - gambit will not assign a continuum type if the volume is already part of a continuum.

that was a bit longer than i intended...

luuk.thielen October 5, 2009 09:49


thanx for the answer. I understand the confusion.

The problem is that I want each volume in a group to have a different "cell-zone name" (as you mention it). So suppose I have a geometry of 1000 volumes. Then I create a group (p.e. D_FLUID) containing all the volumes. Next I would like each volume of the group to get a separate physics id, consisting of a concatenation of the name of the group and the number of the volume (so D_FLUID_VOLUME_1, D_FLUID_VOLUME_2 etc). I understand this can be done by a script that "works" on a journal (as you describe).

However, I was curious if an other option would be to use the "script-language" available in the gambit journal file itself. So using the DO loop functionality available in the journal file, loop over all volumes in the group and giving them a (unique) "cell-zone" name. In other words: can you use groups/volumes as counter in the DO loop expression of the GAMBIT journal file.

I hope my question is a bit clearer now.

mystic_cfd October 6, 2009 11:39

OK, I think I understand. I used the following on a sample database with one group called "D_FLUID" which contains 4 volumes. It should give you the idea...

$n = 0
$grpname = "D_FLUID"
$grpvol_list = LISTENTITY(t_vo,t_gr,$grpname)
$nv = PARAMSIZE("grpvol_list")
DO PARA "n" COND ($n .le. $nv)
$zone_name = $grpname + "_VOLUME_" + ntos($n)
physics create $zone_name ctype "FLUID" volume $grpvol_list[$n]

let me know if you need more of an explanation. if you have multiple groups, you can wrap this code in another DO loop that loops over all the groups in your model.


luuk.thielen October 7, 2009 11:07


thank you for the answer and example. Using your example I was able to "solve the problem".

Thanx again,


All times are GMT -4. The time now is 14:31.