C unit tests for setup, initialization, and cleanup lifecycle entry points. More...
#include "test_support.h"#include "ParticleSwarm.h"#include "ParticlePhysics.h"#include "initialcondition.h"#include "runloop.h"#include "setup.h"#include <stdio.h>#include <string.h>Go to the source code of this file.
Functions | |
| static PetscErrorCode | AssertDirectoryExists (const char *path, const char *context) |
| Asserts that a directory path exists and is readable. | |
| static PetscErrorCode | WriteContextOnlyFile (const char *path, const char *contents) |
| Writes one small temporary text file used by the partial-lifecycle context-only fixture. | |
| static PetscErrorCode | PrepareContextOnlyConfig (char *tmpdir, size_t tmpdir_len, char *control_path, size_t control_path_len) |
| Creates the control-file bundle needed for the context-only cleanup test. | |
| static PetscErrorCode | FreeLifecycleContext (SimCtx **simCtx_ptr) |
| Finalizes and frees one lifecycle test context, then clears any PETSc options used to build it. | |
| static PetscErrorCode | BuildLifecycleContext (PetscBool enable_particles, SimCtx **simCtx_out, char *tmpdir, size_t tmpdir_len) |
| Builds a full setup fixture through environment, grid, BC, and domain-rank initialization. | |
| static PetscErrorCode | BuildContextOnly (SimCtx **simCtx_out, char *tmpdir, size_t tmpdir_len) |
| Builds only the top-level simulation context used by partial-initialization cleanup tests. | |
| static PetscErrorCode | TestSetupRejectsUnimplementedFeatureFlags (void) |
| Tests that setup refuses every flag whose feature is planned but not implemented. | |
| static PetscErrorCode | TryContextWithExtraLines (const char *extra_lines, SimCtx **simCtx_out, PetscErrorCode *ierr_out, char *tmpdir, size_t tmpdir_len) |
| Builds a context from the fixture control file with extra lines appended. | |
| static PetscErrorCode | TestIEMConstantIsConfigurable (void) |
| Tests that the IEM mixing constant defaults to 2.0, follows -iem_constant, accepts zero (no micromixing), and refuses a negative or non-finite value. | |
| static PetscErrorCode | TestUnsolvedFlowUsesOneGridLevel (void) |
| Ensures a run that solves no pressure builds one grid level whatever -mg_level asks, and a solved flow keeps the levels it asks for. | |
| static PetscErrorCode | TestParticleCountMustFitPetscInt (void) |
| Ensures setup refuses a particle count whose widest swarm field PetscInt cannot index. | |
| static PetscErrorCode | TestSetupRejectsNonpositivePostInterval (void) |
| Ensures setup propagates invalid post intervals before either executable can loop. | |
| static PetscErrorCode | TestConfiguredParticleInitialValue (void) |
| Checks a configured particle initial value through the production setup path. | |
| static PetscErrorCode | TestConfiguredIEMUpdatesSwarm (void) |
| Checks configured IEM relaxation through the production swarm update. | |
| static PetscErrorCode | TestIEMRelaxesTowardOwnCellMean (void) |
| Checks that IEM relaxes each particle toward its own cell's scattered mean. | |
| static PetscErrorCode | TestPostprocessorLoadsSavedParticleAverages (void) |
| Checks that post-processing loads the particle averages a checkpoint holds. | |
| static PetscErrorCode | TestSharedRuntimeFixtureContracts (void) |
| Tests that the shared richer runtime fixture mirrors normalized production setup contracts. | |
| static PetscErrorCode | AssertStoredLocalInfoMatchesDMs (UserCtx *user) |
| Asserts that one block's stored local info matches what its DMs report. | |
| static PetscErrorCode | TestSetupLifecycleCoreSolverSetup (void) |
| Tests the core setup lifecycle through environment, grid, BC, rank-info, and Eulerian-state initialization. | |
| static PetscErrorCode | TestSetupLifecycleParticleInitialization (void) |
| Tests particle-swarm initialization and deterministic settlement on a tiny fully initialized case. | |
| static PetscErrorCode | TestSetupLifecycleScatterMetricsAtStepZero (void) |
| Tests that step-zero scalar verification emits scatter_metrics.csv during initialized setup. | |
| static PetscErrorCode | TestSetupLifecycleRandomGeneratorsAndCleanup (void) |
| Tests standalone RNG initialization helpers and minimal-context cleanup. | |
| static PetscErrorCode | TestSetupLifecycleCleanupAcrossInitializationStates (void) |
| Tests cleanup after partial and fuller setup states without requiring unsupported double-finalization behavior. | |
| static PetscErrorCode | TestFieldCatalogMetadataAndViews (void) |
| Verifies catalog completeness, stable name resolution, and runtime view binding. | |
| static PetscErrorCode | TestParticleFieldCatalogMetadata (void) |
| Verifies the separate DMSwarm field catalog and its Eulerian bridge metadata. | |
| static PetscErrorCode | TestFieldCatalogTypedGhostUpdates (void) |
| Verifies typed ghost updates preserve scalar, vector, face, and staggered behavior. | |
| int | main (int argc, char **argv) |
| Runs the unit-setup PETSc test binary. | |
C unit tests for setup, initialization, and cleanup lifecycle entry points.
Definition in file test_setup_lifecycle.c.
|
static |
Asserts that a directory path exists and is readable.
Definition at line 20 of file test_setup_lifecycle.c.
|
static |
Writes one small temporary text file used by the partial-lifecycle context-only fixture.
Definition at line 33 of file test_setup_lifecycle.c.
|
static |
Creates the control-file bundle needed for the context-only cleanup test.
Definition at line 48 of file test_setup_lifecycle.c.
|
static |
Finalizes and frees one lifecycle test context, then clears any PETSc options used to build it.
Definition at line 143 of file test_setup_lifecycle.c.
|
static |
Builds a full setup fixture through environment, grid, BC, and domain-rank initialization.
Definition at line 153 of file test_setup_lifecycle.c.
|
static |
Builds only the top-level simulation context used by partial-initialization cleanup tests.
Definition at line 163 of file test_setup_lifecycle.c.
|
static |
Tests that setup refuses every flag whose feature is planned but not implemented.
Multi-block coupling, immersed boundaries, moving bodies, moving frames and the immersed-body flux corrections were all accepted before, and each ran a different problem without saying so. The conductor refuses the YAML switches; this covers the same flags arriving through a PETSc passthrough. Each flag is appended to an otherwise valid control file, so a later duplicate overrides the fixture's own value.
Definition at line 187 of file test_setup_lifecycle.c.
|
static |
Builds a context from the fixture control file with extra lines appended.
| [in] | extra_lines | Control-file lines appended after the fixture's own. |
| [out] | simCtx_out | Context on success; the partially built context on failure. |
| [out] | ierr_out | CreateSimulationContext's return code, errors suppressed. |
| [out] | tmpdir | Fixture directory, removed by the caller. |
| [in] | tmpdir_len | Capacity of tmpdir. |
Definition at line 232 of file test_setup_lifecycle.c.
|
static |
Tests that the IEM mixing constant defaults to 2.0, follows -iem_constant, accepts zero (no micromixing), and refuses a negative or non-finite value.
Definition at line 257 of file test_setup_lifecycle.c.
|
static |
Ensures a run that solves no pressure builds one grid level whatever -mg_level asks, and a solved flow keeps the levels it asks for.
Definition at line 289 of file test_setup_lifecycle.c.
|
static |
Ensures setup refuses a particle count whose widest swarm field PetscInt cannot index.
Particle fields have up to three components, so the limit is PETSC_MAX_INT / 3 particles; with 64-bit indices no representable -numParticles reaches it.
Definition at line 317 of file test_setup_lifecycle.c.
|
static |
Ensures setup propagates invalid post intervals before either executable can loop.
Definition at line 338 of file test_setup_lifecycle.c.
|
static |
Checks a configured particle initial value through the production setup path.
Psi = x + 2*pid is read from the options, compiled, and applied once positions are final; it varies across particles wherever they are seeded. Particles fill the volume, so cells next to every face are occupied. Every particle must carry exactly its value, and the t=0 scatter must already reflect it: the count-weighted Eulerian Psi sums to the particles' total, so the first IEM update relaxes toward the right mean, and each non-periodic face's dummy cells carry the adjacent cell's mean.
Definition at line 366 of file test_setup_lifecycle.c.
|
static |
Checks configured IEM relaxation through the production swarm update.
Each particle must relax toward the mean of the particles now in its cell, at the configured rate. A zero constant switches micromixing off, and must leave Psi bit-identical: alternating values 0.1 and 0.7 do not survive m + (0.1 - m) * 1 exactly in mixed cells, so the exact comparison shows the update is skipped, not run at a zero rate.
Definition at line 457 of file test_setup_lifecycle.c.
|
static |
Checks that IEM relaxes each particle toward its own cell's scattered mean.
Particles start at random 0 or 1, so cell means differ from cell to cell and from the zero in the boundary storage slots. Relaxing toward the particle's own cell mean at a rate uniform within the cell conserves every cell's scalar sum, so the total is unchanged while the spread shrinks; reading a neighbour's mean, or a boundary slot, breaks the conservation.
Definition at line 534 of file test_setup_lifecycle.c.
|
static |
Checks that post-processing loads the particle averages a checkpoint holds.
A case with restart_mode: init reseeds particles on a solver restart, so the solver must not restore the averages of the particles it discards; the postprocessor reads the same control settings but visualizes what was saved, so it must load them, and refresh the ghosted copy that nodal averaging reads.
Definition at line 594 of file test_setup_lifecycle.c.
|
static |
Tests that the shared richer runtime fixture mirrors normalized production setup contracts.
Definition at line 647 of file test_setup_lifecycle.c.
|
static |
Asserts that one block's stored local info matches what its DMs report.
Grid, rank and particle code read user->info in place of DMDAGetLocalInfo on user->da and user->fda, which relies on both DMs sharing one decomposition.
Definition at line 675 of file test_setup_lifecycle.c.
|
static |
Tests the core setup lifecycle through environment, grid, BC, rank-info, and Eulerian-state initialization.
Definition at line 703 of file test_setup_lifecycle.c.
|
static |
Tests particle-swarm initialization and deterministic settlement on a tiny fully initialized case.
Definition at line 749 of file test_setup_lifecycle.c.
|
static |
Tests that step-zero scalar verification emits scatter_metrics.csv during initialized setup.
Definition at line 788 of file test_setup_lifecycle.c.
|
static |
Tests standalone RNG initialization helpers and minimal-context cleanup.
Definition at line 829 of file test_setup_lifecycle.c.
|
static |
Tests cleanup after partial and fuller setup states without requiring unsupported double-finalization behavior.
Definition at line 872 of file test_setup_lifecycle.c.
|
static |
Verifies catalog completeness, stable name resolution, and runtime view binding.
Definition at line 910 of file test_setup_lifecycle.c.
|
static |
Verifies the separate DMSwarm field catalog and its Eulerian bridge metadata.
Definition at line 1011 of file test_setup_lifecycle.c.
|
static |
Verifies typed ghost updates preserve scalar, vector, face, and staggered behavior.
Definition at line 1068 of file test_setup_lifecycle.c.
| int main | ( | int | argc, |
| char ** | argv | ||
| ) |
Runs the unit-setup PETSc test binary.
Definition at line 1107 of file test_setup_lifecycle.c.