C unit tests for MPI collective helper routines. More...
#include "test_support.h"#include "ParticleMotion.h"#include "ParticleSwarm.h"#include "ParticlePhysics.h"#include "runloop.h"#include "expression.h"#include "initialcondition.h"#include "Boundaries.h"#include "grid.h"#include "Metric.h"#include "walkingsearch.h"#include "setup.h"#include "statistics_target.h"#include "statistics_accumulator.h"#include "statistics_window.h"#include "io.h"#include "field_catalog.h"#include "les.h"#include "logging.h"#include <stdlib.h>Go to the source code of this file.
Macros | |
| #define | TEST_INLET_FLUX(i_, j_) (((i_) % 3 == 0) ? -0.01 : 0.002 * ((i_) + 2 * (j_))) |
Functions | |
| static void | MarkXPeriodic (UserCtx *user) |
| Marks both x boundary faces as geometric periodic boundaries. | |
| static PetscReal | PeriodicScalarValue (PetscInt i, PetscInt j, PetscInt k, PetscReal offset) |
| Returns a deterministic scalar value for periodic-transfer assertions. | |
| static PetscErrorCode | TestDistributeParticlesCollectiveConsistency (void) |
| Tests collective particle distribution consistency across MPI ranks. | |
| static PetscErrorCode | TestBoundingBoxCollectivesMultiRank (void) |
| Tests multi-rank bounding-box gather and broadcast helpers. | |
| static PetscReal | LineFractionTestWidth (PetscInt axis, PetscInt n) |
| Width of cell n (1-based interior index) along an axis in the line-fraction test. | |
| static PetscErrorCode | TestGridLineFractionsFollowArcLength (void) |
| Grid-line fractions follow arc length on a stretched orthogonal grid, and the lines that cross ranks are summed in order. | |
| static PetscErrorCode | TestPeriodicCellFieldSynchronizationMultiRank (void) |
| Tests distributed synchronization of persistent cell-centered scalar fields. | |
| static PetscErrorCode | TestPeriodicGeometryValidationMultiRank (void) |
| Tests periodic seam translation discovery when seam nodes are on different ranks. | |
| static PetscErrorCode | TestPeriodicFaceCenterCoordinatesMultiRank (void) |
| Tests translated face-center ghosts when the periodic axis is partitioned. | |
| static PetscErrorCode | TestPeriodicFaceFieldSynchronizationMultiRank (void) |
| Tests persistent I-face synchronization across an MPI-partitioned seam. | |
| static PetscErrorCode | TestPeriodicStaggeredFieldSynchronizationMultiRank (void) |
| Tests persistent Ucont synchronization across an MPI-partitioned seam. | |
| static PetscErrorCode | ProfiledOnRankOneOnly (void) |
| A profiled function that takes a measurable time; the profiling macros name it by func. | |
| static PetscErrorCode | TestProfilingSummaryReducesOverRanks (void) |
| The final profiling summary reduces each function's total time over ranks. | |
| static PetscErrorCode | TestFindOwnerOfCellMatchesRankRanges (void) |
| The per-axis owner lookup agrees with a scan of every rank's cell ranges. | |
| static PetscErrorCode | TestRestartCellIdMigrationMovesParticleToOwner (void) |
| Tests restart fast-path migration using preloaded cell ownership metadata. | |
| static PetscErrorCode | TestSettlementClassifiesExitOnceAcrossPasses (void) |
| A particle that left the domain is classified once and never re-searched in later passes. | |
| static PetscErrorCode | TestSpatialTargetIsDecompositionIndependent (void) |
| Spatial target domains must not depend on how ranks divide the block. | |
| static PetscErrorCode | TestStatisticsCheckpointRoundTripMultiRank (void) |
| Statistics payloads must survive a checkpoint round trip under decomposition. | |
| static PetscErrorCode | TestLESAveragingIsDecompositionIndependent (void) |
| Tests that LES coefficient averaging does not depend on the decomposition. | |
| static PetscErrorCode | TestInjectionFollowsFluxAndIsKeyedOnTheGrid (void) |
| Tests that injection follows the flux, is keyed on the grid, and carries no state. | |
| static PetscErrorCode | TestIEMReconstructionAcrossSeams (void) |
| Checks that IEM's linear reconstruction holds across subdomain seams. | |
| static PetscErrorCode | RunIEMOnSeededBox (PetscReal step_lo, PetscReal step_hi, PetscBool vary_rate, PetscBool crowd, PetscReal *max_cell_change, PetscReal before[2], PetscReal after[2]) |
| Runs one IEM update on a seeded box after setting each particle's Psi, rate and place. | |
| static PetscErrorCode | TestIEMKeepsCellTotalsWithVaryingRates (void) |
| IEM keeps every cell's Psi total when the particles in a cell relax at different rates. | |
| static PetscErrorCode | TestIEMStaysWithinParticleExtrema (void) |
| IEM keeps Psi within the particles' extrema and each cell's total, across a sharp front. | |
| static PetscErrorCode | TestSourceDrawsAreKeyedOnTheGrid (void) |
| Velocity sources draw by global index, whatever the decomposition. | |
| static PetscReal | InflowOracle (PetscInt64 seed, PetscInt c, PetscInt g0, PetscInt g1, PetscInt64 step, const PetscInt cells[2], const PetscInt half[2], PetscReal *const kernel[2]) |
| A filtered inflow draw at face cell (g0, g1) of -Zeta: the separable kernel applied to the keyed normals on a lattice with a fixed padding beyond the face's edges. | |
| static PetscErrorCode | TestInletFluctuationIsTheFilteredKeyedDraw (void) |
| Tests that an inlet's synthetic fluctuation is the digital filter of draws keyed on the grid, scaled by the Cholesky factor of the Reynolds stresses, on any decomposition. | |
| static PetscErrorCode | TestInjectionRefusesAFaceThatIsNotAnInlet (void) |
| Tests that a face that is not an INLET refuses to inject. | |
| static PetscErrorCode | TestFacePlanesSurvivePeriodicGhostUpdate (void) |
| Tests that, across a periodic seam and rank boundaries, the face planes the search and interpolation read after a ghost update are each cell's own planes. | |
| int | main (int argc, char **argv) |
| Runs the unit-mpi PETSc test binary. | |
C unit tests for MPI collective helper routines.
Definition in file test_mpi_kernels.c.
| #define TEST_INLET_FLUX | ( | i_, | |
| j_ | |||
| ) | (((i_) % 3 == 0) ? -0.01 : 0.002 * ((i_) + 2 * (j_))) |
|
static |
Marks both x boundary faces as geometric periodic boundaries.
Definition at line 32 of file test_mpi_kernels.c.
|
static |
Returns a deterministic scalar value for periodic-transfer assertions.
Definition at line 45 of file test_mpi_kernels.c.
|
static |
Tests collective particle distribution consistency across MPI ranks.
Definition at line 53 of file test_mpi_kernels.c.
|
static |
Tests multi-rank bounding-box gather and broadcast helpers.
Definition at line 86 of file test_mpi_kernels.c.
|
static |
Width of cell n (1-based interior index) along an axis in the line-fraction test.
Definition at line 128 of file test_mpi_kernels.c.
|
static |
Grid-line fractions follow arc length on a stretched orthogonal grid, and the lines that cross ranks are summed in order.
Definition at line 139 of file test_mpi_kernels.c.
|
static |
Tests distributed synchronization of persistent cell-centered scalar fields.
Definition at line 211 of file test_mpi_kernels.c.
|
static |
Tests periodic seam translation discovery when seam nodes are on different ranks.
Definition at line 308 of file test_mpi_kernels.c.
|
static |
Tests translated face-center ghosts when the periodic axis is partitioned.
Definition at line 339 of file test_mpi_kernels.c.
|
static |
Tests persistent I-face synchronization across an MPI-partitioned seam.
Definition at line 393 of file test_mpi_kernels.c.
|
static |
Tests persistent Ucont synchronization across an MPI-partitioned seam.
Definition at line 441 of file test_mpi_kernels.c.
|
static |
A profiled function that takes a measurable time; the profiling macros name it by func.
Definition at line 515 of file test_mpi_kernels.c.
|
static |
The final profiling summary reduces each function's total time over ranks.
A function profiled on rank 1 only must reach rank 0's summary with its maximum on rank 1, its minimum (zero) on rank 0 and one call in total.
Definition at line 534 of file test_mpi_kernels.c.
|
static |
The per-axis owner lookup agrees with a scan of every rank's cell ranges.
Checks every cell of the grid, plus cells just outside each face, which have no owner.
Definition at line 593 of file test_mpi_kernels.c.
|
static |
Tests restart fast-path migration using preloaded cell ownership metadata.
Definition at line 627 of file test_mpi_kernels.c.
|
static |
A particle that left the domain is classified once and never re-searched in later passes.
Rank 0 holds one particle beyond the -Xi face and one that has moved into rank 1, so the settlement needs a second pass. The leaving particle must end EXITED after pass 1 and be skipped afterwards: re-searching it is what used to count it as lost once per pass and, on curved boundaries, migrate it between ranks until the pass limit aborted the run.
Definition at line 685 of file test_mpi_kernels.c.
|
static |
Spatial target domains must not depend on how ranks divide the block.
The global point count is a function of layout, global dimensions, and periodicity alone. Summing the per-rank counts must therefore reproduce the same analytic totals a single rank computes, with no point counted twice at a decomposition seam and none dropped.
Definition at line 753 of file test_mpi_kernels.c.
|
static |
Statistics payloads must survive a checkpoint round trip under decomposition.
The write path gathers each accumulator into natural ordering before it reaches disk, and the read path scatters it back. That pairing is where a decomposition bug would live, so this drives the whole cycle on more than one rank and requires an exact match: the format stores IEEE doubles, and natural ordering is defined to be independent of how ranks divide the block.
Definition at line 813 of file test_mpi_kernels.c.
|
static |
Tests that LES coefficient averaging does not depend on the decomposition.
The averaged coefficient is a physical property of the block, so splitting the same field across more ranks must not change it. This case catches a wrong communicator, a halo entry counted as if it were owned, or a layout boundary plane included in one decomposition but not another. The reference is computed from the analytic definition over the interior index box rather than from a single-rank run, so the test does not merely compare one decomposition against itself.
Definition at line 960 of file test_mpi_kernels.c.
|
static |
Tests that injection follows the flux, is keyed on the grid, and carries no state.
An empty domain, with a different flux through each inlet face cell and outflow through every third. The global count and identities are computed from the formula over all face cells, so they hold whatever the decomposition. Each particle carries the value at the face, sits within u dt of it, awaits location, and a second call for the same step reproduces the first. With a diffusivity, each particle moves further by exactly its own keyed Brownian displacement for the step.
Definition at line 1042 of file test_mpi_kernels.c.
|
static |
Checks that IEM's linear reconstruction holds across subdomain seams.
Particles fill the box and carry Psi = 2 (x + y + z), so every cell's reconstruction reproduces the line up to the noise of its gradient. A seam that hid a neighbour's particles from the gradient would leave the cells beside it relaxing toward their stepped mean, as far from the line as the stepped mean leaves every cell. Each cell's particles are on its owner rank, so the stepped reference is computed there.
Definition at line 1175 of file test_mpi_kernels.c.
|
static |
Runs one IEM update on a seeded box after setting each particle's Psi, rate and place.
The particles fill the tiny periodic box. step_lo/step_hi < 0 keep the linear field 2 (x + y + z); otherwise Psi is step_lo below x = L/2 and step_hi above it. vary_rate gives each particle a diffusivity 0.2 (1 + 0.8 (f - 1/2)), f its position across its cell in x, so the relaxation rate differs between particles in one cell; crowd moves every particle into the low quarter of its cell along each axis. Returns the largest change of a cell's Psi total and the Psi extrema before and after.
Definition at line 1255 of file test_mpi_kernels.c.
|
static |
IEM keeps every cell's Psi total when the particles in a cell relax at different rates.
Each particle relaxes with its own diffusivity, which varies across every cell here, on a linear field. Only a target whose mean and centroid are weighted by the particles' relaxation weights keeps the totals; an unweighted mean and centroid change them by up to a few percent of a cell's total in one step.
Definition at line 1336 of file test_mpi_kernels.c.
|
static |
IEM keeps Psi within the particles' extrema and each cell's total, across a sharp front.
A step from lo to hi across x = L/2: the gradient at the front carries into the neighbouring pure cells, so an unlimited linear target overshoots both values. Three representatives: 0/1 with uniform rates; 0/1 with rates varying within cells and the particles crowded into a corner of each cell; and 2/5, whose bounds are not [0, 1], so a bound fixed at [0, 1] fails.
Definition at line 1355 of file test_mpi_kernels.c.
|
static |
Velocity sources draw by global index, whatever the decomposition.
Every value is compared with a draw this test makes from the cell's or face cell's global indices alone, so a key that depended on the rank layout would fail at any rank count but one. A cell reads one draw per component; a face cell a new one each step, and the same one when a step is revisited.
Definition at line 1386 of file test_mpi_kernels.c.
|
static |
A filtered inflow draw at face cell (g0, g1) of -Zeta: the separable kernel applied to the keyed normals on a lattice with a fixed padding beyond the face's edges.
Definition at line 1487 of file test_mpi_kernels.c.
|
static |
Tests that an inlet's synthetic fluctuation is the digital filter of draws keyed on the grid, scaled by the Cholesky factor of the Reynolds stresses, on any decomposition.
The oracle rebuilds the kernels from the grid spacing, filters the keyed normals at each owned inlet cell, and checks the state in the dummy plane and the boundary velocity at the first step and after one time-filter update. Lengths are chosen so the halo passes the face's closed edges.
Definition at line 1510 of file test_mpi_kernels.c.
|
static |
Tests that a face that is not an INLET refuses to inject.
Definition at line 1612 of file test_mpi_kernels.c.
|
static |
Tests that, across a periodic seam and rank boundaries, the face planes the search and interpolation read after a ghost update are each cell's own planes.
Every grid cell made of physical nodes and every dual cell the interpolation can form must give, to rounding, the distances CalculateDistancesToCellFaces() computes from that cell's own vertices, whatever the fields' sync classes do to the ghosts beyond.
Definition at line 1641 of file test_mpi_kernels.c.
| int main | ( | int | argc, |
| char ** | argv | ||
| ) |
Runs the unit-mpi PETSc test binary.
Definition at line 1712 of file test_mpi_kernels.c.