Functions

Name

Functions -- Values varying in space and time

Synopsis


#include <gfs.h>

#define             GFS_FUNCTION_CLASS                  (klass)
#define             GFS_FUNCTION                        (obj)
#define             GFS_IS_FUNCTION                     (obj)

                    GfsFunctionClass;
                    GfsFunction;

GfsFunctionClass*   gfs_function_class                  (void);
GfsFunction*        gfs_function_new                    (GfsFunctionClass *klass,
                                                         gdouble val);
gdouble             gfs_function_face_value             (GfsFunction *f,
                                                         FttCellFace *fa);
gdouble             gfs_function_value                  (GfsFunction *f,
                                                         FttCell *cell);
void                gfs_function_read                   (GfsFunction *f,
                                                         gpointer domain,
                                                         GtsFile *fp);
void                gfs_function_write                  (GfsFunction *f,
                                                         FILE *fp);
gchar*              gfs_function_description            (GfsFunction *f,
                                                         gboolean truncate);
gdouble             gfs_function_get_constant_value     (GfsFunction *f);
void                gfs_function_set_constant_value     (GfsFunction *f,
                                                         gdouble val);
GfsVariable*        gfs_function_get_variable           (GfsFunction *f);

Description

Functions can be used in most objects which require a numerical parameter. A function can be either 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.)

Details

GFS_FUNCTION_CLASS()

#define             GFS_FUNCTION_CLASS(klass)

klass :


GFS_FUNCTION()

#define             GFS_FUNCTION(obj)

obj :


GFS_IS_FUNCTION()

#define             GFS_IS_FUNCTION(obj)

obj :


GfsFunctionClass

typedef struct {
  GtsObjectClass parent_class;
} GfsFunctionClass;


GfsFunction

typedef struct _GfsFunction GfsFunction;


gfs_function_class ()

GfsFunctionClass*   gfs_function_class                  (void);

Returns :


gfs_function_new ()

GfsFunction*        gfs_function_new                    (GfsFunctionClass *klass,
                                                         gdouble val);

klass :

a GfsFunctionClass.

val :

a value.

Returns :

a new GfsFunction with constant value val.


gfs_function_face_value ()

gdouble             gfs_function_face_value             (GfsFunction *f,
                                                         FttCellFace *fa);

f :

a GfsFunction.

fa :

a FttCellFace.

Returns :

the value of function f at the center of face fa.


gfs_function_value ()

gdouble             gfs_function_value                  (GfsFunction *f,
                                                         FttCell *cell);

f :

a GfsFunction.

cell :

a FttCell or NULL.

Returns :

the value of function f in cell.


gfs_function_read ()

void                gfs_function_read                   (GfsFunction *f,
                                                         gpointer domain,
                                                         GtsFile *fp);

Calls the read() method of f.

f :

a GfsFunction.

domain :

a GfsDomain.

fp :

a GtsFile.


gfs_function_write ()

void                gfs_function_write                  (GfsFunction *f,
                                                         FILE *fp);

Calls the write() method of f.

f :

a GfsFunction.

fp :

a file pointer.


gfs_function_description ()

gchar*              gfs_function_description            (GfsFunction *f,
                                                         gboolean truncate);

f :

a GfsFunction.

truncate :

whether to truncate long descriptions.

Returns :

a newly allocated string describing f.


gfs_function_get_constant_value ()

gdouble             gfs_function_get_constant_value     (GfsFunction *f);

f :

a GfsFunction.

Returns :

the value of function f if f is constant, G_MAXDOUBLE otherwise.


gfs_function_set_constant_value ()

void                gfs_function_set_constant_value     (GfsFunction *f,
                                                         gdouble val);

Sets the value of the constant function f to val.

f :

a GfsFunction.

val :

the value.


gfs_function_get_variable ()

GfsVariable*        gfs_function_get_variable           (GfsFunction *f);

f :

a GfsFunction.

Returns :

the variable containing the value of f if f is a simple variable, NULL otherwise.