PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
 
Loading...
Searching...
No Matches
Functions
test_setup_lifecycle.c File Reference

C unit tests for setup, initialization, and cleanup lifecycle entry points. More...

#include "test_support.h"
#include "ParticleSwarm.h"
#include "initialcondition.h"
#include "runloop.h"
#include "setup.h"
#include <stdio.h>
#include <string.h>
Include dependency graph for test_setup_lifecycle.c:

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 TestSharedRuntimeFixtureContracts (void)
 Tests that the shared richer runtime fixture mirrors normalized production setup contracts.
 
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.
 

Detailed Description

C unit tests for setup, initialization, and cleanup lifecycle entry points.

Definition in file test_setup_lifecycle.c.

Function Documentation

◆ AssertDirectoryExists()

static PetscErrorCode AssertDirectoryExists ( const char *  path,
const char *  context 
)
static

Asserts that a directory path exists and is readable.

Definition at line 19 of file test_setup_lifecycle.c.

20{
21 PetscBool exists = PETSC_FALSE;
22
23 PetscFunctionBeginUser;
24 PetscCall(PetscTestDirectory(path, 'r', &exists));
25 PetscCall(PicurvAssertBool(exists, context));
26 PetscFunctionReturn(0);
27}
PetscErrorCode PicurvAssertBool(PetscBool value, const char *context)
Asserts that one boolean condition is true.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteContextOnlyFile()

static PetscErrorCode WriteContextOnlyFile ( const char *  path,
const char *  contents 
)
static

Writes one small temporary text file used by the partial-lifecycle context-only fixture.

Definition at line 32 of file test_setup_lifecycle.c.

33{
34 FILE *file = NULL;
35
36 PetscFunctionBeginUser;
37 file = fopen(path, "w");
38 PetscCheck(file != NULL, PETSC_COMM_SELF, PETSC_ERR_FILE_OPEN, "Failed to open '%s' for writing.", path);
39 fputs(contents, file);
40 fclose(file);
41 PetscFunctionReturn(0);
42}
Here is the caller graph for this function:

◆ PrepareContextOnlyConfig()

static PetscErrorCode PrepareContextOnlyConfig ( char *  tmpdir,
size_t  tmpdir_len,
char *  control_path,
size_t  control_path_len 
)
static

Creates the control-file bundle needed for the context-only cleanup test.

Definition at line 47 of file test_setup_lifecycle.c.

51{
52 char bcs_path[PETSC_MAX_PATH_LEN];
53 char post_path[PETSC_MAX_PATH_LEN];
54 char output_dir[PETSC_MAX_PATH_LEN];
55 char log_dir[PETSC_MAX_PATH_LEN];
56 char control_buffer[8192];
57
58 PetscFunctionBeginUser;
59 PetscCall(PicurvMakeTempDir(tmpdir, tmpdir_len));
60 PetscCall(PetscSNPrintf(bcs_path, sizeof(bcs_path), "%s/bcs.run", tmpdir));
61 PetscCall(PetscSNPrintf(post_path, sizeof(post_path), "%s/post.run", tmpdir));
62 PetscCall(PetscSNPrintf(output_dir, sizeof(output_dir), "%s/results", tmpdir));
63 PetscCall(PetscSNPrintf(log_dir, sizeof(log_dir), "%s/logs", tmpdir));
64 PetscCall(PetscSNPrintf(control_path, control_path_len, "%s/test.control", tmpdir));
65
66 PetscCall(WriteContextOnlyFile(
67 bcs_path,
68 "-Xi WALL noslip\n"
69 "+Xi WALL noslip\n"
70 "-Eta WALL noslip\n"
71 "+Eta WALL noslip\n"
72 "-Zeta INLET constant_velocity vx=0.0 vy=0.0 vz=1.5\n"
73 "+Zeta OUTLET conservation\n"));
74 PetscCall(WriteContextOnlyFile(
75 post_path,
76 "startTime = 0\n"
77 "endTime = 1\n"
78 "timeStep = 1\n"
79 "output_particles = false\n"));
80 PetscCall(PetscSNPrintf(
81 control_buffer,
82 sizeof(control_buffer),
83 "-start_step 0\n"
84 "-totalsteps 2\n"
85 "-ren 100.0\n"
86 "-dt 0.001\n"
87 "-finit 1\n"
88 "-ucont_x 0.0\n"
89 "-ucont_y 0.0\n"
90 "-ucont_z 1.5\n"
91 "-bcs_files %s\n"
92 "-profiling_timestep_mode off\n"
93 "-profiling_final_summary true\n"
94 "-postprocessing_config_file %s\n"
95 "-grid\n"
96 "-im 6\n"
97 "-jm 6\n"
98 "-km 6\n"
99 "-xMins 0.0\n"
100 "-xMaxs 1.0\n"
101 "-yMins 0.0\n"
102 "-yMaxs 1.0\n"
103 "-zMins 0.0\n"
104 "-zMaxs 1.0\n"
105 "-rxs 1.0\n"
106 "-rys 1.0\n"
107 "-rzs 1.0\n"
108 "-cgrids 0\n"
109 "-nblk 1\n"
110 "-euler_field_source solve\n"
111 "-mom_solver_type DUALTIME_PICARD_RK4\n"
112 "-mom_dt_rk4_residual_norm_noise_allowance_factor 1.07\n"
113 "-mom_resid_atol 1.0e-8\n"
114 "-mom_resid_rtol 1.0e-3\n"
115 "-mom_nk_pic_monitor\n"
116 "-mg_level 1\n"
117 "-poisson 0\n"
118 "-tio 0\n"
119 "-particle_console_output_freq 0\n"
120 "-logfreq 1\n"
121 "-output_dir %s\n"
122 "-restart_dir %s\n"
123 /* This fixture owns its temporary tree and wants it wiped. That is an external
124 * absolute path, so it authorizes the delete explicitly - the runtime guard
125 * makes no exception for tests. */
126 "-allow_unsafe_log_dir true\n"
127 "-log_dir %s\n"
128 "-numParticles 0\n"
129 "-pinit 2\n",
130 bcs_path,
131 post_path,
132 output_dir,
133 output_dir,
134 log_dir));
135 PetscCall(WriteContextOnlyFile(control_path, control_buffer));
136 PetscFunctionReturn(0);
137}
static PetscErrorCode WriteContextOnlyFile(const char *path, const char *contents)
Writes one small temporary text file used by the partial-lifecycle context-only fixture.
PetscErrorCode PicurvMakeTempDir(char *path, size_t path_len)
Creates a unique temporary directory for one test case.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FreeLifecycleContext()

