This page shows the numerics pattern used by a matrix-free pressure projection.
Matrix-Free Pressure Operator
apply_negative_laplacian_with_boundary_rows(p, Ap, nx, ny);
},
nx * ny);
CallableOp< F > make_op(F f, idx rows, idx cols)
Solve the Poisson System
SolverResult cg(const Matrix &A, const Vector &b, Vector &x, real tol=1e-10, idx max_iter=1000, Backend backend=default_backend)
The same code can switch to the sequential backend for diagnostics:
Projection Skeleton
advect_velocity(u, v, dt);
build_divergence_rhs(u, v, rhs);
subtract_pressure_gradient(u, v, pressure, dt);
apply_boundary_conditions(u, v);
constexpr Backend best_backend
This example is intentionally matrix-free: the pressure matrix is represented by the stencil application, not by assembled CSR storage.