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 |
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 | 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, forced rollback, and per-call 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 * | 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.
|
static |
Checks a structured log's row count and required text after a collective solve.
Definition at line 65 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 106 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 124 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 137 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 161 of file test_momentum_newton_krylov.c.
|
static |
Returns whether this rank owns one global DMDA grid point.
Definition at line 221 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 239 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 266 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 297 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 343 of file test_momentum_newton_krylov.c.
|
static |
Verifies repeatable callback output and read-only trial input.
Definition at line 359 of file test_momentum_newton_krylov.c.
|
static |
Verifies fixed, periodic-duplicate, and interior residual rows.
Definition at line 386 of file test_momentum_newton_krylov.c.
|
static |
Proves unit derivatives for every nonperiodic stored-row category and face.
Definition at line 445 of file test_momentum_newton_krylov.c.
|
static |
Proves admitted inlet and outlet face-normal rows have unit self derivatives.
Definition at line 508 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 560 of file test_momentum_newton_krylov.c.
|
static |
Proves single-, double-, triple-, and mixed-boundary periodic equations.
Definition at line 596 of file test_momentum_newton_krylov.c.
|
static |
Compares PETSc's matrix-free action with direct differencing.
Definition at line 661 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 726 of file test_momentum_newton_krylov.c.
|
static |
Forms the complete direct FD Jacobian, checks every row, and compares MFFD actions.
Definition at line 760 of file test_momentum_newton_krylov.c.
|
static |
Audits every row of a complete operator containing periodic duplicates.
Definition at line 870 of file test_momentum_newton_krylov.c.
|
static |
Exercises a converged solve, forced rollback, and per-call cleanup.
Definition at line 914 of file test_momentum_newton_krylov.c.
|
static |
Verifies the six-wall zero-velocity case logs zero Newton/Krylov work.
Definition at line 981 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 1014 of file test_momentum_newton_krylov.c.
|
static |
Guards flat_channel's initial BDF1 residual and both shipped NK PCs.
Definition at line 1062 of file test_momentum_newton_krylov.c.
|
static |
Verifies restarted Newton solves with both supported preconditioners.
Definition at line 1071 of file test_momentum_newton_krylov.c.
|
static |
Confirms unsupported features fail before workspace allocation.
Definition at line 1126 of file test_momentum_newton_krylov.c.
|
static |
Verifies cleanup and rollback after an options failure following asset creation.
Definition at line 1192 of file test_momentum_newton_krylov.c.
|
static |
Verifies finalized application-owned linearization option parsing.
Definition at line 1228 of file test_momentum_newton_krylov.c.
|
static |
Converts an in-domain or periodic-ghost DMDA stencil to PETSc ordering.
Definition at line 1336 of file test_momentum_newton_krylov.c.
|
static |
Reads one DMDA-stencil matrix entry through collective basis vectors.
Definition at line 1362 of file test_momentum_newton_krylov.c.
|
static |
Verifies the exact AIJ layout and preallocation derived from row classes.
Definition at line 1393 of file test_momentum_newton_krylov.c.
|
static |
Verifies the point-block model and common preconditioning-engine wiring.
Definition at line 1475 of file test_momentum_newton_krylov.c.
|
static |
Proves that one periodic matrix row has only its exact +1/-1 pair.
Definition at line 1650 of file test_momentum_newton_krylov.c.
|
static |
Verifies Jacobian creation/registration and baseline alias ownership.
Definition at line 1701 of file test_momentum_newton_krylov.c.
|
static |
Exercises engine-owned periodic duplicate rows on every MPI layout.
Definition at line 1770 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 1828 of file test_momentum_newton_krylov.c.
|
static |
Definition at line 18 of file test_momentum_newton_krylov.c.
|
static |
Definition at line 26 of file test_momentum_newton_krylov.c.
|
static |
Definition at line 34 of file test_momentum_newton_krylov.c.
|
static |
Definition at line 42 of file test_momentum_newton_krylov.c.
|
static |
Definition at line 46 of file test_momentum_newton_krylov.c.
|
static |
Definition at line 50 of file test_momentum_newton_krylov.c.
|
static |
Definition at line 54 of file test_momentum_newton_krylov.c.
|
static |
Definition at line 59 of file test_momentum_newton_krylov.c.