static PetscErrorCode FreeLifecycleContext ( SimCtx **  simCtx_ptr)
static

Finalizes and frees one lifecycle test context, then clears any PETSc options used to build it.

Definition at line 142 of file test_setup_lifecycle.c.

143{
144 PetscFunctionBeginUser;
145 PetscCall(PicurvDestroyRuntimeContext(simCtx_ptr));
146 PetscFunctionReturn(0);
147}
PetscErrorCode PicurvDestroyRuntimeContext(SimCtx **simCtx_ptr)
Finalizes and frees a runtime context built by PicurvBuildTinyRuntimeContext.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ BuildLifecycleContext()

static PetscErrorCode BuildLifecycleContext ( PetscBool  enable_particles,
SimCtx **  simCtx_out,
char *  tmpdir,
size_t  tmpdir_len 
)
static

Builds a full setup fixture through environment, grid, BC, and domain-rank initialization.

Definition at line 152 of file test_setup_lifecycle.c.

153{
154 PetscFunctionBeginUser;
155 PetscCall(PicurvBuildTinyRuntimeContext(NULL, enable_particles, simCtx_out, NULL, tmpdir, tmpdir_len));
156 PetscFunctionReturn(0);
157}
PetscErrorCode PicurvBuildTinyRuntimeContext(const char *bcs_contents, PetscBool enable_particles, SimCtx **simCtx_out, UserCtx **user_out, char *tmpdir, size_t tmpdir_len)
Builds a tiny runtime context through the real setup path for behavior-level tests.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ BuildContextOnly()

static PetscErrorCode BuildContextOnly ( SimCtx **  simCtx_out,
char *  tmpdir,
size_t  tmpdir_len 
)
static

Builds only the top-level simulation context used by partial-initialization cleanup tests.

Definition at line 162 of file test_setup_lifecycle.c.

163{
164 char control_path[PETSC_MAX_PATH_LEN];
165 SimCtx *simCtx = NULL;
166
167 PetscFunctionBeginUser;
168 PetscCall(PetscOptionsClear(NULL));
169 PetscCall(PrepareContextOnlyConfig(tmpdir, tmpdir_len, control_path, sizeof(control_path)));
170 PetscCall(PetscOptionsSetValue(NULL, "-control_file", control_path));
171 PetscCall(CreateSimulationContext(0, NULL, &simCtx));
172 simCtx->exec_mode = EXEC_MODE_SOLVER;
173 *simCtx_out = simCtx;
174 PetscFunctionReturn(0);
175}
PetscErrorCode CreateSimulationContext(int argc, char **argv, SimCtx **p_simCtx)
Allocates and populates the master SimulationContext object.
Definition setup.c:332
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.
@ EXEC_MODE_SOLVER
Definition variables.h:831
ExecutionMode exec_mode
Definition variables.h:877
The master context for the entire simulation.
Definition variables.h:858
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestSharedRuntimeFixtureContracts()

static PetscErrorCode TestSharedRuntimeFixtureContracts ( void  )
static

Tests that the shared richer runtime fixture mirrors normalized production setup contracts.

Definition at line 180 of file test_setup_lifecycle.c.

181{
182 SimCtx *simCtx = NULL;
183 UserCtx *user = NULL;
184 char tmpdir[PETSC_MAX_PATH_LEN];
185
186 PetscFunctionBeginUser;
187 PetscCall(PicurvBuildTinyRuntimeContext(NULL, PETSC_FALSE, &simCtx, &user, tmpdir, sizeof(tmpdir)));
188
189 PetscCall(PicurvAssertBool((PetscBool)(user->bbox.min_coords.x >= -2.0e-6), "runtime fixture bbox xmin should stay inside normalized domain tolerance"));
190 PetscCall(PicurvAssertBool((PetscBool)(user->bbox.max_coords.x <= 1.0 + 2.0e-6), "runtime fixture bbox xmax should stay inside normalized domain tolerance"));
191 PetscCall(PicurvAssertBool((PetscBool)(user->bbox.max_coords.y <= 1.0 + 2.0e-6), "runtime fixture bbox ymax should stay inside normalized domain tolerance"));
192 PetscCall(PicurvAssertBool((PetscBool)(user->bbox.max_coords.z <= 1.0 + 2.0e-6), "runtime fixture bbox zmax should stay inside normalized domain tolerance"));
193 PetscCall(PicurvAssertBool((PetscBool)(simCtx->bboxlist != NULL), "runtime fixture should gather bboxlist through SetupDomainRankInfo"));
194 PetscCall(PicurvAssertBool((PetscBool)(user->RankCellInfoMap != NULL), "runtime fixture should gather rank-cell ownership metadata"));
195 PetscCall(PicurvAssertBool((PetscBool)(simCtx->bboxlist[simCtx->rank].max_coords.x >= user->bbox.max_coords.x - 1.0e-10),
196 "runtime fixture rank bbox entry should include the local bbox extent"));
197
198 PetscCall(PicurvRemoveTempDir(tmpdir));
199 PetscCall(FreeLifecycleContext(&simCtx));
200 PetscFunctionReturn(0);
201}
static PetscErrorCode FreeLifecycleContext(SimCtx **simCtx_ptr)
Finalizes and frees one lifecycle test context, then clears any PETSc options used to build it.
PetscErrorCode PicurvRemoveTempDir(const char *path)
Recursively removes a temporary directory created by PicurvMakeTempDir.
PetscMPIInt rank
Definition variables.h:861
Cmpnts max_coords
Maximum x, y, z coordinates of the bounding box.
Definition variables.h:203
Cmpnts min_coords
Minimum x, y, z coordinates of the bounding box.
Definition variables.h:202
PetscScalar x
Definition variables.h:121
RankCellInfo * RankCellInfoMap
Definition variables.h:1170
BoundingBox * bboxlist
Definition variables.h:995
PetscScalar z
Definition variables.h:121
PetscScalar y
Definition variables.h:121
BoundingBox bbox
Definition variables.h:1087
User-defined context containing data specific to a single computational grid level.
Definition variables.h:1071
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestSetupLifecycleCoreSolverSetup()

