PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
Loading...
Searching...
No Matches
test_setup_lifecycle.c
Go to the documentation of this file.
1/**
2 * @file test_setup_lifecycle.c
3 * @brief C unit tests for setup, initialization, and cleanup lifecycle entry points.
4 */
5
6#include "test_support.h"
7
8#include "ParticleSwarm.h"
9#include "initialcondition.h"
10#include "runloop.h"
11#include "setup.h"
12
13#include <stdio.h>
14#include <string.h>
15
16/**
17 * @brief Asserts that a directory path exists and is readable.
18 */
19static PetscErrorCode AssertDirectoryExists(const char *path, const char *context)
20{
21 PetscBool exists = PETSC_FALSE;
22
23 PetscFunctionBeginUser;
24 PetscCall(PetscTestDirectory(path, 'r', &exists));
25 PetscCall(PicurvAssertBool(exists, context));
26 PetscFunctionReturn(0);
27}
28
29/**
30 * @brief Writes one small temporary text file used by the partial-lifecycle context-only fixture.
31 */
32static PetscErrorCode WriteContextOnlyFile(const char *path, const char *contents)
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}
43
44/**
45 * @brief Creates the control-file bundle needed for the context-only cleanup test.
46 */
47static PetscErrorCode PrepareContextOnlyConfig(char *tmpdir,
48 size_t tmpdir_len,
49 char *control_path,
50 size_t control_path_len)
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 EXPLICIT_RK\n"
112 "-mg_level 1\n"
113 "-poisson 0\n"
114 "-tio 0\n"
115 "-particle_console_output_freq 0\n"
116 "-logfreq 1\n"
117 "-output_dir %s\n"
118 "-restart_dir %s\n"
119 "-log_dir %s\n"
120 "-numParticles 0\n"
121 "-pinit 2\n",
122 bcs_path,
123 post_path,
124 output_dir,
125 output_dir,
126 log_dir));
127 PetscCall(WriteContextOnlyFile(control_path, control_buffer));
128 PetscFunctionReturn(0);
129}
130
131/**
132 * @brief Finalizes and frees one lifecycle test context, then clears any PETSc options used to build it.
133 */
134static PetscErrorCode FreeLifecycleContext(SimCtx **simCtx_ptr)
135{
136 PetscFunctionBeginUser;
137 PetscCall(PicurvDestroyRuntimeContext(simCtx_ptr));
138 PetscFunctionReturn(0);
139}
140
141/**
142 * @brief Builds a full setup fixture through environment, grid, BC, and domain-rank initialization.
143 */
144static PetscErrorCode BuildLifecycleContext(PetscBool enable_particles, SimCtx **simCtx_out, char *tmpdir, size_t tmpdir_len)
145{
146 PetscFunctionBeginUser;
147 PetscCall(PicurvBuildTinyRuntimeContext(NULL, enable_particles, simCtx_out, NULL, tmpdir, tmpdir_len));
148 PetscFunctionReturn(0);
149}
150
151/**
152 * @brief Builds only the top-level simulation context used by partial-initialization cleanup tests.
153 */
154static PetscErrorCode BuildContextOnly(SimCtx **simCtx_out, char *tmpdir, size_t tmpdir_len)
155{
156 char control_path[PETSC_MAX_PATH_LEN];
157 SimCtx *simCtx = NULL;
158
159 PetscFunctionBeginUser;
160 PetscCall(PetscOptionsClear(NULL));
161 PetscCall(PrepareContextOnlyConfig(tmpdir, tmpdir_len, control_path, sizeof(control_path)));
162 PetscCall(PetscOptionsSetValue(NULL, "-control_file", control_path));
163 PetscCall(CreateSimulationContext(0, NULL, &simCtx));
164 simCtx->exec_mode = EXEC_MODE_SOLVER;
165 *simCtx_out = simCtx;
166 PetscFunctionReturn(0);
167}
168
169/**
170 * @brief Tests that the shared richer runtime fixture mirrors normalized production setup contracts.
171 */
172static PetscErrorCode TestSharedRuntimeFixtureContracts(void)
173{
174 SimCtx *simCtx = NULL;
175 UserCtx *user = NULL;
176 char tmpdir[PETSC_MAX_PATH_LEN];
177
178 PetscFunctionBeginUser;
179 PetscCall(PicurvBuildTinyRuntimeContext(NULL, PETSC_FALSE, &simCtx, &user, tmpdir, sizeof(tmpdir)));
180
181 PetscCall(PicurvAssertBool((PetscBool)(user->bbox.min_coords.x >= -2.0e-6), "runtime fixture bbox xmin should stay inside normalized domain tolerance"));
182 PetscCall(PicurvAssertBool((PetscBool)(user->bbox.max_coords.x <= 1.0 + 2.0e-6), "runtime fixture bbox xmax should stay inside normalized domain tolerance"));
183 PetscCall(PicurvAssertBool((PetscBool)(user->bbox.max_coords.y <= 1.0 + 2.0e-6), "runtime fixture bbox ymax should stay inside normalized domain tolerance"));
184 PetscCall(PicurvAssertBool((PetscBool)(user->bbox.max_coords.z <= 1.0 + 2.0e-6), "runtime fixture bbox zmax should stay inside normalized domain tolerance"));
185 PetscCall(PicurvAssertBool((PetscBool)(simCtx->bboxlist != NULL), "runtime fixture should gather bboxlist through SetupDomainRankInfo"));
186 PetscCall(PicurvAssertBool((PetscBool)(user->RankCellInfoMap != NULL), "runtime fixture should gather rank-cell ownership metadata"));
187 PetscCall(PicurvAssertBool((PetscBool)(simCtx->bboxlist[simCtx->rank].max_coords.x >= user->bbox.max_coords.x - 1.0e-10),
188 "runtime fixture rank bbox entry should include the local bbox extent"));
189
190 PetscCall(PicurvRemoveTempDir(tmpdir));
191 PetscCall(FreeLifecycleContext(&simCtx));
192 PetscFunctionReturn(0);
193}
194
195/**
196 * @brief Tests the core setup lifecycle through environment, grid, BC, rank-info, and Eulerian-state initialization.
197 */
198static PetscErrorCode TestSetupLifecycleCoreSolverSetup(void)
199{
200 SimCtx *simCtx = NULL;
201 UserCtx *user = NULL;
202 char tmpdir[PETSC_MAX_PATH_LEN];
203 char results_dir[PETSC_MAX_PATH_LEN];
204 char logs_dir[PETSC_MAX_PATH_LEN];
205 Cmpnts ***ucont = NULL;
206
207 PetscFunctionBeginUser;
208 PetscCall(BuildLifecycleContext(PETSC_FALSE, &simCtx, tmpdir, sizeof(tmpdir)));
209 user = simCtx->usermg.mgctx[simCtx->usermg.mglevels - 1].user;
210
211 PetscCall(PetscSNPrintf(results_dir, sizeof(results_dir), "%s/results", tmpdir));
212 PetscCall(PetscSNPrintf(logs_dir, sizeof(logs_dir), "%s/logs", tmpdir));
213 PetscCall(PicurvAssertBool((PetscBool)(user->da != NULL), "SetupGridAndSolvers should allocate da"));
214 PetscCall(PicurvAssertBool((PetscBool)(user->fda != NULL), "SetupGridAndSolvers should allocate coordinate DM"));
215 PetscCall(PicurvAssertIntEqual(user->IM + 1, user->info.mx, "DM node count should match IM+1"));
216 PetscCall(PicurvAssertBool(user->inletFaceDefined, "SetupBoundaryConditions should identify the inlet face"));
217 PetscCall(PicurvAssertIntEqual(BC_FACE_NEG_Z, user->identifiedInletBCFace, "NEG_Z should be the configured inlet face"));
218 PetscCall(PicurvAssertBool((PetscBool)(simCtx->bboxlist != NULL), "SetupDomainRankInfo should build bboxlist"));
219 PetscCall(PicurvAssertBool((PetscBool)(user->RankCellInfoMap != NULL), "SetupDomainRankInfo should build rank-cell decomposition map"));
220 PetscCall(AssertDirectoryExists(results_dir, "SetupSimulationEnvironment should create the output directory"));
221 PetscCall(AssertDirectoryExists(logs_dir, "SetupSimulationEnvironment should create the log directory"));
222
223 PetscCall(InitializeEulerianState(simCtx));
224 PetscCall(DMDAVecGetArrayRead(user->fda, user->Ucont, &ucont));
225 PetscCall(PicurvAssertBool((PetscBool)(ucont[1][1][1].z > 0.0),
226 "InitializeEulerianState should seed a positive inlet-aligned interior field"));
227 PetscCall(PicurvAssertRealNear(ucont[1][1][1].z, ucont[2][2][2].z, 1.0e-12,
228 "InitializeEulerianState should initialize a spatially consistent interior field"));
229 PetscCall(DMDAVecRestoreArrayRead(user->fda, user->Ucont, &ucont));
230
231 PetscCall(PicurvRemoveTempDir(tmpdir));
232 PetscCall(FreeLifecycleContext(&simCtx));
233 PetscFunctionReturn(0);
234}
235
236/**
237 * @brief Tests particle-swarm initialization and deterministic settlement on a tiny fully initialized case.
238 */
240{
241 SimCtx *simCtx = NULL;
242 UserCtx *user = NULL;
243 char tmpdir[PETSC_MAX_PATH_LEN];
244 PetscInt nlocal = 0;
245 PetscInt *cell_ids = NULL;
246 PetscInt *status = NULL;
247
248 PetscFunctionBeginUser;
249 PetscCall(BuildLifecycleContext(PETSC_TRUE, &simCtx, tmpdir, sizeof(tmpdir)));
250 PetscCall(InitializeEulerianState(simCtx));
251 PetscCall(InitializeParticleSwarm(simCtx));
252 PetscCall(PerformInitializedParticleSetup(simCtx));
253
254 user = simCtx->usermg.mgctx[simCtx->usermg.mglevels - 1].user;
255 PetscCall(PicurvAssertBool((PetscBool)(user->swarm != NULL), "InitializeParticleSwarm should allocate the solver swarm"));
256 PetscCall(DMSwarmGetLocalSize(user->swarm, &nlocal));
257 PetscCall(PicurvAssertIntEqual(8, nlocal, "single-rank lifecycle particle setup should own all seeded particles"));
258
259 PetscCall(DMSwarmGetField(user->swarm, "DMSwarm_CellID", NULL, NULL, (void **)&cell_ids));
260 PetscCall(DMSwarmGetField(user->swarm, "DMSwarm_location_status", NULL, NULL, (void **)&status));
261 for (PetscInt p = 0; p < nlocal; ++p) {
262 PetscCall(PicurvAssertBool((PetscBool)(cell_ids[3 * p + 0] >= 0), "settled particles should have a valid i cell id"));
263 PetscCall(PicurvAssertBool((PetscBool)(cell_ids[3 * p + 1] >= 0), "settled particles should have a valid j cell id"));
264 PetscCall(PicurvAssertBool((PetscBool)(cell_ids[3 * p + 2] >= 0), "settled particles should have a valid k cell id"));
265 PetscCall(PicurvAssertIntEqual(ACTIVE_AND_LOCATED, status[p], "settled particles should be marked ACTIVE_AND_LOCATED"));
266 }
267 PetscCall(DMSwarmRestoreField(user->swarm, "DMSwarm_CellID", NULL, NULL, (void **)&cell_ids));
268 PetscCall(DMSwarmRestoreField(user->swarm, "DMSwarm_location_status", NULL, NULL, (void **)&status));
269
270 PetscCall(PicurvRemoveTempDir(tmpdir));
271 PetscCall(FreeLifecycleContext(&simCtx));
272 PetscFunctionReturn(0);
273}
274
275/**
276 * @brief Tests standalone RNG initialization helpers and minimal-context cleanup.
277 */
279{
280 SimCtx *simCtx = NULL;
281 UserCtx *user = NULL;
282 PetscRandom randx = NULL, randy = NULL, randz = NULL;
283 PetscRandom rand_i = NULL, rand_j = NULL, rand_k = NULL;
284 PetscScalar sample_x = 0.0, sample_i = 0.0;
285 PetscReal seconds = 0.0;
286
287 PetscFunctionBeginUser;
288 PetscCall(PicurvCreateMinimalContexts(&simCtx, &user, 4, 4, 4));
289 user->bbox.min_coords.x = 0.0;
290 user->bbox.min_coords.y = 0.0;
291 user->bbox.min_coords.z = 0.0;
292 user->bbox.max_coords.x = 1.0;
293 user->bbox.max_coords.y = 2.0;
294 user->bbox.max_coords.z = 3.0;
295
296 PetscCall(InitializeRandomGenerators(user, &randx, &randy, &randz));
297 PetscCall(InitializeLogicalSpaceRNGs(&rand_i, &rand_j, &rand_k));
298 PetscCall(InitializeBrownianRNG(simCtx));
299 PetscCall(PicurvAssertBool((PetscBool)(simCtx->BrownianMotionRNG != NULL), "InitializeBrownianRNG should allocate the Brownian RNG"));
300 PetscCall(PicurvAssertBool(RuntimeWalltimeGuardParsePositiveSeconds("12.5", &seconds), "RuntimeWalltimeGuardParsePositiveSeconds should parse positive numeric strings"));
301 PetscCall(PicurvAssertRealNear(12.5, seconds, 1.0e-12, "RuntimeWalltimeGuardParsePositiveSeconds parsed value"));
302
303 PetscCall(PetscRandomGetValue(randx, &sample_x));
304 PetscCall(PetscRandomGetValue(rand_i, &sample_i));
305 PetscCall(PicurvAssertBool((PetscBool)(PetscRealPart(sample_x) >= 0.0 && PetscRealPart(sample_x) <= 1.0),
306 "InitializeRandomGenerators should honor the configured bbox interval"));
307 PetscCall(PicurvAssertBool((PetscBool)(PetscRealPart(sample_i) >= 0.0 && PetscRealPart(sample_i) <= 1.0),
308 "InitializeLogicalSpaceRNGs should generate logical coordinates in [0,1]"));
309
310 PetscCall(PetscRandomDestroy(&randx));
311 PetscCall(PetscRandomDestroy(&randy));
312 PetscCall(PetscRandomDestroy(&randz));
313 PetscCall(PetscRandomDestroy(&rand_i));
314 PetscCall(PetscRandomDestroy(&rand_j));
315 PetscCall(PetscRandomDestroy(&rand_k));
316 PetscCall(PicurvDestroyMinimalContexts(&simCtx, &user));
317 PetscFunctionReturn(0);
318}
319
320/**
321 * @brief Tests cleanup after partial and fuller setup states without requiring unsupported double-finalization behavior.
322 */
324{
325 SimCtx *context_only = NULL;
326 SimCtx *grid_only = NULL;
327 char context_tmpdir[PETSC_MAX_PATH_LEN];
328 char grid_tmpdir[PETSC_MAX_PATH_LEN];
329
330 PetscFunctionBeginUser;
331 PetscCall(BuildContextOnly(&context_only, context_tmpdir, sizeof(context_tmpdir)));
332 PetscCall(PicurvAssertBool((PetscBool)(context_only != NULL), "CreateSimulationContext should allocate the top-level SimCtx"));
333 PetscCall(PicurvAssertIntEqual(1, context_only->block_number, "CreateSimulationContext should parse the configured block count"));
334 PetscCall(PetscOptionsClear(NULL));
335 PetscCall(PicurvRemoveTempDir(context_tmpdir));
336 PetscCall(FreeLifecycleContext(&context_only));
337
338 PetscCall(BuildContextOnly(&grid_only, grid_tmpdir, sizeof(grid_tmpdir)));
339 PetscCall(SetupSimulationEnvironment(grid_only));
340 PetscCall(SetupGridAndSolvers(grid_only));
341 PetscCall(PicurvAssertBool((PetscBool)(grid_only->usermg.mgctx[grid_only->usermg.mglevels - 1].user->Ucont != NULL),
342 "SetupGridAndSolvers should allocate baseline Eulerian vectors"));
343 PetscCall(PicurvRemoveTempDir(grid_tmpdir));
344 PetscCall(FreeLifecycleContext(&grid_only));
345 PetscFunctionReturn(0);
346}
347
348/**
349 * @brief Runs the unit-setup PETSc test binary.
350 */
351int main(int argc, char **argv)
352{
353 PetscErrorCode ierr;
354 const PicurvTestCase cases[] = {
355 {"setup-lifecycle-core-solver-setup", TestSetupLifecycleCoreSolverSetup},
356 {"setup-lifecycle-particle-initialization", TestSetupLifecycleParticleInitialization},
357 {"setup-lifecycle-random-generators-and-cleanup", TestSetupLifecycleRandomGeneratorsAndCleanup},
358 {"setup-lifecycle-cleanup-across-initialization-states", TestSetupLifecycleCleanupAcrossInitializationStates},
359 {"shared-runtime-fixture-contracts", TestSharedRuntimeFixtureContracts},
360 };
361
362 ierr = PetscInitialize(&argc, &argv, NULL, "PICurv setup lifecycle tests");
363 if (ierr) {
364 return (int)ierr;
365 }
366
367 ierr = PicurvRunTests("unit-setup", cases, sizeof(cases) / sizeof(cases[0]));
368 if (ierr) {
369 PetscFinalize();
370 return (int)ierr;
371 }
372
373 ierr = PetscFinalize();
374 return (int)ierr;
375}
Header file for Particle Swarm management functions.
PetscErrorCode InitializeParticleSwarm(SimCtx *simCtx)
High-level particle initialization orchestrator for a simulation run.
PetscErrorCode InitializeEulerianState(SimCtx *simCtx)
High-level orchestrator to set the complete initial state of the Eulerian solver.
PetscErrorCode PerformInitializedParticleSetup(SimCtx *simCtx)
Finalizes the simulation setup at t=0, ensuring a consistent state before time marching.
Definition runloop.c:366
PetscErrorCode InitializeRandomGenerators(UserCtx *user, PetscRandom *randx, PetscRandom *randy, PetscRandom *randz)
Initializes random number generators for assigning particle properties.
Definition setup.c:2539
PetscErrorCode SetupGridAndSolvers(SimCtx *simCtx)
The main orchestrator for setting up all grid-related components.
Definition setup.c:987
PetscErrorCode InitializeBrownianRNG(SimCtx *simCtx)
Initializes a single master RNG for time-stepping physics (Brownian motion).
Definition setup.c:2624
PetscErrorCode SetupSimulationEnvironment(SimCtx *simCtx)
Verifies and prepares the complete I/O environment for a simulation run.
Definition setup.c:694
PetscErrorCode CreateSimulationContext(int argc, char **argv, SimCtx **p_simCtx)
Allocates and populates the master SimulationContext object.
Definition setup.c:50
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:2580
PetscBool RuntimeWalltimeGuardParsePositiveSeconds(const char *text, PetscReal *seconds_out)
Parse a positive floating-point seconds value from runtime metadata.
Definition setup.c:18
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 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.
int main(int argc, char **argv)
Runs the unit-setup PETSc test binary.
static PetscErrorCode AssertDirectoryExists(const char *path, const char *context)
Asserts that a directory path exists and is readable.
static PetscErrorCode TestSetupLifecycleRandomGeneratorsAndCleanup(void)
Tests standalone RNG initialization helpers and minimal-context cleanup.
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 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 FreeLifecycleContext(SimCtx **simCtx_ptr)
Finalizes and frees one lifecycle test context, then clears any PETSc options used to build it.
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 TestSetupLifecycleCleanupAcrossInitializationStates(void)
Tests cleanup after partial and fuller setup states without requiring unsupported double-finalization...
PetscErrorCode PicurvMakeTempDir(char *path, size_t path_len)
Creates a unique temporary directory for one test case.
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 PicurvAssertRealNear(PetscReal expected, PetscReal actual, PetscReal tol, const char *context)
Asserts that two real values agree within tolerance.
PetscErrorCode PicurvDestroyMinimalContexts(SimCtx **simCtx_ptr, UserCtx **user_ptr)
Destroys minimal SimCtx/UserCtx fixtures and all owned PETSc objects.
PetscErrorCode PicurvDestroyRuntimeContext(SimCtx **simCtx_ptr)
Finalizes and frees a runtime context built by PicurvBuildTinyRuntimeContext.
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.
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.
PetscErrorCode PicurvAssertIntEqual(PetscInt expected, PetscInt actual, const char *context)
Asserts that two integer values are equal.
PetscErrorCode PicurvAssertBool(PetscBool value, const char *context)
Asserts that one boolean condition is true.
PetscErrorCode PicurvRemoveTempDir(const char *path)
Recursively removes a temporary directory created by PicurvMakeTempDir.
Shared declarations for the PICurv C test fixture and assertion layer.
Named test case descriptor consumed by PicurvRunTests.
UserCtx * user
Definition variables.h:487
PetscBool inletFaceDefined
Definition variables.h:783
PetscMPIInt rank
Definition variables.h:605
PetscInt block_number
Definition variables.h:667
BCFace identifiedInletBCFace
Definition variables.h:784
@ ACTIVE_AND_LOCATED
Definition variables.h:137
UserMG usermg
Definition variables.h:717
Cmpnts max_coords
Maximum x, y, z coordinates of the bounding box.
Definition variables.h:156
Vec Ucont
Definition variables.h:790
Cmpnts min_coords
Minimum x, y, z coordinates of the bounding box.
Definition variables.h:155
PetscScalar x
Definition variables.h:101
RankCellInfo * RankCellInfoMap
Definition variables.h:834
BoundingBox * bboxlist
Definition variables.h:697
PetscScalar z
Definition variables.h:101
PetscInt mglevels
Definition variables.h:494
PetscRandom BrownianMotionRNG
Definition variables.h:706
DMDALocalInfo info
Definition variables.h:771
PetscScalar y
Definition variables.h:101
@ EXEC_MODE_SOLVER
Definition variables.h:575
PetscInt IM
Definition variables.h:773
MGCtx * mgctx
Definition variables.h:497
ExecutionMode exec_mode
Definition variables.h:620
BoundingBox bbox
Definition variables.h:775
@ BC_FACE_NEG_Z
Definition variables.h:206
A 3D point or vector with PetscScalar components.
Definition variables.h:100
The master context for the entire simulation.
Definition variables.h:602
User-defined context containing data specific to a single computational grid level.
Definition variables.h:764