Well, not really but something approaching. Add the following to your <code>.emacs</code>

+

The default Gerris installation comes with an emacs [http://www.gnu.org/software/emacs/manual/html_node/emacs/Major-Modes.html major mode] to edit Gerris simulation files. To enable it, you need to find where Gerris is installed. For example do:

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?

+

;; gerris mode

+

(add-to-list 'load-path "/usr/share/gerris")

+

(require 'gfs-mode)

-

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:

+

This will setup emacs so that opening files with the ".gfs" extension automatically uses the "gfs-mode" major mode. Alternatively you can manually enable this mode on any file using (within emacs):

where M- stands for the "emacs Meta key" (usually mapped to "esc" on your keyboard).

-

OutputSimulation { istep = 10 } stdout

+

If you now restart emacs and open a .gfs file, you will see that emacs highlights Gerris keywords. These keywords are also "clickable". Clicking on a keyword will open the corresponding documentation in your web browser. If you want, you can customize the way links are opened by configuring the 'browse-url' emacs function which is used by gfs-mode.

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:

+

The gfs-mode also knows how to properly indent Gerris simulation files. A line can easily be indented by pressing the 'Tab' key with the cursor positioned anywhere on the line.

-

OutputSimulation { istep = 100 } sim-%ld.gfs

+

To automatically indent a block of text, use Ctrl-space (or the mouse) to select the block and type:

-

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

+

-

GfsView can read compressed GFS files directly.

+

M-x indent-region

+

(note that you can use the Tab key to autocomplete command names).

+

===Keyword auto-completion===

-

== Writing generic or customized gerris output ==

+

gfs-mode configures [http://www.gnu.org/software/emacs/manual/html_node/emacs/Dynamic-Abbrevs.html dynamic abbrevs] to provide auto-completion for Gerris keywords. Dynamic abbrevs are usually enabled by default in emacs. They work with any buffer. To use auto-completion, type the beginning of the Gerris keyword (e.g. "Out") and type

+

M-/

-

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.

+

repeatedly. This will cycle through all the Gerris keywords starting with "Out".

-

The function "gfs_write_generic_output" is written for this purpose.

+

===Comments===

-

This function could write output data in [http://www.tecplot.com/ Tecplot] or [http://www.cacr.caltech.edu/~slombey/asci/vtk/vtk_formats.simple.html VTK format]. We 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.

''Note that using [[GfsOutputView]] is simpler and more efficient than the technique described in this section.''

-

1) Header (include list of field variables, number of vertexes, number of elements and elements type)

+

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 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 command:

Another example would be computing a distance function (i.e. a levelset function) from a VOF interface description for visualisation using isosurfaces in GfsView. This is easily done using something like:

1. type: type of desired output, "VTK" or "TECPLOT" at the moment are supported.

+

If you want to display only a subset of the mesh in GfsView you can use the <code>NODATA</code> value in a [[GfsFunction]]. For example, setting the scalar field of "Squares" in GfsView to:

-

2. n_filed: number of filed data to be visualized, 0 mean just visualization of mesh.

+

(P > 0 ? P : NODATA)

-

3. filed_name: string array, each item is correspond to each filed, you should include your desired field name, i.e., "U", "V", "W", "P" and desired tracer, e.g., "T", ..., also you could include "Vorticity" to compute and write vorticity field. If for any field, function can not find data pointer from name of variable (except for vorticity), this field is skiped.

+

will only display the pressure field where it is positive. This trick also works for [[GfsOutputPPM]] and [[GfsOutputGRD]].

-

4. plot_depth: depth of cell which are desired to visualize, -1 mean visiting all levels.

+

== VIM features and Gerris ==

-

5. box: if box=NULL, all domain are considered for visualization, but user could define a box to visualize only portion of domain located in the box, to define box you should specify its two corner (by six coordinate, for 2d simulation define two z-value arbitrary).

+

There are plenty of vim features that can be customized to make your life easier when you work with gerris.

-

6. domain: simulation domain.

+

Using tab, you can autocomplete the keywords of gerris. To do that, add the following lines to your .vimrc:

-

+

function! Tab_Or_Complete()

-

At the moment this function could be used to write data on-the-fly but it is easy to write a short code to convert "*.sim" data (result of Gerris) to described format. Maybe in future somebody write a tool to convert "*.sim" files to desired output, you could write its yourself, for this purpose follow instruction same as "gfs2oogl.c", to load simulation object from "*.sim" file).

+

if col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^\w'

+

return "\<C-N>"

+

else

+

return "\<Tab>"

+

endif

+

endfunction

+

:inoremap <Tab> <C-R>=Tab_Or_Complete()<CR>

+

if has("autocmd")

+

"set complete+=k/etc/dictionaries-common/words isk+=.,(

+

set complete+=k/usr/share/gerris/gerris.dic isk+=.,(

+

endif " has("autocmd"

-

=== How to Use ===

+

where <code>/usr/share/gerris/gerris.dic</code> may vary according to how gerris was installed on your system.

-

+

-

+

-

To call this function on-the-fly it is sufficient to include this

+

-

file in "simulation.c" file, i.e. add statement

+

-

+

-

<source lang="c">

+

-

#include "generic_output.c"

+

-

</source>

+

-

+

-

after include statements in the "simulation.c" file of your gerris and add its desired function call in time step loop of "simulation_run" function e.g. at a place like this (determined by "######")

+

-

+

-

<source lang="c">

+

-

+

-

static void simulation_run (GfsSimulation * sim)

+

-

{

+

-

...

+

-

...

+

-

...

+

-

+

-

while (sim->time.t < sim->time.end &&

+

-

sim->time.i < sim->time.iend) {

+

-

+

-

...

+

-

...

+

-

...

+

-

+

-

sim->time.t = sim->tnext;

+

-

sim->time.i++;

+

-

+

-

gts_range_add_value (&domain->timestep,

+

-

gfs_clock_elapsed(domain->timer) - tstart);

+

-

gts_range_update (&domain->timestep);

+

-

gts_range_add_value (&domain->size,

+

-

gfs_domain_size (domain, FTT_TRAVERSE_LEAFS, -1));

+

-

gts_range_update (&domain->size);

+

-

+

-

"######"

+

-

}

+

-

+

-

</source>

+

-

+

-

assume we like to run "heated.gfs" example

+

-

+

-

use the following statements at the specified place (writing output file after each 100 time steps):

+

-

+

-

<source lang="c">

+

-

+

-

{

+

-

gint n_field = 5, plot_depth = -1;

+

-

gchar *filed_name[5] = {"U", "V", "P", "T", "Vorticity"};

+

-

GtsBBox *box= NULL;

+

-

+

-

if(sim->time.i % 100 == 0)

+

-

gfs_write_generic_output ("TECPLOT", n_field,

+

-

filed_name,plot_depth,

+

-

box, domain);

+

-

+

-

// or

+

-

+

-

if(sim->time.i % 100 == 0)

+

-

gfs_write_generic_output ("VTK", n_field,

+

-

filed_name, plot_depth,

+

-

box, domain);

+

-

+

-

}

+

-

+

-

</source>

+

-

+

-

or if you like to limit visulization within a box use this:

+

-

+

-

<source lang="c">

+

-

+

-

{

+

-

gint n_field = 5, plot_depth = -1;

+

-

gchar *filed_name[5] = {"U", "V", "P", "T", "Vorticity"};

+

-

+

-

GtsBBox *box= gts_bbox_new (gts_bbox_class (), NULL,

+

-

-.5, -.5, -.5,

+

-

.5, .5, .5);

+

-

+

-

if(sim->time.i % 100 == 0)

+

-

gfs_write_generic_output ("TECPLOT", n_field,

+

-

filed_name, plot_depth,

+

-

box, domain);

+

-

+

-

// or

+

-

+

-

if(sim->time.i % 100 == 0)

+

-

gfs_write_generic_output ("VTK", n_field,

+

-

filed_name, plot_depth,

+

-

box, domain);

+

-

+

-

}

+

-

+

-

</source>

+

-

+

-

note that resulted files are names as:

+

-

+

-

tecplot%i.plt or paraview%i.vtk

+

-

+

-

where %i determine file number, it is automatically incremented after each output

+

-

+

-

Note that you could write various type or a type with various proberties (e.g. writing both hole data and limited data by a box) simultaneously. For this for this purpose you just include suitable call of function in simulation loop.

+

-

+

-

After modification of code, you should recompile your gerris code to activate this added feature. Of course it is better to include such data in input "*.gfs", i.e. treat its like an event, but prefarably this job should be performed by Gerris mantainer, if he detect that this feature is useful for a portion of Gerris users.

+

-

+

-

(in the case of interest, you could announce your interest to this feature in GSF user mailing list).

+

-

+

-

+

-

=== Tecplot Snapshots ===

+

-

+

-

+

-

[[Image:tecplot1.jpg|thumb|400px]]

+

-

+

-

+

-

[[Image:tecplot2.jpg|thumb|400px]]

+

-

+

-

+

-

=== Paraview Snapshots ===

+

-

+

-

+

-

[[Image:paraview1.jpg|thumb|400px]]

+

-

+

-

+

-

[[Image:paraview2.jpg|thumb|400px]]

+

-

+

-

+

-

[[Image:paraview3.jpg|thumb|600px]]

+

-

+

-

=== Source Code Listing ===

+

-

+

-

<source lang="c">

+

-

+

-

#include <stdlib.h>

+

-

#include <math.h>

+

-

#include <gmodule.h>

+

-

#include "config.h"

+

-

#include "gfsconfig.h"

+

-

#include "simulation.h"

+

-

#include "output.h"

+

-

#include "refine.h"

+

-

#include "solid.h"

+

-

#include "version.h"

+

-

+

-

+

-

+

-

#define SQR(a) ((a)*(a))

+

-

+

-

#define my_alloc(pt, n, type, message) {\

+

-

if(((pt) = (type *) calloc(n,sizeof(type)))==NULL) {\

+

-

printf("\n\n Assertion: There is not sufficient memory to allocate: %s \n\n",message);\

and to place all this stuff in .vim/after/ftplugin/gfs.vim (you can also to load the color scheme of c.vim!!!)

-

/* ---------------------------------------------------

+

== Restarting parallel simulations ==

-

VTK output, it could be imported and visualized by

+

-

free visualization package ParaView, due to

+

-

consistancy with various platform ASCII format is used

+

-

--------------------------------------------------- */

+

-

if(strcmp(type,"VTK") == 0) {

+

Starting from version 2010-07-10 it should be possible to restart large parallel simulations. Just add the standard line:

-

int nn = (FTT_DIMENSION - 1)*4;

+

[[GfsOutputSimulation|OutputSimulation]] { step = 1 } sim-%g.gfs

-

/* name of output file */

+

and do e.g.

-

+

-

++ vtk_counter;

+

-

+

-

strcpy(file_name,"paraview");

+

-

sprintf(temp_string,"%i", vtk_counter);

+

-

strcat(temp_string, ".vtk");

+

-

strcat(file_name,temp_string);

+

-

+

-

fp = fopen (file_name, "w");

+

+

mpirun -np 8 gerris3D sim-10.gfs

-

/* write header of vtk file */

+

with the same number of processors you initially used to create <code>sim-10.gfs</code>.

-

fprintf (fp, "# vtk DataFile Version 2.0\n");

+

Note that if you use this (simple) method each processor will need to read the entire simulation file. If you notice that this phase takes a significant amount of time (e.g. due to filesystem performance when being accessed simultaneously by many processes), you can optimise things using:

-

fprintf (fp, "Unstructured Grid Example\n");

+

-

fprintf (fp, "ASCII\n");

+

-

fprintf (fp, "DATASET UNSTRUCTURED_GRID\n");

+

-

fprintf (fp, "\n");

+

-

/* write spatial coordinates */

+

[[GfsOutputSimulation|OutputSimulation]] { step = 1 } sim-%d-%g.gfs

-

fprintf (fp, "POINTS %i float\n", n_vertex);

+

which will generate a separate file for each process. You can then restart the simulation using e.g.

If you have a multi-core system (let's say 4), you can compile Gerris (and other sources) 4 times faster using:

-

for(i=0; i<n_cells; i++)

+

% make -j4

-

#if FTT_2D

+

-

fprintf (fp, "8 \n");

+

-

#else

+

-

fprintf (fp, "11 \n");

+

-

#endif

+

-

fprintf (fp, "\n");

+

-

/* write scaler fields */

+

== Visualizing VTK parallel files using Visit ==

-

if(n_real_filed>0) {

+

[https://wci.llnl.gov/codes/visit/ Visit] is a nice visualization tool that allows us to visualize, among many other formats, VTK files. For parallel runs, one can generate one vtk file per processor. Then, in order to visualize all the simulation domain, we need to generate a text file with extension .visit that gathers the names of the different vtk files at a given timestep. For example, if we have generated file-0-0.vtk and file-0-1.vtk at t=0, we just need to create the following text file:

-

fprintf (fp, "POINT_DATA %i\n",n_vertex);

+

!NBLOCKS 2

-

fprintf (fp, "\n");

+

file-0-0.vtk

+

file-0-1.vtk

-

for(j=0; j<n_real_filed; j++) {

+

If you have solutions at different time steps and you want to load them at once, then you will need to do something as follows:

-

+

-

fprintf (fp, "SCALARS %s float\n",filed_name[id_real_filed[j]]);

+

-

fprintf (fp, "LOOKUP_TABLE default \n");

+

-

for(i=0; i<n_vertex; i++)

+

!NBLOCKS 2

-

fprintf(fp, "%f\n",field_data[j][i]);

+

file-0-0.vtk

-

fprintf (fp, "\n");

+

file-0-1.vtk

-

}

+

file-1-0.vtk

-

}

+

file-1-1.vtk

-

/* write velosity fields as a vector field,

+

Further information can be found [https://wci.llnl.gov/codes/visit/2.0.0/GettingDataIntoVisIt2.0.0.pdf here].

-

if user include all velosity components */

+

-

if(have_vel_vector[0] == FTT_DIMENSION) {

+

== How to move in 3D in a 2D space ? ==

-

fprintf (fp, "VECTORS Velocity_vector float\n");

+

If you tried to visualize a Z scalar field in a linear object of GfsView2D you noticed it's difficult to move in 3D

+

because you are in a plane ! ;-)

-

#if FTT_2D

+

May be you tried to modify the q0,q1,q2,q3 parameters of your gfv file by hand, but if you don't like sine or cosine the solution

This will setup emacs so that opening files with the ".gfs" extension automatically uses the "gfs-mode" major mode. Alternatively you can manually enable this mode on any file using (within emacs):

M-x gfs-mode

where M- stands for the "emacs Meta key" (usually mapped to "esc" on your keyboard).

If you now restart emacs and open a .gfs file, you will see that emacs highlights Gerris keywords. These keywords are also "clickable". Clicking on a keyword will open the corresponding documentation in your web browser. If you want, you can customize the way links are opened by configuring the 'browse-url' emacs function which is used by gfs-mode.

Keyword auto-completion

gfs-mode configures dynamic abbrevs to provide auto-completion for Gerris keywords. Dynamic abbrevs are usually enabled by default in emacs. They work with any buffer. To use auto-completion, type the beginning of the Gerris keyword (e.g. "Out") and type

M-/

repeatedly. This will cycle through all the Gerris keywords starting with "Out".

Comments

Generating several movies on-the-fly

Note that using GfsOutputView is simpler and more efficient than the technique described in this section.

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 command:

Adding objects after a simulation has completed

Another example would be computing a distance function (i.e. a levelset function) from a VOF interface description for visualisation using isosurfaces in GfsView. This is easily done using something like:

with the same number of processors you initially used to create sim-10.gfs.

Note that if you use this (simple) method each processor will need to read the entire simulation file. If you notice that this phase takes a significant amount of time (e.g. due to filesystem performance when being accessed simultaneously by many processes), you can optimise things using:

Parallel compilation

Visualizing VTK parallel files using Visit

Visit is a nice visualization tool that allows us to visualize, among many other formats, VTK files. For parallel runs, one can generate one vtk file per processor. Then, in order to visualize all the simulation domain, we need to generate a text file with extension .visit that gathers the names of the different vtk files at a given timestep. For example, if we have generated file-0-0.vtk and file-0-1.vtk at t=0, we just need to create the following text file:

!NBLOCKS 2
file-0-0.vtk
file-0-1.vtk

If you have solutions at different time steps and you want to load them at once, then you will need to do something as follows: