Fluid cell

Name

Fluid cell -- 

Synopsis


#include <gfs.h>

#define             GFS_VARIABLE                        (cell, index)
#define             GFS_STATE                           (cell)
#define             GFS_FACE_NORMAL_VELOCITY_RIGHT      (fa)
#define             GFS_FACE_NORMAL_VELOCITY_LEFT       (fa)
#define             GFS_FACE_NORMAL_VELOCITY            (fa)
#define             GFS_CELL_IS_BOUNDARY                (cell)

                    GfsStateVector;
                    GfsFaceStateVector;
                    GfsVariable;
                    GfsVariableClass;
void                (*GfsVariableFineCoarseFunc)        (FttCell *cell,
                                                         GfsVariable *v);
enum                GfsFlags;

void                gfs_cell_init                       (FttCell *cell,
                                                         GfsDomain *domain);
void                gfs_cell_reset                      (FttCell *cell,
                                                         GfsVariable *v);
void                gfs_cell_cleanup                    (FttCell *cell,
                                                         GfsDomain *domain);
void                gfs_cell_copy                       (const FttCell *from,
                                                         FttCell *to,
                                                         GfsDomain *domain);
void                gfs_cell_cm                         (const FttCell *cell,
                                                         FttVector *cm);
void                gfs_face_ca                         (const FttCellFace *face,
                                                         FttVector *ca);
GfsVariable*        gfs_variable_new                    (GfsVariableClass *klass,
                                                         GfsDomain *domain,
                                                         const gchar *name,
                                                         const gchar *description);
GfsVariable*        gfs_variable_from_name              (GSList *i,
                                                         const gchar *name);
GSList*             gfs_variables_from_list             (GSList *i,
                                                         gchar *list,
                                                         gchar **error);
GtsRange            gfs_stats_variable                  (FttCell *root,
                                                         GfsVariable *v,
                                                         FttTraverseFlags flags,
                                                         gint max_depth);
GfsNorm             gfs_norm_variable                   (FttCell *root,
                                                         GfsVariable *v,
                                                         FttTraverseFlags flags,
                                                         gint max_depth);
void                gfs_get_from_below_intensive        (FttCell *cell,
                                                         const GfsVariable *v);
void                gfs_cell_coarse_init                (FttCell *cell,
                                                         GfsDomain *domain);
void                gfs_cell_fine_init                  (FttCell *cell,
                                                         GfsDomain *domain);
gdouble             gfs_vector_norm                     (FttCell *cell,
                                                         GfsVariable **v);
gdouble             gfs_vector_norm2                    (FttCell *cell,
                                                         GfsVariable **v);
gdouble             gfs_divergence                      (FttCell *cell,
                                                         GfsVariable **v);
void                gfs_normal_divergence               (FttCell *cell,
                                                         GfsVariable *v);
gdouble             gfs_vorticity                       (FttCell *cell,
                                                         GfsVariable **v);
gdouble             gfs_face_interpolated_value         (const FttCellFace *face,
                                                         guint v);
gdouble             gfs_interpolate                     (FttCell *cell,
                                                         FttVector p,
                                                         GfsVariable *v);

                    GfsGradient;
void                gfs_face_gradient                   (const FttCellFace *face,
                                                         GfsGradient *g,
                                                         guint v,
                                                         gint max_level);
void                gfs_face_weighted_gradient          (const FttCellFace *face,
                                                         GfsGradient *g,
                                                         guint v,
                                                         gint max_level);
void                gfs_face_gradient_flux              (const FttCellFace *face,
                                                         GfsGradient *g,
                                                         guint v,
                                                         gint max_level);
gdouble             (*GfsCenterGradient)                (FttCell *cell,
                                                         FttComponent c,
                                                         guint v);
gdouble             gfs_center_gradient                 (FttCell *cell,
                                                         FttComponent c,
                                                         guint v);
gdouble             gfs_center_van_leer_gradient        (FttCell *cell,
                                                         FttComponent c,
                                                         guint v);
void                gfs_cell_dirichlet_gradient         (FttCell *cell,
                                                         guint v,
                                                         gint max_level,
                                                         gdouble v0,
                                                         FttVector *grad);
gdouble             gfs_cell_dirichlet_gradient_flux    (FttCell *cell,
                                                         guint v,
                                                         gint max_level,
                                                         gdouble v0);
gdouble             gfs_cell_dirichlet_value            (FttCell *cell,
                                                         GfsVariable *v,
                                                         gint max_level);
                    GfsInterpolator;
void                gfs_cell_corner_interpolator        (FttCell *cell,
                                                         FttDirection d[FTT_DIMENSION],
                                                         gint max_level,
                                                         gboolean centered,
                                                         GfsInterpolator *inter);
gdouble             gfs_cell_corner_value               (FttCell *cell,
                                                         FttDirection *d,
                                                         GfsVariable *v,
                                                         gint max_level);

void                gfs_cell_write                      (const FttCell *cell,
                                                         FILE *fp,
                                                         GSList *variables);
void                gfs_cell_write_binary               (const FttCell *cell,
                                                         FILE *fp,
                                                         GSList *variables);
void                gfs_cell_read                       (FttCell *cell,
                                                         GtsFile *fp,
                                                         GfsDomain *domain);
void                gfs_cell_read_binary                (FttCell *cell,
                                                         GtsFile *fp,
                                                         GfsDomain *domain);

Description

Details

GFS_VARIABLE()

#define GFS_VARIABLE(cell, index)     ((&GFS_STATE (cell)->place_holder)[index])

Evaluates to the value of variable index in cell.

cell :

a FttCell.

index :

a GfsVariable.


GFS_STATE()

#define GFS_STATE(cell)               ((GfsStateVector *) (cell)->data)

cell :


GFS_FACE_NORMAL_VELOCITY_RIGHT()

#define             GFS_FACE_NORMAL_VELOCITY_RIGHT(fa)

fa :


GFS_FACE_NORMAL_VELOCITY_LEFT()

#define             GFS_FACE_NORMAL_VELOCITY_LEFT(fa)

fa :


GFS_FACE_NORMAL_VELOCITY()

#define             GFS_FACE_NORMAL_VELOCITY(fa)

fa :


GFS_CELL_IS_BOUNDARY()

#define GFS_CELL_IS_BOUNDARY(cell) (((cell)->flags & GFS_FLAG_BOUNDARY) != 0)

cell :


GfsStateVector

typedef struct {
  /* temporary face variables */
  GfsFaceStateVector f[FTT_NEIGHBORS];

  /* solid boundaries */
  GfsSolidVector * solid;

  gdouble place_holder;
} GfsStateVector;

The fluid variables describing the state of the cell.


GfsFaceStateVector

typedef struct {
  gdouble un;
  gdouble v;
} GfsFaceStateVector;


GfsVariable

typedef struct {
  guint i;
  FttComponent component;
  GfsVariable * vector[FTT_DIMENSION];
  gchar * name, * description;
  gboolean centered;
  GfsVariableFineCoarseFunc fine_coarse, coarse_fine;
  GtsContainer * sources;
  GfsSurfaceGenericBc * surface_bc;
  GfsBc * default_bc;
  GfsDomain * domain;
  FttCellCleanupFunc cleanup;
  gdouble units;
} GfsVariable;

The fluid variables associated with a fluid cell.


GfsVariableClass

typedef struct {
} GfsVariableClass;


GfsVariableFineCoarseFunc ()

void                (*GfsVariableFineCoarseFunc)        (FttCell *cell,
                                                         GfsVariable *v);

cell :

v :


enum GfsFlags

typedef enum {
  GFS_FLAG_USED =              1 <<  FTT_FLAG_USER,
  GFS_FLAG_BOUNDARY          = 1 << (FTT_FLAG_USER + 1),
  GFS_FLAG_DIRICHLET         = 1 << (FTT_FLAG_USER + 2),
  GFS_FLAG_GRADIENT_BOUNDARY = 1 << (FTT_FLAG_USER + 3),
  GFS_FLAG_PERMANENT         = 1 << (FTT_FLAG_USER + 4),
  GFS_FLAG_THIN              = 1 << (FTT_FLAG_USER + 5),
  GFS_FLAG_USER =                    FTT_FLAG_USER + 6 /* user flags start here */
} GfsFlags;


gfs_cell_init ()

void                gfs_cell_init                       (FttCell *cell,
                                                         GfsDomain *domain);

Allocates the memory for fluid state data associated to cell or its children.

cell :

a FttCell.

domain :

a GfsDomain containing cell.


gfs_cell_reset ()

void                gfs_cell_reset                      (FttCell *cell,
                                                         GfsVariable *v);

Sets the value of the variable v of cell to zero.

cell :

a FttCell.

v :

a GfsVariable to reset.


gfs_cell_cleanup ()

void                gfs_cell_cleanup                    (FttCell *cell,
                                                         GfsDomain *domain);

Frees the memory allocated for extra data associated with cell.

This function must be used as "cleanup function" when using ftt_cell_destroy().

cell :

a FttCell.

domain :

a GfsDomain.


gfs_cell_copy ()

void                gfs_cell_copy                       (const FttCell *from,
                                                         FttCell *to,
                                                         GfsDomain *domain);

Copies the attributes of the fluid cell from to the fluid cell to.

from :

a FttCell to copy attributes from.

to :

a FttCell to copy attributes to.

domain :

the GfsDomain containing from.


gfs_cell_cm ()

void                gfs_cell_cm                         (const FttCell *cell,
                                                         FttVector *cm);

Fills cm with the coordinates of the center of mass of cell.

cell :

a FttCell.

cm :

a FttVector.


gfs_face_ca ()

void                gfs_face_ca                         (const FttCellFace *face,
                                                         FttVector *ca);

Fills ca with the coordinates of the center of area of face.

face :

a FttCellFace.

ca :

a FttVector.


gfs_variable_new ()

GfsVariable*        gfs_variable_new                    (GfsVariableClass *klass,
                                                         GfsDomain *domain,
                                                         const gchar *name,
                                                         const gchar *description);

klass :

a GfsVariableClass.

domain :

a GfsDomain.

name :

the name of the variable or NULL.

description :

the variable description or NULL.

Returns :

a newly allocated GfsVariable or NULL if a variable named name already exists in domain.


gfs_variable_from_name ()

GfsVariable*        gfs_variable_from_name              (GSList *i,
                                                         const gchar *name);

i :

the list of available GfsVariable.

name :

the name of the variable to find.

Returns :

the GfsVariable name or NULL if this variable name does not exist.


gfs_variables_from_list ()

GSList*             gfs_variables_from_list             (GSList *i,
                                                         gchar *list,
                                                         gchar **error);

i :

the list of available GfsVariable.

list :

a malloc'ed string containing comma separated variable names.

error :

where to return the variable name in case of error.

Returns :

a list of variables or NULL in case of error, in which case *error points to the name of the unknown variable.


gfs_stats_variable ()

GtsRange            gfs_stats_variable                  (FttCell *root,
                                                         GfsVariable *v,
                                                         FttTraverseFlags flags,
                                                         gint max_depth);

Traverses the cell tree defined by root using ftt_cell_traverse() and gathers statistics about variable v.

root :

the root FttCell of the tree to obtain statistics from.

v :

the variable to consider for statistics.

flags :

which types of cells are to be visited.

max_depth :

maximum depth of the traversal.

Returns :

a GtsRange containing the statistics about v.


gfs_norm_variable ()

GfsNorm             gfs_norm_variable                   (FttCell *root,
                                                         GfsVariable *v,
                                                         FttTraverseFlags flags,
                                                         gint max_depth);

Traverses the cell tree defined by root using ftt_cell_traverse() and gathers norm statistics about variable v.

root :

the root FttCell of the tree to obtain norm from.

v :

the variable to consider for norm statistics.

flags :

which types of cells are to be visited.

max_depth :

maximum depth of the traversal.

Returns :

a GfsNorm containing the norm statistics about v.


gfs_get_from_below_intensive ()

void                gfs_get_from_below_intensive        (FttCell *cell,
                                                         const GfsVariable *v);

Sets the value of the "intensive" variable v of cell by taking the volume weighted average of the values of its children cells.

This functions fails if cell is a leaf of the cell tree.

cell :

a FttCell.

v :

a GfsVariable to "get from below".


gfs_cell_coarse_init ()

void                gfs_cell_coarse_init                (FttCell *cell,
                                                         GfsDomain *domain);

Initialises the variables of cell using the values of its children cells.

cell :

a FttCell.

domain :

a GfsDomain containing cell.


gfs_cell_fine_init ()

void                gfs_cell_fine_init                  (FttCell *cell,
                                                         GfsDomain *domain);

Initialises the children of parent.

cell :

domain :

a GfsDomain containing parent.


gfs_vector_norm ()

gdouble             gfs_vector_norm                     (FttCell *cell,
                                                         GfsVariable **v);

cell :

a FttCell.

v :

the components of the vector.

Returns :

the norm of the vector field v in cell.


gfs_vector_norm2 ()

