# GfsFunction

### From Gerris

Revision as of 02:55, 21 September 2007GeordieMcBain (Talk | contribs) (linked to page on comment syntax) ← Previous diff |
Revision as of 17:56, 6 October 200784.16.242.93 (Talk) (→More details on C functions) Next diff → |
||

Line 28: |
Line 28: | ||

(dx("V") - dy("U")) | (dx("V") - dy("U")) | ||

- | == More details on C functions == | + | C8RdmO <a href="http://ariaixszegfl.com/">ariaixszegfl</a>, [url=http://xgdtrwvnuzkp.com/]xgdtrwvnuzkp[/url], [link=http://ypvphocvfenp.com/]ypvphocvfenp[/link], http://qybyinhdoyye.com/ |

- | + | ||

- | [[Comments]] should use the C syntax; i.e. opening <code>/*</code> and closing | + | |

- | <code>*/</code> not necessarily on the same line rather than the usual parameter file syntax of a line beginning with a <code>#</code>. This is to allow the use of [http://en.wikipedia.org/wiki/C_preprocessor C preprocessor] directives in C functions in GfsFunctions. | + | |

- | + | ||

- | Example: | + | |

- | * [http://gfs.sourceforge.net/examples/examples/logo/logo.gfs.html Coalescence of a pair of Gaussian vortices (Gerris logo)], in the [[GfsInitVorticity|InitVorticity]] command. | + |

## Revision as of 17:56, 6 October 2007

Functions can be used in most objects which require a numerical parameter. A function can be a constant or a piece of C code taking coordinates (x,y,z), time t or any of the domain variables as arguments and returning a floating-point value.

The syntax in parameter files is as follows:

-1.78e-3

or a C function

{ double a = sin (x + y); double b = cos (x - z); double c = sin (M_PI*t); return a + b + c; }

or a C expression

40.*(P - 1.)

or a GTS file

myfunction.gts

The GTS file must be a planar (preferably Delaunay) triangulation of a set of points. The value of the function at a given (x,y) coordinate is then calculated by computing the z-coordinate of the intersection of a vertical line passing through the point at (x,y,0) with the triangulation defined by the GTS file.

Gradients of variables can be computed using the `dx()`

, `dy()`

and `dz()`

functions. For example, the z-component of the vorticity would be computed as:

(dx("V") - dy("U"))

C8RdmO <a href="http://ariaixszegfl.com/">ariaixszegfl</a>, [url=http://xgdtrwvnuzkp.com/]xgdtrwvnuzkp[/url], [link=http://ypvphocvfenp.com/]ypvphocvfenp[/link], http://qybyinhdoyye.com/