16static PetscReal
ScalarValue(PetscInt i, PetscInt j, PetscInt k)
18 return (PetscReal)(i + 10 * j + 100 * k);
25 PetscReal global_error = 0.0;
27 PetscFunctionBeginUser;
28 PetscCallMPI(MPI_Allreduce(&local_error, &global_error, 1, MPIU_REAL, MPI_MAX,
30 PetscCall(
PicurvAssertBool((PetscBool)(global_error <= tolerance), context));
31 PetscFunctionReturn(0);
40 PetscReal ***pressure = NULL;
42 const PetscReal ***pressure_result = NULL;
43 const PetscReal ***pressure_nodal = NULL;
44 const PetscReal ***qcrit = NULL;
45 const Cmpnts ***velocity_nodal = NULL;
46 PetscReal pressure_error = 0.0;
47 PetscReal pressure_nodal_error = 0.0;
48 PetscReal velocity_nodal_error = 0.0;
49 PetscReal qcrit_error = 0.0;
50 PetscInt local_physical_nodes = 0;
51 PetscInt global_physical_nodes = 0;
52 PetscInt local_q_points = 0;
53 PetscInt global_q_points = 0;
55 PetscFunctionBeginUser;
57 PetscCall(PetscCalloc1(1, &simCtx->
pps));
67 PetscCall(DMDAVecGetArray(user->
da, user->
P, &pressure));
68 PetscCall(DMDAVecGetArray(user->
fda, user->
Ucat, &velocity));
69 for (PetscInt k = user->
info.zs; k < user->
info.zs + user->
info.zm; ++k) {
70 for (PetscInt j = user->
info.ys; j < user->
info.ys + user->
info.ym; ++j) {
71 for (PetscInt i = user->
info.xs; i < user->
info.xs + user->
info.xm; ++i) {
73 velocity[k][j][i] = (
Cmpnts){1.0, 2.0, 3.0};
77 PetscCall(DMDAVecRestoreArray(user->
fda, user->
Ucat, &velocity));
78 PetscCall(DMDAVecRestoreArray(user->
da, user->
P, &pressure));
87 PetscCall(PetscStrncpy(
89 "NormalizeRelativeField:P;"
90 "CellToNodeAverage:P>P_nodal;CellToNodeAverage:Ucat>Ucat_nodal;"
95 PetscCall(DMDAVecGetArrayRead(user->
da, user->
P, &pressure_result));
96 PetscCall(DMDAVecGetArrayRead(user->
da, user->
P_nodal, &pressure_nodal));
97 PetscCall(DMDAVecGetArrayRead(user->
fda, user->
Ucat_nodal, &velocity_nodal));
98 PetscCall(DMDAVecGetArrayRead(user->
da, user->
Qcrit, &qcrit));
99 for (PetscInt k = user->
info.zs; k < user->
info.zs + user->
info.zm; ++k) {
100 for (PetscInt j = user->
info.ys; j < user->
info.ys + user->
info.ym; ++j) {
101 for (PetscInt i = user->
info.xs; i < user->
info.xs + user->
info.xm; ++i) {
102 const PetscBool physical_node =
103 (PetscBool)(i < user->info.mx - 1 && j < user->info.my - 1 &&
104 k < user->info.mz - 1);
105 const PetscBool q_point =
106 (PetscBool)(i >= 1 && i < user->info.mx - 1 &&
107 j >= 1 && j < user->info.my - 1 &&
108 k >= 1 && k < user->info.mz - 1);
109 const PetscReal expected_pressure = 2.0 * (
ScalarValue(i, j, k) - 111.0);
111 pressure_error = PetscMax(
113 PetscAbsReal(pressure_result[k][j][i] - expected_pressure));
115 const PetscReal expected_nodal =
118 pressure_nodal_error = PetscMax(
119 pressure_nodal_error,
120 PetscAbsReal(pressure_nodal[k][j][i] - expected_nodal));
121 velocity_nodal_error = PetscMax(
122 velocity_nodal_error,
123 PetscAbsReal(velocity_nodal[k][j][i].x - 1.0));
124 velocity_nodal_error = PetscMax(
125 velocity_nodal_error,
126 PetscAbsReal(velocity_nodal[k][j][i].y - 2.0));
127 velocity_nodal_error = PetscMax(
128 velocity_nodal_error,
129 PetscAbsReal(velocity_nodal[k][j][i].z - 3.0));
130 ++local_physical_nodes;
132 pressure_nodal_error = PetscMax(
133 pressure_nodal_error,
134 PetscAbsReal(pressure_nodal[k][j][i] -
kSentinel));
135 velocity_nodal_error = PetscMax(
136 velocity_nodal_error,
137 PetscAbsReal(velocity_nodal[k][j][i].x -
kSentinel));
138 velocity_nodal_error = PetscMax(
139 velocity_nodal_error,
140 PetscAbsReal(velocity_nodal[k][j][i].y -
kSentinel));
141 velocity_nodal_error = PetscMax(
142 velocity_nodal_error,
143 PetscAbsReal(velocity_nodal[k][j][i].z -
kSentinel));
145 qcrit_error = PetscMax(
147 PetscAbsReal(qcrit[k][j][i] - (q_point ? 0.0 :
kSentinel)));
148 if (q_point) ++local_q_points;
152 PetscCall(DMDAVecRestoreArrayRead(user->
da, user->
Qcrit, &qcrit));
153 PetscCall(DMDAVecRestoreArrayRead(user->
fda, user->
Ucat_nodal, &velocity_nodal));
154 PetscCall(DMDAVecRestoreArrayRead(user->
da, user->
P_nodal, &pressure_nodal));
155 PetscCall(DMDAVecRestoreArrayRead(user->
da, user->
P, &pressure_result));
157 PetscCallMPI(MPI_Allreduce(&local_physical_nodes, &global_physical_nodes, 1,
158 MPIU_INT, MPI_SUM, PETSC_COMM_WORLD));
159 PetscCallMPI(MPI_Allreduce(&local_q_points, &global_q_points, 1,
160 MPIU_INT, MPI_SUM, PETSC_COMM_WORLD));
162 global_physical_nodes,
163 "the Eulerian pipeline must visit every physical node exactly once"));
166 "Q-criterion must visit every interior cell exactly once"));
168 "pressure normalization and dimensionalization are decomposition independent"));
170 "scalar nodal averaging covers rank interfaces and physical boundaries"));
172 "vector nodal averaging covers rank interfaces and physical boundaries"));
174 "Q-criterion covers the complete distributed interior"));
177 PetscFunctionReturn(0);
186 PetscMPIInt rank = 0, size = 1;
187 PetscInt source_local = 0;
188 PetscInt source_global = 0;
189 PetscInt post_local = 0;
190 PetscInt post_global = 0;
192 PetscScalar (*velocity)[3] = NULL;
193 const PetscScalar *ske = NULL;
194 PetscReal local_error = 0.0;
195 const PetscInt total_particles = 7;
197 PetscFunctionBeginUser;
198 PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD, &rank));
199 PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD, &size));
200 source_local = total_particles / size + (rank < total_particles % size ? 1 : 0);
201 PetscCall(PetscMemzero(&pps,
sizeof(pps)));
210 PetscCallMPI(MPI_Exscan(&source_local, &offset, 1, MPIU_INT, MPI_SUM,
212 if (rank == 0) offset = 0;
214 PetscCall(DMSwarmGetField(user->
swarm,
"velocity", NULL, NULL, (
void **)&velocity));
215 for (PetscInt p = 0; p < source_local; ++p) {
216 const PetscReal tag = (PetscReal)(offset + p + 1);
218 velocity[p][0] = tag;
219 velocity[p][1] = 2.0;
220 velocity[p][2] = -1.0;
222 PetscCall(DMSwarmRestoreField(user->
swarm,
"velocity", NULL, NULL,
223 (
void **)&velocity));
226 PetscCall(DMSwarmGetLocalSize(user->
swarm, &source_local));
227 PetscCall(DMSwarmGetSize(user->
swarm, &source_global));
228 PetscCall(DMSwarmGetLocalSize(user->
post_swarm, &post_local));
229 PetscCall(DMSwarmGetSize(user->
post_swarm, &post_global));
231 "derived particle fields must share source local ownership"));
233 "derived and source swarms must have the same global size"));
235 PetscCall(DMSwarmGetField(user->
post_swarm,
"ske", NULL, NULL, (
void **)&ske));
236 for (PetscInt p = 0; p < source_local; ++p) {
237 const PetscReal tag = (PetscReal)(offset + p + 1);
238 const PetscReal expected = 0.5 * (tag * tag + 5.0);
240 local_error = PetscMax(local_error,
241 PetscAbsReal(PetscRealPart(ske[p]) - expected));
243 PetscCall(DMSwarmRestoreField(user->
post_swarm,
"ske", NULL, NULL, (
void **)&ske));
245 "specific kinetic energy must match every source particle"));
248 PetscFunctionReturn(0);
256 PetscMPIInt rank = 0, size = 1;
257 const PetscInt targets[] = {7, 3, 9, 0};
259 PetscFunctionBeginUser;
260 PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD, &rank));
261 PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD, &size));
265 for (
size_t target_index = 0;
266 target_index <
sizeof(targets) /
sizeof(targets[0]); ++target_index) {
269 const PetscInt target = targets[target_index];
270 const PetscInt expected_local =
271 target / size + (rank < target % size ? 1 : 0);
274 PetscCall(DMSwarmGetLocalSize(user->
swarm, &local));
275 PetscCall(DMSwarmGetSize(user->
swarm, &global));
277 "global swarm resize must use balanced local sizes"));
279 "global swarm resize must conserve the requested total"));
283 PetscFunctionReturn(0);
294 PetscReal ***pressure = NULL;
295 const PetscReal ***nodal = NULL;
297 PetscInt components = 0;
298 PetscInt local_checked = 0;
299 PetscInt global_checked = 0;
300 PetscReal local_error = 0.0;
303 PetscFunctionBeginUser;
304 PetscCall(PetscMemzero(&definition,
sizeof(definition)));
305 PetscCall(PetscStrncpy(definition.
name,
"analytic",
sizeof(definition.
name)));
313 PetscCall(VecSet(user->
Nvert, 0.0));
321 PetscCall(DMDAVecGetArray(user->
da, user->
P, &pressure));
322 for (PetscInt k = user->
info.zs; k < user->
info.zs + user->
info.zm; ++k)
323 for (PetscInt j = user->
info.ys; j < user->
info.ys + user->
info.ym; ++j)
324 for (PetscInt i = user->
info.xs; i < user->
info.xs + user->
info.xm; ++i)
326 PetscCall(DMDAVecRestoreArray(user->
da, user->
P, &pressure));
329 &result, &components));
331 "the pressure mean must derive as a scalar field"));
333 "the pressure mean must use the scalar nodal staging vector"));
335 PetscCall(DMDAVecGetArrayRead(user->
da, result, &nodal));
336 for (PetscInt k = PetscMax(user->
info.zs, 1);
337 k < PetscMin(user->
info.zs + user->
info.zm, user->
info.mz - 2); ++k) {
338 for (PetscInt j = PetscMax(user->
info.ys, 1);
339 j < PetscMin(user->
info.ys + user->
info.ym, user->
info.my - 2); ++j) {
340 for (PetscInt i = PetscMax(user->
info.xs, 1);
341 i < PetscMin(user->
info.xs + user->
info.xm, user->
info.mx - 2); ++i) {
342 local_error = PetscMax(
344 PetscAbsReal(nodal[k][j][i] - (
ScalarValue(i, j, k) + 55.5)));
349 PetscCall(DMDAVecRestoreArrayRead(user->
da, result, &nodal));
350 PetscCallMPI(MPI_Allreduce(&local_checked, &global_checked, 1, MPIU_INT, MPI_SUM,
354 "the derived mean must cover every fully resolved nodal point"));
356 "field-statistics nodal derivation must cross rank interfaces"));
364 PetscFunctionReturn(0);
381 const PetscBool over_ik[3] = {PETSC_TRUE, PETSC_FALSE, PETSC_TRUE};
382 PetscReal ***pressure = NULL, sums[3][64], reduced[3][64];
383 PetscMPIInt rank = 0;
384 char tmpdir[PETSC_MAX_PATH_LEN], prefix[PETSC_MAX_PATH_LEN + 16], path[PETSC_MAX_PATH_LEN + 64];
386 PetscFunctionBeginUser;
387 PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD, &rank));
388 PetscCall(PetscMemzero(&definition,
sizeof(definition)));
389 PetscCall(PetscStrncpy(definition.
name,
"plane",
sizeof(definition.
name)));
398 PetscCall(VecSet(user->
Nvert, 0.0));
399 PetscCall(VecSet(user->
lNvert, 0.0));
402 PetscCall(DMDAVecGetArray(user->
da, user->
P, &pressure));
403 for (PetscInt k = user->
info.zs; k < user->
info.zs + user->
info.zm; ++k)
404 for (PetscInt j = user->
info.ys; j < user->
info.ys + user->
info.ym; ++j)
405 for (PetscInt i = user->
info.xs; i < user->
info.xs + user->
info.xm; ++i)
407 PetscCall(DMDAVecRestoreArray(user->
da, user->
P, &pressure));
412 PetscCall(PetscMemzero(sums,
sizeof(sums)));
413 for (PetscInt k = plan.
start[2]; k < plan.
end[2]; ++k)
414 for (PetscInt j = plan.
start[1]; j < plan.
end[1]; ++j)
415 for (PetscInt i = plan.
start[0]; i < plan.
end[0]; ++i) {
420 PetscCallMPI(MPI_Allreduce(sums, reduced, 3 * 64, MPIU_REAL, MPI_SUM, PETSC_COMM_WORLD));
423 PetscCallMPI(MPI_Bcast(tmpdir, PETSC_MAX_PATH_LEN, MPI_CHAR, 0, PETSC_COMM_WORLD));
424 PetscCall(PetscSNPrintf(prefix,
sizeof(prefix),
"%s/Field", tmpdir));
429 PetscInt rows = 0, expected_rows = 0;
432 PetscCall(PetscSNPrintf(path,
sizeof(path),
"%s_profile_plane_00007.csv", prefix));
433 csv = fopen(path,
"r");
434 PetscCheck(csv != NULL, PETSC_COMM_SELF, PETSC_ERR_FILE_OPEN,
"Cannot open %s", path);
435 PetscCheck(fgets(line,
sizeof(line), csv) != NULL, PETSC_COMM_SELF, PETSC_ERR_FILE_READ,
"Empty profile");
436 PetscCall(
PicurvAssertBool((PetscBool)(strcmp(line,
"j,x,y,z,plane_P_mean,plane_P_rms\n") == 0),
437 "the header names the retained index, coordinates and outputs"));
438 while (fgets(line,
sizeof(line), csv)) {
440 double x, y, z, mean, rms;
441 PetscReal expected_mean, expected_rms;
443 PetscCheck(sscanf(line,
"%d,%lf,%lf,%lf,%lf,%lf", &cell, &x, &y, &z, &mean, &rms) == 6,
444 PETSC_COMM_SELF, PETSC_ERR_FILE_READ,
"Malformed profile row: %s", line);
445 expected_mean = reduced[1][cell + 1] / reduced[0][cell + 1];
446 expected_rms = PetscSqrtReal(reduced[2][cell + 1] / reduced[0][cell + 1] - PetscSqr(expected_mean));
448 PetscCall(
PicurvAssertRealNear(expected_rms, rms, 1.0e-9,
"the row RMS is the plane's pooled RMS"));
450 "the row coordinate is the plane's cell centre"));
454 for (PetscInt j = 0; j < 64; ++j)
if (reduced[0][j] > 0.0) expected_rows++;
461 PetscFunctionReturn(0);
479 const PetscBool over_ik[3] = {PETSC_TRUE, PETSC_FALSE, PETSC_TRUE};
480 PetscReal sums[2][64], reduced[2][64];
481 PetscMPIInt rank = 0;
482 char tmpdir[PETSC_MAX_PATH_LEN], prefix[PETSC_MAX_PATH_LEN + 16], path[PETSC_MAX_PATH_LEN + 64];
484 PetscFunctionBeginUser;
485 PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD, &rank));
486 PetscCall(PetscMemzero(&definition,
sizeof(definition)));
487 PetscCall(PetscStrncpy(definition.
name,
"plane",
sizeof(definition.
name)));
496 PetscCall(VecSet(user->
Nvert, 0.0));
497 PetscCall(VecSet(user->
lNvert, 0.0));
500 for (PetscInt state = 0; state < 2; ++state) {
501 PetscReal ***pressure = NULL;
503 PetscCall(DMDAVecGetArray(user->
da, user->
P, &pressure));
504 for (PetscInt k = user->
info.zs; k < user->
info.zs + user->
info.zm; ++k)
505 for (PetscInt j = user->
info.ys; j < user->
info.ys + user->
info.ym; ++j)
506 for (PetscInt i = user->
info.xs; i < user->
info.xs + user->
info.xm; ++i)
507 pressure[k][j][i] =
ScalarValue(i, j, k) + state * (PetscReal)(i + 1);
508 PetscCall(DMDAVecRestoreArray(user->
da, user->
P, &pressure));
513 PetscCall(PetscMemzero(sums,
sizeof(sums)));
514 for (PetscInt k = plan.
start[2]; k < plan.
end[2]; ++k)
515 for (PetscInt j = plan.
start[1]; j < plan.
end[1]; ++j)
516 for (PetscInt i = plan.
start[0]; i < plan.
end[0]; ++i) {
518 sums[1][j] += PetscSqr(0.5 * (PetscReal)(i + 1));
520 PetscCallMPI(MPI_Allreduce(sums, reduced, 2 * 64, MPIU_REAL, MPI_SUM, PETSC_COMM_WORLD));
523 PetscCallMPI(MPI_Bcast(tmpdir, PETSC_MAX_PATH_LEN, MPI_CHAR, 0, PETSC_COMM_WORLD));
524 PetscCall(PetscSNPrintf(prefix,
sizeof(prefix),
"%s/Field", tmpdir));
532 PetscCall(PetscSNPrintf(path,
sizeof(path),
"%s_profile_plane_00003.csv", prefix));
533 csv = fopen(path,
"r");
534 PetscCheck(csv != NULL, PETSC_COMM_SELF, PETSC_ERR_FILE_OPEN,
"Cannot open %s", path);
535 PetscCheck(fgets(line,
sizeof(line), csv) != NULL, PETSC_COMM_SELF, PETSC_ERR_FILE_READ,
"Empty profile");
536 PetscCall(
PicurvAssertBool((PetscBool)(strcmp(line,
"j,x,y,z,plane_P_rms,plane_P_point_variance\n") == 0),
537 "the point variance is written beside the pooled RMS"));
538 while (fgets(line,
sizeof(line), csv)) {
540 double x, y, z, rms, point_variance;
541 PetscCheck(sscanf(line,
"%d,%lf,%lf,%lf,%lf,%lf", &cell, &x, &y, &z, &rms, &point_variance) == 6,
542 PETSC_COMM_SELF, PETSC_ERR_FILE_READ,
"Malformed profile row: %s", line);
543 PetscCall(
PicurvAssertRealNear(reduced[1][cell + 1] / reduced[0][cell + 1], point_variance, 1.0e-12,
544 "the row point variance is the plane mean of point variances"));
545 PetscCall(
PicurvAssertBool((PetscBool)(PetscSqr(rms) > point_variance + 1.0e-6),
546 "the pooled variance also carries the spread of the point means"));
550 PetscInt expected_rows = 0;
551 for (PetscInt j = 0; j < 64; ++j)
if (reduced[0][j] > 0.0) expected_rows++;
558 PetscFunctionReturn(0);
574 ierr = PetscInitialize(&argc, &argv, NULL,
575 "PICurv serial/MPI post-processing compute tests");
576 if (ierr)
return (
int)ierr;
578 sizeof(cases) /
sizeof(cases[0]));
583 ierr = PetscFinalize();
PetscErrorCode ResizeSwarmGlobally(DM swarm, PetscInt N_target)
Resizes a swarm collectively to a target global particle count.
PetscErrorCode ComputeWindowStatisticsProfile(UserCtx *user, const PicurvWindowDefinition *definition, const PicurvWindowStorage *storage, const char *outputs, const PetscBool average_direction[3], const char *output_prefix, PetscInt ti)
Writes a window's statistics merged over homogeneous directions as a profile.
PetscErrorCode ComputeWindowStatisticNodal(UserCtx *user, const PicurvWindowDefinition *definition, const PicurvWindowStorage *storage, const char *outputs, PetscInt output_index, char *out_name, size_t name_size, Vec *out_vec, PetscInt *out_components)
Derives one accumulated statistic and converts it to nodal values.
PetscErrorCode DimensionalizeField(UserCtx *user, const char *field_name)
Scales a specified field from non-dimensional to dimensional units in-place.
PetscErrorCode EulerianDataProcessingPipeline(UserCtx *user, PostProcessParams *pps)
Parses the processing pipeline string and executes the requested kernels.
PetscErrorCode ParticleDataProcessingPipeline(UserCtx *user, PostProcessParams *pps)
Parses and executes the particle pipeline using a robust two-pass approach.
PetscErrorCode SetupPostProcessSwarm(UserCtx *user, PostProcessParams *pps)
Creates a new, dedicated DMSwarm for post-processing tasks.
Per-window PETSc accumulator storage and pointwise application.
#define PICURV_STATISTICS_PAYLOAD_NAME_LENGTH
Maximum stored length of a payload name, including the terminator.
PetscErrorCode PicurvWindowStorageCreate(UserCtx *user, const PicurvWindowDefinition *definition, PicurvWindowStorage *storage)
Allocates the accumulator state one window owns on one block.
PetscErrorCode PicurvWindowAccumulate(UserCtx *user, const PicurvWindowDefinition *definition, PicurvWindowStorage *storage, PetscReal weight)
Applies one accepted completed state to a window's accumulators.
PetscErrorCode PicurvWindowStorageDestroy(PicurvWindowStorage *storage)
Releases accumulator state previously created for one window.
Independent accumulator state for one window on one block.
Spatial target resolution for the field-statistics pipeline.
@ PICURV_STATISTICS_MASK_FLUID
PetscInt end[3]
Exclusive end per dimension (i, j, k).
PetscInt start[3]
Inclusive start per dimension (i, j, k).
PetscErrorCode SpatialTargetPlanCreate(UserCtx *user, FieldId field_id, PicurvStatisticsMask mask, SpatialTargetPlan *plan)
Resolves the iteration domain for one field on one block.
Resolved iteration domain for one field on one block.
Window lifecycle, scheduling, and weighting for the field-statistics pipeline.
PicurvWindowFieldRequest fields[16]
PicurvCadenceKind cadence_kind
PetscInt step_cadence
Used when cadence_kind is step; must be positive.
PetscErrorCode PicurvWindowInit(PicurvWindow *window, const PicurvWindowDefinition *definition)
Validates a definition and initializes a window to the pending state.
PetscBool want_second
Also keep the centered second moment.
PetscInt field_id
Catalogued Eulerian field identity.
@ PICURV_WEIGHTING_SAMPLE
Equal weight per accepted state.
@ PICURV_CADENCE_STEP
Every n completed steps from activation.
PicurvWeighting weighting
Runtime state of one window.
The scientifically immutable definition of one window.
static PetscErrorCode TestResizeSwarmGloballyBalanced(void)
Checks that global resizing produces one balanced global population.
static PetscErrorCode TestFieldStatisticsDerivedNodalMultiRank(void)
Exercises accumulator-to-derived-nodal field statistics across ownership boundaries.
static PetscErrorCode TestParticlePipelineMatchesSourceOwnership(void)
Verifies the production-created derived swarm mirrors source ownership.
static const PetscReal kSentinel
static PetscReal ScalarValue(PetscInt i, PetscInt j, PetscInt k)
Analytic scalar field used to expose misplaced or missing grid points.
int main(int argc, char **argv)
Runs the serial/MPI post-processing compute regression suite.
static PetscErrorCode AssertGlobalError(PetscReal local_error, PetscReal tolerance, const char *context)
Requires every rank's maximum error to be within tolerance.
static PetscErrorCode TestFieldStatisticsProfileMultiRank(void)
A wall-normal profile CSV holds each plane's pooled moments on any decomposition.
static PetscErrorCode TestEulerianPipelineDecompositionIndependent(void)
Exercises every Eulerian transformation currently dispatched by the pipeline.
static PetscErrorCode TestFieldStatisticsPointVarianceProfile(void)
A point_variance profile is the plane mean of each point's own variance.
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 PicurvCreateSwarmPair(UserCtx *user, PetscInt nlocal, const char *post_field_name)
Creates matched solver and post-processing swarms for tests.
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 PicurvPopulateUniformCellCenters(UserCtx *user)
Populates cell center coordinates for a uniform grid on [0,1]^3.
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.
PetscInt fieldStatisticsWindowCount
PetscBool fieldStatisticsEnabled
struct PicurvWindow * fieldStatisticsWindows
char particle_pipeline[1024]
char process_pipeline[1024]
struct PicurvWindowStorage * fieldStatisticsStorage
A 3D point or vector with PetscScalar components.
Holds all configuration parameters for a post-processing run.
The master context for the entire simulation.
User-defined context containing data specific to a single computational grid level.