static PetscErrorCode TestSetupLifecycleCoreSolverSetup ( void  )
static

Tests the core setup lifecycle through environment, grid, BC, rank-info, and Eulerian-state initialization.

Definition at line 206 of file test_setup_lifecycle.c.

207{
208 SimCtx *simCtx = NULL;
209 UserCtx *user = NULL;
210 char tmpdir[PETSC_MAX_PATH_LEN];
211 char results_dir[PETSC_MAX_PATH_LEN];
212 char logs_dir[PETSC_MAX_PATH_LEN];
213 Cmpnts ***ucont = NULL;
214
215 PetscFunctionBeginUser;
216 PetscCall(BuildLifecycleContext(PETSC_FALSE, &simCtx, tmpdir, sizeof(tmpdir)));
217 user = simCtx->usermg.mgctx[simCtx->usermg.mglevels - 1].user;
218
219 PetscCall(PetscSNPrintf(results_dir, sizeof(results_dir), "%s/results", tmpdir));
220 PetscCall(PetscSNPrintf(logs_dir, sizeof(logs_dir), "%s/logs", tmpdir));
221 PetscCall(PicurvAssertBool((PetscBool)(user->da != NULL), "SetupGridAndSolvers should allocate da"));
222 PetscCall(PicurvAssertBool((PetscBool)(user->fda != NULL), "SetupGridAndSolvers should allocate coordinate DM"));
223 PetscCall(PicurvAssertIntEqual(user->IM + 1, user->info.mx, "DM node count should match IM+1"));
224 PetscCall(PicurvAssertBool(user->inletFaceDefined, "SetupBoundaryConditions should identify the inlet face"));
225 PetscCall(PicurvAssertIntEqual(BC_FACE_NEG_Z, user->identifiedInletBCFace, "NEG_Z should be the configured inlet face"));
226 PetscCall(PicurvAssertBool((PetscBool)(simCtx->bboxlist != NULL), "SetupDomainRankInfo should build bboxlist"));
227 PetscCall(PicurvAssertBool((PetscBool)(user->RankCellInfoMap != NULL), "SetupDomainRankInfo should build rank-cell decomposition map"));
228 PetscCall(AssertDirectoryExists(results_dir, "SetupSimulationEnvironment should create the output directory"));
229 PetscCall(AssertDirectoryExists(logs_dir, "SetupSimulationEnvironment should create the log directory"));
230
231 PetscCall(InitializeEulerianState(simCtx));
232 PetscCall(DMDAVecGetArrayRead(user->fda, user->Ucont, &ucont));
233 PetscCall(PicurvAssertBool((PetscBool)(ucont[1][1][1].z > 0.0),
234 "InitializeEulerianState should seed a positive inlet-aligned interior field"));
235 PetscCall(PicurvAssertRealNear(ucont[1][1][1].z, ucont[2][2][2].z, 1.0e-12,
236 "InitializeEulerianState should initialize a spatially consistent interior field"));
237 PetscCall(DMDAVecRestoreArrayRead(user->fda, user->Ucont, &ucont));
238
239 PetscCall(PicurvRemoveTempDir(tmpdir));
240 PetscCall(FreeLifecycleContext(&simCtx));
241 PetscFunctionReturn(0);
242}
PetscErrorCode InitializeEulerianState(SimCtx *simCtx)
High-level orchestrator to set the complete initial state of the Eulerian solver.
static PetscErrorCode AssertDirectoryExists(const char *path, const char *context)
Asserts that a directory path exists and is readable.
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.
PetscErrorCode PicurvAssertRealNear(PetscReal expected, PetscReal actual, PetscReal tol, const char *context)
Asserts that two real values agree within tolerance.
PetscErrorCode PicurvAssertIntEqual(PetscInt expected, PetscInt actual, const char *context)
Asserts that two integer values are equal.
UserCtx * user
Definition variables.h:730
PetscBool inletFaceDefined
Definition variables.h:1097
BCFace identifiedInletBCFace
Definition variables.h:1098
UserMG usermg
Definition variables.h:1017
Vec Ucont
Definition variables.h:1111
PetscInt mglevels
Definition variables.h:737
DMDALocalInfo info
Definition variables.h:1083
PetscInt IM
Definition variables.h:1085
MGCtx * mgctx
Definition variables.h:740
@ BC_FACE_NEG_Z
Definition variables.h:294
A 3D point or vector with PetscScalar components.
Definition variables.h:120
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestSetupLifecycleParticleInitialization()

static PetscErrorCode TestSetupLifecycleParticleInitialization ( void  )
static

Tests particle-swarm initialization and deterministic settlement on a tiny fully initialized case.

Definition at line 247 of file test_setup_lifecycle.c.

