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 PetscErrorCode | ConfigureNormalSourceInlet (UserCtx *user, BCFace face, const char *speed) |
Configures face as a prescribed-velocity inlet with source 0 in the normal frame. | |
| 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 | 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 | TestInletPicSliceSourceBehavior (void) |
| Tests a prescribed-velocity inlet loading and applying one Z-face PICSLICE profile. | |
| static PetscErrorCode | TestInletSourceAddsToPicSlice (void) |
| Tests expressions added to a profile file: a bulk velocity scales the expressions and leaves the file's data as measured, as it does a generator's field in the interior. | |
| static PetscErrorCode | TestBoundaryConditionFactoryRejectsUnsupportedHandler (void) |
| Tests that unsupported handler types are rejected by the factory. | |
| static PetscErrorCode | TestInletNormalSourceBehavior (void) |
| Tests a constant normal-speed source's face writes and flux 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 | SetUniformCartesian (Vec v, PetscReal x, PetscReal y, PetscReal z) |
| Sets every entry of a three-component vector to one Cartesian value. | |
| static PetscErrorCode | TestWallFreeSlipHandlerFaceMatrix (void) |
| Tests the free-slip wall across the full face matrix on a Cartesian grid. | |
| static PetscErrorCode | TestWallFreeSlipCurvilinearNormal (void) |
| Tests the free-slip wall against a face whose normal is not a grid axis. | |
| static PetscErrorCode | TestFreeSlipWallExertsNoShear (void) |
| Tests which faces exert shear, and that only a free-slip wall mirrors the eddy viscosity. | |
| static PetscErrorCode | TestInletNormalSourceFaceMatrix (void) |
| Tests a constant normal-speed source's flux accounting and face writes across all faces. | |
| static PetscErrorCode | TestInletParabolicSourceBehavior (void) |
| Tests a parabola written in the arc-length fractions on a tiny Z-face. | |
| static PetscErrorCode | TestInletOneAxisSourceIsUniformAlongTheOther (void) |
| Tests that a profile in one fraction is uniform along the other tangential axis. | |
| static PetscErrorCode | TestInletParabolicSourceFaceMatrix (void) |
| Tests a parabola in each face's two tangential fractions across all faces: its centreline, wall-adjacent value, and flux. | |
| static PetscErrorCode | TestInletSourceFollowsTimeAndBulkVelocity (void) |
| Tests that a source in t is re-evaluated once per step, and that a bulk velocity rescales the face to its target mean normal speed each step. | |
| static PetscErrorCode | ApplyHandlerAtTime (BoundaryCondition *bc, BCContext *ctx, PetscInt step, PetscReal physical_time) |
| Runs the handler at one time as a new step of its own. | |
| static PetscErrorCode | TestInletRecordingOfCartesianVelocities (void) |
| Tests a recording of Cartesian velocities: every component reaches the boundary, reversed flow is allowed, frames interpolate linearly in time, and past the end they repeat when asked and are refused when not. | |
| static PetscErrorCode | TestInletFlowRateAndFaceRadius (void) |
Tests that a flow-rate target sets the face's total flux, whatever its area, and that r is the distance from the face's centre. | |
| static PetscErrorCode | TestWallMovingAlongItself (void) |
| Tests a moving wall on both a - and a + face: its velocity along the wall reaches the boundary value and the face stays closed, a slight tilt is removed, and a velocity through the wall is refused. | |
| 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 | SetCellNormalVelocity (UserCtx *user, BCFace face, PetscInt k, PetscInt j, PetscInt i, PetscReal value) |
| Sets the face-normal Ucat component of one cell and refreshes lUcat. | |
| static PetscErrorCode | ApplyOutletAndMeasure (BoundaryCondition *bc, BCContext *ctx, BCFace face, PetscReal inflow, PetscReal outflow_measured, PetscReal *sample_flux, Cmpnts *sample_ubcs, PetscReal *total) |
| Runs one outlet Apply with the given sums and returns the face's sample flux and total. | |
| static PetscErrorCode | TestOutletConservationBackflowClip (void) |
| Tests the conservation outlet's backflow clip on +X, +Y, +Z and on -X, -Z. | |
| static PetscErrorCode | TestOutletConservationClipFrozenPerStep (void) |
| Tests that the backflow clip's rule and clipped set are frozen within a time step. | |
| 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, Cmpnts velocity) |
| Seeds the fields ApplyWallFunction() reads, for walls on xi and eta faces. | |
| 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 | TestApplyWallFunctionSkipsFreeSlipWalls (void) |
| Tests that the wall model leaves a free-slip wall alone. | |
| 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 | TestWallModelEdgeCellHasOneStressPerWall (void) |
| Tests that a cell beside two walls gets one independent stress per wall face. | |
| 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 15 of file test_boundaries.c.
|
static |
Destroys one boundary-condition handler allocated by a boundary test.
Definition at line 35 of file test_boundaries.c.
|
static |
Chooses a stable interior node index for face-sample assertions on tiny test grids.
Definition at line 53 of file test_boundaries.c.
Extracts the velocity component aligned with the supplied boundary-face normal.
Definition at line 69 of file test_boundaries.c.
|
static |
Returns the sign convention used for face-normal flux expectations.
Definition at line 88 of file test_boundaries.c.
|
static |
Configures face as a prescribed-velocity inlet with source 0 in the normal frame.
The source's options live in the global database, so each call replaces the last.
Definition at line 107 of file test_boundaries.c.
Computes the number of face-interior sample points for a given boundary face.
Definition at line 122 of file test_boundaries.c.
|
static |
Selects representative Ucont and Ubcs slots for face-matrix assertions.
Definition at line 141 of file test_boundaries.c.
|
static |
Selects center, off-center, and wall-adjacent slots for parabolic-face checks.
Definition at line 187 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 the boundary-condition factory assignments for representative handlers.
Definition at line 289 of file test_boundaries.c.
|
static |
Reapplies a static inlet through the first three time-step contexts.
Definition at line 316 of file test_boundaries.c.
|
static |
Tests the implemented-handler matrix exposed by the factory.
Definition at line 334 of file test_boundaries.c.
|
static |
Writes a tiny canonical PICSLICE profile for boundary handler tests.
Definition at line 365 of file test_boundaries.c.
|
static |
Tests a prescribed-velocity inlet loading and applying one Z-face PICSLICE profile.
Definition at line 388 of file test_boundaries.c.
|
static |
Tests expressions added to a profile file: a bulk velocity scales the expressions and leaves the file's data as measured, as it does a generator's field in the interior.
Definition at line 448 of file test_boundaries.c.
|
static |
Tests that unsupported handler types are rejected by the factory.
Definition at line 512 of file test_boundaries.c.
|
static |
Tests a constant normal-speed source's face writes and flux on a Z inlet.
Definition at line 532 of file test_boundaries.c.
|
static |
Verifies curvilinear projection and Cartesian dummy reflection for the shared inlet path.
Definition at line 581 of file test_boundaries.c.
|
static |
Tests wall no-slip application across the full face matrix.
Definition at line 641 of file test_boundaries.c.
|
static |
Sets every entry of a three-component vector to one Cartesian value.
Definition at line 687 of file test_boundaries.c.
|
static |
Tests the free-slip wall across the full face matrix on a Cartesian grid.
With an adjacent velocity of (1, 2, 3) the boundary value is that velocity less its component normal to the face, the normal flux vanishes, and the dummy cell mirrors the interior: the normal component reversed, the tangential ones kept. That mirror is the symmetry-plane condition.
Definition at line 704 of file test_boundaries.c.
|
static |
Tests the free-slip wall against a face whose normal is not a grid axis.
The -Zeta face metric is (0, 3, 4), so the unit normal is (0, 0.6, 0.8). An adjacent velocity (1, 1, 1) has normal part 1.4 along it, leaving (1, 0.16, -0.12), whose flux through the face is zero.
Definition at line 770 of file test_boundaries.c.
|
static |
Tests which faces exert shear, and that only a free-slip wall mirrors the eddy viscosity.
Definition at line 810 of file test_boundaries.c.
|
static |
Tests a constant normal-speed source's flux accounting and face writes across all faces.
Definition at line 857 of file test_boundaries.c.
|
static |
Tests a parabola written in the arc-length fractions on a tiny Z-face.
Definition at line 931 of file test_boundaries.c.
|
static |
Tests that a profile in one fraction is uniform along the other tangential axis.
A channel periodic in i has walls only in j, so its inlet is the parabola in eta.
Definition at line 971 of file test_boundaries.c.
|
static |
Tests a parabola in each face's two tangential fractions across all faces: its centreline, wall-adjacent value, and flux.
Definition at line 1007 of file test_boundaries.c.
|
static |
Tests that a source in t is re-evaluated once per step, and that a bulk velocity rescales the face to its target mean normal speed each step.
Definition at line 1086 of file test_boundaries.c.
|
static |
Runs the handler at one time as a new step of its own.
Definition at line 1141 of file test_boundaries.c.
|
static |
Tests a recording of Cartesian velocities: every component reaches the boundary, reversed flow is allowed, frames interpolate linearly in time, and past the end they repeat when asked and are refused when not.
Definition at line 1158 of file test_boundaries.c.
|
static |
Tests that a flow-rate target sets the face's total flux, whatever its area, and that r is the distance from the face's centre.
Definition at line 1253 of file test_boundaries.c.
|
static |
Tests a moving wall on both a - and a + face: its velocity along the wall reaches the boundary value and the face stays closed, a slight tilt is removed, and a velocity through the wall is refused.
Definition at line 1329 of file test_boundaries.c.
|
static |
Tests outlet conservation handler correction and post-step flux accounting.
Definition at line 1398 of file test_boundaries.c.
|
static |
Tests outlet-conservation correction and flux accounting across all outlet faces.
Definition at line 1455 of file test_boundaries.c.
|
static |
Sets the face-normal Ucat component of one cell and refreshes lUcat.
Definition at line 1536 of file test_boundaries.c.
|
static |
Runs one outlet Apply with the given sums and returns the face's sample flux and total.
Definition at line 1554 of file test_boundaries.c.
|
static |
Tests the conservation outlet's backflow clip on +X, +Y, +Z and on -X, -Z.
Fluxes are signed along +xi, so outflow is F > 0 on a positive face and F < 0 on a negative one (an outlet there pairs with an inlet on the positive side); every value below is multiplied by that outward sign s. On a 4 x 4 outlet with Ucat = s (1,1,1), one sample cell is set per case:
Definition at line 1597 of file test_boundaries.c.
|
static |
Tests that the backflow clip's rule and clipped set are frozen within a time step.
The decision is taken at the step's first Apply and held: a reversed face that recovers mid-step stays clipped, and a face that reverses mid-step after a no-clip decision keeps the uniform rule; both are re-decided when the step advances. Fails if the decision is re-taken on every Apply (which would make the Newton residual jump) or never re-taken.
Definition at line 1694 of file test_boundaries.c.
|
static |
Tests non-periodic cell-field finalization without modifying Ucont.
Definition at line 1756 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 1800 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 1876 of file test_boundaries.c.
Seeds the fields ApplyWallFunction() reads, for walls on xi and eta faces.
A uniform velocity and unit metrics on both wall orientations make the wall distances and face normals analytically known, so the test can reproduce the model's own arithmetic without copying the integration's index choices.
Definition at line 1897 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 orienting the stress wrongly all still produce a plausible-looking stress. The checks here: the stored friction velocity inverts the log law at the reference cell's distance; the stored stress is u_tau^2 along the flow, in the face's dummy cell; and the resolved velocity is left exactly as it was.
Definition at line 1941 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 friction velocities from identical inputs, or the selector is decorative again.
Definition at line 2040 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 2083 of file test_boundaries.c.
|
static |
Tests that the wall model leaves a free-slip wall alone.
Definition at line 2126 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 2178 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 2236 of file test_boundaries.c.
|
static |
Tests that a cell beside two walls gets one independent stress per wall face.
The edge cell is where the previous design overwrote one velocity twice, the second wall reading the first wall's output as its reference. Here each face must store its own stress in its own dummy cell from its own reference cell, the resolved velocity must not move, the cell's friction velocity must be the RMS over its two faces, and each face element must count once in the diagnostics.
Definition at line 2306 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 2374 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 2445 of file test_boundaries.c.
| int main | ( | int | argc, |
| char ** | argv | ||
| ) |
Runs the unit-boundaries PETSc test binary.
Definition at line 2550 of file test_boundaries.c.