Focused tests for the version-one matrix-free momentum solver. More...
#include "test_support.h"#include "initialcondition.h"#include "../../src/momentum_newton_krylov.c"Go to the source code of this file.
Macros | |
| #define | MomentumSolver_NewtonKrylov MomentumSolver_NewtonKrylov_PrivateCopy |
| #define | MomentumSolver_NewtonKrylov_Destroy MomentumSolver_NewtonKrylov_Destroy_PrivateCopy |
Functions | |
| static PetscErrorCode | AssertNewtonLog (const char *path, PetscInt expected_rows, const char *needle_a, const char *needle_b) |
| Checks a structured log's row count and required text after a collective solve. | |
| static PetscErrorCode | BuildNewtonFixture (const char *bcs, SimCtx **simCtx, UserCtx **user, char *tmpdir, size_t tmpdir_len) |
| Builds and initializes a small runtime context for Newton tests. | |
| static PetscErrorCode | DestroyNewtonFixture (SimCtx **simCtx, char *tmpdir) |
| Destroys a Newton test fixture and its temporary files. | |
| static PetscErrorCode | WriteNewtonPicSlice (const char *path) |
| Writes one static 5x5 PICSLICE profile used by the full runtime fixture. | |
| static PetscErrorCode | CheckResidualRepeatabilityForBC (const char *bcs, const char *label) |
| Checks callback repeatability, diagnostic-state independence, and X integrity. | |
| static PetscBool | OwnsStoredPoint (UserCtx *user, PetscInt i, PetscInt j, PetscInt k) |
| Returns whether this rank owns one global DMDA grid point. | |
| static PetscErrorCode | PerturbStoredValue (UserCtx *user, Vec vec, PetscInt i, PetscInt j, PetscInt k, PetscInt component, PetscScalar delta) |
| Adds a scalar perturbation to one stored staggered component. | |
| static PetscErrorCode | GetStoredValue (UserCtx *user, Vec vec, PetscInt i, PetscInt j, PetscInt k, PetscInt component, PetscScalar *value) |
| Reads one globally indexed stored component on any MPI decomposition. | |
| static PetscErrorCode | MeasureStoredDerivative (UserCtx *user, Vec x, PetscInt row_i, PetscInt row_j, PetscInt row_k, PetscInt row_component, PetscInt col_i, PetscInt col_j, PetscInt col_k, PetscInt col_component, PetscReal *derivative) |
| Finite-differences one callback row with respect to one stored unknown. | |
| static PetscErrorCode | CheckStoredDerivative (UserCtx *user, Vec x, PetscInt row_i, PetscInt row_j, PetscInt row_k, PetscInt row_component, PetscInt col_i, PetscInt col_j, PetscInt col_k, PetscInt col_component, PetscReal expected, PetscReal tolerance, const char *label) |
| Asserts one finite-differenced callback row derivative equals an expected value. | |
| static PetscErrorCode | TestResidualRepeatabilityAndInputIntegrity (void) |
| Verifies repeatable callback output and read-only trial input. | |
| static PetscErrorCode | TestConstraintRows (void) |
| Verifies fixed, periodic-duplicate, and interior residual rows. | |
| static PetscErrorCode | TestFixedConstraintDerivativesAllFaces (void) |
| Proves unit derivatives for every nonperiodic stored-row category and face. | |
| static PetscErrorCode | TestInletOutletConstraintDerivatives (void) |
| Proves admitted inlet and outlet face-normal rows have unit self derivatives. | |
| static PetscErrorCode | CheckSingleAxisPeriodicDerivatives (const char *bcs, PetscInt axis) |
| Checks one periodic configuration's endpoint derivatives on every component. | |
| static PetscErrorCode | TestPeriodicConstraintDerivativesAndIntersections (void) |
| Proves single-, double-, triple-, and mixed-boundary periodic equations. | |
| static PetscErrorCode | TestMatrixFreeDerivative (void) |
| Compares PETSc's matrix-free action with direct differencing. | |
| static PetscErrorCode | BuildMinimalWallOperatorFixture (SimCtx **simCtx, UserCtx **user, PetscBool x_periodic) |
| Builds a compact all-wall operator fixture through real boundary handlers. | |
| static PetscErrorCode | TestFreeSlipWallsSolve (void) |
| A Newton solve with free-slip walls converges, preconditioned and not. | |
| static PetscErrorCode | TestTwoDSolveHoldsMaskedComponent (void) |
| A TwoD solve converges, preconditioned and not, and holds the masked component. | |
| static PetscErrorCode | TestWholeOperatorDirectJacobian (void) |
| Forms the complete direct FD Jacobian, checks every row, and compares MFFD actions. | |
| static PetscErrorCode | TestPeriodicOperatorHasNoZeroRows (void) |
| Audits every row of a complete operator containing periodic duplicates. | |
| static PetscErrorCode | TestSmallSolveAndRollback (void) |
| Exercises a converged solve, a committed unconverged solve, a non-finite rollback, and cleanup. | |
| static PetscErrorCode | TestZeroIterationStructuredLogging (void) |
| Verifies the six-wall zero-velocity case logs zero Newton/Krylov work. | |
| static PetscErrorCode | CheckFlatChannelStartup (PetscBool use_point_block) |
| Exercises the straight-duct BDF1 startup path used by flat_channel. | |
| static PetscErrorCode | TestFlatChannelStartup (void) |
| Guards flat_channel's initial BDF1 residual and both shipped NK PCs. | |
| static PetscErrorCode | TestRestartAndContinuationSolve (void) |
| Verifies restarted Newton solves with both supported preconditioners. | |
| static PetscErrorCode | TestUnsupportedConfigurationFailsBeforeAllocation (void) |
| Confirms unsupported features fail before workspace allocation. | |
| static PetscErrorCode | TestPostAllocationFailureCleanup (void) |
| Verifies cleanup and rollback after an options failure following asset creation. | |
| static PetscErrorCode | TestLinearizationConfigParsing (void) |
| Verifies finalized application-owned linearization option parsing. | |
| static PetscErrorCode | TestStencilToGlobal (UserCtx *user, MatStencil stencil, PetscInt *global_index) |
| Converts an in-domain or periodic-ghost DMDA stencil to PETSc ordering. | |
| static PetscErrorCode | PreconditionerMatrixStencilEntry (UserCtx *user, Mat preconditioning_matrix, MatStencil row, MatStencil col, PetscScalar *value) |
| Reads one DMDA-stencil matrix entry through collective basis vectors. | |
| static PetscErrorCode | AssertExactPointBlockMatrixAllocation (UserCtx *user, Mat matrix, PetscBool require_offrank_periodic) |
| Verifies the exact AIJ layout and preallocation derived from row classes. | |
| static PetscErrorCode | TestPointBlockPreconditionerEngine (void) |
| Verifies the point-block model and common preconditioning-engine wiring. | |
| static PetscErrorCode | AssertPeriodicPreconditionerRow (UserCtx *user, Mat matrix, MatStencil row, const char *message) |
| Proves that one periodic matrix row has only its exact +1/-1 pair. | |
| static PetscErrorCode | TestJacobianInterfaceAndBaselineAlias (void) |
| Verifies Jacobian creation/registration and baseline alias ownership. | |
| static PetscErrorCode | TestPointBlockPeriodicAssembly (void) |
| Exercises engine-owned periodic duplicate rows on every MPI layout. | |
| int | main (int argc, char **argv) |
| Runs the focused Newton–Krylov unit suite. | |
Variables | |
| static const char * | geometric_periodic_bcs |
| static const char * | free_slip_wall_bcs |
| static const char * | fixed_wall_bcs |
| static const char * | parabolic_bcs |
| static const char * | periodic_x_bcs |
| static const char * | periodic_y_bcs |
| static const char * | periodic_z_bcs |
| static const char * | periodic_xy_bcs |
| static const char * | periodic_xyz_bcs |
Focused tests for the version-one matrix-free momentum solver.
The implementation is included intentionally: its callback helpers remain private in production while this translation unit can verify them directly.
Definition in file test_momentum_newton_krylov.c.
| #define MomentumSolver_NewtonKrylov MomentumSolver_NewtonKrylov_PrivateCopy |
Definition at line 14 of file test_momentum_newton_krylov.c.
| #define MomentumSolver_NewtonKrylov_Destroy MomentumSolver_NewtonKrylov_Destroy_PrivateCopy |
Definition at line 15 of file test_momentum_newton_krylov.c.
|
static |
Checks a structured log's row count and required text after a collective solve.
Definition at line 77 of file test_momentum_newton_krylov.c.
|
static |
Builds and initializes a small runtime context for Newton tests.
| bcs | Optional boundary configuration text. |
| simCtx | Returned simulation context. |
| user | Returned finest-level block context. |
| tmpdir | Returned temporary directory. |
| tmpdir_len | Capacity of tmpdir. |
Definition at line 121 of file test_momentum_newton_krylov.c.
|
static |
Destroys a Newton test fixture and its temporary files.
| simCtx | Fixture simulation context. |
| tmpdir | Fixture temporary directory. |
Definition at line 139 of file test_momentum_newton_krylov.c.
|
static |
Writes one static 5x5 PICSLICE profile used by the full runtime fixture.
| path | Output profile path. |
Definition at line 152 of file test_momentum_newton_krylov.c.
|
static |
Checks callback repeatability, diagnostic-state independence, and X integrity.
| bcs | Boundary configuration text, or NULL for the standard inlet/outlet fixture. |
| label | Configuration label used in assertion diagnostics. |
Definition at line 176 of file test_momentum_newton_krylov.c.
|
static |
Returns whether this rank owns one global DMDA grid point.
Definition at line 236 of file test_momentum_newton_krylov.c.
|
static |
Adds a scalar perturbation to one stored staggered component.
| user | Block context defining vector ownership. |
| vec | Vector to modify. |
| i | Global i index. |
| j | Global j index. |
| k | Global k index. |
| component | Component 0=x, 1=y, 2=z. |
| delta | Increment to apply. |
Definition at line 254 of file test_momentum_newton_krylov.c.
|
static |
Reads one globally indexed stored component on any MPI decomposition.
| user | Block context defining vector ownership. |
| vec | Vector to inspect. |
| i | Global i index. |
| j | Global j index. |
| k | Global k index. |
| component | Component 0=x, 1=y, 2=z. |
| value | Returned globally reduced scalar. |
Definition at line 281 of file test_momentum_newton_krylov.c.
|
static |
Finite-differences one callback row with respect to one stored unknown.
| user | Active block context with allocated Rhs. |
| x | Base trial vector. |
| row_i | Residual-row i index. |
| row_j | Residual-row j index. |
| row_k | Residual-row k index. |
| row_component | Residual-row component. |
| col_i | Perturbed unknown i index. |
| col_j | Perturbed unknown j index. |
| col_k | Perturbed unknown k index. |
| col_component | Perturbed unknown component. |
| derivative | Returned finite-difference derivative of the row w.r.t. the unknown. |
Definition at line 312 of file test_momentum_newton_krylov.c.
|
static |
Asserts one finite-differenced callback row derivative equals an expected value.
| user | Active block context with allocated Rhs. |
| x | Base trial vector. |
| row_i | Residual-row i index. |
| row_j | Residual-row j index. |
| row_k | Residual-row k index. |
| row_component | Residual-row component. |
| col_i | Perturbed unknown i index. |
| col_j | Perturbed unknown j index. |
| col_k | Perturbed unknown k index. |
| col_component | Perturbed unknown component. |
| expected | Expected derivative. |
| tolerance | Absolute derivative tolerance. |
| label | Assertion label. |
Definition at line 358 of file test_momentum_newton_krylov.c.
|
static |
Verifies repeatable callback output and read-only trial input.
Definition at line 374 of file test_momentum_newton_krylov.c.
|
static |
Verifies fixed, periodic-duplicate, and interior residual rows.
Definition at line 402 of file test_momentum_newton_krylov.c.
|
static |
Proves unit derivatives for every nonperiodic stored-row category and face.
Definition at line 461 of file test_momentum_newton_krylov.c.
|
static |
Proves admitted inlet and outlet face-normal rows have unit self derivatives.
Definition at line 524 of file test_momentum_newton_krylov.c.
|
static |
Checks one periodic configuration's endpoint derivatives on every component.
| bcs | Boundary text selecting the periodic axis. |
| axis | Periodic axis index. |
Definition at line 576 of file test_momentum_newton_krylov.c.
|
static |
Proves single-, double-, triple-, and mixed-boundary periodic equations.
Definition at line 612 of file test_momentum_newton_krylov.c.
|
static |
Compares PETSc's matrix-free action with direct differencing.
Definition at line 677 of file test_momentum_newton_krylov.c.
|
static |
Builds a compact all-wall operator fixture through real boundary handlers.
| simCtx | Returned simulation context. |
| user | Returned block context. |
| x_periodic | Whether the x faces use geometric periodicity. |
Definition at line 742 of file test_momentum_newton_krylov.c.
|
static |
A Newton solve with free-slip walls converges, preconditioned and not.
Free-slip walls are supported by Newton Krylov from the start: the matrix-free action carries the reflected boundary through the residual, and the point-block preconditioner approximates the operator without wall-specific terms.
Definition at line 780 of file test_momentum_newton_krylov.c.
|
static |
A TwoD solve converges, preconditioned and not, and holds the masked component.
ComputeRHS() zeroes the masked component's spatial terms, so its residual row is the time derivative alone. With the same value at every history level, BDF2's solution of that row is the value itself, so a nonzero xi flux must survive the solve unchanged, as the Picard solver's skipped row keeps it.
Definition at line 815 of file test_momentum_newton_krylov.c.
|
static |
Forms the complete direct FD Jacobian, checks every row, and compares MFFD actions.
Definition at line 862 of file test_momentum_newton_krylov.c.
|
static |
Audits every row of a complete operator containing periodic duplicates.
Definition at line 972 of file test_momentum_newton_krylov.c.
|
static |
Exercises a converged solve, a committed unconverged solve, a non-finite rollback, and cleanup.
Definition at line 1016 of file test_momentum_newton_krylov.c.
|
static |
Verifies the six-wall zero-velocity case logs zero Newton/Krylov work.
Definition at line 1107 of file test_momentum_newton_krylov.c.
|
static |
Exercises the straight-duct BDF1 startup path used by flat_channel.
The conservation outlet consumes lUcat during its first boundary pass. This test deliberately evaluates the callback at the initialized state before installing SNES, then completes the first nonlinear solve with each shipped preconditioner. It catches a missing Ucont -> Ucat -> lUcat seed as a non-finite initial residual rather than hiding it behind later MFFD work.
Definition at line 1140 of file test_momentum_newton_krylov.c.
|
static |
Guards flat_channel's initial BDF1 residual and both shipped NK PCs.
Definition at line 1188 of file test_momentum_newton_krylov.c.
|
static |
Verifies restarted Newton solves with both supported preconditioners.
Definition at line 1197 of file test_momentum_newton_krylov.c.
|
static |
Confirms unsupported features fail before workspace allocation.
Definition at line 1252 of file test_momentum_newton_krylov.c.
|
static |
Verifies cleanup and rollback after an options failure following asset creation.
Definition at line 1321 of file test_momentum_newton_krylov.c.
|
static |
Verifies finalized application-owned linearization option parsing.
Definition at line 1357 of file test_momentum_newton_krylov.c.
|
static |
Converts an in-domain or periodic-ghost DMDA stencil to PETSc ordering.
Definition at line 1465 of file test_momentum_newton_krylov.c.
|
static |
Reads one DMDA-stencil matrix entry through collective basis vectors.
Definition at line 1491 of file test_momentum_newton_krylov.c.
|
static |
Verifies the exact AIJ layout and preallocation derived from row classes.
Definition at line 1522 of file test_momentum_newton_krylov.c.
|
static |
Verifies the point-block model and common preconditioning-engine wiring.
Definition at line 1604 of file test_momentum_newton_krylov.c.
|
static |
Proves that one periodic matrix row has only its exact +1/-1 pair.
Definition at line 1779 of file test_momentum_newton_krylov.c.
|
static |
Verifies Jacobian creation/registration and baseline alias ownership.
Definition at line 1830 of file test_momentum_newton_krylov.c.
|
static |
Exercises engine-owned periodic duplicate rows on every MPI layout.
Definition at line 1899 of file test_momentum_newton_krylov.c.
| int main | ( | int | argc, |
| char ** | argv | ||
| ) |
Runs the focused Newton–Krylov unit suite.
| argc | Command-line argument count. |
| argv | Command-line argument vector. |
Definition at line 1957 of file test_momentum_newton_krylov.c.
|
static |
Definition at line 20 of file test_momentum_newton_krylov.c.
|
static |
Definition at line 30 of file test_momentum_newton_krylov.c.
|
static |
Definition at line 38 of file test_momentum_newton_krylov.c.
|
static |
Definition at line 46 of file test_momentum_newton_krylov.c.
|
static |
Definition at line 54 of file test_momentum_newton_krylov.c.
|
static |
Definition at line 58 of file test_momentum_newton_krylov.c.
|
static |
Definition at line 62 of file test_momentum_newton_krylov.c.
|
static |
Definition at line 66 of file test_momentum_newton_krylov.c.
|
static |
Definition at line 71 of file test_momentum_newton_krylov.c.