248{
249 SimCtx *simCtx = NULL;
250 UserCtx *user = NULL;
251 char tmpdir[PETSC_MAX_PATH_LEN];
252 PetscInt nlocal = 0;
253 PetscInt *cell_ids = NULL;
254 PetscInt *status = NULL;
255
256 PetscFunctionBeginUser;
257 PetscCall(BuildLifecycleContext(PETSC_TRUE, &simCtx, tmpdir, sizeof(tmpdir)));
258 PetscCall(InitializeEulerianState(simCtx));
259 PetscCall(InitializeParticleSwarm(simCtx));
260 PetscCall(PerformInitializedParticleSetup(simCtx));
261
262 user = simCtx->usermg.mgctx[simCtx->usermg.mglevels - 1].user;
263 PetscCall(PicurvAssertBool((PetscBool)(user->swarm != NULL), "InitializeParticleSwarm should allocate the solver swarm"));
264 PetscCall(DMSwarmGetLocalSize(user->swarm, &nlocal));
265 PetscCall(PicurvAssertIntEqual(8, nlocal, "single-rank lifecycle particle setup should own all seeded particles"));
266
267 PetscCall(DMSwarmGetField(user->swarm, "DMSwarm_CellID", NULL, NULL, (void **)&cell_ids));
268 PetscCall(DMSwarmGetField(user->swarm, "DMSwarm_location_status", NULL, NULL, (void **)&status));
269 for (PetscInt p = 0; p < nlocal; ++p) {
270 PetscCall(PicurvAssertBool((PetscBool)(cell_ids[3 * p + 0] >= 0), "settled particles should have a valid i cell id"));
271 PetscCall(PicurvAssertBool((PetscBool)(cell_ids[3 * p + 1] >= 0), "settled particles should have a valid j cell id"));
272 PetscCall(PicurvAssertBool((PetscBool)(cell_ids[3 * p + 2] >= 0), "settled particles should have a valid k cell id"));
273 PetscCall(PicurvAssertIntEqual(ACTIVE_AND_LOCATED, status[p], "settled particles should be marked ACTIVE_AND_LOCATED"));
274 }
275 PetscCall(DMSwarmRestoreField(user->swarm, "DMSwarm_CellID", NULL, NULL, (void **)&cell_ids));
276 PetscCall(DMSwarmRestoreField(user->swarm, "DMSwarm_location_status", NULL, NULL, (void **)&status));
277
278 PetscCall(PicurvRemoveTempDir(tmpdir));
279 PetscCall(FreeLifecycleContext(&simCtx));
280 PetscFunctionReturn(0);
281}
PetscErrorCode InitializeParticleSwarm(SimCtx *simCtx)
High-level particle initialization orchestrator for a simulation run.
PetscErrorCode PerformInitializedParticleSetup(SimCtx *simCtx)
Finalizes the simulation setup at t=0, ensuring a consistent state before time marching.
Definition runloop.c:365
@ ACTIVE_AND_LOCATED
Definition variables.h:169
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestSetupLifecycleScatterMetricsAtStepZero()

static PetscErrorCode TestSetupLifecycleScatterMetricsAtStepZero ( void  )
static

Tests that step-zero scalar verification emits scatter_metrics.csv during initialized setup.

Definition at line 286 of file test_setup_lifecycle.c.

287{
288 SimCtx *simCtx = NULL;
289 UserCtx *user = NULL;
290 char tmpdir[PETSC_MAX_PATH_LEN];
291 char metrics_path[PETSC_MAX_PATH_LEN];
292
293 PetscFunctionBeginUser;
294 PetscCall(BuildLifecycleContext(PETSC_TRUE, &simCtx, tmpdir, sizeof(tmpdir)));
295 user = simCtx->usermg.mgctx[simCtx->usermg.mglevels - 1].user;
296 PetscCall(PetscStrncpy(simCtx->eulerianSource, "analytical", sizeof(simCtx->eulerianSource)));
297 PetscCall(PetscStrncpy(simCtx->AnalyticalSolutionType, "ZERO_FLOW", sizeof(simCtx->AnalyticalSolutionType)));
298 simCtx->StepsToRun = 0;
299 simCtx->StartStep = 0;
300 simCtx->verificationScalar.enabled = PETSC_TRUE;
301 PetscCall(PetscStrncpy(simCtx->verificationScalar.mode,
302 "analytical",
303 sizeof(simCtx->verificationScalar.mode)));
304 PetscCall(PetscStrncpy(simCtx->verificationScalar.profile,
305 "CONSTANT",
306 sizeof(simCtx->verificationScalar.profile)));
307 simCtx->verificationScalar.value = 1.25;
308
309 PetscCall(InitializeEulerianState(simCtx));
310 PetscCall(InitializeParticleSwarm(simCtx));
311 PetscCall(PerformInitializedParticleSetup(simCtx));
312
313 PetscCall(PetscSNPrintf(metrics_path, sizeof(metrics_path), "%s/results/analysis/metrics/scatter_metrics.csv", tmpdir));
314 PetscCall(PicurvAssertFileExists(metrics_path,
315 "PerformInitializedParticleSetup should emit scatter_metrics.csv for a zero-step scalar verification run"));
316 PetscCall(PicurvAssertBool((PetscBool)(user->swarm != NULL),
317 "zero-step scalar verification setup should leave the swarm initialized"));
318
319 PetscCall(PicurvRemoveTempDir(tmpdir));
320 PetscCall(FreeLifecycleContext(&simCtx));
321 PetscFunctionReturn(0);
322}
PetscErrorCode PicurvAssertFileExists(const char *path, const char *context)
Asserts that a filesystem path exists as a readable file.
PetscInt StepsToRun
Definition variables.h:869
PetscInt StartStep
Definition variables.h:868
VerificationScalarConfig verificationScalar
Definition variables.h:942
char eulerianSource[PETSC_MAX_PATH_LEN]
Definition variables.h:878
char AnalyticalSolutionType[PETSC_MAX_PATH_LEN]
Definition variables.h:893
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestSetupLifecycleRandomGeneratorsAndCleanup()

static PetscErrorCode TestSetupLifecycleRandomGeneratorsAndCleanup ( void  )
static

Tests standalone RNG initialization helpers and minimal-context cleanup.

Definition at line 327 of file test_setup_lifecycle.c.

