Gerris
Functions

utils.c File Reference

GfsFunction and various utility functions. More...

Functions

gchar * gfs_mkftemp (gchar *tmpl)
gchar * gfs_template (void)
void gfs_object_clone (GtsObject *object, GtsObject *clone)
gboolean gfs_char_in_string (char c, const char *s)
gchar * gfs_file_statement (GtsFile *fp)
void gfs_pending_functions_compilation (GtsFile *fp)
GString * gfs_function_expression (GtsFile *fp, gboolean *is_expression)
GfsFunction * gfs_function_new (GfsFunctionClass *klass, gdouble val)
void gfs_function_set_units (GfsFunction *f, gdouble units)
gchar * gfs_function_description (GfsFunction *f, gboolean truncate)
gdouble gfs_function_value (GfsFunction *f, FttCell *cell)
gdouble gfs_function_face_value (GfsFunction *f, FttCellFace *fa)
void gfs_function_set_constant_value (GfsFunction *f, gdouble val)
gdouble gfs_function_get_constant_value (GfsFunction *f)
gboolean gfs_function_is_constant (const GfsFunction *f)
GfsVariable * gfs_function_get_variable (GfsFunction *f)
void gfs_function_read (GfsFunction *f, gpointer domain, GtsFile *fp)
void gfs_function_write (GfsFunction *f, FILE *fp)
gdouble gfs_function_spatial_value (GfsFunction *f, const FttVector *p)
gdouble gfs_read_constant (GtsFile *fp, gpointer domain)
GtsObjectClass * gfs_object_class_from_name (const gchar *name)
void gfs_eigenvalues (gdouble a[FTT_DIMENSION][FTT_DIMENSION], gdouble d[FTT_DIMENSION], gdouble v[FTT_DIMENSION][FTT_DIMENSION])
gdouble gfs_matrix_inverse (gdouble **m, guint n, gdouble pivmin)
gpointer gfs_matrix_new (guint n, guint p, guint size)
void gfs_matrix_free (gpointer m)
GfsClock * gfs_clock_new (void)
void gfs_clock_start (GfsClock *t)
void gfs_clock_stop (GfsClock *t)
gdouble gfs_clock_elapsed (GfsClock *t)
void gfs_clock_destroy (GfsClock *t)
FILE * gfs_union_open (FILE *fp, int rank, GfsUnionFile *file)
void gfs_union_close (FILE *fp, int rank, GfsUnionFile *file)
GSList * gfs_format_new (const gchar *format, GtsFile *fp, gboolean *dynamic, gboolean *parallel)
void gfs_format_destroy (GSList *f)
gchar * gfs_format_string (GSList *format, gint pid, guint niter, gdouble time)
gdouble gfs_format_time_value (GSList *format, const gchar *string)
void gfs_cell_message (const FttCell *cell, const gchar *format,...)
void gfs_debug (const gchar *format,...)
void gfs_debug_enabled (gboolean enabled)
gboolean gfs_read_vector (GtsFile *fp, gchar *component[FTT_DIMENSION])
gboolean gfs_read_variable_vector (GtsFile *fp, GfsVariable *vector[FTT_DIMENSION], GfsDomain *domain)
gboolean gfs_read_function_vector (GtsFile *fp, GfsVariable *vector[FTT_DIMENSION], GfsFunction *function[FTT_DIMENSION], gpointer sim)

Detailed Description

GfsFunction and various utility functions.


Function Documentation

void gfs_cell_message ( const FttCell *  cell,
const gchar *  format,
  ... 
)
Parameters:
cella #FttCell.
formata string format. ...: arguments for format.

Logs a message preceded by the pointer, position and level of cell.

Here is the call graph for this function:

gboolean gfs_char_in_string ( char  c,
const char *  s 
)
Parameters:
ca character.
sa string.
Returns:
TRUE if c belongs to s, FALSE otherwise.

Here is the caller graph for this function:

void gfs_clock_destroy ( GfsClock *  t)
Parameters:
ta #GfsClock.

Destroys the clock, freeing the memory allocated for it.

gdouble gfs_clock_elapsed ( GfsClock *  t)
Parameters:
ta #GfsClock.
Returns:
the time elapsed in seconds since t was started.

Here is the caller graph for this function:

GfsClock* gfs_clock_new ( void  )
Returns:
a new #GfsClock.
void gfs_clock_start ( GfsClock *  t)
Parameters:
ta #GfsClock.

Starts clock t.

Here is the caller graph for this function:

void gfs_clock_stop ( GfsClock *  t)
Parameters:
ta #GfsClock.

Stops clock t.

Here is the caller graph for this function:

void gfs_debug ( const gchar *  format,
  ... 
)
Parameters:
formata string format. ...: arguments for format.

Logs a debugging message (only when gfs_debug_enabled() is set to TRUE).

Here is the caller graph for this function:

void gfs_debug_enabled ( gboolean  enabled)
Parameters:
enabledwhether to enable debug message logging.

Enables or disables debug message logging (see also gfs_debug()).

void gfs_eigenvalues ( gdouble  a[FTT_DIMENSION][FTT_DIMENSION],
gdouble  d[FTT_DIMENSION],
gdouble  v[FTT_DIMENSION][FTT_DIMENSION] 
)
Parameters:
aa symmetric matrix.
da vector.
vanother matrix.

Fills d (resp. v) with the eigenvalues (resp. eigenvectors) of matrix a.

Here is the caller graph for this function:

gchar* gfs_file_statement ( GtsFile *  fp)
Parameters:
fpa #GtsFile.

Reads the next brackets-delimited ({...}) statemement in fp, including all comments.

