project.h file
Projection residual for an incompressible pressure solve.
The residual is the cell-centered divergence of a MAC velocity. The variable-density operator is the 5- or 7-point stencil with face weight scaled by the inverse face density. Constant density 1 matches the assembled grid Laplacian. The solve stays vm_; this module does not solve.
Functions
-
void vm_project_residual(vm_
float_ t* r, const vm_ float_ t* u, const vm_ float_ t* v, const vm_ float_ t* w, vm_ grid3 g) - Projection residual
$r = \nabla\cdot v^\*$. -
auto vm_project_laplacian(vm_
spmat* A, const vm_ float_ t* rho, vm_ grid3 g, vm_ bc_ t bc) -> bool - Fill a caller-owned CSR with
$-\nabla\cdot((1/\rho)\nabla)$.
Function documentation
void vm_project_residual(vm_ float_ t* r,
const vm_ float_ t* u,
const vm_ float_ t* v,
const vm_ float_ t* w,
vm_ grid3 g)
Projection residual $r = \nabla\cdot v^\*$.
| Parameters | |
|---|---|
| r | Output residual; length vm_. |
| u | MAC face-centered x-velocity; length vm_. |
| v | MAC face-centered y-velocity; length vm_. |
| w | MAC face-centered z-velocity, or NULL when g.nz <= 1. |
| g | Grid dimensions and spacing. |
Cell-centered divergence of a MAC velocity. w may be NULL when g.nz <= 1. r has length vm_.
bool vm_project_laplacian(vm_ spmat* A,
const vm_ float_ t* rho,
vm_ grid3 g,
vm_ bc_ t bc)
Fill a caller-owned CSR with $-\nabla\cdot((1/\rho)\nabla)$.
| Parameters | |
|---|---|
| A | Output sparse matrix; size vm_. |
| rho | Cell-centered density, length vm_, or NULL. |
| g | Grid dimensions and spacing. |
| bc | Boundary condition (VM_ or VM_). |
| Returns | false if a pointer is NULL, the grid is invalid, or a density is non-positive. |
Same boundary treatment as vm_: Dirichlet boundary cells become identity rows, homogeneous Neumann drops the missing neighbour. Face density is the arithmetic mean of the two cell densities; a domain boundary face uses the cell density. Constant rho == 1 matches the assembled Laplacian. NULL rho means density 1 everywhere.