Tips and tricks

From Gerris

(Difference between revisions)
Jump to: navigation, search
Revision as of 17:05, 29 January 2008
Rohtav (Talk | contribs)

← Previous diff
Revision as of 17:13, 29 January 2008
Rohtav (Talk | contribs)

Next diff →
Line 38: Line 38:
GfsView can read compressed GFS files directly. GfsView can read compressed GFS files directly.
-== Writing generic or customized output ==+ 
 +== Writing generic or customized gerris output ==
 + 
 + 
 +Since most of visualization package on the market (or as open-source) do not support quadtree/octree data format, to use benefits of third party visualization packages rather than GFSView we should convert Gerris results to a general unstructured data.
 +
 +VTK format could be visualized by powerful free package: [http://www.paraview.org/HTML/Index.html Paraview].
 + 
 +The function "gfs_write_generic_output" is written for this purpose.
 + 
 +This function could write output data in Tecplot or [http://www.cacr.caltech.edu/~slombey/asci/vtk/vtk_formats.simple.html VTK format]. I mean generic output because Tecplot format is almost a general unstructured data type and you could easily modify its (code or resulted file) for your own need. Alternatively you could contact me and I could do its for you (just describe your format). All data are written in ASCII format.
 + 
 + Tecplot format is briefly as follows:
 + 
 + 1) Header (include list of field variables, number of vertexes, number of elements and elements type)
 + 2) Spatial coordinates plus filed variables related to listed variables in header
 + 3) Element connectivity
 + 
 + For more details regarding to VTK format refer to the following
 + linke:
 +
 + http://www.vtk.org/pdf/file-formats.pdf
 + 
 + or
 + 
 + http://www.cacr.caltech.edu/~slombey/asci/vtk/vtk_formats.simple.html
 + 
 + 
 + Brief algorithm:
 + 
 + 1) Construct mesh connectivity 4/8 vertex per cell.
 + 
 + 2) Optimize connectivity by removing repeated vertexes,
 + this considerably reduce data size and improve considerably
 + speed of rendering (very important for 3d or large scale
 + simulation).
 + 
 + 3) Interpolation of cell-wise data to vertexes.
 + 
 + 4) Writing results on a text file.

Revision as of 17:13, 29 January 2008

Contents

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
sleep 10
rm -f $movies

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 }" }

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.


Writing generic or customized gerris output


Since most of visualization package on the market (or as open-source) do not support quadtree/octree data format, to use benefits of third party visualization packages rather than GFSView we should convert Gerris results to a general unstructured data.

VTK format could be visualized by powerful free package: Paraview.

The function "gfs_write_generic_output" is written for this purpose.

This function could write output data in Tecplot or VTK format. I mean generic output because Tecplot format is almost a general unstructured data type and you could easily modify its (code or resulted file) for your own need. Alternatively you could contact me and I could do its for you (just describe your format). All data are written in ASCII format.

 Tecplot format is briefly as follows:

1) Header (include list of field variables, number of vertexes, number of elements and elements type) 2) Spatial coordinates plus filed variables related to listed variables in header 3) Element connectivity

For more details regarding to VTK format refer to the following linke:

http://www.vtk.org/pdf/file-formats.pdf

     or
     http://www.cacr.caltech.edu/~slombey/asci/vtk/vtk_formats.simple.html


Brief algorithm:

1) Construct mesh connectivity 4/8 vertex per cell.

2) Optimize connectivity by removing repeated vertexes, this considerably reduce data size and improve considerably speed of rendering (very important for 3d or large scale simulation).

3) Interpolation of cell-wise data to vertexes.

4) Writing results on a text file.

Personal tools
communication