C unit tests for boundary factories, inlet ownership, and face helpers. More...
Go to the source code of this file.
Functions | |
| static PetscErrorCode | AppendBCParam (BC_Param **head, const char *key, const char *value) |
| Appends one key/value pair to a linked list of boundary-condition parameters. | |
| static PetscErrorCode | DestroyBoundaryHandler (BoundaryCondition **bc_ptr) |
| Destroys one boundary-condition handler allocated by a boundary test. | |
| static PetscInt | InteriorSampleIndex (PetscInt nodes) |
| Chooses a stable interior node index for face-sample assertions on tiny test grids. | |
| static PetscReal | GetFaceNormalComponent (Cmpnts value, BCFace face) |
| Extracts the velocity component aligned with the supplied boundary-face normal. | |
| static PetscReal | GetFaceOrientationSign (BCFace face) |
| Returns the sign convention used for face-normal flux expectations. | |
| static const char * | GetInletParamKey (BCFace face) |
| Maps an inlet face to the matching configuration key used by the handler parser. | |
| static PetscReal | GetFaceInteriorPointCount (const UserCtx *user, BCFace face) |
| Computes the number of face-interior sample points for a given boundary face. | |
| static PetscErrorCode | GetRepresentativeFaceSlots (const UserCtx *user, BCFace face, PetscInt *ucont_k, PetscInt *ucont_j, PetscInt *ucont_i, PetscInt *ubcs_k, PetscInt *ubcs_j, PetscInt *ubcs_i) |
Selects representative Ucont and Ubcs slots for face-matrix assertions. | |
| static PetscErrorCode | GetParabolicSampleSlots (const UserCtx *user, BCFace face, PetscInt *center_k, PetscInt *center_j, PetscInt *center_i, PetscInt *off_k, PetscInt *off_j, PetscInt *off_i, PetscInt *wall_k, PetscInt *wall_j, PetscInt *wall_i, PetscInt *ubcs_center_k, PetscInt *ubcs_center_j, PetscInt *ubcs_center_i) |
| Selects center, off-center, and wall-adjacent slots for parabolic-face checks. | |
| static void | ResetBoundaryFaceConfig (BoundaryFaceConfig *cfg) |
| Resets one boundary-face configuration entry to a neutral test-local baseline. | |
| static PetscErrorCode | TestCanRankServiceFaceMatchesInletWhenDefined (void) |
| Tests that face-service detection matches a defined inlet face. | |
| static PetscErrorCode | TestCanRankServiceInletFaceRequiresDefinition (void) |
| Tests that inlet-face service requires an inlet face to be defined. | |
| static PetscErrorCode | TestBoundaryConditionFactoryAssignments (void) |
| Tests the boundary-condition factory assignments for representative handlers. | |
| static PetscErrorCode | ApplyInletAcrossFirstSteps (BoundaryCondition *bc, BCContext *ctx) |
| Reapplies a static inlet through the first three time-step contexts. | |
| static PetscErrorCode | TestBoundaryConditionFactoryImplementedHandlerMatrix (void) |
| Tests the implemented-handler matrix exposed by the factory. | |
| static PetscErrorCode | WritePicSliceForTests (const char *path, PetscInt n1, PetscInt n2, PetscReal base) |
| Writes a tiny canonical PICSLICE profile for boundary handler tests. | |
| static PetscErrorCode | TestInletProfileFromFileHandlerBehavior (void) |
| Tests prescribed-flow inlet handler loading and applying one Z-face profile. | |
| static PetscErrorCode | TestBoundaryConditionFactoryRejectsUnsupportedHandler (void) |
| Tests that unsupported handler types are rejected by the factory. | |
| static PetscErrorCode | TestGetDeterministicFaceGridLocationFaceMatrix (void) |
| Tests deterministic inlet-face grid-location helpers across all faces. | |
| static PetscErrorCode | TestGetRandomCellAndLogicalCoordsOnInletFaceMatrix (void) |
| Tests random inlet-face cell selection across all supported faces. | |
| static PetscErrorCode | TestInletConstantVelocityHandlerBehavior (void) |
| Tests constant inlet handler initialization and face writes on a Z inlet. | |
| static PetscErrorCode | TestInletCommonApplicationCurvilinearMetric (void) |
| Verifies curvilinear projection and Cartesian dummy reflection for the shared inlet path. | |
| static PetscErrorCode | TestWallNoSlipHandlerFaceMatrix (void) |
| Tests wall no-slip application across the full face matrix. | |
| static PetscErrorCode | TestInletConstantVelocityHandlerFaceMatrix (void) |
| Tests constant-inlet initialization, flux accounting, and face writes across all faces. | |
| static PetscErrorCode | TestInletParabolicProfileHandlerBehavior (void) |
| Tests parabolic inlet handler shape on a tiny Z-face. | |
| static PetscErrorCode | TestInletParabolicProfileUniformAlongPeriodicAxis (void) |
| Tests that the parabolic inlet is uniform along a periodic cross-stream axis. | |
| static PetscErrorCode | TestInletParabolicProfileHandlerFaceMatrix (void) |
| Tests parabolic-inlet centerline, wall, and flux behavior across all faces. | |
| static PetscErrorCode | TestOutletConservationHandlerBehavior (void) |
| Tests outlet conservation handler correction and post-step flux accounting. | |
| static PetscErrorCode | TestOutletConservationHandlerFaceMatrix (void) |
| Tests outlet-conservation correction and flux accounting across all outlet faces. | |
| static PetscErrorCode | TestFinalizePostProjectionCellFieldsNonPeriodic (void) |
| Tests non-periodic cell-field finalization without modifying Ucont. | |
| static PetscErrorCode | TestEnforceRHSBoundaryConditionsMatchesRowClassification (void) |
| EnforceRHSBoundaryConditions() must zero a row exactly when it is not an unknown. | |
| static PetscErrorCode | SeedWallFrictionVelocityStorage (UserCtx *user) |
| Allocates the wall-model storage the way production allocates it. | |
| static PetscErrorCode | SeedWallFunctionFixture (UserCtx *user, PetscReal tangential_speed) |
| Seeds the fields ApplyWallFunction() reads on a single wall face. | |
| static PetscErrorCode | TestApplyWallFunctionMatchesTheLogLawItDispatches (void) |
| Tests that the wall-function integration reproduces the model it dispatches to. | |
| static PetscErrorCode | TestWallFunctionModelSelectorChoosesTheLaw (void) |
| Tests that the model selector actually changes which law is applied. | |
| static PetscErrorCode | TestApplyWallFunctionSkipsNonWallFaces (void) |
| Tests that a face which is not a wall is left alone by the wall function. | |
| static PetscErrorCode | TestWallModelFrictionVelocityRespondsToTheFlow (void) |
| Tests that every wall law's friction velocity responds to the flow it is given. | |
| static PetscErrorCode | TestWallFrictionVelocityStorageMatchesTheCatalog (void) |
| Tests that the friction-velocity storage matches what the field catalog declares. | |
| static PetscErrorCode | TestWallModelDiagnosticsRecordTheCorrectedCells (void) |
| Tests that the wall pass records the statistics its diagnostics report. | |
| static PetscErrorCode | TestDummyCellsFollowEachFieldsBoundaryRule (void) |
| Checks each cell-centred field's dummy-cell rule, faces then edges. | |
| int | main (int argc, char **argv) |
| Runs the unit-boundaries PETSc test binary. | |
C unit tests for boundary factories, inlet ownership, and face helpers.
Definition in file test_boundaries.c.
|
static |
Appends one key/value pair to a linked list of boundary-condition parameters.
Definition at line 14 of file test_boundaries.c.
|
static |
Destroys one boundary-condition handler allocated by a boundary test.
Definition at line 34 of file test_boundaries.c.
|
static |
Chooses a stable interior node index for face-sample assertions on tiny test grids.
Definition at line 52 of file test_boundaries.c.
Extracts the velocity component aligned with the supplied boundary-face normal.
Definition at line 68 of file test_boundaries.c.
|
static |
Returns the sign convention used for face-normal flux expectations.
Definition at line 87 of file test_boundaries.c.
|
static |
Maps an inlet face to the matching configuration key used by the handler parser.
Definition at line 105 of file test_boundaries.c.
Computes the number of face-interior sample points for a given boundary face.
Definition at line 124 of file test_boundaries.c.
|
static |
Selects representative Ucont and Ubcs slots for face-matrix assertions.
Definition at line 143 of file test_boundaries.c.
|
static |
Selects center, off-center, and wall-adjacent slots for parabolic-face checks.
Definition at line 189 of file test_boundaries.c.
|
static |
Resets one boundary-face configuration entry to a neutral test-local baseline.
Definition at line 249 of file test_boundaries.c.
|
static |
Tests that face-service detection matches a defined inlet face.
Definition at line 263 of file test_boundaries.c.
|
static |
Tests that inlet-face service requires an inlet face to be defined.
Definition at line 294 of file test_boundaries.c.
|
static |
Tests the boundary-condition factory assignments for representative handlers.
Definition at line 317 of file test_boundaries.c.
|
static |
Reapplies a static inlet through the first three time-step contexts.
Definition at line 353 of file test_boundaries.c.
|
static |
Tests the implemented-handler matrix exposed by the factory.
Definition at line 371 of file test_boundaries.c.
|
static |
Writes a tiny canonical PICSLICE profile for boundary handler tests.
Definition at line 403 of file test_boundaries.c.
|
static |
Tests prescribed-flow inlet handler loading and applying one Z-face profile.
Definition at line 426 of file test_boundaries.c.
|
static |
Tests that unsupported handler types are rejected by the factory.
Definition at line 487 of file test_boundaries.c.
|
static |
Tests deterministic inlet-face grid-location helpers across all faces.
Definition at line 507 of file test_boundaries.c.
|
static |
Tests random inlet-face cell selection across all supported faces.
Definition at line 553 of file test_boundaries.c.
|
static |
Tests constant inlet handler initialization and face writes on a Z inlet.
Definition at line 625 of file test_boundaries.c.
|
static |
Verifies curvilinear projection and Cartesian dummy reflection for the shared inlet path.
Definition at line 677 of file test_boundaries.c.
|
static |
Tests wall no-slip application across the full face matrix.
Definition at line 740 of file test_boundaries.c.
|
static |
Tests constant-inlet initialization, flux accounting, and face writes across all faces.
Definition at line 788 of file test_boundaries.c.
|
static |
Tests parabolic inlet handler shape on a tiny Z-face.
Definition at line 867 of file test_boundaries.c.
|
static |
Tests that the parabolic inlet is uniform along a periodic cross-stream axis.
A channel periodic in i has walls only in j, so its inlet is the exact one-dimensional parabola in j.
Definition at line 911 of file test_boundaries.c.
|
static |
Tests parabolic-inlet centerline, wall, and flux behavior across all faces.
Definition at line 950 of file test_boundaries.c.
|
static |
Tests outlet conservation handler correction and post-step flux accounting.
Definition at line 1029 of file test_boundaries.c.
|
static |
Tests outlet-conservation correction and flux accounting across all outlet faces.
Definition at line 1086 of file test_boundaries.c.
|
static |
Tests non-periodic cell-field finalization without modifying Ucont.
Definition at line 1167 of file test_boundaries.c.
|
static |
EnforceRHSBoundaryConditions() must zero a row exactly when it is not an unknown.
This is the invariant that ties the residual path to ClassifyMomentumRow(). It is checked across a non-periodic, a singly-periodic and a fully-periodic configuration because the defect it guards against was visible only when an axis was periodic: the duplicate column at index 0 was left unzeroed, so ComputeTotalResidual()'s BDF term accumulated there on every call and the residual norm stopped describing the state. A sentinel fill makes an untouched row detectable rather than accidentally correct.
Definition at line 1211 of file test_boundaries.c.
|
static |
Allocates the wall-model storage the way production allocates it.
Production creates each global on da and ghosts it into the local view. A fixture that allocates differently - a different DM, only one of a pair, or only one of the fields the same block creates - tests a layout the solver never uses, which is how a DM/dof mismatch survived in ApplyWallFunction while these cases passed. The wall eddy viscosity is allocated in that same block and cleared at the top of every pass, so a fixture omitting it dereferences a null vector before reaching any assertion. Every wall case routes through here so the two cannot drift.
Definition at line 1287 of file test_boundaries.c.
|
static |
Seeds the fields ApplyWallFunction() reads on a single wall face.
A uniform tangential velocity and unit metrics make the wall distances and the face normal analytically known, so the test can reproduce the model's own arithmetic without copying the integration's index choices.
Definition at line 1308 of file test_boundaries.c.
|
static |
Tests that the wall-function integration reproduces the model it dispatches to.
The kernels are covered separately; what is unverified without this is the wiring around them, where the plausible failures are silent. Feeding the reference and boundary wall distances in the wrong order, taking the reference velocity from the wrong cell, or normalising the face normal incorrectly all still produce a plausible-looking corrected velocity. The check here is that the corrected first-interior velocity is exactly what the log-law model predicts at that cell's distance, for the friction velocity the integration itself stored.
Definition at line 1348 of file test_boundaries.c.
|
static |
Tests that the model selector actually changes which law is applied.
The selector was previously validated in the configuration layer and then dropped, so every case ran the log law whatever it asked for. Distinct laws must produce distinct corrections from identical inputs, or the selector is decorative again.
Definition at line 1440 of file test_boundaries.c.
|
static |
Tests that a face which is not a wall is left alone by the wall function.
Definition at line 1481 of file test_boundaries.c.
|
static |
Tests that every wall law's friction velocity responds to the flow it is given.
A law that ignores the resolved velocity and reports a fixed number still slows the first cell and still differs from the other laws, so the selector test above passes over it. Driving a law at two different speeds and requiring the friction velocity to follow is what distinguishes a model from a constant.
All three laws are covered. Werner-Wengle is the reason this case exists: it used to report its Newton initial guess rather than solving, so every wall cell in a run carried the same u_tau while still slowing the cell and still differing from the other laws, which is everything the selector test above checks.
Definition at line 1527 of file test_boundaries.c.
|
static |
Tests that the friction-velocity storage matches what the field catalog declares.
The wall model reaches its storage through a DM, and PETSc only rejects a mismatched DM/vector pairing at the moment of access - inside a branch that runs only when wall functions are enabled on a case that has a WALL face. That is how storage created from a dof-3 DM and read through a dof-1 one stayed latent. Comparing the allocation against the catalog descriptor turns that into a failure here.
Definition at line 1583 of file test_boundaries.c.
|
static |
Tests that the wall pass records the statistics its diagnostics report.
y+ cannot be recovered downstream, so it is formed where the wall distance is still in hand. This checks that what is accumulated there is the same quantity the reported column claims to be, and that a pass over no wall face records nothing rather than recording zeros.
Definition at line 1636 of file test_boundaries.c.
|
static |
Checks each cell-centred field's dummy-cell rule, faces then edges.
Interior cells carry index-unique sentinels and every dummy cell starts poisoned, so a wrong offset or a missed face shows. Velocity dummies must put the face average on Ubcs; pressure and the particle scalar copy the adjacent cell (zero normal gradient); each edge dummy is the mean of its two face neighbours; and a field with no rule, or one that is not cell-centred, is refused.
Definition at line 1705 of file test_boundaries.c.
| int main | ( | int | argc, |
| char ** | argv | ||
| ) |
Runs the unit-boundaries PETSc test binary.
Definition at line 1810 of file test_boundaries.c.