C unit tests for the LES subgrid-scale closure. More...
Go to the source code of this file.
Functions | |
| static PetscErrorCode | TestSymTensorAlgebra (void) |
| Tests the symmetric-tensor primitives against hand-computed values. | |
| static PetscErrorCode | TestStrainRateFromGradients (void) |
| Tests strain-rate assembly and its magnitude for a known velocity gradient. | |
| static PetscErrorCode | TestFilterWidthModelsSeparateOnStretchedCell (void) |
| Tests that the three filter-width models separate on an anisotropic cell. | |
| static void | ParallelepipedMetrics (Cmpnts a, Cmpnts b, Cmpnts c, Cmpnts *csi, Cmpnts *eta, Cmpnts *zet, PetscReal *aj) |
| Face-area vectors and inverse volume of the parallelepiped spanned by a, b, c. | |
| static PetscErrorCode | TestFilterWidthIsIndependentOfCellOrientation (void) |
| Tests that a filter width is a property of the cell, not of its orientation. | |
| static PetscErrorCode | TestScottiFilterWidthMatchesClosedForm (void) |
| Tests the Scotti aspect-ratio correction against its closed form. | |
| static Cmpnts | RotateForInvarianceTest (Cmpnts v) |
| Rotates a vector by Rz(40 deg) then Rx(25 deg). | |
| static void | RotateGradientForInvarianceTest (const Cmpnts rows[3], Cmpnts out[3]) |
| Rotates a velocity gradient g_ij = du_i/dx_j as R g R^T, rows passed as dudx, dvdx, dwdx. | |
| static PetscErrorCode | TestWALEAndVremanKernels (void) |
| Tests the WALE and Vreman kernels against independent evaluations. | |
| static PetscErrorCode | TestLeonardStressVanishesOnUniformFlow (void) |
| Tests that the Leonard stress vanishes on a uniform velocity field. | |
| static PetscErrorCode | TestGermanoModelTensorOnConstantStrain (void) |
| Tests the model tensor where the two filter terms provably coincide. | |
| static PetscErrorCode | TestGermanoModelTensorUsesFilteredProduct (void) |
| Tests that the model tensor uses the filtered product, not the filtered factors. | |
| static PetscErrorCode | TestClipModelCoefficientModes (void) |
| Tests each limiting mode, including the sign that carries backscatter. | |
| static PetscErrorCode | TestEddyViscosityFloorBoundsTotalViscosity (void) |
| Tests eddy-viscosity assembly and the total-viscosity floor. | |
| static PetscErrorCode | TestSubgridKineticEnergy (void) |
| Tests the Yoshizawa subgrid kinetic energy against its closed form. | |
| static PetscErrorCode | FillLocalScalar (UserCtx *user, Vec local, PetscReal value) |
| Fills a ghosted local scalar field over the whole local array. | |
| static PetscErrorCode | SetInteriorScalar (UserCtx *user, Vec local, PetscReal value) |
| Writes a scalar into every cell the closure treats as owned and interior. | |
| static PetscErrorCode | ReadLocalScalar (UserCtx *user, Vec local, PetscInt i, PetscInt j, PetscInt k, PetscReal *value) |
| Reads one cell of a ghosted local scalar field. | |
| static void | DeclarePeriodicFaces (UserCtx *user, PetscBool xi, PetscBool eta, PetscBool zeta) |
| Declares periodic boundary pairs on the axes a test wants homogeneous. | |
| static PetscErrorCode | TestAverageRatioLocalIsPointwise (void) |
| Tests that an empty direction set reproduces the pointwise local model. | |
| static PetscErrorCode | TestAverageRatioDividesSummedFields (void) |
| Tests that averaging divides summed numerators by summed denominators. | |
| static PetscErrorCode | TestAverageRatioRetainsUnaveragedDirection (void) |
| Tests that averaging over two directions leaves a profile along the third. | |
| static PetscErrorCode | TestAverageRatioIgnoresPeriodicDuplicatePlanes (void) |
| Tests that a spatial average ignores the periodic duplicate planes. | |
| static PetscErrorCode | TestHomogeneousAveragingDerivesPeriodicAxes (void) |
| Tests that homogeneous averaging falls back to the block's periodic axes. | |
| static PetscErrorCode | TestAveragingModesSelectTheirOwnDirections (void) |
| Tests that local and global averaging ignore the configured direction list. | |
| static PetscErrorCode | TestConstantModelNeedsNoCoefficientField (void) |
| Tests that the constant model builds its viscosity without a coefficient field. | |
| static PetscErrorCode | TestDynamicProcedureRejectsConstantModel (void) |
| Tests that the dynamic procedure refuses to run for the constant model. | |
| static PetscErrorCode | TestDynamicProcedureVanishesOnUniformFlow (void) |
| Tests that the dynamic procedure returns a zero coefficient on uniform flow. | |
| static PetscErrorCode | TestDynamicProcedureGlobalAverageIsUniform (void) |
| Tests the dynamic procedure end to end on a periodic sheared field. | |
| static PetscErrorCode | SimpsonCoefficientOnLinearField (PetscReal width_ratio, PetscReal *coefficient) |
| Runs the dynamic procedure with the Simpson kernel on a linear field and returns the raw coefficient at the block centre. | |
| static PetscErrorCode | TestDynamicProcedureSimpsonRatioCountsFilteredDirections (void) |
| Tests that the Simpson kernel's width ratio applies to the two directions it filters. | |
| int | main (int argc, char **argv) |
| Entry point for the LES closure suite. | |
C unit tests for the LES subgrid-scale closure.
The suite is layered the way the module is. Pure kernels are checked against hand computed values with no PETSc objects at all; the Germano pieces are checked on fields whose answers are known in closed form; and the driver routines are checked on a small DMDA fixture.
Two of the cases exist because of specific defects and are worth naming. The "filtered-product" case pins the distinction between the filter of a product and the product of filtered factors, which the model tensor once collapsed. The "duplicate-plane" case pins the requirement that a spatial average count each physical cell once on a periodic block, where the two layout boundary planes are copies of interior cells.
Definition in file test_les.c.
|
static |
Tests the symmetric-tensor primitives against hand-computed values.
Definition at line 29 of file test_les.c.
|
static |
Tests strain-rate assembly and its magnitude for a known velocity gradient.
Definition at line 68 of file test_les.c.
|
static |
Tests that the three filter-width models separate on an anisotropic cell.
Definition at line 93 of file test_les.c.
|
static |
Face-area vectors and inverse volume of the parallelepiped spanned by a, b, c.
Definition at line 123 of file test_les.c.
|
static |
Tests that a filter width is a property of the cell, not of its orientation.
The widths used to come from the Cartesian components of the cell diagonal. On the Humphrey bend an identical wall cell got a geometric-mean width three times larger, and so nine times the eddy viscosity, merely because the bend had turned it through 45 degrees relative to the x and y axes.
Definition at line 142 of file test_les.c.
|
static |
Tests the Scotti aspect-ratio correction against its closed form.
Scotti, Meneveau & Lilly (1993) multiply the cube root of the extents by f(a1, a2) = cosh(sqrt((4/27)(ln^2 a1 - ln a1 ln a2 + ln^2 a2))), with a1, a2 the two shorter extents over the longest. f is exactly 1 for a cube, so the width must equal the cube root there, and it must be unchanged by rotating the cell.
Definition at line 186 of file test_les.c.
Rotates a vector by Rz(40 deg) then Rx(25 deg).
Definition at line 217 of file test_les.c.
Rotates a velocity gradient g_ij = du_i/dx_j as R g R^T, rows passed as dudx, dvdx, dwdx.
Definition at line 226 of file test_les.c.
|
static |
Tests the WALE and Vreman kernels against independent evaluations.
Reference values come from a separate numpy evaluation of the published formulas for the gradient below. Both models must vanish in pure shear, which is the property that lets them stay silent in a laminar shear layer, and both must be unchanged when the velocity gradient and the cell rotate together.
Definition at line 252 of file test_les.c.
|
static |
Tests that the Leonard stress vanishes on a uniform velocity field.
Definition at line 292 of file test_les.c.
|
static |
Tests the model tensor where the two filter terms provably coincide.
On a constant strain field the test filter is the identity, so the filter of the product equals the product of the filtered factors and the model tensor collapses to a closed form, -2 Delta^2 (alpha - 1) |S| S_ij, made trace free. This is the one configuration in which the corrected tensor and the collapsed expression that preceded it agree, which is what makes it a clean analytic anchor.
Definition at line 316 of file test_les.c.
|
static |
Tests that the model tensor uses the filtered product, not the filtered factors.
Builds a stencil whose strain magnitude varies across it, so the test filter of |S| S_ij genuinely differs from |S|^ S^_ij. The model tensor must be built from the former. Collapsing it onto the latter yields -2 Delta^2 (alpha - 1) |S|^ S^_ij, which is well scaled, responds to the flow, and is not the Germano-Lilly tensor; this case fails if the two are ever conflated again.
Definition at line 349 of file test_les.c.
|
static |
Tests each limiting mode, including the sign that carries backscatter.
Definition at line 401 of file test_les.c.
|
static |
Tests eddy-viscosity assembly and the total-viscosity floor.
Definition at line 434 of file test_les.c.
|
static |
Tests the Yoshizawa subgrid kinetic energy against its closed form.
Definition at line 459 of file test_les.c.
|
static |
Fills a ghosted local scalar field over the whole local array.
Writes the halo as well as the owned cells, so a test can poison the layout boundary planes and observe whether an averaging routine counts them.
Definition at line 478 of file test_les.c.
|
static |
Writes a scalar into every cell the closure treats as owned and interior.
Definition at line 489 of file test_les.c.
|
static |
Reads one cell of a ghosted local scalar field.
Definition at line 513 of file test_les.c.
|
static |
Declares periodic boundary pairs on the axes a test wants homogeneous.
The shared fixture builds a periodic DMDA from the SimCtx flags but leaves the boundary face configuration untouched. The periodic field synchronization reads the faces rather than the flags, so a test that synchronizes has to declare them. The closure's own periodicity questions are answered from the flags, so tests that only ask those do not call this.
Definition at line 534 of file test_les.c.
|
static |
Tests that an empty direction set reproduces the pointwise local model.
Definition at line 548 of file test_les.c.
|
static |
Tests that averaging divides summed numerators by summed denominators.
The distinction matters: the mean of the quotients differs from the quotient of the means, and Lilly's least-squares closure calls for the latter. Separating them needs a denominator that varies too. Three cells carry 1/1 and two carry 6/2, so every pointwise quotient is 1 or 3 and their mean is 9/5, while the ratio of the sums is 15/7. Only the second answer can come from averaging the two fields first.
Definition at line 603 of file test_les.c.
|
static |
Tests that averaging over two directions leaves a profile along the third.
Definition at line 662 of file test_les.c.
|
static |
Tests that a spatial average ignores the periodic duplicate planes.
On a periodic block, index 0 and index m-1 hold copies of interior cells. Counting them would weight those cells twice. The test poisons both planes and requires the average not to move.
Definition at line 719 of file test_les.c.
|
static |
Tests that homogeneous averaging falls back to the block's periodic axes.
Definition at line 784 of file test_les.c.
|
static |
Tests that local and global averaging ignore the configured direction list.
Definition at line 818 of file test_les.c.
|
static |
Tests that the constant model builds its viscosity without a coefficient field.
UserCtx::CS and UserCtx::lCs are deliberately left unallocated. If the constant path ever reaches for them again this case crashes rather than silently reintroducing a field of one repeated number.
Definition at line 849 of file test_les.c.
|
static |
Tests that the dynamic procedure refuses to run for the constant model.
Definition at line 897 of file test_les.c.
|
static |
Tests that the dynamic procedure returns a zero coefficient on uniform flow.
Exercises the whole path: the strain precompute and its halo, the stencil gather, every test filter, both contractions, the averaging, and the limiting. A uniform field has no strain and no stress between the two filter widths, so the Germano identity has nothing to fit and the coefficient must come out exactly zero.
Definition at line 929 of file test_les.c.
|
static |
Tests the dynamic procedure end to end on a periodic sheared field.
Runs the full procedure on a block that is periodic in all three directions, where the strain precompute has to reach across the wrap correctly, and asks for global averaging. Two things must hold: every cell receives the same finite coefficient, because a global average is one number for the block; and the coefficient stays inside the configured ceiling.
Definition at line 985 of file test_les.c.
|
static |
Runs the dynamic procedure with the Simpson kernel on a linear field and returns the raw coefficient at the block centre.
| [in] | width_ratio | Configured test-to-grid width ratio. |
| [out] | coefficient | The unclipped dynamic coefficient at cell (4, 4, 4). |
Definition at line 1052 of file test_les.c.
|
static |
Tests that the Simpson kernel's width ratio applies to the two directions it filters.
Simpson filters i and k only, so the cube-root test-to-grid width ratio is ratio^(2/3) and alpha is ratio^(4/3), not ratio^2. On a linear field the coefficient is proportional to 1 / (alpha - 1), so two ratios fix the exponent without depending on any other convention in the procedure.
Definition at line 1108 of file test_les.c.
| int main | ( | int | argc, |
| char ** | argv | ||
| ) |
Entry point for the LES closure suite.
Definition at line 1128 of file test_les.c.