![]() | ![]() | ![]() | Gerris Flow Solver Reference Manual | ![]() |
---|
#include <gfs.h> struct GfsMultilevelParams;void gfs_multilevel_params_init (GfsMultilevelParams *par);void gfs_multilevel_params_read (GfsMultilevelParams *par,GtsFile *fp);void gfs_multilevel_params_write (GfsMultilevelParams *par,FILE *fp);void gfs_relax (GfsDomain *domain,guint d,gint max_depth, GfsVariable *u, GfsVariable *rhs);void gfs_residual (GfsDomain *domain,guint d, FttTraverseFlags flags,gint max_depth, GfsVariable *u, GfsVariable *rhs, GfsVariable *res);void gfs_poisson_coefficients (GfsDomain *domain, GfsVariable *c,gdouble rho);void gfs_poisson_cycle (GfsDomain *domain,guint d,guint levelmin,guint depth,guint nrelax, GfsVariable *u, GfsVariable *rhs);void gfs_correct_normal_velocities (GfsDomain *domain,guint dimension, GfsVariable *p,gdouble dt);void gfs_mac_projection (GfsDomain *domain, GfsMultilevelParams *par, GfsAdvectionParams *apar);void gfs_approximate_projection (GfsDomain *domain, GfsMultilevelParams *par, GfsAdvectionParams *apar); GfsNorm gfs_domain_norm_residual (GfsDomain *domain, FttTraverseFlags flags,gint max_depth,gdouble dt);
struct GfsMultilevelParams { gdouble tolerance; guint nrelax; guint minlevel; guint nitermax; guint dimension; guint niter; GfsNorm residual_before, residual; };
void gfs_multilevel_params_read (GfsMultilevelParams *par,GtsFile *fp);
par : | |
fp : |
|
void gfs_multilevel_params_write (GfsMultilevelParams *par,FILE *fp);
Writes in fp a text representation of the multilevel parameters par.
par : | the multilevel parameters. |
fp : | a file pointer. |
void gfs_relax (GfsDomain *domain,guint d,gint max_depth, GfsVariable *u, GfsVariable *rhs);
Apply one pass of a Jacobi relaxation to all the leaf cells of domain with a level inferior or equal to max_depth and to all the cells at level max_depth. The relaxation should converge (if the right-hand-side rhs verifies the solvability conditions) toward the solution of a Poisson equation for u at the maximum depth.
domain : | the domain to relax. |
d : | number of dimensions (2 or 3). |
max_depth : | the maximum depth of the domain to relax. |
u : | the variable to use as left-hand side. |
rhs : | the variable to use as right-hand side. |
void gfs_residual (GfsDomain *domain,guint d, FttTraverseFlags flags,gint max_depth, GfsVariable *u, GfsVariable *rhs, GfsVariable *res);
For each cell of domain, computes the sum of the residual over the volume of the cell for a Poisson equation with u as left-hand-side and rhs as right-hand-side. Stores the result in res.
domain : | a domain. |
d : | number of dimensions (2 or 3). |
flags : | which types of cells are to be visited. |
max_depth : | maximum depth of the traversal. |
u : | the variable to use as left-hand side. |
rhs : | the variable to use as right-hand side. |
res : | the variable to use to store the residual. |
void gfs_poisson_coefficients (GfsDomain *domain, GfsVariable *c,gdouble rho);
Initializes the face coefficients for the Poisson equation.
domain : | a GfsDomain. |
c : | the volume fraction. |
rho : | the relative density. |
void gfs_poisson_cycle (GfsDomain *domain,guint d,guint levelmin,guint depth,guint nrelax, GfsVariable *u, GfsVariable *rhs);
Apply one multigrid iteration to the Poisson equation defined by u and rhs.
The initial value of GFS_RES on the leaves of root must be set to
the residual of the Poisson equation (using gfs_residual()
).
The face coefficients must be set using gfs_poisson_coefficients()
.
The values of u on the leaf cells are updated as well as the values of GFS_RES (i.e. the cell tree is ready for another iteration).
domain : | the domain on which to solve the Poisson equation. |
d : | number of dimensions (2 or 3). |
levelmin : | the top level of the multigrid hierarchy. |
depth : | the total depth of the domain. |
nrelax : | the number of relaxations to apply at each level. |
u : | the variable to use as left-hand side. |
rhs : | the variable to use as right-hand side. |
void gfs_correct_normal_velocities (GfsDomain *domain,guint dimension, GfsVariable *p,gdouble dt);
Corrects the normal velocity field of domain using p and and dt.
Also fills the g[] field with the centered gradient of p.
domain : | a GfsDomain. |
dimension : | the number of dimensions (2 or 3). |
p : | the pressure field. |
dt : | the timestep. |
void gfs_mac_projection (GfsDomain *domain, GfsMultilevelParams *par, GfsAdvectionParams *apar);
Corrects the face-centered velocity field (MAC field) on the leaf level of domain using an exact (MAC) projection. The resulting face-centered velocity field is (almost) exactly divergence free. The (potential) pressure field is also obtained as a by-product as well as its gradient at the center of the leaf cells of the domain (the gradient is stored in the GFS_G variables and is obtained by simple averaging from the face values to the center).
The residual field of the par projection parameters is set to the norm of the residual after the projection. The niter field of the par projection parameters is set to the number of iterations performed to solve the Poisson equation. The other projection parameters are not modified.
domain : | a GfsDomain. |
par : | the projection control parameters. |
apar : | the advection parameters. |
void gfs_approximate_projection (GfsDomain *domain, GfsMultilevelParams *par, GfsAdvectionParams *apar);
Corrects the centered velocity field on the leaf level of domain using an approximate projection. The resulting centered velocity field is approximately divergence free. The (potential) pressure field is also obtained as a by-product.
The residual field of the par projection parameters is set to the norm of the residual (on the MAC grid) after the projection. The niter field of the par projection parameters is set to the number of iterations performed to solve the Poisson equation. The other projection parameters are not modified.
The Poisson equation for the pressure is first solved on a MAC grid where the MAC velocities are obtained from the centered velocities by simple averaging. The resulting pressure gradients (defined on the faces) are then averaged down on the center of the cells to correct the centered velocity.
domain : | a GfsDomain. |
par : | the projection control parameters. |
apar : | the advection parameters. |
GfsNorm gfs_domain_norm_residual (GfsDomain *domain, FttTraverseFlags flags,gint max_depth,gdouble dt);
Traverses the domain defined by domain using gfs_domain_cell_traverse()
and gathers norm statistics about the volume weighted relative residual
(i.e. the sum of the residual over the volume defined by each cell
divided by the total volume of the cell).
domain : | the domain to obtain the norm from. |
flags : | which types of cells are to be visited. |
max_depth : | maximum depth of the traversal. |
dt : | the time step. |
Returns : | a GfsNorm containing the norm statistics about the volume weighted relative residual. |
<<< Volume of Fluid advection | Diffusion solver >>> |