C unit tests for per-window accumulator storage and pointwise application. More...
#include "test_support.h"#include "statistics_accumulator.h"#include "statistics_moments.h"#include "field_catalog.h"#include "statistics_window.h"#include "statistics_target.h"Go to the source code of this file.
Macros | |
| #define | ACC_N 6 /* fixture size; cell domain is 5x5x5 */ |
| #define | ACC_CELLS 125 |
Functions | |
| static PicurvWindowDefinition | AccDefinition (PetscBool want_second) |
| Builds a definition requesting Ucat and P with second moments. | |
| static PetscErrorCode | SetUniform (UserCtx *user, PetscReal x, PetscReal y, PetscReal z, PetscReal p) |
| Sets Ucat to a uniform vector and P to a uniform scalar. | |
| static PetscErrorCode | ReadScalarAt (UserCtx *user, Vec v, PetscInt i, PetscInt j, PetscInt k, PetscReal *out) |
| Reads one interior point of a scalar accumulator vector. | |
| static PetscErrorCode | ReadComponentAt (UserCtx *user, Vec v, PetscInt components, PetscInt component, PetscInt i, PetscInt j, PetscInt k, PetscReal *out) |
| Reads one component of a multi-component accumulator vector at an interior point. | |
| static PetscErrorCode | TestComponentCounts (void) |
| Component counts follow the documented product shapes. | |
| static PetscErrorCode | TestStorageShape (void) |
| Storage allocates one mean per field and the right number of product components. | |
| static PetscErrorCode | TestKnownAccumulationAcrossField (void) |
| Three accepted states reproduce the analytically known moments at every point. | |
| static PetscErrorCode | TestValidFractionRange (void) |
| The valid-fraction range reports mask coverage, including a never-valid point. | |
| static PetscErrorCode | TestValidFractionDetectsNeverValidPoint (void) |
| A point blanked from the start is reported as never valid. | |
| static PetscErrorCode | TestCovarianceAccumulation (void) |
| A vector-scalar covariance reproduces its analytically known components. | |
| static PetscErrorCode | TestScalarSelfCovarianceMatchesSecondMoment (void) |
| A field's covariance with itself reduces exactly to its own second moment. | |
| static PetscErrorCode | TestCovarianceRequiresFieldMembership (void) |
| A covariance member missing from the field list is rejected, not silently skipped. | |
| static PetscErrorCode | TestDerivedQuantities (void) |
| Derived quantities reproduce the analytic values the accumulated state implies. | |
| static PetscErrorCode | TestSpatialMeanExcludesUnsampledPoints (void) |
| The spatial mean divides by sampled points, not by the whole vector. | |
| static PetscErrorCode | TestPayloadEnumeration (void) |
| Payload enumeration covers every vector exactly once with stable names. | |
| static PetscErrorCode | TestWeightedAccumulation (void) |
| Unequal weights reproduce the weighted result the kernels define. | |
| static PetscErrorCode | TestMaskedPointsAreExcluded (void) |
| Masked points accumulate nothing, and remain distinguishable from unsampled ones. | |
| static PetscErrorCode | TestConstantFieldZeroProduct (void) |
| A constant field yields exactly zero product at every point. | |
| static PetscErrorCode | TestRunloopDriverAppliesScheduledStates (void) |
| The runloop entry point applies exactly the states the schedule accepts. | |
| static void | PlaceParticle (PetscReal *velocity, PetscReal *psi, PetscInt *cell, PetscInt p, PetscInt ci, PetscInt cj, PetscInt ck, const PetscReal v[3], PetscReal value) |
| Places one particle in a geometric cell with the given velocity and scalar. | |
| static PetscErrorCode | TestParticleEnsembleMatchesStreamingState (void) |
| A cell's particles form the same state the streaming accumulator builds. | |
| static PetscReal | ReductionScalar (PetscInt i, PetscInt j, PetscInt k, PetscInt s) |
| Closed-form test field: a scalar varying in every direction and over samples. | |
| static PetscErrorCode | TestReductionEqualsPooledMoments (void) |
| A homogeneous merge equals the moments of the slot's pooled sample set. | |
| static PetscErrorCode | SetParticleState (UserCtx *user, PetscReal psi_value, PetscReal particles) |
| Sets Psi and the particle count uniformly, so a state is occupied or not everywhere. | |
| static PetscErrorCode | TestParticleSampledFieldUsesOccupiedStates (void) |
| A particle-sampled field is accumulated over the occupied states only. | |
| static PetscErrorCode | TestReductionPoolsOnlyOccupiedSamples (void) |
| A homogeneous merge of a particle-sampled field pools only its occupied samples. | |
| int | main (int argc, char **argv) |
| Entry point for the accumulator suite. | |
C unit tests for per-window accumulator storage and pointwise application.
The field series reuses the values verified analytically by the moment-kernel suite, so a failure here isolates the field-to-accumulator wiring rather than the numerics: three samples of (1,2,3), (3,6,5), (5,4,7) have means (3,4,5) and symmetric centered products (8,4,8,8,4,8) in (xx,xy,xz,yy,yz,zz) order.
Definition in file test_statistics_accumulator.c.
| #define ACC_N 6 /* fixture size; cell domain is 5x5x5 */ |
Definition at line 19 of file test_statistics_accumulator.c.
| #define ACC_CELLS 125 |
Definition at line 20 of file test_statistics_accumulator.c.
|
static |
Builds a definition requesting Ucat and P with second moments.
Definition at line 23 of file test_statistics_accumulator.c.
|
static |
Sets Ucat to a uniform vector and P to a uniform scalar.
Definition at line 38 of file test_statistics_accumulator.c.
|
static |
Reads one interior point of a scalar accumulator vector.
Definition at line 59 of file test_statistics_accumulator.c.
|
static |
Reads one component of a multi-component accumulator vector at an interior point.
Definition at line 70 of file test_statistics_accumulator.c.
|
static |
Component counts follow the documented product shapes.
Definition at line 84 of file test_statistics_accumulator.c.
|
static |
Storage allocates one mean per field and the right number of product components.
Definition at line 108 of file test_statistics_accumulator.c.
|
static |
Three accepted states reproduce the analytically known moments at every point.
Definition at line 146 of file test_statistics_accumulator.c.
|
static |
The valid-fraction range reports mask coverage, including a never-valid point.
This is the mask-health indicator the console snapshot prints, and it is the only signal that distinguishes a mean built from every state from one built from none. A blanked point keeps a zero mean that looks like a legitimate value, so the range has to surface it.
Definition at line 211 of file test_statistics_accumulator.c.
|
static |
A point blanked from the start is reported as never valid.
Definition at line 256 of file test_statistics_accumulator.c.
|
static |
A vector-scalar covariance reproduces its analytically known components.
Definition at line 288 of file test_statistics_accumulator.c.
|
static |
A field's covariance with itself reduces exactly to its own second moment.
Definition at line 341 of file test_statistics_accumulator.c.
|
static |
A covariance member missing from the field list is rejected, not silently skipped.
Definition at line 380 of file test_statistics_accumulator.c.
|
static |
Derived quantities reproduce the analytic values the accumulated state implies.
The series is the one the moment suite verifies by hand, so a failure here isolates the normalization and component selection rather than the accumulation: with three unit-weight samples, R_ij = C_ij / 3, and the diagonal of the Ucat tensor is 8/3 in each direction, giving TKE = 4 and an RMS of sqrt(8/3) per component.
Definition at line 419 of file test_statistics_accumulator.c.
|
static |
The spatial mean divides by sampled points, not by the whole vector.
A derived field is zero outside the target domain and wherever the mask never admitted a point. Those zeros are absences, and averaging over them silently scales the answer down by the fraction of the vector the window never covered — a wrong number that still looks plausible.
Definition at line 583 of file test_statistics_accumulator.c.
|
static |
Payload enumeration covers every vector exactly once with stable names.
Definition at line 651 of file test_statistics_accumulator.c.
|
static |
Unequal weights reproduce the weighted result the kernels define.
Definition at line 726 of file test_statistics_accumulator.c.
|
static |
Masked points accumulate nothing, and remain distinguishable from unsampled ones.
Definition at line 760 of file test_statistics_accumulator.c.
|
static |
A constant field yields exactly zero product at every point.
Definition at line 797 of file test_statistics_accumulator.c.
|
static |
The runloop entry point applies exactly the states the schedule accepts.
Drives FieldStatisticsUpdateWindows directly, so the scheduling decision and the field accumulation are exercised through the same path the solver uses rather than being tested only in isolation.
Definition at line 834 of file test_statistics_accumulator.c.
|
static |
Places one particle in a geometric cell with the given velocity and scalar.
Definition at line 896 of file test_statistics_accumulator.c.
|
static |
A cell's particles form the same state the streaming accumulator builds.
Three particles carry the suite's reference series in one cell, so the two-pass ensemble must reproduce the means, symmetric products and vector-scalar co-moment that the streaming tests assert for the same samples. A lone particle in another cell has its own values as mean and no spread; an empty cell stays unsampled.
Definition at line 912 of file test_statistics_accumulator.c.
|
static |
Closed-form test field: a scalar varying in every direction and over samples.
Definition at line 993 of file test_statistics_accumulator.c.
|
static |
A homogeneous merge equals the moments of the slot's pooled sample set.
Two states of a field varying across the averaged plane are accumulated, then the state is merged over i and k. Each j slot must hold the mean and variance of all of its points' samples pooled, which differs from the average of the point variances by the spread of the point means. The merged state also derives through the unchanged derivation.
Definition at line 1007 of file test_statistics_accumulator.c.
|
static |
Sets Psi and the particle count uniformly, so a state is occupied or not everywhere.
Definition at line 1076 of file test_statistics_accumulator.c.
|
static |
A particle-sampled field is accumulated over the occupied states only.
Three states of the suite's reference series, the second with no particle in any cell. Ucat is ordinary, so it keeps all three samples; Psi and the Ucat-Psi pair keep the first and third. The pair is centred on Ucat's mean over those two states, (3,3,5), not on its all-state mean, (3,4,5). Psi's outputs are flagged as occupied-set outputs.
Definition at line 1092 of file test_statistics_accumulator.c.
|
static |
A homogeneous merge of a particle-sampled field pools only its occupied samples.
Psi takes the value i at cell i while occupied, and the cells with i odd never hold a particle; their zeros must not enter the plane mean.
Definition at line 1160 of file test_statistics_accumulator.c.
| int main | ( | int | argc, |
| char ** | argv | ||
| ) |
Entry point for the accumulator suite.
Definition at line 1209 of file test_statistics_accumulator.c.