![]() | ![]() | ![]() | Gerris Flow Solver Reference Manual | ![]() |
---|
#include <gfs.h> #define GFS_VARIABLE (cell, index) #define GFS_STATE (cell) #define GFS_VELOCITY_COMPONENT (index) #define GFS_VELOCITY_INDEX (component) #define GFS_GRADIENT_COMPONENT (index) #define GFS_GRADIENT_INDEX (component) #define GFS_FACE_NORMAL_VELOCITY_RIGHT (fa) #define GFS_FACE_NORMAL_VELOCITY_LEFT (fa) #define GFS_FACE_NORMAL_VELOCITY (fa) #define GFS_IS_SMALL (cell) #define GFS_CELL_IS_BOUNDARY (cell) struct GfsStateVector; struct GfsFaceStateVector; struct GfsVariable; enum GfsPermanentVariable; struct GfsVariableClass;void (*GfsVariableDerivedFunc) (FttCell *cell, GfsVariable *v);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);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,GtsObject *parent, constgchar *name,gboolean centered,guint i); GfsVariable* gfs_variable_list_copy (GfsVariable *v,GtsObject *parent);void gfs_variable_list_destroy (GfsVariable *v); GfsVariable* gfs_variable_from_name (GfsVariable *variables, constgchar *name); GfsVariable* gfs_variables_from_list (GfsVariable *variables,gchar *list,gchar **error); #define gfs_variable_parent (v) #define gfs_variable_set_parent (v, pa)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_get_from_below_extensive (FttCell *cell, const GfsVariable *v);void gfs_get_from_above (FttCell *cell, const GfsVariable *v);void gfs_cell_coarse_init (FttCell *cell, GfsDomain *domain);void gfs_cell_fine_init (FttCell *cell, GfsDomain *domain);void gfs_cell_init_fraction (FttCell *root,GtsSurface *s,GNode *stree,gboolean is_open, GfsVariable *c);void gfs_velocity_norm (FttCell *cell, GfsVariable *v);void gfs_velocity_norm2 (FttCell *cell, GfsVariable *v);void gfs_divergence (FttCell *cell);void gfs_normal_divergence (FttCell *cell);void 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); struct 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);void gfs_face_gradient_flux_centered (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);gdouble gfs_cell_laplacian (FttCell *cell, GfsVariable *v); struct 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, GfsVariable *variables);void gfs_cell_write_binary (const FttCell *cell,FILE *fp, GfsVariable *variables);void gfs_cell_read (FttCell *cell,GtsFile *fp, GfsDomain *domain);void gfs_cell_read_binary (FttCell *cell,GtsFile *fp, GfsDomain *domain);
#define GFS_VARIABLE(cell, index) ((&GFS_STATE (cell)->div)[index])
Evaluates to the value of variable index in cell.
cell : | a FttCell. |
index : | a GfsVariable. |
#define GFS_CELL_IS_BOUNDARY(cell) (((cell)->flags & GFS_FLAG_BOUNDARY) != 0)
cell : |
|
struct GfsStateVector { /* temporary face variables */ GfsFaceStateVector f[FTT_NEIGHBORS]; /* solid boundaries */ GfsSolidVector * solid; /* centered temporary variables */ gdouble div, dp, res; gdouble g[FTT_DIMENSION]; /* centered primitive variables */ gdouble p; gdouble u, v; #if (!FTT_2D) gdouble w; #endif /* FTT_3D */ };
The fluid variables describing the state of the cell.
struct GfsVariable { guint i; gchar * name; gboolean centered, temporary; GfsVariableDerivedFunc derived; GfsVariableFineCoarseFunc fine_coarse; GtsContainer * sources; GfsSurfaceGenericBc * surface_bc; GfsVariable * next; GtsObject * p; };
The fluid variables associated with a fluid cell.
typedef enum { /* centered temporary variables */ GFS_DIV = 0, GFS_DP, GFS_RES, GFS_GX, GFS_GY, #if (!FTT_2D) GFS_GZ, #endif /* FTT_3D */ /* centered primitive variables */ GFS_P, GFS_U, GFS_V, #if (!FTT_2D) GFS_W, #endif /* FTT_3D */ } GfsPermanentVariable;
void (*GfsVariableFineCoarseFunc) (FttCell *cell, GfsVariable *v);
cell : | |
v : |
|
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_USER = FTT_FLAG_USER + 3 /* user flags start here */ } GfsFlags;
void gfs_cell_init (FttCell *cell, GfsDomain *domain);
Allocates the memory for fluid state data associated to cell.
cell : | a FttCell. |
domain : | a GfsDomain containing cell. |
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. |
void gfs_cell_cleanup (FttCell *cell);
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. |
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. |
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. |
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. |
GfsVariable* gfs_variable_new (GfsVariableClass *klass,GtsObject *parent, constgchar *name,gboolean centered,guint i);
klass : | |
parent : | the parent or NULL. |
name : | the name of the variable. |
centered : | is the variable cell-centered? |
i : | the variable index. |
Returns : | a newly allocated GfsVariable, |
GfsVariable* gfs_variable_list_copy (GfsVariable *v,GtsObject *parent);
v : | a GfsVariable. |
parent : | the parent of the new list or NULL. |
Returns : | a new variable list copy of v. |
void gfs_variable_list_destroy (GfsVariable *v);
Free all the memory allocated for the list starting at v.
v : | a GfsVariable. |
GfsVariable* gfs_variable_from_name (GfsVariable *variables, constgchar *name);
variables : | 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. |
GfsVariable* gfs_variables_from_list (GfsVariable *variables,gchar *list,gchar **error);
variables : | 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. |
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 |
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. |
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". |
void gfs_get_from_below_extensive (FttCell *cell, const GfsVariable *v);
Sets the value of the "extensive" variable v of cell as (half in 3D) the sum 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". |
void gfs_get_from_above (FttCell *cell, const GfsVariable *v);
Sets the value of the variable v of cell to the value of this variable in its parent cell.
This function fails if cell is the root of the cell tree.
cell : | a FttCell. |
v : | a GfsVariable to "get from above". |
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. |
void gfs_cell_fine_init (FttCell *cell, GfsDomain *domain);
Initializes the variables of cell using interpolation from its parent cell.
First-order interpolation (straight injection) is used for boundary cells and second-order interpolation for the other cells.
cell : | a FttCell. |
domain : | a GfsDomain containing cell. |
void gfs_cell_init_fraction (FttCell *root,GtsSurface *s,GNode *stree,gboolean is_open, GfsVariable *c);
Initializes the fraction c of all the cells of the cell tree starting at root.
root : | the root FttCell of the cell tree. |
s : | a closed, orientable surface defining the solid boundary. |
stree : | a bounding box tree of the faces of s. |
is_open : | TRUE if s is an "open" boundary i.e. the signed volume enclosed by s is negative, FALSE otherwise. |
c : | a GfsVariable. |
void gfs_velocity_norm (FttCell *cell, GfsVariable *v);
Fills variable v of cell with the norm of the velocity field in this cell.
cell : | a FttCell. |
v : | a GfsVariable. |
void gfs_velocity_norm2 (FttCell *cell, GfsVariable *v);
Fills variable v of cell with the squared norm of the velocity field in this cell.
cell : | a FttCell. |
v : | a GfsVariable. |
void gfs_divergence (FttCell *cell);
Fills variable GFS_DIV of cell with the divergence of the (centered) velocity field in this cell.
cell : | a FttCell. |
void gfs_normal_divergence (FttCell *cell);
Fills variable GFS_DIV of cell with the integral of the divergence of the (MAC) velocity field in this cell.
cell : | a FttCell. |
void gfs_vorticity (FttCell *cell, GfsVariable *v);
Fills variable v of cell with the vorticity (norm of the vorticity vector in 3D) of the velocity field in this cell.
cell : | a FttCell. |
v : | a GfsVariable. |
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 |
v : | a GfsVariable index. |
Returns : | the value of variable v on the face. |
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. |
struct GfsGradient { gdouble a, b; };
Defines the (second-order accurate) gradient of a variable v in a given direction as: a*GFS_VARIABLE (cell, v) + b.
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.
face : | a FttCellFace. |
g : | the GfsGradient. |
v : | a GfsVariable index. |
max_level : | the maximum cell level to consider (-1 means no restriction). |
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). |
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). |
void gfs_face_gradient_flux_centered (const FttCellFace *face, GfsGradient *g,guint v,gint max_level);
face : | |
g : | |
v : | |
max_level : |
|
gdouble (*GfsCenterGradient) (FttCell *cell, FttComponent c,guint v);
cell : | |
c : | |
v : | |
Returns : |
|
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. |
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. |
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. |
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. |
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. |
gdouble gfs_cell_laplacian (FttCell *cell, GfsVariable *v);
cell : | a FttCell. |
v : | a GfsVariable. |
Returns : | an evaluation of the Laplacian of v at the center of cell normalized by h^2, where h is the cell size. |
struct GfsInterpolator { #if FTT_2D FttCell * c[7]; gdouble w[7]; #else /* 3D */ FttCell * c[29]; gdouble w[29]; #endif /* 3D */ guint n; };
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 : |
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. |
void gfs_cell_write (const FttCell *cell,FILE *fp, GfsVariable *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 GfsVariable to be written. |
void gfs_cell_write_binary (const FttCell *cell,FILE *fp, GfsVariable *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 GfsVariable to be written. |
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 |
domain : | the GfsDomain containing cell. |
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 |
domain : | the GfsDomain containing cell. |
<<< Flow solver | Solid boundaries >>> |