C unit tests for Poisson, RHS, body-force, and diffusivity helpers. More...
#include "test_support.h"#include "poisson.h"#include "rhs.h"#include "setup.h"#include "verification_sources.h"Go to the source code of this file.
Functions | |
| static PetscErrorCode | EnsurePoissonAndRhsVectors (UserCtx *user) |
| Allocates Poisson/RHS support vectors required by the tests. | |
| static PetscErrorCode | TestUpdatePressureAddsPhi (void) |
| Tests that pressure updates add the correction potential. | |
| static PetscErrorCode | TestPoissonRHSZeroDivergence (void) |
| Tests that the Poisson RHS is zero for zero-divergence velocity. | |
| static PetscErrorCode | TestComputeBodyForcesDispatcher (void) |
| Tests the body-force dispatcher across supported source terms. | |
| static PetscErrorCode | TestComputeEulerianDiffusivityMolecularOnly (void) |
| Tests Eulerian diffusivity for the molecular-only configuration. | |
| static PetscErrorCode | TestConvectionZeroField (void) |
| Tests that convection vanishes for a quiescent field. | |
| static PetscErrorCode | TestViscousUniformField (void) |
| Tests that viscous terms vanish for a uniform field. | |
| static PetscErrorCode | ScaleMinimalMetricsToSpacing (UserCtx *user, PetscReal h) |
| Rescales the minimal fixture's unit metrics to cubic cells of edge h. | |
| static PetscErrorCode | ClarkToMolecularRatioPerX (PetscReal h, PetscInt probe, PetscReal *ratio_per_x) |
| Returns the Clark contribution over the molecular viscous one, per unit x, at one cell. | |
| static PetscErrorCode | TestClarkGradientModelScalesWithFilterWidthSquared (void) |
| Tests that the Clark gradient model scales as the square of the filter width. | |
| static PetscErrorCode | TestComputeRHSZeroFieldNoForcing (void) |
| Tests that the full RHS remains zero without forcing on a quiescent field. | |
| static PetscErrorCode | TestComputeEulerianDiffusivityGradientConstantField (void) |
| Tests diffusivity-gradient computation on a constant field. | |
| static PetscErrorCode | TestComputeEulerianDiffusivityVerificationLinearX (void) |
| Tests verification-driven linear diffusivity override and its gradient. | |
| static PetscErrorCode | TestAssemblePoissonOperatorPopulatesRows (void) |
| Tests that Poisson matrix assembly produces a populated operator on a tiny Cartesian grid. | |
| static PetscErrorCode | RandomizeMinimalFaceMetrics (UserCtx *user) |
| Fills every face metric and Jacobian of the minimal fixture with reproducible random values, so each face gradient carries all of its cross terms. | |
| static PetscErrorCode | TestOperatorAndProjectionShareOneFaceGradient (void) |
| Tests that the operator is exactly the divergence of the projection's gradient. | |
| static PetscErrorCode | TestProjectionZeroPhiLeavesVelocityUnchanged (void) |
| Tests that projection leaves a zero pressure-correction field unchanged. | |
| static PetscErrorCode | TestProjectionLinearPhiCorrectsVelocity (void) |
| Tests that projection applies the expected x-direction correction for a linear pressure field. | |
| static PetscErrorCode | PerturbInteriorFaceFluxes (UserCtx *user, PetscReal amplitude) |
| Adds a smooth divergent perturbation to every interior face flux. | |
| static PetscErrorCode | TestPoissonSolverMultigridProjectsToDivergenceFree (void) |
| Tests that the production multigrid Poisson solve and projection remove a divergence. | |
| static PetscErrorCode | CountFileOccurrences (const char *path, const char *needle, PetscInt *count) |
Counts the occurrences of needle in a text file; a missing file counts zero. | |
| static PetscErrorCode | TestPoissonSolverMultigridReusesItsSolver (void) |
| Tests that the multigrid solver is built once and reused on later steps. | |
| static PetscErrorCode | TestPoissonSolverMultigridHonoursDistinctSweeps (void) |
| Tests that unequal pre- and post-smoothing counts give two distinct smoothers. | |
| static PetscErrorCode | TestPoissonNullSpaceRemovesTheInteriorMean (void) |
| Tests the null space attached to the operator. | |
| static PetscErrorCode | TestPoissonSolverMultigridRefusesAnOvercoarsenedHierarchy (void) |
| Tests that an over-coarsened hierarchy stops the run at the Poisson solve. | |
| int | main (int argc, char **argv) |
| Runs the unit-poisson-rhs PETSc test binary. | |
C unit tests for Poisson, RHS, body-force, and diffusivity helpers.
Definition in file test_poisson_rhs.c.
|
static |
Allocates Poisson/RHS support vectors required by the tests.
Definition at line 16 of file test_poisson_rhs.c.
|
static |
Tests that pressure updates add the correction potential.
Definition at line 31 of file test_poisson_rhs.c.
|
static |
Tests that the Poisson RHS is zero for zero-divergence velocity.
Definition at line 52 of file test_poisson_rhs.c.
|
static |
Tests the body-force dispatcher across supported source terms.
Definition at line 86 of file test_poisson_rhs.c.
|
static |
Tests Eulerian diffusivity for the molecular-only configuration.
Definition at line 140 of file test_poisson_rhs.c.
|
static |
Tests that convection vanishes for a quiescent field.
Definition at line 167 of file test_poisson_rhs.c.
|
static |
Tests that viscous terms vanish for a uniform field.
Definition at line 194 of file test_poisson_rhs.c.
|
static |
Rescales the minimal fixture's unit metrics to cubic cells of edge h.
Definition at line 220 of file test_poisson_rhs.c.
|
static |
Returns the Clark contribution over the molecular viscous one, per unit x, at one cell.
The field is u_x = x^2 on cubic cells of edge h, so du/dx = 2x and the exact gradient-model stress tau_11 = (h^2/12)(du/dx)^2 varies along x. Both the model's and viscosity's contributions leave Viscous() through the same flux differences, so their ratio does not depend on how Viscous() normalizes its output.
Definition at line 252 of file test_poisson_rhs.c.
|
static |
Tests that the Clark gradient model scales as the square of the filter width.
The gradient-model stress is tau_ij = (Delta_k^2/12) du_i/dx_k du_j/dx_k, so for a fixed physical field its force grows as Delta^2 relative to the molecular viscous force. Halving the spacing must therefore divide the Clark-to-molecular ratio at a given x by four. Fixtures with unit cells hide any error in the power of Delta, which is why the spacing is varied here.
Definition at line 311 of file test_poisson_rhs.c.
|
static |
Tests that the full RHS remains zero without forcing on a quiescent field.
Definition at line 339 of file test_poisson_rhs.c.
|
static |
Tests diffusivity-gradient computation on a constant field.
Definition at line 366 of file test_poisson_rhs.c.
|
static |
Tests verification-driven linear diffusivity override and its gradient.
Definition at line 387 of file test_poisson_rhs.c.
|
static |
Tests that Poisson matrix assembly produces a populated operator on a tiny Cartesian grid.
Definition at line 433 of file test_poisson_rhs.c.
|
static |
Fills every face metric and Jacobian of the minimal fixture with reproducible random values, so each face gradient carries all of its cross terms.
Definition at line 469 of file test_poisson_rhs.c.
|
static |
Tests that the operator is exactly the divergence of the projection's gradient.
With random non-orthogonal metrics and one solid cell, projecting a zero flux with a random Phi and forming the right-hand side of the result must reproduce -A Phi on every fluid row. The identity holds for any metric values only if the operator and the projection use the same face gradient, including its one-sided forms beside walls and solid cells.
Definition at line 506 of file test_poisson_rhs.c.
|
static |
Tests that projection leaves a zero pressure-correction field unchanged.
Definition at line 575 of file test_poisson_rhs.c.
|
static |
Tests that projection applies the expected x-direction correction for a linear pressure field.
Definition at line 601 of file test_poisson_rhs.c.
|
static |
Adds a smooth divergent perturbation to every interior face flux.
Boundary faces are left alone, so the inflow still balances the outflow and the Neumann pressure problem stays solvable.
Definition at line 645 of file test_poisson_rhs.c.
|
static |
Tests that the production multigrid Poisson solve and projection remove a divergence.
Runs PoissonSolver_Multigrid through the real setup path with a three-level hierarchy, then the same UpdatePressure/ProjectVelocity pair the time loop uses, and requires the projected field to be divergence-free to the solve tolerance.
Definition at line 672 of file test_poisson_rhs.c.
|
static |
Counts the occurrences of needle in a text file; a missing file counts zero.
Definition at line 708 of file test_poisson_rhs.c.
|
static |
Tests that the multigrid solver is built once and reused on later steps.
Two consecutive solves must use the same Krylov solver and operator, both must converge, and the convergence log must hold one header per step.
Definition at line 729 of file test_poisson_rhs.c.
|
static |
Tests that unequal pre- and post-smoothing counts give two distinct smoothers.
With pre_sweeps 1 and post_sweeps 3 every smoothed level must run one sweep before the coarse correction and three after it, the post-smoother must keep the configured smoother type, and the solve must still remove the divergence. With equal counts the shared smoother runs the configured sweeps.
Definition at line 779 of file test_poisson_rhs.c.
|
static |
Tests the null space attached to the operator.
Removing it from a constant must leave zero everywhere, and from a linear field must leave zero mean over the interior with zero dummy layers.
Definition at line 845 of file test_poisson_rhs.c.
|
static |
Tests that an over-coarsened hierarchy stops the run at the Poisson solve.
Three levels on a 9-node grid leave a coarse operator the preconditioner cannot factor. The solve must return PETSC_ERR_NOT_CONVERGED rather than hand an unsolved Phi to the projection.
Definition at line 891 of file test_poisson_rhs.c.
| int main | ( | int | argc, |
| char ** | argv | ||
| ) |
Runs the unit-poisson-rhs PETSc test binary.
Definition at line 922 of file test_poisson_rhs.c.