Returns:
a newly allocated string containing the text of the next statement in fp, or NULL if an error occured in which case fp->error is set.

Here is the caller graph for this function:

void gfs_format_destroy ( GSList *  f)
Parameters:
fa list of #GfsFormat.

Frees all memory allocated for f.

GSList* gfs_format_new ( const gchar *  format,
GtsFile *  fp,
gboolean *  dynamic,
gboolean *  parallel 
)
Parameters:
formata string.
fpa #GtsFile or NULL.
dynamicset to TRUE if the format is time-dependent.
parallelset to TRUE if the format is PID-dependent.

If fp is not NULL and and error occurs, an error message is set in fp.

Returns:
a list of #GfsFormat composing format.

Here is the call graph for this function:

gchar* gfs_format_string ( GSList *  format,
gint  pid,
guint  niter,
gdouble  time 
)
Parameters:
formata GSList of #GfsFormat.
pidthe PID.
niternumber of iterations done in the simulation.
timesimulation time.
Returns:
a newly-allocated string (file name) built from the GfsFormat contained in GSList. It typically includes informations on the PID, the time and/or the number of iterations done in the simulation.
gdouble gfs_format_time_value ( GSList *  format,
const gchar *  string 
)
Parameters:
formata list of #GfsFormat.
stringa string formatted according to format.
Returns:
the value of the time or iteration contained in s or G_MAXDOUBLE if s is not formatted according to format.

Here is the call graph for this function:

void gfs_matrix_free ( gpointer  m)
Parameters:
ma matrix allocated with gfs_matrix_new().

Frees the memory occupied by m.

gdouble gfs_matrix_inverse ( gdouble **  m,
guint  n,
gdouble  pivmin 
)
Parameters:
ma square matrix.
nsize of the matrix.
pivminthe minimum value of the pivoting coefficient.

Replaces m with its inverse.

Returns:
0. if the inversion encounters a pivot coefficient smaller than or equal to pivmin (i.e. m is non-invertible), the minimum absolute value of the pivoting coefficient otherwise.
gpointer gfs_matrix_new ( guint  n,
guint  p,
guint  size 
)
Parameters:
nthe size of the matrix.
pthe size of the matrix.
sizethe size of the matrix elements.

The matrix elements are initialised to zero.

Returns:
a newly allocated matrix.
gchar* gfs_mkftemp ( gchar *  tmpl)
Parameters:
tmpltemplate FIFO name

Creates a temporary FIFO. See the mkfifo() documentation on most UNIX-like systems.

Returns:
A pointer to tmpl, which has been modified to hold the directory name. In case of errors, NULL is returned and errno will be set.

Here is the caller graph for this function:

GtsObjectClass* gfs_object_class_from_name ( const gchar *  name)
Parameters:
namethe name of the class.

Looks for a class called name. If none is found append the "Gfs" prefix and look again.

Returns:
the class or NULL if none was found.

Here is the caller graph for this function:

void gfs_object_clone ( GtsObject *  object,
GtsObject *  clone 
)
Parameters:
objectthe #GtsObject to clone.
clonethe clone of object.

Makes clone the clone of object using the write() and read() methods of object.

void gfs_pending_functions_compilation ( GtsFile *  fp)
Parameters:
fpa #GtsFile.

Compiles and links pending #GfsFunction definitions.

Compilation errors are reported in fp.

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean gfs_read_function_vector ( GtsFile *  fp,
GfsVariable *  vector[FTT_DIMENSION],
GfsFunction *  function[FTT_DIMENSION],
gpointer  sim 
)
Parameters:
fpa #GtsFile.
vectoran array of vector component variables.
functionan array of vector component #GfsFunction corresponding to vector.
simthe #GfsSimulation to which vector belongs.

Reads a vector from fp and fills vector.

Returns:
TRUE if all vector components have been read, FALSE otherwise, in which case the error is reported in fp.

Here is the call graph for this function:

gboolean gfs_read_variable_vector ( GtsFile *  fp,
GfsVariable *  vector[FTT_DIMENSION],
GfsDomain *  domain 
)
Parameters:
fpa #GtsFile.
vectoran array of vector component variables.
domainthe #GfsDomain to which vector belongs.

Reads a vector from fp and fills vector.

Returns:
TRUE if all vector components have been read, FALSE otherwise, in which case the error is reported in fp.

Here is the call graph for this function:

gboolean gfs_read_vector ( GtsFile *  fp,
gchar *  component[FTT_DIMENSION] 
)
Parameters:
fpa #GtsFile.
componentan array of vector component names.

Reads a vector from fp and fills component. Note that the component strings need to be freed after use.

Returns:
TRUE if all vector components have been read, FALSE otherwise, in which case the error is reported in fp.

Here is the caller graph for this function:

gchar* gfs_template ( void  )
Returns:
the template for a temporary file name.

Here is the caller graph for this function:

void gfs_union_close ( FILE *  fp,
int  rank,
GfsUnionFile *  file 
)
Parameters:
fpa file pointer.
rankthe rank of the current parallel process.
filea #GfsUnionFile returned by a call to gfs_union_open().

Closes a "parallel" file previously opened using gfs_union_open().

Here is the caller graph for this function:

FILE* gfs_union_open ( FILE *  fp,
int  rank,
GfsUnionFile *  file 
)
Parameters:
fpa file pointer.
rankthe rank of the current parallel process.
filea #GfsUnionFile.

Opens a "parallel" file which serialises multiple parallel (write) accesses to the file pointed to by fp.

This file must be closed with gfs_union_close().

Returns:
a "parallel" file pointer associated with fp.

Here is the caller graph for this function:

 All Data Structures Files Functions Variables