Pressure-Poisson projection: the multigrid pressure-correction solve, the pressure update, and the velocity correction that makes Ucont divergence-free.
More...
Go to the source code of this file.
Data Structures | |
| struct | PoissonTransverseDifference |
| Transverse difference used at one face. More... | |
| struct | PoissonFaceMetrics |
Read-only face metric arrays: metric[n][b] is F_b on the n-faces. More... | |
Macros | |
| #define | POISSON_SOLID_THRESHOLD 0.1 |
Cells whose nvert exceeds this value are solid. | |
Enumerations | |
| enum | PoissonTransverseKind { POISSON_TRANSVERSE_NONE = 0 , POISSON_TRANSVERSE_LOWER , POISSON_TRANSVERSE_UPPER , POISSON_TRANSVERSE_CENTRAL } |
| The transverse stencils a face gradient can use; see PoissonOperator_TransverseKind(). More... | |
Functions | |
| static PetscReal | PoissonOperator_AtBN (const PetscReal ***field, const PetscInt c[3], PetscInt b, PetscInt p, PetscInt n, PetscInt q) |
Value of a cell-centred array at c + p e_b + q e_n. | |
| static PoissonTransverseKind | PoissonOperator_TransverseKind (const PetscReal ***nvert, const PetscInt c[3], PetscInt n, PetscInt t, const PetscInt m[3], const PetscBool periodic[3]) |
Chooses the transverse stencil along axis t at the face between cell c and c + e_n. | |
| static PetscReal | PoissonOperator_TransverseFieldDifference (const PetscReal ***nvert, const PetscReal ***field, const PetscInt c[3], PetscInt n, PetscInt t, const PetscInt m[3], const PetscBool periodic[3]) |
Transverse difference of field along axis t at the face between cell c and c + e_n: (sum of the row-pair hi - sum of the row-pair lo) * weight. | |
| static PetscReal | PoissonOperator_FaceGradientFlux (const PoissonFaceMetrics *metrics, const PetscReal ***nvert, const PetscReal ***field, const PetscInt c[3], PetscInt n, const PetscInt m[3], const PetscBool periodic[3]) |
Gradient flux of a cell-centred field through the face between cell c and c + e_n: sum_b g_nb D_b(field) of the face gradient defined in poisson.c. | |
| PetscErrorCode | PoissonOperator_GetFaceMetrics (UserCtx *user, PoissonFaceMetrics *metrics) |
Borrows read access to the face metric arrays of user. | |
| PetscErrorCode | PoissonOperator_RestoreFaceMetrics (UserCtx *user, PoissonFaceMetrics *metrics) |
| Returns the arrays borrowed by PoissonOperator_GetFaceMetrics(). | |
| PetscErrorCode | PoissonSolver_Multigrid (UserMG *usermg) |
| Solves the pressure-correction equation for every block with geometric multigrid. | |
| PetscErrorCode | AssemblePoissonOperator (UserCtx *user) |
| Assembles the pressure-correction operator on one multigrid level. | |
| PetscErrorCode | ComputePoissonRHS (UserCtx *user, Vec B) |
| Forms the right-hand side of the pressure-correction equation. | |
| PetscErrorCode | UpdatePressure (UserCtx *user) |
Adds the pressure correction to the pressure, P += Phi, and refreshes both fields' periodic images and ghosts. | |
| PetscErrorCode | ProjectVelocity (UserCtx *user) |
Corrects the contravariant flux with the gradient of Phi. | |
Pressure-Poisson projection: the multigrid pressure-correction solve, the pressure update, and the velocity correction that makes Ucont divergence-free.
The discrete operator, the right-hand side, and the projection gradient are built from one face-gradient definition, so the Laplacian the solver inverts is exactly the divergence of the gradient the projection applies.
Every masked operation reads the solid field from the UserCtx of the level it acts on (lNvert). Solid cells are excluded from the operator, the right-hand side, the projection, and the multigrid transfers; cells next to a solid face use one-sided transverse differences.
Definition in file poisson.h.
| struct PoissonTransverseDifference |
Transverse difference used at one face.
The difference is weight * (sum of Phi on row hi - sum of Phi on row lo), where a row is the pair of cells on either side of the face, displaced by the given offset along the transverse axis.
| Data Fields | ||
|---|---|---|
| PetscInt | lo | Transverse offset of the subtracted row pair. |
| PetscInt | hi | Transverse offset of the added row pair. |
| PetscReal | weight | 0.25 central, 0.5 one-sided, 0 when no fluid side remains. |
| struct PoissonFaceMetrics |
| #define POISSON_SOLID_THRESHOLD 0.1 |
The transverse stencils a face gradient can use; see PoissonOperator_TransverseKind().
Definition at line 51 of file poisson.h.
|
inlinestatic |
Value of a cell-centred array at c + p e_b + q e_n.
With b, n, p and q constants every offset is a constant, so the per-face stencils below compile to straight-line loads.
| [in] | field | Ghosted cell-centred array, indexed [k][j][i]. |
| [in] | c | Cell (i, j, k). |
| [in] | b | First axis. |
| [in] | p | Displacement along b. |
| [in] | n | Second axis. |
| [in] | q | Displacement along n. |
Definition at line 72 of file poisson.h.
|
inlinestatic |
Chooses the transverse stencil along axis t at the face between cell c and c + e_n.
The central difference averages the two cells beside the face over rows -1 and +1. When the +1 row is a non-periodic boundary layer or touches a solid cell, the difference falls back to rows -1 and 0, and symmetrically to rows 0 and +1; with neither side available the transverse term vanishes.
| [in] | nvert | Ghosted solid field. |
| [in] | c | Cell on the low side of the face. |
| [in] | n | Face orientation (0, 1, 2 for i, j, k). |
| [in] | t | Transverse axis, not n. |
| [in] | m | Grid sizes (mx, my, mz). |
| [in] | periodic | Whether each axis is periodic. |
Definition at line 95 of file poisson.h.
|
inlinestatic |
Transverse difference of field along axis t at the face between cell c and c + e_n: (sum of the row-pair hi - sum of the row-pair lo) * weight.
| [in] | nvert | Ghosted solid field. |
| [in] | field | Ghosted cell-centred field. |
| [in] | c | Cell on the low side of the face. |
| [in] | n | Face orientation (0, 1, 2 for i, j, k). |
| [in] | t | Transverse axis, not n. |
| [in] | m | Grid sizes (mx, my, mz). |
| [in] | periodic | Whether each axis is periodic. |
Definition at line 126 of file poisson.h.
|
inlinestatic |
Gradient flux of a cell-centred field through the face between cell c and c + e_n: sum_b g_nb D_b(field) of the face gradient defined in poisson.c.
The projection applies it to Phi; the momentum residual applies it to P, so both use the one discrete gradient.
| [in] | metrics | Face metric arrays from PoissonOperator_GetFaceMetrics(). |
| [in] | nvert | Ghosted solid field. |
| [in] | field | Ghosted cell-centred field whose gradient is taken. |
| [in] | c | Cell on the low side of the face. |
| [in] | n | Face orientation (0, 1, 2 for i, j, k). |
| [in] | m | Grid sizes (mx, my, mz). |
| [in] | periodic | Whether each axis is periodic. |
Definition at line 162 of file poisson.h.
| PetscErrorCode PoissonOperator_GetFaceMetrics | ( | UserCtx * | user, |
| PoissonFaceMetrics * | metrics | ||
| ) |
Borrows read access to the face metric arrays of user.
| [in] | user | Block context whose ghosted face metrics are read. |
| [out] | metrics | Face metric arrays; return them with PoissonOperator_RestoreFaceMetrics(). |
Borrows read access to the face metric arrays of user.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/poisson.h.
Definition at line 147 of file poisson.c.
| PetscErrorCode PoissonOperator_RestoreFaceMetrics | ( | UserCtx * | user, |
| PoissonFaceMetrics * | metrics | ||
| ) |
Returns the arrays borrowed by PoissonOperator_GetFaceMetrics().
| [in] | user | Block context the arrays were borrowed from. |
| [in,out] | metrics | Face metric arrays to return. |
Returns the arrays borrowed by PoissonOperator_GetFaceMetrics().
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/poisson.h.
Definition at line 171 of file poisson.c.
|
extern |
Solves the pressure-correction equation for every block with geometric multigrid.
On the first call for a block, assembles the operator on every multigrid level and builds the outer Krylov solver with its PCMG preconditioner, grid transfers, level smoothers, coarse solve, and null space. The solver is kept in the finest level's UserCtx::ksp and reused on every later call; it is destroyed with the context.
Each call refreshes the ghosted contravariant flux, forms the right-hand side, solves for Phi on the finest level, and appends the iteration history to Poisson_Solver_Convergence_History_Block_<bi>.log in the run's log directory.
Solver controls are read from PETSc options under the ps_ prefix (-ps_ksp_*, -ps_mg_levels_N_*, -ps_mg_coarse_*) when the solver is built.
| [in,out] | usermg | Multigrid hierarchy; the finest level's Phi receives the solution. |
Solves the pressure-correction equation for every block with geometric multigrid.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/poisson.h.
Definition at line 922 of file poisson.c.
|
extern |
Assembles the pressure-correction operator on one multigrid level.
Allocates user->A on the first call and reassembles its entries on later calls into the same nonzero structure. Fluid rows carry the 19-point curvilinear Laplacian; dummy rows on the domain boundary and solid rows are identities. Non-periodic faces are homogeneous Neumann; periodic faces wrap to the opposite interior layer.
| [in,out] | user | Level context supplying metrics, lNvert, and boundary types. |
Assembles the pressure-correction operator on one multigrid level.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/poisson.h.
Definition at line 244 of file poisson.c.
|
extern |
Forms the right-hand side of the pressure-correction equation.
Writes the scaled divergence of the ghosted contravariant flux lUcont into B, zero on dummy and solid cells, and stores its domain integral in SimCtx::poissonSourceImbalance.
| [in] | user | Finest-level context. |
| [out] | B | Right-hand-side vector on user->da. |
Forms the right-hand side of the pressure-correction equation.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/poisson.h.
Definition at line 344 of file poisson.c.
|
extern |
Adds the pressure correction to the pressure, P += Phi, and refreshes both fields' periodic images and ghosts.
| [in,out] | user | Block context holding P and Phi. |
Adds the pressure correction to the pressure, P += Phi, and refreshes both fields' periodic images and ghosts.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/poisson.h.
Definition at line 405 of file poisson.c.
|
extern |
Corrects the contravariant flux with the gradient of Phi.
Subtracts dt / COEF_TIME_ACCURACY times the face pressure-gradient flux from every fluid face of Ucont, then refreshes the periodic images, reconstructs the Cartesian velocity, and finalizes the cell fields that depend on it.
| [in,out] | user | Block context; reads the ghosted lPhi. |
Corrects the contravariant flux with the gradient of Phi.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/poisson.h.
Definition at line 425 of file poisson.c.