Tips and tricks

From Gerris

(Difference between revisions)
Jump to: navigation, search
Revision as of 22:56, 19 March 2007
Popinet (Talk | contribs)
(Tip and tricks moved to Tips and tricks: spelling)
← Previous diff
Revision as of 06:40, 24 May 2007
Popinet (Talk | contribs)

Next diff →
Line 4: Line 4:
(setq auto-mode-alist (cons '("\\.gfs\\'" . shell-script-mode) auto-mode-alist)) (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 [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:
 +
 + #!/bin/sh
 +
 + movies="wide closeup overview"
 + rm -f $movies
 + mkfifo $movies
 +
 + gerris3D mysimulation.gfs | tee $movies > /dev/null &
 + for movie in $movies; do
 + gfsview-batch3D $movie.gfv < $movie | ppm2mpeg > $movie.mpg &
 + done
 +
 +of course the simulation file <code>mysimulation.gfs</code> should contain lines looking like:
 +
 + OutputSimulation { istep = 10 } stdout
 + EventScript { istep = 10 } { echo "Save stdout { width = 1024 height = 768 }" }

Revision as of 06:40, 24 May 2007

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 and the tee utility 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 | tee $movies > /dev/null &
for movie in $movies; do
    gfsview-batch3D $movie.gfv < $movie | ppm2mpeg > $movie.mpg &
done

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

OutputSimulation { istep = 10 } stdout
EventScript { istep = 10 } { echo "Save stdout { width = 1024 height = 768 }" }
Personal tools
communication