328{
329 SimCtx *simCtx = NULL;
330 UserCtx *user = NULL;
331 PetscRandom randx = NULL, randy = NULL, randz = NULL;
332 PetscRandom rand_i = NULL, rand_j = NULL, rand_k = NULL;
333 PetscScalar sample_x = 0.0, sample_i = 0.0;
334 PetscReal seconds = 0.0;
335
336 PetscFunctionBeginUser;
337 PetscCall(PicurvCreateMinimalContexts(&simCtx, &user, 4, 4, 4));
338 user->bbox.min_coords.x = 0.0;
339 user->bbox.min_coords.y = 0.0;
340 user->bbox.min_coords.z = 0.0;
341 user->bbox.max_coords.x = 1.0;
342 user->bbox.max_coords.y = 2.0;
343 user->bbox.max_coords.z = 3.0;
344
345 PetscCall(InitializeRandomGenerators(user, &randx, &randy, &randz));
346 PetscCall(InitializeLogicalSpaceRNGs(&rand_i, &rand_j, &rand_k));
347 PetscCall(InitializeBrownianRNG(simCtx));
348 PetscCall(PicurvAssertBool((PetscBool)(simCtx->BrownianMotionRNG != NULL), "InitializeBrownianRNG should allocate the Brownian RNG"));
349 PetscCall(PicurvAssertBool(RuntimeWalltimeGuardParsePositiveSeconds("12.5", &seconds), "RuntimeWalltimeGuardParsePositiveSeconds should parse positive numeric strings"));
350 PetscCall(PicurvAssertRealNear(12.5, seconds, 1.0e-12, "RuntimeWalltimeGuardParsePositiveSeconds parsed value"));
351
352 PetscCall(PetscRandomGetValue(randx, &sample_x));
353 PetscCall(PetscRandomGetValue(rand_i, &sample_i));
354 PetscCall(PicurvAssertBool((PetscBool)(PetscRealPart(sample_x) >= 0.0 && PetscRealPart(sample_x) <= 1.0),
355 "InitializeRandomGenerators should honor the configured bbox interval"));
356 PetscCall(PicurvAssertBool((PetscBool)(PetscRealPart(sample_i) >= 0.0 && PetscRealPart(sample_i) <= 1.0),
357 "InitializeLogicalSpaceRNGs should generate logical coordinates in [0,1]"));
358
359 PetscCall(PetscRandomDestroy(&randx));
360 PetscCall(PetscRandomDestroy(&randy));
361 PetscCall(PetscRandomDestroy(&randz));
362 PetscCall(PetscRandomDestroy(&rand_i));
363 PetscCall(PetscRandomDestroy(&rand_j));
364 PetscCall(PetscRandomDestroy(&rand_k));
365 PetscCall(PicurvDestroyMinimalContexts(&simCtx, &user));
366 PetscFunctionReturn(0);
367}
PetscErrorCode InitializeRandomGenerators(UserCtx *user, PetscRandom *randx, PetscRandom *randy, PetscRandom *randz)
Initializes random number generators for assigning particle properties.
Definition setup.c:3813
PetscErrorCode InitializeBrownianRNG(SimCtx *simCtx)
Initializes a single master RNG for time-stepping physics (Brownian motion).
Definition setup.c:3898
PetscErrorCode InitializeLogicalSpaceRNGs(PetscRandom *rand_logic_i, PetscRandom *rand_logic_j, PetscRandom *rand_logic_k)
Initializes random number generators for logical space operations [0.0, 1.0).
Definition setup.c:3854
PetscBool RuntimeWalltimeGuardParsePositiveSeconds(const char *text, PetscReal *seconds_out)
Parse a positive floating-point seconds value from runtime metadata.
Definition setup.c:41
PetscErrorCode PicurvCreateMinimalContexts(SimCtx **simCtx_out, UserCtx **user_out, PetscInt mx, PetscInt my, PetscInt mz)
Builds minimal SimCtx and UserCtx fixtures for C unit tests.
PetscErrorCode PicurvDestroyMinimalContexts(SimCtx **simCtx_ptr, UserCtx **user_ptr)
Destroys minimal SimCtx/UserCtx fixtures and all owned PETSc objects.
PetscRandom BrownianMotionRNG
Definition variables.h:1006
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestSetupLifecycleCleanupAcrossInitializationStates()

static PetscErrorCode TestSetupLifecycleCleanupAcrossInitializationStates ( void  )
static

Tests cleanup after partial and fuller setup states without requiring unsupported double-finalization behavior.

Definition at line 372 of file test_setup_lifecycle.c.

373{
374 SimCtx *context_only = NULL;
375 SimCtx *grid_only = NULL;
376 char context_tmpdir[PETSC_MAX_PATH_LEN];
377 char grid_tmpdir[PETSC_MAX_PATH_LEN];
378
379 PetscFunctionBeginUser;
380 PetscCall(BuildContextOnly(&context_only, context_tmpdir, sizeof(context_tmpdir)));
381 PetscCall(PicurvAssertBool((PetscBool)(context_only != NULL), "CreateSimulationContext should allocate the top-level SimCtx"));
382 PetscCall(PicurvAssertIntEqual(1, context_only->block_number, "CreateSimulationContext should parse the configured block count"));
384 "deprecated RK4 selector should normalize to the Jameson solver enum"));
386 "deprecated RK4 residual-noise option should populate the Jameson control"));
387 PetscCall(PicurvAssertRealNear(1.0e-8, context_only->mom_resid_atol, 1.0e-12,
388 "momentum absolute residual tolerance should be parsed"));
389 PetscCall(PicurvAssertRealNear(1.0e-3, context_only->mom_resid_rtol, 1.0e-12,
390 "momentum relative residual tolerance should be parsed"));
391 PetscCall(PicurvAssertBool(context_only->mom_nk_monitor_history,
392 "Newton structured history monitor should be parsed"));
393 PetscCall(PetscOptionsClear(NULL));
394 PetscCall(PicurvRemoveTempDir(context_tmpdir));
395 PetscCall(FreeLifecycleContext(&context_only));
396
397 PetscCall(BuildContextOnly(&grid_only, grid_tmpdir, sizeof(grid_tmpdir)));
398 PetscCall(SetupSimulationEnvironment(grid_only));
399 PetscCall(SetupGridAndSolvers(grid_only));
400 PetscCall(PicurvAssertBool((PetscBool)(grid_only->usermg.mgctx[grid_only->usermg.mglevels - 1].user->Ucont != NULL),
401 "SetupGridAndSolvers should allocate baseline Eulerian vectors"));
402 PetscCall(PicurvRemoveTempDir(grid_tmpdir));
403 PetscCall(FreeLifecycleContext(&grid_only));
404 PetscFunctionReturn(0);
405}
PetscErrorCode SetupGridAndSolvers(SimCtx *simCtx)
The main orchestrator for setting up all grid-related components.
Definition setup.c:1958
PetscErrorCode SetupSimulationEnvironment(SimCtx *simCtx)
Verifies and prepares the complete I/O environment for a simulation run.
Definition setup.c:1633
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.
PetscBool mom_nk_monitor_history
Definition variables.h:916
PetscInt block_number
Definition variables.h:954
@ MOMENTUM_SOLVER_DUALTIME_PICARD_JAMESON_RK
Definition variables.h:695
PetscReal mom_dt_jameson_residual_norm_noise_allowance_factor
Definition variables.h:911
PetscReal mom_resid_rtol
Definition variables.h:902
PetscReal mom_resid_atol
Definition variables.h:902
MomentumSolverType mom_solver_type
Definition variables.h:900
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestFieldCatalogMetadataAndViews()

static PetscErrorCode TestFieldCatalogMetadataAndViews ( void  )
static

Verifies catalog completeness, stable name resolution, and runtime view binding.

Definition at line 410 of file test_setup_lifecycle.c.

411{
412 SimCtx *simCtx = NULL;
413 UserCtx *user = NULL;
414 FieldId parsed_id = FIELD_ID_INVALID;
415 FieldView view;
416 const FieldDescriptor *descriptor = NULL;
417 Vec coordinates = NULL;
418 Vec local_coordinates = NULL;
419 PetscErrorCode unknown_name_ierr;
420 PetscErrorCode unavailable_view_ierr;
421
422 PetscFunctionBeginUser;
423 PetscCall(PicurvCreateMinimalContexts(&simCtx, &user, 4, 4, 4));
424
425 for (PetscInt raw_id = 0; raw_id < FIELD_ID_COUNT; ++raw_id) {
426 PetscCall(FieldGetDescriptor((FieldId)raw_id, &descriptor));
427 PetscCall(PicurvAssertIntEqual(raw_id, (PetscInt)descriptor->id,
428 "catalog entry should retain its declared FieldId"));
429 PetscCall(PicurvAssertBool((PetscBool)(descriptor->canonical_name != NULL &&
430 descriptor->canonical_name[0] != '\0'),
431 "every field descriptor should have a canonical name"));
432 PetscCall(PicurvAssertBool((PetscBool)(descriptor->dof == 1 ||
433 descriptor->dof == 2 ||
434 descriptor->dof == 3),
435 "every ghost-updatable catalog field should declare a supported dof"));
436 PetscCall(PicurvAssertBool((PetscBool)((descriptor->capabilities &
438 "every phase-one field should advertise ghost-update capability"));
439 PetscCall(FieldIdFromName(descriptor->canonical_name, &parsed_id));
440 PetscCall(PicurvAssertIntEqual(raw_id, (PetscInt)parsed_id,
441 "canonical field names should round-trip to their IDs"));
442 PetscCall(PicurvAssertBool((PetscBool)(strcmp(FieldCanonicalName((FieldId)raw_id),
443 descriptor->canonical_name) == 0),
444 "FieldCanonicalName should return catalog-owned canonical text"));
445 }
446
447 PetscCall(FieldIdFromName("eddy viscosity", &parsed_id));
448 PetscCall(PicurvAssertIntEqual(FIELD_ID_NU_T, parsed_id,
449 "Nu_t compatibility alias should resolve case-insensitively"));
450 PetscCall(FieldIdFromName("cs", &parsed_id));
451 PetscCall(PicurvAssertIntEqual(FIELD_ID_CS, parsed_id,
452 "CS compatibility alias should resolve case-insensitively"));
453 PetscCall(FieldIdFromName("X-Face-Centers", &parsed_id));
454 PetscCall(PicurvAssertIntEqual(FIELD_ID_CENTX, parsed_id,
455 "diagnostic face-center name should resolve to the canonical field"));
456
457 PetscCall(FieldGetDescriptor(FIELD_ID_UCONT, &descriptor));
459 "Ucont should retain component-staggered topology metadata"));
461 "Ucont should retain component-staggered ghost repair metadata"));
462 PetscCall(FieldGetDescriptor(FIELD_ID_CSI, &descriptor));
463 PetscCall(PicurvAssertIntEqual(FIELD_LAYOUT_I_FACE, descriptor->layout,
464 "Csi should retain I-face topology metadata"));
466 "Csi should retain I-face ghost repair metadata"));
467 PetscCall(FieldGetDescriptor(FIELD_ID_IAJ, &descriptor));
468 PetscCall(PicurvAssertIntEqual(1, descriptor->dof,
469 "IAj should retain scalar face-field metadata"));
470
471 PetscCall(FieldGetView(user, FIELD_ID_P, &view));
472 PetscCall(PicurvAssertBool((PetscBool)(view.dm == user->da &&
473 view.global_vec == user->P &&
474 view.local_vec == user->lP),
475 "P field view should bind the existing scalar DM and Vec pair"));
476 PetscCall(FieldGetView(user, FIELD_ID_UCAT, &view));
477 PetscCall(PicurvAssertBool((PetscBool)(view.dm == user->fda &&
478 view.global_vec == user->Ucat &&
479 view.local_vec == user->lUcat),
480 "Ucat field view should bind the existing vector DM and Vec pair"));
481
482 PetscCall(DMGetCoordinates(user->da, &coordinates));
483 PetscCall(DMGetCoordinatesLocal(user->da, &local_coordinates));
484 PetscCall(FieldGetView(user, FIELD_ID_COORDINATES, &view));
485 PetscCall(PicurvAssertBool((PetscBool)(view.dm == user->fda &&
486 view.global_vec == coordinates &&
487 view.local_vec == local_coordinates),
488 "coordinate field view should bind PETSc-owned coordinate vectors"));
489
490 PetscCall(PetscPushErrorHandler(PetscIgnoreErrorHandler, NULL));
491 unknown_name_ierr = FieldIdFromName("NotARegisteredEulerianField", &parsed_id);
492 PetscCall(PetscPopErrorHandler());
493 PetscCall(PicurvAssertIntEqual(PETSC_ERR_ARG_UNKNOWN_TYPE, unknown_name_ierr,
494 "unknown field names should fail at the name-ingress boundary"));
495 PetscCall(PicurvAssertIntEqual(FIELD_ID_INVALID, parsed_id,
496 "failed field-name resolution should return FIELD_ID_INVALID"));
497
498 PetscCall(PetscPushErrorHandler(PetscIgnoreErrorHandler, NULL));
499 unavailable_view_ierr = FieldGetView(user, FIELD_ID_K_OMEGA, &view);
500 PetscCall(PetscPopErrorHandler());
501 PetscCall(PicurvAssertIntEqual(PETSC_ERR_ARG_WRONGSTATE, unavailable_view_ierr,
502 "catalogued optional fields without storage should report unavailable state"));
503
504 PetscCall(PicurvDestroyMinimalContexts(&simCtx, &user));
505 PetscFunctionReturn(0);
506}
FieldLayout layout
PetscErrorCode FieldIdFromName(const char *field_name, FieldId *field_id)
Resolve a user-facing field name once into its typed identity.
@ FIELD_CAPABILITY_GHOST_UPDATE
@ FIELD_SYNC_COMPONENT_STAGGERED
@ FIELD_SYNC_I_FACE
unsigned int capabilities
const char * FieldCanonicalName(FieldId field_id)
Return the canonical printable name for an ID.
PetscErrorCode FieldGetView(UserCtx *user, FieldId field_id, FieldView *view)
Resolve the existing DM and global/local vectors for one field.
@ FIELD_LAYOUT_I_FACE
@ FIELD_LAYOUT_COMPONENT_STAGGERED
const char * canonical_name
FieldSyncClass sync_class
PetscErrorCode FieldGetDescriptor(FieldId field_id, const FieldDescriptor **descriptor)
Return immutable metadata for a valid field identifier.
FieldId
Compile-time identity for a catalogued Eulerian field.
@ FIELD_ID_CSI
@ FIELD_ID_IAJ
@ FIELD_ID_UCAT
@ FIELD_ID_COORDINATES
@ FIELD_ID_K_OMEGA
@ FIELD_ID_NU_T
@ FIELD_ID_UCONT
@ FIELD_ID_CS
@ FIELD_ID_INVALID
@ FIELD_ID_P
@ FIELD_ID_CENTX
@ FIELD_ID_COUNT
Immutable metadata for one field identity.
Non-owning runtime objects resolved for one field and UserCtx.
Vec lUcat
Definition variables.h:1111
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestParticleFieldCatalogMetadata()

static PetscErrorCode TestParticleFieldCatalogMetadata ( void  )
static

Verifies the separate DMSwarm field catalog and its Eulerian bridge metadata.

Definition at line 511 of file test_setup_lifecycle.c.

512{
514 const ParticleFieldDescriptor *descriptor = NULL;
515 PetscErrorCode unknown_name_ierr;
516
517 PetscFunctionBeginUser;
518 for (PetscInt raw_id = 0; raw_id < PARTICLE_FIELD_ID_COUNT; ++raw_id) {
519 PetscCall(ParticleFieldGetDescriptor((ParticleFieldId)raw_id, &descriptor));
520 PetscCall(PicurvAssertIntEqual(raw_id, (PetscInt)descriptor->id,
521 "particle catalog entry should retain its declared ID"));
522 PetscCall(PicurvAssertBool((PetscBool)(descriptor->canonical_name != NULL &&
523 descriptor->canonical_name[0] != '\0'),
524 "every particle field should have a canonical DMSwarm name"));
525 PetscCall(PicurvAssertBool((PetscBool)(descriptor->components == 1 ||
526 descriptor->components == 3),
527 "persistent particle fields should declare one or three components"));
528 PetscCall(ParticleFieldIdFromName(descriptor->canonical_name, &parsed_id));
529 PetscCall(PicurvAssertIntEqual(raw_id, (PetscInt)parsed_id,
530 "canonical particle field names should round-trip to their IDs"));
531 PetscCall(PicurvAssertBool((PetscBool)(strcmp(ParticleFieldName((ParticleFieldId)raw_id),
532 descriptor->canonical_name) == 0),
533 "ParticleFieldName should return catalog-owned PETSc text"));
534 }
535
536 PetscCall(ParticleFieldIdFromName("particlevelocity", &parsed_id));
538 "particle velocity alias should resolve case-insensitively"));
539 PetscCall(ParticleFieldIdFromName("Migration Status", &parsed_id));
541 "migration-status output alias should resolve to the PETSc field"));
542
543 PetscCall(ParticleFieldGetDescriptor(PARTICLE_FIELD_ID_PSI, &descriptor));
544 PetscCall(PicurvAssertBool((PetscBool)((descriptor->capabilities &
546 "Psi should advertise its active particle-to-Eulerian scatter"));
548 "particle Psi should target Eulerian Psi"));
549 PetscCall(ParticleFieldGetDescriptor(PARTICLE_FIELD_ID_PID, &descriptor));
551 "particle IDs should be marked as PETSc-managed"));
552 PetscCall(PicurvAssertIntEqual(PETSC_INT64, descriptor->data_type,
553 "particle IDs should retain 64-bit storage metadata"));
554
555 PetscCall(PetscPushErrorHandler(PetscIgnoreErrorHandler, NULL));
556 unknown_name_ierr = ParticleFieldIdFromName("NotARegisteredParticleField", &parsed_id);
557 PetscCall(PetscPopErrorHandler());
558 PetscCall(PicurvAssertIntEqual(PETSC_ERR_ARG_UNKNOWN_TYPE, unknown_name_ierr,
559 "unknown particle names should fail at the text-ingress boundary"));
561 "failed particle name resolution should return the invalid ID"));
562 PetscFunctionReturn(0);
563}
@ FIELD_ID_PSI
const char * ParticleFieldName(ParticleFieldId field_id)
Return the canonical PETSc DMSwarm name for an ID.
ParticleFieldId
Compile-time identity for a persistent solver-particle field.
@ PARTICLE_FIELD_ID_LOCATION_STATUS
@ PARTICLE_FIELD_ID_PID
@ PARTICLE_FIELD_ID_PSI
@ PARTICLE_FIELD_ID_COUNT
@ PARTICLE_FIELD_ID_INVALID
@ PARTICLE_FIELD_ID_VELOCITY
ParticleFieldRegistration registration
PetscErrorCode ParticleFieldIdFromName(const char *field_name, ParticleFieldId *field_id)
Resolve a canonical name or registered alias at a text-ingress boundary.
@ PARTICLE_FIELD_CAPABILITY_EULERIAN_SCATTER
@ PARTICLE_FIELD_REGISTRATION_PETSC
PetscErrorCode ParticleFieldGetDescriptor(ParticleFieldId field_id, const ParticleFieldDescriptor **descriptor)
Return immutable metadata for a valid particle field ID.
Immutable metadata for one persistent particle field.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestFieldCatalogTypedGhostUpdates()

