|
PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
|
Go to the source code of this file.
Macros | |
| #define | __FUNCT__ "GhostNodeVelocity" |
| #define | GridInterpolation(i, j, k, ic, jc, kc, ia, ja, ka, user) |
| #define | __FUNCT__ "GridRestriction" |
| #define | CP 0 |
| #define | EP 1 |
| #define | WP 2 |
| #define | NP 3 |
| #define | SP 4 |
| #define | TP 5 |
| #define | BP 6 |
| #define | NE 7 |
| #define | SE 8 |
| #define | NW 9 |
| #define | SW 10 |
| #define | TN 11 |
| #define | BN 12 |
| #define | TS 13 |
| #define | BS 14 |
| #define | TE 15 |
| #define | BE 16 |
| #define | TW 17 |
| #define | BW 18 |
| #define | __FUNCT__ "Projection" |
| #define | __FUNCT__ "UpdatePressure" |
| #define | __FUNCT__ "PoissonNullSpaceFunction" |
| #define | __FUNCT__ "PoissonLHSNew" |
| #define | __FUNCT__ "PoissonRHS" |
| #define | __FUNCT__ "PoissonSolver_MG" |
Functions | |
| static PetscErrorCode | GhostNodeVelocity (UserCtx *user) |
| static PetscInt | Gidx (PetscInt i, PetscInt j, PetscInt k, UserCtx *user) |
| static PetscErrorCode | GridRestriction (PetscInt i, PetscInt j, PetscInt k, PetscInt *ih, PetscInt *jh, PetscInt *kh, UserCtx *user) |
| PetscErrorCode | Projection (UserCtx *user) |
| Performs the projection step to enforce an incompressible velocity field. | |
| PetscErrorCode | UpdatePressure (UserCtx *user) |
| Updates the pressure field and handles periodic boundary conditions. | |
| static PetscErrorCode | mymatmultadd (Mat mat, Vec v1, Vec v2) |
| PetscErrorCode | PoissonNullSpaceFunction (MatNullSpace nullsp, Vec X, void *ctx) |
| The callback function for PETSc's MatNullSpace object. | |
| PetscErrorCode | MyInterpolation (Mat A, Vec X, Vec F) |
| The callback function for the multigrid interpolation operator (MatShell). | |
| static PetscErrorCode | RestrictResidual_SolidAware (Mat A, Vec X, Vec F) |
| PetscErrorCode | MyRestriction (Mat A, Vec X, Vec F) |
| The callback function for the multigrid restriction operator (MatShell). | |
| PetscErrorCode | PoissonLHSNew (UserCtx *user) |
| Assembles the Left-Hand Side (LHS) matrix for the Pressure Poisson Equation. | |
| PetscErrorCode | PoissonRHS (UserCtx *user, Vec B) |
| Computes the Right-Hand-Side (RHS) of the Poisson equation, which is the divergence of the intermediate velocity field. | |
| PetscErrorCode | VolumeFlux_rev (UserCtx *user, PetscReal *ibm_Flux, PetscReal *ibm_Area, PetscInt flg) |
| A specialized version of VolumeFlux, likely for reversed normals. | |
| PetscErrorCode | VolumeFlux (UserCtx *user, PetscReal *ibm_Flux, PetscReal *ibm_Area, PetscInt flg) |
| Calculates the net flux across the immersed boundary surface. | |
| PetscErrorCode | FullyBlocked (UserCtx *user) |
| PetscErrorCode | MyNvertRestriction (UserCtx *user_h, UserCtx *user_c) |
| PetscErrorCode | PoissonSolver_MG (UserMG *usermg) |
| Solves the pressure-Poisson equation using a geometric multigrid method. | |
| #define GridInterpolation | ( | i, | |
| j, | |||
| k, | |||
| ic, | |||
| jc, | |||
| kc, | |||
| ia, | |||
| ja, | |||
| ka, | |||
| user | |||
| ) |
Definition at line 798 of file poisson.c.
|
static |
Definition at line 8 of file poisson.c.
|
static |
Definition at line 833 of file poisson.c.
|
static |
Definition at line 853 of file poisson.c.
| PetscErrorCode Projection | ( | UserCtx * | user | ) |
Performs the projection step to enforce an incompressible velocity field.
Corrects the contravariant velocity field Ucont to be divergence-free using the gradient of the pressure correction field Phi.
This function executes the final "correction" stage of a fractional-step (projection) method for solving the incompressible Navier-Stokes equations. After solving the Pressure Poisson Equation to get a pressure correction Phi, this function uses Phi to correct the intermediate velocity field, making it divergence-free.
The main steps are:
∇Φ). This is done using finite differences on a generalized curvilinear grid.Ucont by subtracting the scaled pressure gradient. The update rule is: U_new = U_intermediate - Δt * G * ∇Φ, where G is the metric tensor g_ij that transforms the gradient into contravariant components.nvert > 0.1). This preserves accuracy at the fluid-solid interface.Ucont, it calls helper functions to convert the velocity back to Cartesian coordinates (Contra2Cart) and update all ghost cell values.| [in,out] | user | Pointer to the UserCtx struct, containing simulation context, grid metrics, and the velocity/pressure fields. |
Definition at line 948 of file poisson.c.
| PetscErrorCode UpdatePressure | ( | UserCtx * | user | ) |
Updates the pressure field and handles periodic boundary conditions.
Updates the pressure field P with the pressure correction Phi computed by the Poisson solver.
This function is a core part of the projection method in a CFD solver. It is called after the Pressure Poisson Equation has been solved to obtain a pressure correction field, Phi.
The function performs two main operations:
P by adding the pressure correction Phi at every grid point in the fluid domain. The operation is P_new = P_old + Phi.bctype == 7), this function manually updates the pressure values in the ghost cells. It copies values from the physical cells on one side of the domain to the corresponding ghost cells on the opposite side. This ensures that subsequent calculations involving pressure gradients are correct across periodic boundaries. The refactored version consolidates the original code's redundant updates into a single, efficient pass.| [in,out] | user | Pointer to the UserCtx struct, containing simulation context and the pressure vectors P and Phi. |
Definition at line 1502 of file poisson.c.
|
static |
| PetscErrorCode PoissonNullSpaceFunction | ( | MatNullSpace | nullsp, |
| Vec | X, | ||
| void * | ctx | ||
| ) |
The callback function for PETSc's MatNullSpace object.
This function removes the null space from the Poisson solution vector by ensuring the average pressure is zero, which is necessary for problems with pure Neumann boundary conditions.
| nullsp | The MatNullSpace context. |
| X | The vector to be corrected. |
| ctx | A void pointer to the UserCtx. |
Definition at line 1686 of file poisson.c.
| PetscErrorCode MyInterpolation | ( | Mat | A, |
| Vec | X, | ||
| Vec | F | ||
| ) |
The callback function for the multigrid interpolation operator (MatShell).
Defines the coarse-to-fine grid transfer for the pressure correction.
| A | The shell matrix context. |
| X | The coarse-grid source vector. |
| F | The fine-grid destination vector. |
Definition at line 1879 of file poisson.c.
|
static |
Definition at line 1986 of file poisson.c.
| PetscErrorCode MyRestriction | ( | Mat | A, |
| Vec | X, | ||
| Vec | F | ||
| ) |
The callback function for the multigrid restriction operator (MatShell).
Defines the fine-to-coarse grid transfer for the Poisson residual.
| A | The shell matrix context. |
| X | The fine-grid source vector. |
| F | The coarse-grid destination vector. |
Definition at line 2061 of file poisson.c.
| PetscErrorCode PoissonLHSNew | ( | UserCtx * | user | ) |
Assembles the Left-Hand Side (LHS) matrix for the Pressure Poisson Equation.
Assembles the Left-Hand-Side (LHS) matrix (Laplacian operator) for the Poisson equation on a single grid level.
This function constructs the sparse matrix A (the LHS) for the linear system Ax = B, which is the Pressure Poisson Equation (PPE). The matrix A represents a discrete version of the negative Laplacian operator (-∇²), tailored for a general curvilinear, staggered grid.
The assembly process is highly complex and follows these main steps:
A pre-allocating space for a 19-point stencil per row. On subsequent calls, it simply zeroes out the existing matrix.g11, g12, ..., g33) at the cell faces. These g_ij coefficients are essential for defining the Laplacian operator in generalized curvilinear coordinates and account for grid stretching and non-orthogonality.(i,j,k). For each point, it determines the matrix row entries based on its status:nvert > 0.1), it sets an identity row (A(row,row) = 1), effectively removing it from the linear solve.MatAssemblyBegin/End is called to finalize the global matrix, making it ready for use by a linear solver.| [in,out] | user | Pointer to the UserCtx struct, containing all simulation context, grid data, and the matrix A. |
Definition at line 2207 of file poisson.c.
| PetscErrorCode PoissonRHS | ( | UserCtx * | user, |
| Vec | B | ||
| ) |
Computes the Right-Hand-Side (RHS) of the Poisson equation, which is the divergence of the intermediate velocity field.
| user | The UserCtx for the grid level. |
| B | The PETSc Vec where the RHS result will be stored. |
Definition at line 2810 of file poisson.c.
| PetscErrorCode VolumeFlux_rev | ( | UserCtx * | user, |
| PetscReal * | ibm_Flux, | ||
| PetscReal * | ibm_Area, | ||
| PetscInt | flg | ||
| ) |
A specialized version of VolumeFlux, likely for reversed normals.
| user | The UserCtx for the grid level. |
| ibm_Flux | (Output) The calculated net flux. |
| ibm_Area | (Output) The total surface area of the IB. |
| flg | A flag controlling the correction behavior. |
Definition at line 2891 of file poisson.c.
| PetscErrorCode VolumeFlux | ( | UserCtx * | user, |
| PetscReal * | ibm_Flux, | ||
| PetscReal * | ibm_Area, | ||
| PetscInt | flg | ||
| ) |
Calculates the net flux across the immersed boundary surface.
| user | The UserCtx for the grid level. |
| ibm_Flux | (Output) The calculated net flux. |
| ibm_Area | (Output) The total surface area of the IB. |
| flg | A flag controlling the correction behavior. |
Definition at line 3133 of file poisson.c.
| PetscErrorCode FullyBlocked | ( | UserCtx * | user | ) |
Definition at line 3761 of file poisson.c.
Definition at line 3844 of file poisson.c.
| PetscErrorCode PoissonSolver_MG | ( | UserMG * | usermg | ) |
Solves the pressure-Poisson equation using a geometric multigrid method.
This function orchestrates the entire multigrid V-cycle for the pressure correction equation. It assembles the Laplacian matrix on all grid levels, sets up the KSP solvers, smoothers, restriction/interpolation operators, and executes the solve.
| usermg | The UserMG context containing the entire multigrid hierarchy. |
Definition at line 3959 of file poisson.c.