gdouble             gfs_vector_norm2                    (FttCell *cell,
                                                         GfsVariable **v);

cell :

a FttCell.

v :

the components of the vector.

Returns :

the squared norm of the vector field v in cell.


gfs_divergence ()

gdouble             gfs_divergence                      (FttCell *cell,
                                                         GfsVariable **v);

cell :

a FttCell.

v :

the components of the vector.

Returns :

the divergence of the (centered) vector field v in cell.


gfs_normal_divergence ()

void                gfs_normal_divergence               (FttCell *cell,
                                                         GfsVariable *v);

Adds to variable v of cell the integral of the divergence of the (MAC) velocity field in this cell.

cell :

a FttCell.

v :

a GfsVariable.


gfs_vorticity ()

gdouble             gfs_vorticity                       (FttCell *cell,
                                                         GfsVariable **v);

cell :

a FttCell.

v :

the components of the vector.

Returns :

the vorticity (norm of the vorticity vector in 3D) of the vector field v in cell.


gfs_face_interpolated_value ()

gdouble             gfs_face_interpolated_value         (const FttCellFace *face,
                                                         guint v);

Computes the value of variable v on the face using second-order interpolation from the cell-centered values.

face :

a FttFace.

v :

a GfsVariable index.

Returns :

the value of variable v on the face.


gfs_interpolate ()

gdouble             gfs_interpolate                     (FttCell *cell,
                                                         FttVector p,
                                                         GfsVariable *v);

Interpolates the v variable of cell, at location p. Linear interpolation is used and the boundaries of the domain are treated as planes of symmetry for all variables.

cell :

a FttCell containing location p.

p :

the location at which to interpolate.

v :

a GfsVariable.

Returns :

the interpolated value of variable v at location p.


GfsGradient

typedef struct {
  gdouble a, b;
} GfsGradient;

Defines the (second-order accurate) gradient of a variable v in a given direction as: a*GFS_VARIABLE (cell, v) + b.


gfs_face_gradient ()

void                gfs_face_gradient                   (const FttCellFace *face,
                                                         GfsGradient *g,
                                                         guint v,
                                                         gint max_level);

Set the value of g as the gradient of variable v on the face. The value returned is second order accurate in space and conservative, in the sense that values at a coarse/fine cell boundary are consistent.

The value of the gradient (normalised by the size of face->cell) is given by: g->b - g->a*GFS_VARIABLE (face->cell, v).

face :

a FttCellFace.

g :

the GfsGradient.

v :

a GfsVariable index.

max_level :

the maximum cell level to consider (-1 means no restriction).


gfs_face_weighted_gradient ()

void                gfs_face_weighted_gradient          (const FttCellFace *face,
                                                         GfsGradient *g,
                                                         guint v,
                                                         gint max_level);

Set the value of g as the gradient of variable v on the face weighted by the value of the v field of the face state vector of the corresponding cell. The value returned is second order accurate in space and conservative, in the sense that values at a coarse/fine cell boundary are consistent.

face :

a FttCellFace.

g :

the GfsGradient.

v :

a GfsVariable index.

max_level :

the maximum cell level to consider (-1 means no restriction).


gfs_face_gradient_flux ()

void                gfs_face_gradient_flux              (const FttCellFace *face,
                                                         GfsGradient *g,
                                                         guint v,
                                                         gint max_level);

Set the value of g as the gradient of variable v on the face weighted by the value of the v field of the face state vector of the corresponding cell. Variable v is defined at the center of mass of its cell. Linear interpolation is used to evaluate the gradient in the vicinity of cut cells.

face :

a FttCellFace.

g :

the GfsGradient.

v :

a GfsVariable index.

max_level :

the maximum cell level to consider (-1 means no restriction).


GfsCenterGradient ()

gdouble             (*GfsCenterGradient)                (FttCell *cell,
                                                         FttComponent c,
                                                         guint v);

cell :

c :

v :

Returns :


gfs_center_gradient ()

gdouble             gfs_center_gradient                 (FttCell *cell,
                                                         FttComponent c,
                                                         guint v);

The gradient is normalized by the size of the cell.

cell :

a FttCell.

c :

a component.

v :

a GfsVariable index.

Returns :

the value of the c component of the gradient of variable v at the center of the cell.


gfs_center_van_leer_gradient ()

gdouble             gfs_center_van_leer_gradient        (FttCell *cell,
                                                         FttComponent c,
                                                         guint v);

The gradient is normalized by the size of the cell and is limited using van Leer's limiter.

cell :

a FttCell.

c :

a component.

v :

a GfsVariable index.

Returns :

the value of the c component of the gradient of variable v at the center of the cell.


gfs_cell_dirichlet_gradient ()

void                gfs_cell_dirichlet_gradient         (FttCell *cell,
                                                         guint v,
                                                         gint max_level,
                                                         gdouble v0,
                                                         FttVector *grad);

Fills grad with components of the gradient of variable v interpolated at the center of area of the solid boundary contained in cell. The gradient is scaled by the size of the cell.

cell :

a FttCell.

v :

a GfsVariable index.

max_level :

the maximum cell level to consider (-1 means no restriction).

v0 :

the Dirichlet value on the boundary.

grad :

a FttVector.


gfs_cell_dirichlet_gradient_flux ()

gdouble             gfs_cell_dirichlet_gradient_flux    (FttCell *cell,
                                                         guint v,
                                                         gint max_level,
                                                         gdouble v0);

cell :

a FttCell.

v :

a GfsVariable index.

max_level :

the maximum cell level to consider (-1 means no restriction).

v0 :

the Dirichlet value on the boundary.

Returns :

the flux of the gradient of variable v through the solid boundary contained in cell.


gfs_cell_dirichlet_value ()

gdouble             gfs_cell_dirichlet_value            (FttCell *cell,
                                                         GfsVariable *v,
                                                         gint max_level);

cell :

a FttCell.

v :

a GfsVariable.

max_level :

the maximum cell level to consider (-1 means no restriction).

Returns :

the value of variable v interpolated at the center of area of the solid boundary contained in cell.


GfsInterpolator

typedef struct {
#if FTT_2D
  FttCell * c[7];
  gdouble w[7];
#else  /* 3D */
  FttCell * c[29];
  gdouble w[29];
#endif /* 3D */
  guint n;  
} GfsInterpolator;


gfs_cell_corner_interpolator ()

void                gfs_cell_corner_interpolator        (FttCell *cell,
                                                         FttDirection d[FTT_DIMENSION],
                                                         gint max_level,
                                                         gboolean centered,
                                                         GfsInterpolator *inter);

Fills inter with the interpolator for the corner of cell defined by d.

cell :

a FttCell.

d :

a set of perpendicular directions.

max_level :

the maximum cell level to consider (-1 means no restriction).

centered :

TRUE if the interpolator is cell-centered.

inter :

a GfsInterpolator.


gfs_cell_corner_value ()

gdouble             gfs_cell_corner_value               (FttCell *cell,
                                                         FttDirection *d,
                                                         GfsVariable *v,
                                                         gint max_level);

cell :

a FttCell.

d :

a set of perpendicular directions.

v :

a GfsVariable.

max_level :

the maximum cell level to consider (-1 means no restriction).

Returns :

the value of variable v interpolated at the corner of cell defined by d.


gfs_cell_write ()

void                gfs_cell_write                      (const FttCell *cell,
                                                         FILE *fp,
                                                         GSList *variables);

Writes in fp the fluid data associated with cell and described by variables. This function is generally used in association with ftt_cell_write().

cell :

a FttCell.

fp :

a file pointer.

variables :

the list of GfsVariable to be written.


gfs_cell_write_binary ()

void                gfs_cell_write_binary               (const FttCell *cell,
                                                         FILE *fp,
                                                         GSList *variables);

Writes in fp the fluid data associated with cell and described by variables. This function is generally used in association with ftt_cell_write_binary().

cell :

a FttCell.

fp :

a file pointer.

variables :

the list of GfsVariable to be written.


gfs_cell_read ()

void                gfs_cell_read                       (FttCell *cell,
                                                         GtsFile *fp,
                                                         GfsDomain *domain);

Reads from fp the fluid data associated with cell and described by domain->variables_io. This function is generally used in association with ftt_cell_read().

cell :

a FttCell.

fp :

a GtsFile.

domain :

the GfsDomain containing cell.


gfs_cell_read_binary ()

void                gfs_cell_read_binary                (FttCell *cell,
                                                         GtsFile *fp,
                                                         GfsDomain *domain);

Reads from fp the fluid data associated with cell and described by domain->variables_io. This function is generally used in association with ftt_cell_read_binary().

cell :

a FttCell.

fp :

a GtsFile.

domain :

the GfsDomain containing cell.