Tips and tricks

From Gerris

(Difference between revisions)
Jump to: navigation, search
Revision as of 04:59, 5 February 2008
Popinet (Talk | contribs)
(Removed Rohallah's comments, see FAQ)
← Previous diff
Revision as of 05:24, 3 September 2008
Popinet (Talk | contribs)
(Improved movie generation technique using the new "Append" keyword)
Next diff →
Line 9: Line 9:
While it is fairly simple to use the scripting mode of gfsview and unix pipes to [http://gfs.sourceforge.net/examples/examples/boussinesq.html generate a movie] on the fly from a running simulation, how does one generate several movies simultaneously? While it is fairly simple to use the scripting mode of gfsview and unix pipes to [http://gfs.sourceforge.net/examples/examples/boussinesq.html generate a movie] on the fly from a running simulation, how does one generate several movies simultaneously?
-Using named unix fifos and the <code>tee</code> utility it is fairly easy too. For example if one has three gfsview files called <code>wide.gfv</code>, <code>closeup.gfv</code> and <code>overview.gfv</code> and want to generate the three corresponding movies <code>wide.mpg</code>, <code>closeup.mpg</code> and <code>overview.mpg</code> in one go, one could use the following script:+Using named unix fifos it is fairly easy too. For example if one has three gfsview files called <code>wide.gfv</code>, <code>closeup.gfv</code> and <code>overview.gfv</code> and want to generate the three corresponding movies <code>wide.mpg</code>, <code>closeup.mpg</code> and <code>overview.mpg</code> in one go, one could use the following script:
#!/bin/sh #!/bin/sh
Line 17: Line 17:
mkfifo $movies mkfifo $movies
- gerris3D mysimulation.gfs | tee $movies > /dev/null &+ gerris3D mysimulation.gfs | gfsview-batch3D &
for movie in $movies; do for movie in $movies; do
- gfsview-batch3D $movie.gfv < $movie | ppm2mpeg > $movie.mpg &+ ppm2mpeg < $movie > $movie.mpg &
done done
- sleep 10 
- rm -f $movies 
-of course the simulation file <code>mysimulation.gfs</code> should contain lines looking like:+the simulation file <code>mysimulation.gfs</code> should also contain lines looking like:
- OutputSimulation { istep = 10 } stdout+ OutputSimulation { step = 0.01 } stdout
- EventScript { istep = 10 } { echo "Save stdout { width = 1024 height = 768 }" }+ EventScript { step = 0.01 } {
 + movies="wide closeup overview"
 + for movie in $movies; do
 + echo "Clear"
 + cat $movie.gfv
 + echo "Append $movie { width = 1024 height = 768 }"
 + done
 + }
== Compressing simulation files == == Compressing simulation files ==

Revision as of 05:24, 3 September 2008

Emacs mode for Gerris files

Well, not really but something approaching. Add the following to your .emacs

(setq auto-mode-alist (cons '("\\.gfs\\'" . shell-script-mode) auto-mode-alist))

Generating several movies on-the-fly

While it is fairly simple to use the scripting mode of gfsview and unix pipes to generate a movie on the fly from a running simulation, how does one generate several movies simultaneously?

Using named unix fifos it is fairly easy too. For example if one has three gfsview files called wide.gfv, closeup.gfv and overview.gfv and want to generate the three corresponding movies wide.mpg, closeup.mpg and overview.mpg in one go, one could use the following script:

#!/bin/sh

movies="wide closeup overview"
rm -f $movies
mkfifo $movies

gerris3D mysimulation.gfs | gfsview-batch3D &
for movie in $movies; do
    ppm2mpeg < $movie > $movie.mpg &
done

the simulation file mysimulation.gfs should also contain lines looking like:

OutputSimulation { step = 0.01 } stdout
EventScript { step = 0.01 } {
  movies="wide closeup overview"
  for movie in $movies; do
    echo "Clear"
    cat $movie.gfv
    echo "Append $movie { width = 1024 height = 768 }"
  done
}

Compressing simulation files

When it is useful to save simulation results at regular intervals, the size of the files can be reduced by using on-the-fly compression. This can be done like this:

OutputSimulation { istep = 100 } sim-%ld.gfs
EventScript { istep = 100 } { gzip -f -q sim-*.gfs }

GfsView can read compressed GFS files directly.

Personal tools
communication