/** * ConvergenceControl — Iterative linear solvers for PDE systems. * * Conjugate Gradient (matrix-free) for general SPD systems. * Jacobi iteration for grid-based Poisson/diffusion equations. */ import { RegularGrid3D } from './RegularGrid3D'; export interface ConvergenceResult { converged: boolean; iterations: number; residual: number; maxChange: number; residualHistory?: number[]; } /** * Matrix-free Conjugate Gradient solver for Ax = b. * * @param applyA Function that computes A*x into the output buffer * @param b Right-hand side vector * @param x Initial guess (modified in place with solution) * @param maxIter Maximum iterations * @param tol Convergence tolerance. Threshold is max(tol * ||b||, tol * ||x_0||, abstol) * @param diagA Optional diagonal of A for Jacobi preconditioning * @param abstol Absolute tolerance flooring */ export declare function conjugateGradient(applyA: (x: Float32Array, out: Float32Array) => void, b: Float32Array, x: Float32Array, maxIter: number, tol: number, diagA?: Float32Array, abstol?: number): ConvergenceResult; /** * Jacobi iterative solver for grid-based Laplacian equations. * Solves ∇²u = rhs on a RegularGrid3D using weighted Jacobi. * * @param grid Solution field (modified in place) * @param rhs Right-hand side field * @param alpha Coefficient (typically dx² for Poisson) * @param beta Denominator coefficient (typically 6 for 3D Laplacian) * @param maxIter Maximum iterations * @param tol Convergence tolerance on max absolute change * @param omega Relaxation factor (0.67 for damped Jacobi, 1.0 for standard) */ export declare function jacobiIteration(grid: RegularGrid3D, rhs: RegularGrid3D, alpha: number, beta: number, maxIter: number, tol: number, omega?: number): ConvergenceResult; /** * Anisotropic Jacobi iteration for implicit diffusion on non-cubic grids. * Solves (I − dt·α·∇²) u = rhs where the Laplacian uses per-axis spacings: * * u·(1 + 2(wx+wy+wz)) − wx(u_x± ) − wy(u_y±) − wz(u_z±) = rhs * with wx = dt·α/dx², wy = dt·α/dy², wz = dt·α/dz² * * Jacobi update: u ← (rhs + wx·Σu_x± + wy·Σu_y± + wz·Σu_z±) / (1 + 2(wx+wy+wz)) * * For dx = dy = dz this is algebraically identical to jacobiIteration with * alpha = dx²/(dt·α), beta = 6 + alpha (multiply numerator and denominator * by dx²/(dt·α)). * * @param grid Solution field (modified in place; boundary cells untouched) * @param rhs Right-hand side field * @param wx,wy,wz Per-axis implicit weights dt·α/dxᵢ² * @param maxIter Maximum iterations * @param tol Convergence tolerance on max absolute change * @param omega Relaxation factor (0.67 for damped Jacobi, 1.0 for standard) */ export declare function jacobiIterationAnisotropic(grid: RegularGrid3D, rhs: RegularGrid3D, wx: number, wy: number, wz: number, maxIter: number, tol: number, omega?: number): ConvergenceResult; /** * Anisotropic Jacobi iteration for the pure Poisson equation ∇²φ = f on * non-cubic grids (dx ≠ dy ≠ dz). * * Unlike {@link jacobiIterationAnisotropic} — which solves the implicit-diffusion * form (I − dt·α·∇²)u = rhs and therefore carries an identity term in its * diagonal (diag = 1 + 2(wx+wy+wz)) — this solves the *operator-only* Poisson * system with NO identity term: * * wx(φ_x± ) + wy(φ_y± ) + wz(φ_z± ) − 2(wx+wy+wz)·φ = f * ⇒ φ ← (f + wx·Σφ_x± + wy·Σφ_y± + wz·Σφ_z±) / (2(wx+wy+wz)) * with wx = 1/dx², wy = 1/dy², wz = 1/dz² * * For dx = dy = dz this reduces exactly to `jacobiIteration(grid, rhs, alpha=dx², beta=6)` * (multiply numerator and denominator by dx²). Reusing `jacobiIterationAnisotropic` * for pressure projection would instead introduce a spurious +1 identity bias — * it would converge to a solution of (I + ∇²_aniso)φ = f rather than ∇²_aniso φ = f. * * @param grid Solution field (modified in place; boundary cells untouched) * @param rhs Right-hand side field f (caller's sign convention) * @param wx,wy,wz Per-axis Poisson weights 1/dxᵢ² * @param maxIter Maximum iterations * @param tol Convergence tolerance on max absolute change * @param omega Relaxation factor (0.67 for damped Jacobi, 1.0 for standard) */ export declare function jacobiIterationPoissonAnisotropic(grid: RegularGrid3D, rhs: RegularGrid3D, wx: number, wy: number, wz: number, maxIter: number, tol: number, omega?: number): ConvergenceResult; /** * Variable-coefficient Jacobi iteration for grid-based Poisson-like equations. * Solves ∇·(a(x) ∇u) = rhs on a RegularGrid3D using weighted Jacobi. * * The coefficient field `aCoeff` stores a(i,j,k) at each interior cell. * The discrete stencil uses harmonic-mean face coefficients for variable density: * a_{face} = 2·a_center·a_neighbor / (a_center + a_neighbor) * * For isotropic h = dx = dy = dz: * u_center = (Σ a_face · u_neighbor + h² · rhs_center) / (Σ a_face) * * @param grid Solution field (modified in place) * @param rhs Right-hand side field * @param aCoeff Variable coefficient field (e.g. 1/ρ for multiphase Poisson) * @param dx Grid spacing (assumed uniform in all directions) * @param maxIter Maximum iterations * @param tol Convergence tolerance on max absolute change * @param omega Relaxation factor (0.67 for damped Jacobi) */ export declare function variableCoefficientJacobiIteration(grid: RegularGrid3D, rhs: RegularGrid3D, aCoeff: RegularGrid3D, dx: number, maxIter: number, tol: number, omega?: number): ConvergenceResult; //# sourceMappingURL=ConvergenceControl.d.ts.map