static PetscErrorCode TestFieldCatalogTypedGhostUpdates ( void  )
static

Verifies typed ghost updates preserve scalar, vector, face, and staggered behavior.

Definition at line 568 of file test_setup_lifecycle.c.

569{
570 SimCtx *simCtx = NULL;
571 UserCtx *user = NULL;
572
573 PetscFunctionBeginUser;
574 PetscCall(PicurvCreateMinimalContexts(&simCtx, &user, 4, 4, 4));
575
576 PetscCall(VecSet(user->P, 4.25));
577 PetscCall(VecSet(user->lP, -1.0));
578 PetscCall(UpdateLocalGhosts(user, FIELD_ID_P));
579 PetscCall(PicurvAssertVecConstant(user->lP, 4.25, 1.0e-12,
580 "typed scalar ghost update should scatter P"));
581
582 PetscCall(VecSet(user->Ucat, 7.5));
583 PetscCall(VecSet(user->lUcat, -1.0));
584 PetscCall(UpdateLocalGhosts(user, FIELD_ID_UCAT));
585 PetscCall(PicurvAssertVecConstant(user->lUcat, 7.5, 1.0e-12,
586 "typed cell-vector ghost update should scatter Ucat"));
587
588 PetscCall(VecSet(user->IAj, 2.0));
589 PetscCall(VecSet(user->lIAj, -1.0));
590 PetscCall(UpdateLocalGhosts(user, FIELD_ID_IAJ));
591 PetscCall(PicurvAssertVecConstant(user->lIAj, 2.0, 1.0e-12,
592 "typed scalar face-field ghost update should scatter IAj"));
593
594 PetscCall(VecSet(user->Ucont, 3.0));
595 PetscCall(VecSet(user->lUcont, -1.0));
596 PetscCall(UpdateLocalGhosts(user, FIELD_ID_UCONT));
597 PetscCall(PicurvAssertVecConstant(user->lUcont, 3.0, 1.0e-12,
598 "typed component-staggered ghost update should scatter Ucont"));
599
600 PetscCall(PicurvDestroyMinimalContexts(&simCtx, &user));
601 PetscFunctionReturn(0);
602}
PetscErrorCode UpdateLocalGhosts(UserCtx *user, FieldId field_id)
Updates the local vector (including ghost points) from its corresponding global vector.
Definition setup.c:2451
PetscErrorCode PicurvAssertVecConstant(Vec vec, PetscScalar expected, PetscReal tol, const char *context)
Asserts that a PETSc vector is spatially constant within tolerance.
Vec lUcont
Definition variables.h:1111
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Runs the unit-setup PETSc test binary.

Definition at line 607 of file test_setup_lifecycle.c.

608{
609 PetscErrorCode ierr;
610 const PicurvTestCase cases[] = {
611 {"setup-lifecycle-core-solver-setup", TestSetupLifecycleCoreSolverSetup},
612 {"setup-lifecycle-particle-initialization", TestSetupLifecycleParticleInitialization},
613 {"setup-lifecycle-scatter-metrics-step-zero", TestSetupLifecycleScatterMetricsAtStepZero},
614 {"setup-lifecycle-random-generators-and-cleanup", TestSetupLifecycleRandomGeneratorsAndCleanup},
615 {"setup-lifecycle-cleanup-across-initialization-states", TestSetupLifecycleCleanupAcrossInitializationStates},
616 {"shared-runtime-fixture-contracts", TestSharedRuntimeFixtureContracts},
617 {"field-catalog-metadata-and-views", TestFieldCatalogMetadataAndViews},
618 {"particle-field-catalog-metadata", TestParticleFieldCatalogMetadata},
619 {"field-catalog-typed-ghost-updates", TestFieldCatalogTypedGhostUpdates},
620 };
621
622 ierr = PetscInitialize(&argc, &argv, NULL, "PICurv setup lifecycle tests");
623 if (ierr) {
624 return (int)ierr;
625 }
626
627 ierr = PicurvRunTests("unit-setup", cases, sizeof(cases) / sizeof(cases[0]));
628 if (ierr) {
629 PetscFinalize();
630 return (int)ierr;
631 }
632
633 ierr = PetscFinalize();
634 return (int)ierr;
635}
static PetscErrorCode TestParticleFieldCatalogMetadata(void)
Verifies the separate DMSwarm field catalog and its Eulerian bridge metadata.
static PetscErrorCode TestSetupLifecycleScatterMetricsAtStepZero(void)
Tests that step-zero scalar verification emits scatter_metrics.csv during initialized setup.
static PetscErrorCode TestFieldCatalogMetadataAndViews(void)
Verifies catalog completeness, stable name resolution, and runtime view binding.
static PetscErrorCode TestSetupLifecycleRandomGeneratorsAndCleanup(void)
Tests standalone RNG initialization helpers and minimal-context cleanup.
static PetscErrorCode TestSetupLifecycleParticleInitialization(void)
Tests particle-swarm initialization and deterministic settlement on a tiny fully initialized case.
static PetscErrorCode TestSetupLifecycleCoreSolverSetup(void)
Tests the core setup lifecycle through environment, grid, BC, rank-info, and Eulerian-state initializ...
static PetscErrorCode TestSharedRuntimeFixtureContracts(void)
Tests that the shared richer runtime fixture mirrors normalized production setup contracts.
static PetscErrorCode TestFieldCatalogTypedGhostUpdates(void)
Verifies typed ghost updates preserve scalar, vector, face, and staggered behavior.
static PetscErrorCode TestSetupLifecycleCleanupAcrossInitializationStates(void)
Tests cleanup after partial and fuller setup states without requiring unsupported double-finalization...
PetscErrorCode PicurvRunTests(const char *suite_name, const PicurvTestCase *cases, size_t case_count)
Runs a named C test suite and prints pass/fail progress markers.
Named test case descriptor consumed by PicurvRunTests.
Here is the call graph for this function: