27static PetscErrorCode
AssertFileContains(
const char *path,
const char *needle,
const char *context)
33 PetscFunctionBeginUser;
34 fp = fopen(path,
"rb");
36 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_FILE_OPEN,
"Failed to open '%s' for assertion.", path);
38 if (fseek(fp, 0, SEEK_END) != 0) {
40 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_FILE_OPEN,
"Failed to seek '%s'.", path);
42 file_size = ftell(fp);
45 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_FILE_OPEN,
"Failed to measure '%s'.", path);
47 if (fseek(fp, 0, SEEK_SET) != 0) {
49 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_FILE_OPEN,
"Failed to rewind '%s'.", path);
52 PetscCall(PetscMalloc1((
size_t)file_size + 1, &buffer));
54 size_t bytes_read = fread(buffer, 1, (
size_t)file_size, fp);
55 if (bytes_read != (
size_t)file_size) {
57 PetscCall(PetscFree(buffer));
58 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_FILE_OPEN,
"Failed to read '%s'.", path);
61 buffer[file_size] =
'\0';
64 PetscCall(
PicurvAssertBool((PetscBool)(strstr(buffer, needle) != NULL), context));
65 PetscCall(PetscFree(buffer));
66 PetscFunctionReturn(0);
78 PetscFunctionBeginUser;
79 fp = fopen(path,
"rb");
81 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_FILE_OPEN,
"Failed to open '%s' for assertion.", path);
83 if (fseek(fp, 0, SEEK_END) != 0) {
85 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_FILE_OPEN,
"Failed to seek '%s'.", path);
87 file_size = ftell(fp);
90 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_FILE_OPEN,
"Failed to measure '%s'.", path);
92 if (fseek(fp, 0, SEEK_SET) != 0) {
94 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_FILE_OPEN,
"Failed to rewind '%s'.", path);
97 PetscCall(PetscMalloc1((
size_t)file_size + 1, &buffer));
99 size_t bytes_read = fread(buffer, 1, (
size_t)file_size, fp);
100 if (bytes_read != (
size_t)file_size) {
102 PetscCall(PetscFree(buffer));
103 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_FILE_OPEN,
"Failed to read '%s'.", path);
106 buffer[file_size] =
'\0';
109 PetscCall(
PicurvAssertBool((PetscBool)(strstr(buffer, needle) == NULL), context));
110 PetscCall(PetscFree(buffer));
111 PetscFunctionReturn(0);
130 PetscInt current_row = 0;
132 PetscBool header_found = PETSC_FALSE;
134 PetscFunctionBeginUser;
135 PetscCheck(path != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
"Log path cannot be NULL.");
136 PetscCheck(header != NULL && header_len > 0, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
"Log header buffer cannot be NULL.");
137 PetscCheck(row != NULL && row_len > 0, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
"Log row buffer cannot be NULL.");
138 PetscCheck(row_index >= 1, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE,
"Log row index must be >= 1.");
140 fp = fopen(path,
"r");
141 PetscCheck(fp != NULL, PETSC_COMM_SELF, PETSC_ERR_FILE_OPEN,
"Failed to open log '%s'.", path);
143 while (fgets(line,
sizeof(line), fp) != NULL) {
144 if (line[0] ==
'#' || line[0] ==
'\n' || line[0] ==
'\r')
continue;
146 PetscCall(PetscStrncpy(header, line, header_len));
147 header_found = PETSC_TRUE;
151 if (current_row == row_index) {
152 PetscCall(PetscStrncpy(row, line, row_len));
154 PetscFunctionReturn(0);
159 if (!header_found) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_FILE_READ,
"Log '%s' has no column header.", path);
160 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_FILE_READ,
"Log '%s' does not contain data row %d.", path, (
int)row_index);
166static PetscErrorCode
LogFindColumnIndex(
const char *header,
const char *column_name, PetscInt *index_out)
168 char local_header[8192];
169 char *saveptr = NULL;
173 PetscFunctionBeginUser;
174 PetscCheck(header != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
"Log header cannot be NULL.");
175 PetscCheck(column_name != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
"Log column name cannot be NULL.");
176 PetscCheck(index_out != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
"Log column index output cannot be NULL.");
178 PetscCall(PetscStrncpy(local_header, header,
sizeof(local_header)));
179 token = strtok_r(local_header,
",\r\n", &saveptr);
180 while (token != NULL) {
181 while (*token ==
' ') token++;
182 char *end = token + strlen(token) - 1;
183 while (end > token && (*end ==
' ' || *end ==
'\r' || *end ==
'\n')) end--;
185 if (strcmp(token, column_name) == 0) {
187 PetscFunctionReturn(0);
189 token = strtok_r(NULL,
",\r\n", &saveptr);
192 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG,
"Log column '%s' was not found.", column_name);
200 const char *column_name,
204 char local_row[8192];
205 char *saveptr = NULL;
207 PetscInt target_index = -1;
210 PetscFunctionBeginUser;
211 PetscCheck(row != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
"Log row cannot be NULL.");
212 PetscCheck(value != NULL && value_len > 0, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
"Log value buffer cannot be NULL.");
215 PetscCall(PetscStrncpy(local_row, row,
sizeof(local_row)));
217 token = strtok_r(local_row,
",\r\n", &saveptr);
218 while (token != NULL) {
219 if (index == target_index) {
220 while (*token ==
' ') token++;
221 char *end = token + strlen(token) - 1;
222 while (end > token && (*end ==
' ' || *end ==
'\r' || *end ==
'\n')) end--;
224 PetscCall(PetscStrncpy(value, token, value_len));
225 PetscFunctionReturn(0);
227 token = strtok_r(NULL,
",\r\n", &saveptr);
230 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG,
"Log row is missing column '%s'.", column_name);
236static PetscErrorCode
LogGetColumnInt(
const char *header,
const char *row,
const char *column_name, PetscInt *value_out)
242 PetscFunctionBeginUser;
243 PetscCheck(value_out != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
"Log integer output cannot be NULL.");
245 parsed = strtol(text, &endptr, 10);
246 PetscCheck(endptr != text, PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG,
"Log column '%s' did not contain an integer.", column_name);
247 *value_out = (PetscInt)parsed;
248 PetscFunctionReturn(0);
254static PetscErrorCode
LogGetColumnReal(
const char *header,
const char *row,
const char *column_name, PetscReal *value_out)
260 PetscFunctionBeginUser;
261 PetscCheck(value_out != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
"Log real output cannot be NULL.");
263 parsed = strtod(text, &endptr);
264 PetscCheck(endptr != text, PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG,
"Log column '%s' did not contain a real value.", column_name);
265 *value_out = (PetscReal)parsed;
266 PetscFunctionReturn(0);
286 char tmpdir[PETSC_MAX_PATH_LEN];
287 char capture_path[PETSC_MAX_PATH_LEN];
288 FILE *capture_file = NULL;
289 int saved_stdout = -1;
291 size_t bytes_read = 0;
294 PetscFunctionBeginUser;
295 PetscCheck(fn != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
"Capture callback cannot be NULL.");
296 PetscCheck(captured != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
"Capture buffer cannot be NULL.");
297 PetscCheck(captured_len > 0, PETSC_COMM_SELF, PETSC_ERR_ARG_SIZ,
"Capture buffer must be non-empty.");
300 PetscCall(PetscSNPrintf(capture_path,
sizeof(capture_path),
"%s/logging.out", tmpdir));
303 saved_stdout = dup(STDOUT_FILENO);
304 PetscCheck(saved_stdout >= 0, PETSC_COMM_SELF, PETSC_ERR_SYS,
"dup(STDOUT_FILENO) failed.");
305 capture_fd = open(capture_path, O_CREAT | O_TRUNC | O_WRONLY, 0600);
306 PetscCheck(capture_fd >= 0, PETSC_COMM_SELF, PETSC_ERR_FILE_OPEN,
"Failed to open capture file '%s'.", capture_path);
307 PetscCheck(dup2(capture_fd, STDOUT_FILENO) >= 0, PETSC_COMM_SELF, PETSC_ERR_SYS,
"dup2() failed while redirecting stdout.");
311 ierr = fn(user, simCtx, ctx);
313 PetscCheck(dup2(saved_stdout, STDOUT_FILENO) >= 0, PETSC_COMM_SELF, PETSC_ERR_SYS,
"dup2() failed while restoring stdout.");
318 capture_file = fopen(capture_path,
"r");
319 PetscCheck(capture_file != NULL, PETSC_COMM_SELF, PETSC_ERR_FILE_OPEN,
"Failed to read capture file '%s'.", capture_path);
320 bytes_read = fread(captured, 1, captured_len - 1, capture_file);
321 captured[bytes_read] =
'\0';
322 fclose(capture_file);
324 PetscFunctionReturn(0);
332 PetscInt print_interval = *((PetscInt *)ctx);
334 PetscFunctionBeginUser;
337 PetscFunctionReturn(0);
345 PetscInt step = *((PetscInt *)ctx);
347 PetscFunctionBeginUser;
349 PetscFunctionReturn(0);
357 PetscInt step = *((PetscInt *)ctx);
359 PetscFunctionBeginUser;
361 PetscFunctionReturn(0);
371 PetscFunctionBeginUser;
374 PetscFunctionReturn(0);
382 PetscReal *positions = NULL;
383 PetscReal *velocities = NULL;
384 PetscReal *weights = NULL;
385 PetscInt *cell_ids = NULL;
386 PetscInt *status = NULL;
387 PetscReal *psi = NULL;
389 PetscFunctionBeginUser;
392 (*simCtx_out)->np = 2;
393 (*simCtx_out)->particleConsoleOutputFreq = 2;
394 (*simCtx_out)->LoggingFrequency = 1;
396 PetscCall(DMSwarmGetField((*user_out)->swarm,
"position", NULL, NULL, (
void **)&positions));
397 PetscCall(DMSwarmGetField((*user_out)->swarm,
"velocity", NULL, NULL, (
void **)&velocities));
398 PetscCall(DMSwarmGetField((*user_out)->swarm,
"weight", NULL, NULL, (
void **)&weights));
399 PetscCall(DMSwarmGetField((*user_out)->swarm,
"DMSwarm_CellID", NULL, NULL, (
void **)&cell_ids));
400 PetscCall(DMSwarmGetField((*user_out)->swarm,
"DMSwarm_location_status", NULL, NULL, (
void **)&status));
401 PetscCall(DMSwarmGetField((*user_out)->swarm,
"Psi", NULL, NULL, (
void **)&psi));
403 positions[0] = 0.25; positions[1] = 0.50; positions[2] = 0.75;
404 positions[3] = 0.50; positions[4] = 0.50; positions[5] = 0.50;
405 velocities[0] = 1.0; velocities[1] = 2.0; velocities[2] = 3.0;
406 velocities[3] = 4.0; velocities[4] = 5.0; velocities[5] = 6.0;
407 weights[0] = 0.2; weights[1] = 0.3; weights[2] = 0.4;
408 weights[3] = 0.5; weights[4] = 0.5; weights[5] = 0.5;
409 cell_ids[0] = 0; cell_ids[1] = 0; cell_ids[2] = 0;
410 cell_ids[3] = 1; cell_ids[4] = 1; cell_ids[5] = 1;
416 PetscCall(DMSwarmRestoreField((*user_out)->swarm,
"Psi", NULL, NULL, (
void **)&psi));
417 PetscCall(DMSwarmRestoreField((*user_out)->swarm,
"DMSwarm_location_status", NULL, NULL, (
void **)&status));
418 PetscCall(DMSwarmRestoreField((*user_out)->swarm,
"DMSwarm_CellID", NULL, NULL, (
void **)&cell_ids));
419 PetscCall(DMSwarmRestoreField((*user_out)->swarm,
"weight", NULL, NULL, (
void **)&weights));
420 PetscCall(DMSwarmRestoreField((*user_out)->swarm,
"velocity", NULL, NULL, (
void **)&velocities));
421 PetscCall(DMSwarmRestoreField((*user_out)->swarm,
"position", NULL, NULL, (
void **)&positions));
422 PetscFunctionReturn(0);
432 PetscFunctionBeginUser;
433 PetscCheck(user != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
"UserCtx cannot be NULL.");
434 PetscCheck(field != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
"Velocity field cannot be NULL.");
436 PetscCall(DMDAVecGetArray(user->
fda, field, &arr));
437 for (PetscInt k = user->
info.zs; k < user->
info.zs + user->
info.zm; ++k) {
438 for (PetscInt j = user->
info.ys; j < user->
info.ys + user->
info.ym; ++j) {
439 for (PetscInt i = user->
info.xs; i < user->
info.xs + user->
info.xm; ++i) {
446 PetscCall(DMDAVecRestoreArray(user->
fda, field, &arr));
447 PetscFunctionReturn(0);
455 PetscReal ***arr = NULL;
457 PetscFunctionBeginUser;
458 PetscCheck(user != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
"UserCtx cannot be NULL.");
459 PetscCheck(field != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
"Scalar field cannot be NULL.");
461 PetscCall(DMDAVecGetArray(user->
da, field, &arr));
462 for (PetscInt k = user->
info.zs; k < user->
info.zs + user->
info.zm; ++k) {
463 for (PetscInt j = user->
info.ys; j < user->
info.ys + user->
info.ym; ++j) {
464 for (PetscInt i = user->
info.xs; i < user->
info.xs + user->
info.xm; ++i) {
465 arr[k][j][i] = value;
469 PetscCall(DMDAVecRestoreArray(user->
da, field, &arr));
470 PetscFunctionReturn(0);
483 const PetscInt ncells = user->
info.mz - 2;
485 PetscFunctionBeginUser;
486 PetscCheck(user != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
"UserCtx cannot be NULL.");
487 PetscCheck(field != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
"Velocity field cannot be NULL.");
489 PetscCall(DMDAVecGetArray(user->
fda, field, &arr));
490 for (PetscInt k = user->
info.zs; k < user->
info.zs + user->
info.zm; ++k) {
491 const PetscInt cell = (k == 0) ? ncells : (k == user->
info.mz - 1) ? 1 : k;
492 PetscReal z_phase = (2.0 * PETSC_PI * (PetscReal)(cell - 1)) / (PetscReal)ncells;
493 for (PetscInt j = user->
info.ys; j < user->
info.ys + user->
info.ym; ++j) {
494 for (PetscInt i = user->
info.xs; i < user->
info.xs + user->
info.xm; ++i) {
495 arr[k][j][i].
x = 0.0;
496 arr[k][j][i].
y = v_amp * PetscSinReal(z_phase);
497 arr[k][j][i].
z = w_const;
501 PetscCall(DMDAVecRestoreArray(user->
fda, field, &arr));
502 PetscFunctionReturn(0);
511 PetscFunctionBeginUser;
513 "BCFaceToString should report the negative-x face"));
515 "ParticleInitializationToString should report the volume mode"));
517 "LESModelToString should report the constant model"));
519 "MomentumSolverTypeToString should report the explicit solver"));
521 "MomentumSolverTypeToString should report the Newton Krylov solver"));
523 "BCTypeToString should report periodic boundaries"));
525 "BCHandlerTypeToString should report the driven periodic handler"));
527 "ParticleLocationStatusToString should report LOST state"));
529 "ParticleLocationStatusToString should report EXITED state"));
530 PetscFunctionReturn(0);
538 PetscFunctionBeginUser;
540 "get_log_level should honor LOG_LEVEL=INFO in this test binary"));
542 PetscFunctionReturn(0);
550 const char *allow_list[] = {
"ComputeSpecificKE",
"WriteEulerianFile"};
552 PetscFunctionBeginUser;
555 "Allowed list should include ComputeSpecificKE"));
557 "Allowed list should exclude unknown function names"));
561 "Empty allow-list should permit all functions"));
562 PetscFunctionReturn(0);
572 PetscFunctionBeginUser;
573 PetscCall(PetscMemzero(&simCtx,
sizeof(simCtx)));
578 "Particle snapshot contract should be enabled when particles and cadence are configured"));
580 "Snapshot should emit on cadence-aligned completed steps"));
582 "Snapshot should not emit off-cadence"));
586 "Zero cadence should disable periodic particle snapshots"));
588 "NULL SimCtx should never emit periodic snapshots"));
589 PetscFunctionReturn(0);
601 memset(&definition, 0,
sizeof(definition));
606 definition.
bounded = PETSC_TRUE;
622 PetscFunctionBeginUser;
623 PetscCall(PetscMemzero(&simCtx,
sizeof(simCtx)));
631 "Statistics snapshot contract should be enabled when a window and cadence are configured"));
633 "Snapshot should emit on cadence-aligned completed steps"));
635 "Snapshot should not emit off-cadence"));
637 "Snapshot should not emit for a step that has not completed"));
641 "Zero cadence should disable periodic statistics snapshots"));
643 "Zero cadence should not emit even on the step that opens a run"));
650 "A configured cadence should not enable snapshots without an accumulating window"));
655 "A disabled subsystem should not emit statistics snapshots"));
658 "NULL SimCtx should never emit periodic snapshots"));
659 PetscFunctionReturn(0);
667 char tmpdir[PETSC_MAX_PATH_LEN];
668 char allow_path[PETSC_MAX_PATH_LEN];
669 char dual_log_path[PETSC_MAX_PATH_LEN];
674 PetscReal distances[6] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
678 PetscFunctionBeginUser;
679 PetscCall(PetscMemzero(&cell,
sizeof(cell)));
681 PetscCall(PetscSNPrintf(allow_path,
sizeof(allow_path),
"%s/allowed_functions.txt", tmpdir));
682 PetscCall(PetscSNPrintf(dual_log_path,
sizeof(dual_log_path),
"%s/dual-monitor.log", tmpdir));
684 file = fopen(allow_path,
"w");
685 PetscCheck(file != NULL, PETSC_COMM_SELF, PETSC_ERR_FILE_OPEN,
"Failed to create allow-list file '%s'.", allow_path);
686 fputs(
" ComputeSpecificKE \n", file);
687 fputs(
"# comment-only line\n", file);
688 for (PetscInt i = 0; i < 17; ++i) {
689 fprintf(file,
"Helper_%02d # trailing comment\n", (
int)i);
695 PetscCall(
PicurvAssertIntEqual(18, nfuncs,
"LoadAllowedFunctionsFromFile should trim comments and keep all identifiers"));
696 PetscCall(
PicurvAssertBool((PetscBool)(strcmp(funcs[0],
"ComputeSpecificKE") == 0),
697 "LoadAllowedFunctionsFromFile should trim leading and trailing whitespace"));
698 PetscCall(
PicurvAssertBool((PetscBool)(strcmp(funcs[17],
"Helper_16") == 0),
699 "LoadAllowedFunctionsFromFile should grow past the initial pointer capacity"));
702 for (PetscInt i = 0; i < 8; ++i) {
710 PetscCall(PetscCalloc1(1, &monctx));
712 PetscCheck(monctx->
file_handle != NULL, PETSC_COMM_SELF, PETSC_ERR_FILE_OPEN,
"Failed to create dual-monitor log '%s'.", dual_log_path);
716 "DualMonitorDestroy should clear the caller-owned context pointer"));
721 PetscCall(PetscPrintf(PETSC_COMM_SELF,
"\n"));
724 PetscFunctionReturn(0);
734 char tmpdir[PETSC_MAX_PATH_LEN];
735 char continuity_path[PETSC_MAX_PATH_LEN];
736 PetscReal ***p = NULL;
739 PetscErrorCode ierr_minmax = 0;
741 PetscFunctionBeginUser;
744 PetscCall(PetscStrncpy(simCtx->
log_dir, tmpdir,
sizeof(simCtx->
log_dir)));
765 PetscCall(PetscSNPrintf(continuity_path,
sizeof(continuity_path),
"%s/Continuity_Metrics.csv", simCtx->
log_dir));
767 PetscCall(
AssertFileContains(continuity_path,
"step,block,max_divergence,max_divergence_k",
"continuity metrics CSV should include the header"));
768 PetscCall(
AssertFileContains(continuity_path,
"1,0,1.2500000000e+00,3,2,1,17,",
"continuity metrics CSV should record the divergence and its [k][j][i] location"));
769 PetscCall(
AssertFileContains(continuity_path,
"\n2,0,7.5000000000e-01,",
"continuity metrics CSV should append later timesteps"));
771 PetscCall(DMDAVecGetArray(user->
da, user->
P, &p));
772 PetscCall(DMDAVecGetArray(user->
fda, user->
Ucat, &ucat));
773 PetscCall(DMDAVecGetArray(user->
fda, user->
Ucont, &ucont));
774 for (PetscInt k = user->
info.zs; k < user->
info.zs + user->
info.zm; ++k) {
775 for (PetscInt j = user->
info.ys; j < user->
info.ys + user->
info.ym; ++j) {
776 for (PetscInt i = user->
info.xs; i < user->
info.xs + user->
info.xm; ++i) {
777 p[k][j][i] = (PetscReal)(i + j + k);
778 ucat[k][j][i].
x = (PetscReal)i;
779 ucat[k][j][i].
y = (PetscReal)(-j);
780 ucat[k][j][i].
z = (PetscReal)(2 * k);
781 ucont[k][j][i].
x = (PetscReal)(10 + i);
782 ucont[k][j][i].
y = (PetscReal)(20 + j);
783 ucont[k][j][i].
z = (PetscReal)(30 + k);
787 PetscCall(DMDAVecRestoreArray(user->
fda, user->
Ucont, &ucont));
788 PetscCall(DMDAVecRestoreArray(user->
fda, user->
Ucat, &ucat));
789 PetscCall(DMDAVecRestoreArray(user->
da, user->
P, &p));
791 PetscCall(DMGlobalToLocalBegin(user->
da, user->
P, INSERT_VALUES, user->
lP));
792 PetscCall(DMGlobalToLocalEnd(user->
da, user->
P, INSERT_VALUES, user->
lP));
793 PetscCall(DMGlobalToLocalBegin(user->
fda, user->
Ucat, INSERT_VALUES, user->
lUcat));
794 PetscCall(DMGlobalToLocalEnd(user->
fda, user->
Ucat, INSERT_VALUES, user->
lUcat));
795 PetscCall(DMGlobalToLocalBegin(user->
fda, user->
Ucont, INSERT_VALUES, user->
lUcont));
796 PetscCall(DMGlobalToLocalEnd(user->
fda, user->
Ucont, INSERT_VALUES, user->
lUcont));
803 PetscCall(PetscPushErrorHandler(PetscIgnoreErrorHandler, NULL));
805 PetscCall(PetscPopErrorHandler());
807 "LOG_FIELD_MIN_MAX should reject invalid field IDs"));
811 PetscFunctionReturn(0);
821 PetscReal (*pos_arr)[3] = NULL;
822 PetscReal (*vel_arr)[3] = NULL;
823 Vec position_vec = NULL;
824 Vec analytical_vec = NULL;
825 const PetscScalar *analytical_arr = NULL;
826 char tmpdir[PETSC_MAX_PATH_LEN];
827 char metrics_path[PETSC_MAX_PATH_LEN];
829 PetscFunctionBeginUser;
834 PetscCall(PetscOptionsSetValue(NULL,
"-ic_source_frame",
"cartesian"));
835 PetscCall(PetscOptionsSetValue(NULL,
"-ic_source_expr_0",
"sin(x)*cos(y)*cos(z)*exp(-2*t)"));
836 PetscCall(PetscOptionsSetValue(NULL,
"-ic_source_expr_1",
"(-cos(x)*sin(y)*cos(z)*exp(-2*t))"));
837 PetscCall(PetscOptionsSetValue(NULL,
"-ic_source_expr_2",
"0"));
848 PetscCall(DMSwarmGetField(user->
swarm,
"position", NULL, NULL, (
void *)&pos_arr));
849 pos_arr[0][0] = 0.5 * PETSC_PI; pos_arr[0][1] = 0.0; pos_arr[0][2] = 0.0;
850 pos_arr[1][0] = 0.0; pos_arr[1][1] = 0.5 * PETSC_PI; pos_arr[1][2] = 0.0;
851 PetscCall(DMSwarmRestoreField(user->
swarm,
"position", NULL, NULL, (
void *)&pos_arr));
853 PetscCall(DMSwarmCreateGlobalVectorFromField(user->
swarm,
"position", &position_vec));
854 PetscCall(VecDuplicate(position_vec, &analytical_vec));
855 PetscCall(VecCopy(position_vec, analytical_vec));
858 PetscCall(DMSwarmGetField(user->
swarm,
"velocity", NULL, NULL, (
void *)&vel_arr));
859 PetscCall(VecGetArrayRead(analytical_vec, &analytical_arr));
860 for (PetscInt particle = 0; particle < 2; ++particle) {
861 vel_arr[particle][0] = PetscRealPart(analytical_arr[3 * particle + 0]);
862 vel_arr[particle][1] = PetscRealPart(analytical_arr[3 * particle + 1]);
863 vel_arr[particle][2] = PetscRealPart(analytical_arr[3 * particle + 2]);
865 PetscCall(VecRestoreArrayRead(analytical_vec, &analytical_arr));
866 PetscCall(DMSwarmRestoreField(user->
swarm,
"velocity", NULL, NULL, (
void *)&vel_arr));
868 PetscCall(VecDestroy(&analytical_vec));
869 PetscCall(DMSwarmDestroyGlobalVectorFromField(user->
swarm,
"position", &position_vec));
872 PetscCall(PetscSNPrintf(metrics_path,
sizeof(metrics_path),
"%s/interpolation_error.csv", simCtx->
analysis_dir));
873 PetscCall(
PicurvAssertFileExists(metrics_path,
"LOG_INTERPOLATION_ERROR should write interpolation_error.csv"));
875 "interpolation_error.csv should record physical time, not time multiplied by dt"));
879 PetscFunctionReturn(0);
892 char tmpdir[PETSC_MAX_PATH_LEN];
893 char metrics_path[PETSC_MAX_PATH_LEN];
895 PetscFunctionBeginUser;
906 PetscCall(DMCreateLocalVector(user->
da, &user->
lNu_t));
907 PetscCall(VecSet(user->
lNu_t, 0.0));
908 PetscCall(VecSet(user->
lAj, 1.0));
912 PetscCall(PetscSNPrintf(metrics_path,
sizeof(metrics_path),
"%s/les_coefficient.csv", simCtx->
analysis_dir));
914 PetscCall(
AssertFileContains(metrics_path,
"3,5.000000e-01,nan,2.000000e-01,4.000000e-02,",
915 "the constant model should write nan for cs_effective and its Cs in cs_mean"));
918 PetscFunctionReturn(0);
929 char tmpdir[PETSC_MAX_PATH_LEN];
930 char metrics_path[PETSC_MAX_PATH_LEN];
931 PetscReal *positions = NULL;
932 PetscReal *psi = NULL;
933 PetscInt *cell_ids = NULL;
934 PetscInt *status = NULL;
935 PetscInt particle = 0;
937 PetscFunctionBeginUser;
941 PetscCall(PetscStrncpy(simCtx->
log_dir, tmpdir,
sizeof(simCtx->
log_dir)));
949 PetscCall(DMSwarmGetField(user->
swarm,
"position", NULL, NULL, (
void **)&positions));
950 PetscCall(DMSwarmGetField(user->
swarm,
"DMSwarm_CellID", NULL, NULL, (
void **)&cell_ids));
951 PetscCall(DMSwarmGetField(user->
swarm,
"DMSwarm_location_status", NULL, NULL, (
void **)&status));
952 PetscCall(DMSwarmGetField(user->
swarm,
"Psi", NULL, NULL, (
void **)&psi));
954 for (PetscInt k = 0; k < 3; ++k) {
955 for (PetscInt j = 0; j < 3; ++j) {
956 for (PetscInt i = 0; i < 3; ++i) {
957 positions[3 * particle + 0] = (i + 0.5) / 4.0;
958 positions[3 * particle + 1] = (j + 0.5) / 4.0;
959 positions[3 * particle + 2] = (k + 0.5) / 4.0;
960 cell_ids[3 * particle + 0] = i;
961 cell_ids[3 * particle + 1] = j;
962 cell_ids[3 * particle + 2] = k;
970 PetscCall(DMSwarmRestoreField(user->
swarm,
"Psi", NULL, NULL, (
void **)&psi));
971 PetscCall(DMSwarmRestoreField(user->
swarm,
"DMSwarm_location_status", NULL, NULL, (
void **)&status));
972 PetscCall(DMSwarmRestoreField(user->
swarm,
"DMSwarm_CellID", NULL, NULL, (
void **)&cell_ids));
973 PetscCall(DMSwarmRestoreField(user->
swarm,
"position", NULL, NULL, (
void **)&positions));
978 PetscCall(PetscSNPrintf(metrics_path,
sizeof(metrics_path),
"%s/scatter_metrics.csv", simCtx->
analysis_dir));
981 "Scatter metrics CSV header should include relative_L2_error"));
983 "3,3.000000e-01,27,27,27,1.000000e+00,1.000000e+00,5.400000e+01,5.400000e+01,0.000000e+00,0.000000e+00,0.000000e+00,0.000000e+00,0.000000e+00",
984 "Scatter metrics CSV should record the expected constant-field zero-error row"));
988 PetscFunctionReturn(0);
998 PetscInt print_interval = 1;
1001 PetscFunctionBeginUser;
1004 PetscCall(
PicurvAssertBool((PetscBool)(strstr(captured,
"Position (x,y,z)") != NULL),
1005 "LOG_PARTICLE_FIELDS should print the particle table header"));
1006 PetscCall(
PicurvAssertBool((PetscBool)(strstr(captured,
"Weights (a1,a2,a3)") != NULL),
1007 "LOG_PARTICLE_FIELDS should print the weight-column header"));
1009 PetscFunctionReturn(0);
1020 char captured[8192];
1022 PetscFunctionBeginUser;
1025 PetscCall(
PicurvAssertBool((PetscBool)(strstr(captured,
"Particle states at step 4") != NULL),
1026 "EmitParticleConsoleSnapshot should print the step banner"));
1027 PetscCall(
PicurvAssertBool((PetscBool)(strstr(captured,
"Position (x,y,z)") != NULL),
1028 "EmitParticleConsoleSnapshot should reuse the particle table output"));
1030 PetscFunctionReturn(0);
1049 char captured[8192];
1051 PetscFunctionBeginUser;
1053 PetscCall(VecSet(user->
Nvert, 0.0));
1065 for (PetscInt offered = 0; offered <= step; ++offered) {
1070 captured,
sizeof(captured)));
1071 PetscCall(
PicurvAssertBool((PetscBool)(strstr(captured,
"Statistics windows at step 2") != NULL),
1072 "EmitStatisticsConsoleSnapshot should print the step banner"));
1073 PetscCall(
PicurvAssertBool((PetscBool)(strstr(captured,
"console_window") != NULL),
1074 "EmitStatisticsConsoleSnapshot should name each configured window"));
1075 PetscCall(
PicurvAssertBool((PetscBool)(strstr(captured,
"samples=2") != NULL),
1076 "EmitStatisticsConsoleSnapshot should report the accepted sample count"));
1077 PetscCall(
PicurvAssertBool((PetscBool)(strstr(captured,
"valid=[") != NULL),
1078 "EmitStatisticsConsoleSnapshot should report mask coverage once storage carries samples"));
1082 captured,
sizeof(captured)));
1084 "a disabled subsystem emits no statistics console output"));
1091 PetscFunctionReturn(0);
1098 PetscReal ***p = NULL;
1099 const DMDALocalInfo info = user->
info;
1101 PetscFunctionBeginUser;
1102 PetscCall(DMDAVecGetArray(user->
da, user->
P, &p));
1103 for (PetscInt k = info.zs; k < info.zs + info.zm; ++k)
1104 for (PetscInt j = info.ys; j < info.ys + info.ym; ++j)
1105 for (PetscInt i = info.xs; i < info.xs + info.xm; ++i) p[k][j][i] = value;
1106 PetscCall(DMDAVecRestoreArray(user->
da, user->
P, &p));
1107 PetscFunctionReturn(0);
1119 PetscInt console_frequency)
1121 PetscFunctionBeginUser;
1129 for (PetscInt step = 0; step <= 3; ++step) {
1136 PetscFunctionReturn(0);
1143 PetscBool equal = PETSC_FALSE;
1145 PetscFunctionBeginUser;
1146 PetscCall(VecEqual(expected, actual, &equal));
1148 PetscFunctionReturn(0);
1167 char captured[8192];
1170 PetscFunctionBeginUser;
1173 PetscCall(VecSet(user->
Nvert, 0.0));
1181 "both cadences accept the same states"));
1183 "both cadences accumulate the same total weight"));
1185 "per-point sample counts are independent of the console cadence"));
1187 "per-point weights are independent of the console cadence"));
1189 "means are independent of the console cadence"));
1191 "second moments are independent of the console cadence"));
1199 captured,
sizeof(captured)));
1200 PetscCall(
PicurvAssertBool((PetscBool)(strstr(captured,
"console_window") != NULL),
1201 "the reporting cadence emits console output at this log level"));
1210 PetscFunctionReturn(0);
1220 char tmpdir[PETSC_MAX_PATH_LEN];
1221 char metrics_path[PETSC_MAX_PATH_LEN];
1223 PetscFunctionBeginUser;
1226 PetscCall(PetscStrncpy(simCtx->
log_dir, tmpdir,
sizeof(simCtx->
log_dir)));
1238 PetscScalar ***count = NULL;
1240 count[0][0][0] = 5.0;
1241 PetscCall(DMDAVecRestoreArray(user->
da, user->
ParticleCount, &count));
1245 const PetscInt cells = (user->
info.mx - 2) * (user->
info.my - 2) * (user->
info.mz - 2);
1250 "the mean is the particles in cells over the physical cell count"));
1255 PetscCall(PetscSNPrintf(metrics_path,
sizeof(metrics_path),
"%s/search_metrics.csv", simCtx->
analysis_dir));
1257 PetscCall(
AssertFileContains(metrics_path,
",occupied_cells,particles_per_cell_min,particles_per_cell_mean,particles_per_cell_max",
1258 "search_metrics.csv should carry the occupied-cell count and the per-cell statistics"));
1259 PetscCall(
AssertFileContains(metrics_path,
",1,7,2,3,",
"search_metrics.csv should record lost, cumulative lost, migrated and passes in order"));
1262 PetscFunctionReturn(0);
1272 char tmpdir[PETSC_MAX_PATH_LEN];
1273 char metrics_path[PETSC_MAX_PATH_LEN];
1275 PetscFunctionBeginUser;
1278 PetscCall(PetscStrncpy(simCtx->
log_dir, tmpdir,
sizeof(simCtx->
log_dir)));
1304 PetscCall(PetscSNPrintf(metrics_path,
sizeof(metrics_path),
"%s/search_metrics.csv", simCtx->
analysis_dir));
1306 PetscCall(
AssertFileContains(metrics_path,
"search_attempts",
"Search metrics CSV header should include search_attempts"));
1307 PetscCall(
AssertFileContains(metrics_path,
"search_population",
"Search metrics CSV header should include search_population"));
1308 PetscCall(
AssertFileContains(metrics_path,
"max_particle_pass_depth",
"Search metrics CSV header should include max_particle_pass_depth"));
1309 PetscCall(
AssertFileContains(metrics_path,
"search_work_index",
"Search metrics CSV header should include search_work_index"));
1310 PetscCall(
AssertFileContains(metrics_path,
"re_search_fraction",
"Search metrics CSV header should include re_search_fraction"));
1311 PetscCall(
AssertFileContains(metrics_path,
"lost_cumulative",
"Search metrics CSV header should include the cumulative-loss column"));
1312 PetscCall(
AssertFileContains(metrics_path,
"2,2.000000e-01,2,1,7,2,3,4,2.500000e+00,6,1,2,3,1,3,1.500000e+00,2,1,1,10,2,1,5.000000e-01,5.000000e+00,1.000000e+00",
"Search metrics CSV should record the V2 raw and derived search metrics"));
1315 PetscFunctionReturn(0);
1325 char captured[8192];
1328 PetscFunctionBeginUser;
1330 PetscCall(VecSet(user->
P, 7.0));
1331 PetscCall(DMGlobalToLocalBegin(user->
da, user->
P, INSERT_VALUES, user->
lP));
1332 PetscCall(DMGlobalToLocalEnd(user->
da, user->
P, INSERT_VALUES, user->
lP));
1334 PetscCall(
PicurvAssertBool((PetscBool)(strstr(captured,
"Field Anatomy Log: [P]") != NULL),
1335 "LOG_FIELD_ANATOMY should print the requested field name"));
1336 PetscCall(
PicurvAssertBool((PetscBool)(strstr(captured,
"Layout: [Cell-Centered]") != NULL),
1337 "LOG_FIELD_ANATOMY should report the inferred data layout"));
1339 PetscFunctionReturn(0);
1360 char tmpdir[PETSC_MAX_PATH_LEN];
1361 char timestep_path[PETSC_MAX_PATH_LEN];
1362 char summary_path[PETSC_MAX_PATH_LEN];
1363 static char selected_name[] =
"ProfiledFlowSolver";
1364 static char helper_name[] =
"ProfiledEnabledHelper";
1365 char *selected_funcs[] = {selected_name};
1366 char *helpers[] = {helper_name};
1368 PetscFunctionBeginUser;
1369 PetscCall(PetscMemzero(&simCtx,
sizeof(simCtx)));
1371 PetscCall(PetscStrncpy(simCtx.
log_dir, tmpdir,
sizeof(simCtx.
log_dir)));
1396 PetscCall(PetscSNPrintf(timestep_path,
sizeof(timestep_path),
"%s/Profiling_Timestep_Summary.csv", simCtx.
log_dir));
1397 PetscCall(PetscSNPrintf(summary_path,
sizeof(summary_path),
"%s/ProfilingSummary_Solver.csv", simCtx.
log_dir));
1401 "profiling timestep summary should contain the CSV header"));
1403 "profiling timestep summary should log selected functions"));
1405 "a call before the step interval was reset belongs to no step"));
1407 "profiling timestep summary should omit unselected functions in selected mode"));
1409 "profiling final summary should be a CSV with its header"));
1411 "profiling final summary should include selected functions in the picurv section"));
1413 "profiling final summary should include total-time entries for unselected functions"));
1415 "a helper named in profiling.helpers is timed"));
1417 "a helper not named in profiling.helpers records nothing"));
1419 "the summary should list PETSc's own events in the petsc section"));
1421 PetscFunctionReturn(0);
1430 char tmpdir[PETSC_MAX_PATH_LEN];
1431 char memory_path[PETSC_MAX_PATH_LEN];
1433 PetscFunctionBeginUser;
1434 PetscCall(PetscMemzero(&simCtx,
sizeof(simCtx)));
1436 PetscCall(PetscStrncpy(simCtx.
log_dir, tmpdir,
sizeof(simCtx.
log_dir)));
1442 PetscCall(PetscMemorySetGetMaximumUsage());
1446 PetscCall(PetscSNPrintf(memory_path,
sizeof(memory_path),
"%s/Runtime_Memory.csv", simCtx.
log_dir));
1449 "runtime memory log should be a CSV with its header"));
1451 "runtime memory log should contain a step row"));
1453 "runtime memory log should contain a final row"));
1455 "runtime memory log should record final reason"));
1458 PetscCall(
PicurvAssertBool((PetscBool)(remove(memory_path) == 0),
"enabled runtime memory log should be removable"));
1461 "disabled runtime memory log should not create a file"));
1463 PetscFunctionReturn(0);
1474 char tmpdir[PETSC_MAX_PATH_LEN], path[PETSC_MAX_PATH_LEN];
1477 PetscFunctionBeginUser;
1479 PetscCall(PetscSNPrintf(path,
sizeof(path),
"%s/history.csv", tmpdir));
1481 PetscCall(PetscCalloc1(1, &simCtx));
1482 for (PetscInt step = 0; step < 2; ++step) {
1484 fprintf(f,
"%d,fresh\n", (
int)step);
1487 PetscCall(
AssertFileContains(path,
"step,value\n0,fresh\n1,fresh\n",
"a later open must not truncate the step-0 rows"));
1488 PetscCall(PetscFree(simCtx));
1490 PetscCall(PetscCalloc1(1, &simCtx));
1493 for (PetscInt step = 15; step <= 20; step += 5) {
1495 fprintf(f,
"%d,continued\n", (
int)step);
1498 PetscCall(
AssertFileContains(path,
"1,fresh\n# Continuation from step 10\n15,continued\n20,continued\n",
1499 "a continuation is marked once, at its first write"));
1500 PetscCall(PetscFree(simCtx));
1502 PetscFunctionReturn(0);
1512 char tmpdir[PETSC_MAX_PATH_LEN];
1513 char log_path[PETSC_MAX_PATH_LEN];
1514 PetscBool exists = PETSC_FALSE;
1516 PetscFunctionBeginUser;
1519 PetscCall(PetscStrncpy(simCtx->
log_dir, tmpdir,
sizeof(simCtx->
log_dir)));
1524 PetscCall(PetscSNPrintf(log_path,
sizeof(log_path),
"%s/solution_convergence.csv", simCtx->
log_dir));
1525 PetscCall(PetscTestFile(log_path,
'r', &exists));
1527 "disabled solution convergence must not create a log"));
1531 PetscFunctionReturn(0);
1541 char tmpdir[PETSC_MAX_PATH_LEN];
1542 char log_path[PETSC_MAX_PATH_LEN];
1548 PetscReal ***nvert = NULL;
1549 PetscReal mean_speed = NAN;
1550 PetscReal mean_speed_ref = NAN;
1551 PetscReal mean_speed_abs = NAN;
1552 PetscReal p_abs = NAN;
1553 PetscInt has_reference_1 = 0;
1554 PetscInt has_reference_2 = 0;
1556 PetscFunctionBeginUser;
1559 PetscCall(PetscStrncpy(simCtx->
log_dir, tmpdir,
sizeof(simCtx->
log_dir)));
1568 PetscCall(DMDAVecGetArray(user->
da, user->
Nvert, &nvert));
1569 nvert[1][1][1] = 1.0;
1570 PetscCall(DMDAVecRestoreArray(user->
da, user->
Nvert, &nvert));
1571 PetscCall(DMDAVecGetArray(user->
fda, user->
Ucat, &ucat));
1572 ucat[1][1][1].
x = 999.0;
1573 PetscCall(DMDAVecRestoreArray(user->
fda, user->
Ucat, &ucat));
1582 PetscCall(DMDAVecGetArray(user->
fda, user->
Ucat, &ucat));
1583 ucat[1][1][1].
x = 999.0;
1584 PetscCall(DMDAVecRestoreArray(user->
fda, user->
Ucat, &ucat));
1587 PetscCall(PetscSNPrintf(log_path,
sizeof(log_path),
"%s/solution_convergence.csv", simCtx->
log_dir));
1599 PetscCall(
PicurvAssertBool((PetscBool)(strcmp(mode,
"steady_deterministic") == 0),
1600 "steady solution convergence row should record the mode name"));
1602 "the first steady solution-convergence row should be a warmup row"));
1604 "steady solution convergence should compare against the previous solved step"));
1606 "steady solution convergence should mask IBM-marked solid cells"));
1608 "steady solution convergence should report the previous-step mean speed"));
1610 "steady solution convergence should report mean-speed drift"));
1612 "steady solution convergence pressure drift should be gauge invariant"));
1616 PetscFunctionReturn(0);
1626 char tmpdir[PETSC_MAX_PATH_LEN];
1627 char log_path[PETSC_MAX_PATH_LEN];
1632 PetscInt has_reference_1 = 0;
1633 PetscInt has_reference_2 = 0;
1634 PetscInt has_reference_3 = 0;
1635 PetscInt phase_step_1 = -1;
1636 PetscInt phase_step_2 = -1;
1637 PetscInt phase_step_3 = -1;
1638 PetscReal mean_speed_ref_2 = NAN;
1639 PetscReal mean_speed_abs_2 = NAN;
1641 PetscFunctionBeginUser;
1644 PetscCall(PetscStrncpy(simCtx->
log_dir, tmpdir,
sizeof(simCtx->
log_dir)));
1668 PetscCall(PetscSNPrintf(log_path,
sizeof(log_path),
"%s/solution_convergence.csv", simCtx->
log_dir));
1669 PetscCall(
PicurvAssertFileExists(log_path,
"periodic solution-convergence logging should write the log"));
1683 "the first periodic phase visit should log warmup without a reference"));
1685 "the first periodic cycle should fully warm up before comparisons begin"));
1687 "the repeated periodic phase visit should compare against the stored reference"));
1689 "periodic solution convergence should log the current phase slot"));
1691 "periodic solution convergence should log distinct phase slots during warmup"));
1693 "periodic solution convergence should reuse the same phase slot on later cycles"));
1695 "periodic solution convergence should report the stored phase-aligned reference"));
1697 "periodic solution convergence should report the phase-aligned drift"));
1701 PetscFunctionReturn(0);
1711 char tmpdir[PETSC_MAX_PATH_LEN];
1712 char log_path[PETSC_MAX_PATH_LEN];
1715 PetscReal mean_speed_window = NAN;
1716 PetscReal mean_speed_window_prev = NAN;
1717 PetscReal mean_speed_window_abs = NAN;
1718 PetscReal mean_speed_rms_window = NAN;
1719 PetscReal mean_ke_window = NAN;
1720 PetscReal mean_ke_window_prev = NAN;
1721 PetscReal mean_ke_window_abs = NAN;
1722 PetscReal mean_ke_rms_window_abs = NAN;
1723 PetscInt has_reference = 0;
1724 const PetscReal speed_samples[4] = {1.0, 3.0, 2.0, 4.0};
1726 PetscFunctionBeginUser;
1729 PetscCall(PetscStrncpy(simCtx->
log_dir, tmpdir,
sizeof(simCtx->
log_dir)));
1734 for (PetscInt step = 0; step < 4; ++step) {
1735 simCtx->
step = step + 1;
1736 simCtx->
ti = 0.1 * (PetscReal)(step + 1);
1741 PetscCall(PetscSNPrintf(log_path,
sizeof(log_path),
"%s/solution_convergence.csv", simCtx->
log_dir));
1742 PetscCall(
PicurvAssertFileExists(log_path,
"statistical solution-convergence logging should write the log"));
1746 PetscCall(
LogGetColumnReal(header, row,
"spd_win_prev", &mean_speed_window_prev));
1747 PetscCall(
LogGetColumnReal(header, row,
"spd_win_abs", &mean_speed_window_abs));
1748 PetscCall(
LogGetColumnReal(header, row,
"spd_rms_win", &mean_speed_rms_window));
1750 PetscCall(
LogGetColumnReal(header, row,
"ke_win_prev", &mean_ke_window_prev));
1751 PetscCall(
LogGetColumnReal(header, row,
"ke_win_abs", &mean_ke_window_abs));
1752 PetscCall(
LogGetColumnReal(header, row,
"ke_rms_abs", &mean_ke_rms_window_abs));
1755 "statistical solution convergence should emit adjacent-window drift once two windows exist"));
1757 "statistical solution convergence should report the current mean-speed window"));
1759 "statistical solution convergence should report the previous mean-speed window"));
1761 "statistical solution convergence should report mean-speed window drift"));
1763 "statistical solution convergence should report current mean-speed RMS"));
1765 "statistical solution convergence should report the current kinetic-energy window"));
1767 "statistical solution convergence should report the previous kinetic-energy window"));
1769 "statistical solution convergence should report kinetic-energy window drift"));
1771 "statistical solution convergence should report RMS kinetic-energy drift"));
1775 PetscFunctionReturn(0);
1788 char tmpdir[PETSC_MAX_PATH_LEN];
1789 char log_path[PETSC_MAX_PATH_LEN];
1792 PetscReal mean_speed = NAN;
1795 PetscFunctionBeginUser;
1798 PetscCall(PetscStrncpy(simCtx->
log_dir, tmpdir,
sizeof(simCtx->
log_dir)));
1800 PetscCall(DMDAVecGetArray(user->
fda, user->
Ucat, &arr));
1801 for (PetscInt k = user->
info.zs; k < user->
info.zs + user->
info.zm; ++k) {
1802 for (PetscInt j = user->
info.ys; j < user->
info.ys + user->
info.ym; ++j) {
1803 for (PetscInt i = user->
info.xs; i < user->
info.xs + user->
info.xm; ++i) {
1804 const PetscBool ghost = (PetscBool)(i == 0 || j == 0 || k == 0 || i == user->
info.mx - 1 ||
1805 j == user->
info.my - 1 || k == user->
info.mz - 1);
1806 arr[k][j][i].
x = 0.0;
1807 arr[k][j][i].
y = 0.0;
1808 arr[k][j][i].
z = ghost ? 100.0 : 1.0;
1812 PetscCall(DMDAVecRestoreArray(user->
fda, user->
Ucat, &arr));
1820 PetscCall(PetscSNPrintf(log_path,
sizeof(log_path),
"%s/solution_convergence.csv", simCtx->
log_dir));
1824 "mean speed must average physical cells only, not wall ghost images"));
1828 PetscFunctionReturn(0);
1843 const PetscInt km_values[] = {8, 16};
1844 const PetscInt n_cases = (PetscInt)(
sizeof(km_values) /
sizeof(km_values[0]));
1846 PetscFunctionBeginUser;
1847 for (PetscInt t = 0; t < n_cases; ++t) {
1848 const PetscInt km = km_values[t];
1851 char tmpdir[PETSC_MAX_PATH_LEN];
1852 char log_path[PETSC_MAX_PATH_LEN];
1855 PetscReal mean_ke = NAN;
1858 PETSC_TRUE, PETSC_TRUE, PETSC_TRUE));
1860 PetscCall(PetscStrncpy(simCtx->
log_dir, tmpdir,
sizeof(simCtx->
log_dir)));
1872 PetscCall(PetscSNPrintf(log_path,
sizeof(log_path),
"%s/solution_convergence.csv", simCtx->
log_dir));
1876 "periodic sinusoidal field mean KE must equal 0.5025 (no duplicate endpoint)"));
1881 PetscFunctionReturn(0);
1890 PetscErrorCode ierr;
1920 (void)setenv(
"LOG_LEVEL",
"INFO", 1);
1922 ierr = PetscInitialize(&argc, &argv, NULL,
"PICurv logging tests");
1927 ierr =
PicurvRunTests(
"unit-logging", cases,
sizeof(cases) /
sizeof(cases[0]));
1935 ierr = PetscFinalize();
PetscErrorCode AnalyticalFieldDestroy(SimCtx *simCtx)
Release what AnalyticalSolutionEngine() keeps from step to step, if anything.
PetscErrorCode AnalyticalSolutionEngine(SimCtx *simCtx)
Sets the Eulerian fields from the case's source (-ic_source_*) at the step's time.
PetscErrorCode SetAnalyticalSolutionForParticles(Vec tempVec, SimCtx *simCtx)
Evaluates the analytical velocity at particle positions.
PetscErrorCode CalculateParticleCountPerCell(UserCtx *user)
Counts particles in each cell of the DMDA 'da' and stores the result in user->ParticleCount.
FieldId
Compile-time identity for a catalogued Eulerian field.
PetscErrorCode ScatterAllParticleFieldsToEulerFields(UserCtx *user)
Scatters a predefined set of particle fields to their corresponding Eulerian fields.
PetscErrorCode LogLESDiagnostics(UserCtx *user)
Appends one row of LES coefficient statistics to the run's log directory.
Logging utilities and macros for PETSc-based applications.
PetscErrorCode LOG_FIELD_MIN_MAX(UserCtx *user, FieldId field_id)
Computes and logs the local and global min/max values of a 3-component vector field.
void set_allowed_functions(const char **functionList, int count)
Sets the global list of function names that are allowed to log.
PetscErrorCode PicurvOpenRunCsv(SimCtx *simCtx, const char *dir, const char *filename, const char *header, PicurvCsvLifecycle lifecycle, PetscBool required, FILE **file)
Opens one of the run's CSV records (diagnostics, solver history, profiling) for writing.
PetscBool ShouldEmitPeriodicStatisticsConsoleSnapshot(const struct SimCtx *simCtx, PetscInt completed_step)
Reports whether a completed step falls on the console snapshot cadence.
@ PICURV_CSV_TRUNCATE_ON_FRESH
A fresh run's first write empties the file; a continued run appends.
const char * BCHandlerTypeToString(BCHandlerType handler_type)
Converts a BCHandlerType enum to its string representation.
PetscBool is_function_allowed(const char *functionName)
Checks if a given function is in the allow-list.
PetscErrorCode DualMonitorDestroy(void **ctx)
Destroys the DualMonitorCtx.
PetscBool IsStatisticsConsoleSnapshotEnabled(const struct SimCtx *simCtx)
Reports whether the periodic statistics console snapshot is enabled.
PetscErrorCode LOG_INTERPOLATION_ERROR(UserCtx *user)
Logs the interpolation error between the analytical and computed solutions.
PetscBool ShouldEmitPeriodicParticleConsoleSnapshot(const SimCtx *simCtx, PetscInt completed_step)
Returns whether a particle console snapshot should be emitted for the completed timestep.
const char * BCFaceToString(BCFace face)
Returns the canonical log token for a boundary-face enum value.
PetscErrorCode FreeAllowedFunctions(char **funcs, PetscInt n)
Free an array previously returned by LoadAllowedFunctionsFromFile().
PetscBool IsParticleConsoleSnapshotEnabled(const SimCtx *simCtx)
Returns whether periodic particle console snapshots are enabled.
PetscErrorCode print_log_level(void)
Prints the current logging level to the console.
#define PROFILE_HELPER_BEGIN
Marks the beginning of a profiled helper: timed only when enabled by name.
#define PROFILE_HELPER_END
Alias of PROFILE_FUNCTION_END for a function that began with PROFILE_HELPER_BEGIN.
PetscErrorCode EmitParticleConsoleSnapshot(UserCtx *user, SimCtx *simCtx, PetscInt step)
Emits one particle console snapshot into the main solver log.
void PrintProgressBar(PetscInt step, PetscInt startStep, PetscInt totalSteps, PetscReal currentTime, PetscReal seconds_per_step, PetscInt64 lost_cumulative)
Prints a progress bar to the console.
#define PROFILE_FUNCTION_END
Marks the end of a profiled code block.
PetscErrorCode ProfilingFinalize(SimCtx *simCtx)
Writes the end-of-run profiling summary across all ranks; collective on PETSC_COMM_WORLD.
PetscErrorCode LoadAllowedFunctionsFromFile(const char filename[], char ***funcsOut, PetscInt *nOut)
Load function names from a text file.
PetscErrorCode EmitStatisticsConsoleSnapshot(UserCtx *user, const struct SimCtx *simCtx, PetscInt step)
Emits one console snapshot of window progress.
PetscErrorCode RuntimeMemoryLogSample(SimCtx *simCtx, PetscInt step, const char *event, const char *reason)
Append a reduced runtime memory sample to the configured memory log.
PetscErrorCode ProfilingLogTimestepSummary(SimCtx *simCtx, PetscInt step)
Logs the performance summary for the current timestep and resets timers.
PetscErrorCode LOG_FACE_DISTANCES(PetscReal *d)
Prints the signed distances to each face of the cell.
PetscErrorCode LOG_PARTICLE_FIELDS(UserCtx *user, PetscInt printInterval)
Prints particle fields in a table that automatically adjusts its column widths.
const char * BCTypeToString(BCType type)
Returns the canonical log token for a boundary mathematical type.
PetscErrorCode CalculateAdvancedParticleMetrics(UserCtx *user)
Computes advanced particle statistics and stores them in SimCtx.
const char * ParticleLocationStatusToString(ParticleLocationStatus level)
A function that outputs the name of the current level in the ParticleLocation enum.
PetscErrorCode LOG_SCATTER_METRICS(UserCtx *user)
Logs particle-to-grid scatter verification metrics for the prescribed scalar truth path.
PetscErrorCode LOG_SOLUTION_CONVERGENCE(SimCtx *simCtx)
Logs physical solution-convergence metrics once per completed timestep.
PetscErrorCode LOG_CONTINUITY_METRICS(UserCtx *user)
Logs continuity metrics for a single block to a file.
PetscErrorCode LOG_FIELD_ANATOMY(UserCtx *user, FieldId field_id, const char *stage_name)
Logs the anatomy of a specified field at key boundary locations, respecting the solver's specific gri...
PetscErrorCode LOG_SEARCH_METRICS(UserCtx *user)
Writes compact runtime search metrics to CSV and optionally to console.
PetscErrorCode ProfilingInitialize(SimCtx *simCtx)
Applies the profiling configuration from SimCtx to PICurv's PETSc log events.
@ LOG_INFO
Informational messages about program execution.
#define PROFILE_FUNCTION_BEGIN
Marks the beginning of a profiled function: an always-on aggregate timer.
const char * LESModelToString(LESModelType LESFlag)
Returns the canonical log token for an LES model selector.
PetscErrorCode LOG_CELL_VERTICES(const Cell *cell, PetscMPIInt rank)
Prints the coordinates of a cell's vertices.
PetscErrorCode ProfilingResetTimestepCounters(void)
Starts a new per-step profiling interval.
const char * MomentumSolverTypeToString(MomentumSolverType SolverFlag)
Returns the canonical log token for a momentum-solver selector.
const char * ParticleInitializationToString(ParticleInitializationType ParticleInitialization)
Returns the canonical log token for a particle-initialization mode.
static LogLevel get_log_level(void)
Retrieves the current logging level from the environment variable LOG_LEVEL.
Context for a dual-purpose KSP monitor.
PetscErrorCode InitializeSolutionConvergenceState(SimCtx *simCtx)
Allocates any runtime storage required by solution-convergence logging.
Per-window PETSc accumulator storage and pointwise application.
Vec weight
Per-point valid weight.
Vec * mean
One per field, matching that field's layout.
PetscErrorCode PicurvWindowStorageCreate(UserCtx *user, const PicurvWindowDefinition *definition, PicurvWindowStorage *storage)
Allocates the accumulator state one window owns on one block.
Vec * m2
One per field; NULL when no second moment was requested.
Vec count
Per-point accepted sample count.
PetscErrorCode PicurvWindowStorageDestroy(PicurvWindowStorage *storage)
Releases accumulator state previously created for one window.
Independent accumulator state for one window on one block.
Window lifecycle, scheduling, and weighting for the field-statistics pipeline.
PicurvWindowFieldRequest fields[16]
PetscErrorCode FieldStatisticsUpdateWindows(struct SimCtx *simCtx, PetscInt step, PetscReal time)
Offers one completed state to every configured window.
PetscReal end_time
Requested end; ignored when bounded is false.
PicurvCadenceKind cadence_kind
PetscInt step_cadence
Used when cadence_kind is step; must be positive.
#define PICURV_WINDOW_NAME_LENGTH
Maximum stored length of a window name, including the terminator.
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.
PetscBool bounded
False for an open-ended window.
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 TestParticleConsoleSnapshotCadence(void)
Tests periodic particle console snapshot enablement and cadence.
static PetscErrorCode SetUniformScalarField(UserCtx *user, Vec field, PetscReal value)
Fills one scalar field with a uniform constant state.
static PetscErrorCode TestFieldAnatomyLogging(void)
Tests stdout field-anatomy logging on the corrected production-like DM fixture.
static PetscErrorCode LogGetColumnText(const char *header, const char *row, const char *column_name, char *value, size_t value_len)
Extracts one comma-separated log cell as text by header name.
static PetscErrorCode InvokeParticleConsoleSnapshot(UserCtx *user, SimCtx *simCtx, void *ctx)
Adapts EmitParticleConsoleSnapshot() to the generic stdout-capture callback shape.
static void ProfiledUnselectedAggregate(void)
Profiled stand-in: an aggregate the per-step list does not select.
static PetscErrorCode TestStatisticsConsoleSnapshotLogging(void)
Tests statistics console snapshot content, and its silence when disabled.
static PetscErrorCode TestParticleConsoleSnapshotLogging(void)
Tests console snapshot logging against the public periodic-snapshot helper.
static PetscErrorCode TestStatisticsConsoleSnapshotCadence(void)
Tests periodic statistics console snapshot enablement and cadence.
static PetscErrorCode CaptureLoggingOutput(UserCtx *user, SimCtx *simCtx, CapturedLoggingFn fn, void *ctx, char *captured, size_t captured_len)
Captures stdout emitted by one logging helper into a temporary file-backed buffer.
static PetscErrorCode TestGetLogLevelFromEnvironment(void)
Tests that log level selection honors the environment variable.
int main(int argc, char **argv)
Runs the unit-logging PETSc test binary.
static PetscErrorCode TestLoggingContinuityAndFieldDiagnostics(void)
Tests continuity, min/max, and anatomy logging helpers on minimal runtime fixtures.
static PetscErrorCode AssertVecsIdentical(Vec expected, Vec actual, const char *context)
Asserts two accumulator vectors are bit-identical.
static PetscErrorCode TestPeriodicSinusoidalMeanKE(void)
Regression test: volume-averaged mean KE of a sinusoidal field in a fully periodic domain.
PetscErrorCode(* CapturedLoggingFn)(UserCtx *user, SimCtx *simCtx, void *ctx)
static PetscErrorCode TestSolutionConvergenceStatisticalLogging(void)
Tests statistical solution-convergence sliding-window metrics.
static PetscErrorCode SetUniformPressure(UserCtx *user, PetscReal value)
Sets the pressure field to a uniform value across the owned range.
static PetscErrorCode AssertFileNotContains(const char *path, const char *needle, const char *context)
Asserts that one text file does not contain an excluded substring.
static PetscErrorCode AccumulateAtConsoleCadence(SimCtx *simCtx, UserCtx *user, PicurvWindow *window, PicurvWindowStorage *storage, const PicurvWindowDefinition *definition, PetscInt console_frequency)
Drives one accumulation run at a given console cadence, in the runloop's order.
static PicurvWindowDefinition LoggingStatisticsDefinition(void)
Builds the window definition backing this suite's statistics console fixture.
static PetscErrorCode InvokeFieldAnatomyLog(UserCtx *user, SimCtx *simCtx, void *ctx)
Adapts LOG_FIELD_ANATOMY() to the generic stdout-capture callback shape.
static PetscErrorCode TestSolutionConvergenceMeansExcludeGhostLayers(void)
Regression test: convergence observables ignore the ghost layers of a walled box.
static void ProfiledEnabledHelper(void)
Profiled stand-in: a helper that profiling.helpers names.
static PetscErrorCode TestSolutionConvergencePeriodicLogging(void)
Tests periodic solution-convergence warmup and phase-aligned reference reuse.
static PetscErrorCode TestStringConversionHelpers(void)
Tests string-conversion helpers for configured enums and unknown values.
static PetscErrorCode SetSinusoidalVZField(UserCtx *user, Vec field, PetscReal v_amp, PetscReal w_const)
Fills one Cartesian velocity field with u=0, v=v_amp*sin(2π*k/km), w=w_const.
static PetscErrorCode TestLoggingFileParsingAndFormattingHelpers(void)
Tests logging-side file parsing, helper formatting, and progress utilities.
static PetscErrorCode TestAllowedFunctionsFilter(void)
Tests the function allow-list filter used by the logging layer.
static PetscErrorCode TestInterpolationErrorLogging(void)
Tests interpolation-error logging against an analytically matched particle field.
static PetscErrorCode SeedLoggingParticleFixture(SimCtx **simCtx_out, UserCtx **user_out)
Creates a small particle-bearing runtime fixture used by logging tests.
static PetscErrorCode TestScatterMetricsLogging(void)
Tests file-backed scatter metrics logging against a fully occupied constant field.
static PetscErrorCode TestParticleMetricsLogging(void)
Tests file-backed particle metrics logging after derived metrics are computed.
static PetscErrorCode TestSearchMetricsLogging(void)
Tests file-backed search metrics logging with the compact CSV contract.
static PetscErrorCode InvokeStatisticsConsoleSnapshot(UserCtx *user, SimCtx *simCtx, void *ctx)
Adapts EmitStatisticsConsoleSnapshot() to the generic stdout-capture callback shape.
static PetscErrorCode TestParticleFieldTableLogging(void)
Tests stdout particle-table logging on a production-like swarm fixture.
static void ProfiledFlowSolver(void)
Profiled stand-in: an aggregate named FlowSolver.
static PetscErrorCode TestSolutionConvergenceDisabled(void)
Verifies -solution_convergence_enabled=false suppresses the convergence writer.
static PetscErrorCode LogFindColumnIndex(const char *header, const char *column_name, PetscInt *index_out)
Returns the zero-based column index for one comma-separated header field.
static PetscErrorCode SetUniformVelocityField(UserCtx *user, Vec field, PetscReal ux, PetscReal uy, PetscReal uz)
Fills one Cartesian velocity field with a uniform constant state.
static PetscErrorCode TestRunCsvFirstOpenIsTrackedPerRun(void)
The run's first open of a CSV record is found by path, whenever it falls: a step-0 write survives a l...
static PetscErrorCode ReadLogHeaderAndRow(const char *path, PetscInt row_index, char *header, size_t header_len, char *row, size_t row_len)
Reads the column header and the requested 1-based data row from a comma-separated solution-convergenc...
static PetscErrorCode TestLESDiagnosticsConstantModelHasNoMeasuredCoefficient(void)
Tests that the constant Smagorinsky model reports its configured coefficient, not a measured one.
static PetscErrorCode AssertFileContains(const char *path, const char *needle, const char *context)
Asserts that one text file contains a required substring.
static PetscErrorCode LogGetColumnReal(const char *header, const char *row, const char *column_name, PetscReal *value_out)
Extracts one comma-separated log cell as a real by header name.
static PetscErrorCode TestSolutionConvergenceSteadyLogging(void)
Tests steady solution-convergence log output, IBM masking, and gauge-invariant pressure drift.
static PetscErrorCode TestProfilingLifecycleHelpers(void)
Tests profiling helper lifecycle logging for timestep and final-summary outputs.
static PetscErrorCode LogGetColumnInt(const char *header, const char *row, const char *column_name, PetscInt *value_out)
Extracts one comma-separated log cell as an integer by header name.
static void ProfiledDisabledHelper(void)
Profiled stand-in: a helper that profiling.helpers does not name.
static PetscErrorCode TestConsoleCadenceDoesNotChangeAccumulation(void)
Tests that the console cadence has no effect on any accumulated result.
static PetscErrorCode InvokeParticleFieldLog(UserCtx *user, SimCtx *simCtx, void *ctx)
Adapts LOG_PARTICLE_FIELDS() to the generic stdout-capture callback shape.
static PetscErrorCode TestRuntimeMemoryLogHelpers(void)
Tests runtime memory log header, step rows, final rows, and disabled mode.
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 PicurvCreateMinimalContextsWithPeriodicity(SimCtx **simCtx_out, UserCtx **user_out, PetscInt mx, PetscInt my, PetscInt mz, PetscBool x_periodic, PetscBool y_periodic, PetscBool z_periodic)
Builds minimal SimCtx and UserCtx fixtures for C unit tests with configurable periodicity.
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 PicurvAssertFileExists(const char *path, const char *context)
Asserts that a filesystem path exists as a readable file.
PetscErrorCode PicurvAssertIntEqual(PetscInt expected, PetscInt actual, const char *context)
Asserts that two integer values are equal.
PetscErrorCode PicurvPopulateIdentityMetrics(UserCtx *user)
Populates identity metric vectors on the minimal grid fixture.
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 particlesPerCellMin
Fewest particles in any cell after the step.
PetscInt particlesPerCellMax
Most particles in any cell after the step.
PetscInt fieldStatisticsWindowCount
PetscBool profilingFinalSummary
PetscInt64 searchLocatedCount
PetscInt statisticsConsoleOutputFreq
PetscInt64 searchLostCount
LESConfig les_config
Parameters of the LES closure selected by les.
@ PARTICLE_INIT_VOLUME
Random volumetric distribution across the domain.
@ LOST
The search failed for a particle believed to be inside the domain.
@ EXITED
The particle crossed a domain-boundary face whose particle policy removes it.
PetscBool runtimeMemoryLogEnabled
Enable the rank-reduced runtime memory log (log_dir/Runtime_Memory.csv).
PetscInt64 boundaryClampCount
PetscInt particlesLostLastStep
Particles removed this step because their search failed.
PetscInt64 traversalStepsSum
@ BC_HANDLER_PERIODIC_DRIVEN_CONSTANT_FLUX
PetscReal poissonSourceImbalance
PetscInt64 searchPopulation
PetscBool solutionConvergenceEnabled
PetscInt occupiedCellCount
char profilingTimestepMode[32]
PetscBool fieldStatisticsEnabled
@ MOMENTUM_SOLVER_EXPLICIT_RK
@ MOMENTUM_SOLVER_NEWTON_KRYLOV
PetscInt solutionConvergencePeriodSteps
PetscInt64 bboxGuessFallbackCount
char analysis_dir[PETSC_MAX_PATH_LEN]
PetscInt64 bboxGuessSuccessCount
struct PicurvWindow * fieldStatisticsWindows
char log_dir[PETSC_MAX_PATH_LEN]
PetscInt64 maxParticlePassDepth
PetscInt64 maxTraversalSteps
PetscInt64 particlesLostCumulative
PetscInt diagnostics_cadence
Steps between diagnostic rows.
PetscReal particlesPerCellMean
Particles counted in cells divided by the cell count.
PetscBool runtimeMemoryLogHasPrevious
True after the first process-memory sample.
char ** profilingSelectedFuncs
PetscBool diagnostics_enabled
Append per-step coefficient statistics to the run log directory.
PetscReal constant_cs
Fixed Cs for CONSTANT_SMAGORINSKY; unused by the dynamic model.
PetscInt solutionConvergenceWindowSteps
PetscInt nProfilingSelectedFuncs
PetscInt particlesMigratedLastStep
struct PicurvWindowStorage * fieldStatisticsStorage
PetscInt particleConsoleOutputFreq
SearchMetricsState searchMetrics
PetscInt migrationPassesLastStep
PetscInt les
Active LES closure; an LESModelType value.
@ SOLUTION_CONVERGENCE_PERIODIC_DETERMINISTIC
@ SOLUTION_CONVERGENCE_STATISTICAL_STEADY
@ SOLUTION_CONVERGENCE_STEADY_DETERMINISTIC
SolutionConvergenceMode solutionConvergenceMode
char ** profilingHelpers
Helper functions whose timers are enabled (-profiling_helpers).
PetscInt64 searchAttempts
PetscInt64 maxTraversalFailCount
PetscInt nProfilingHelpers
VerificationFieldConfig verificationScalar
Cmpnts vertices[8]
Coordinates of the eight vertices of the cell.
PetscReal particleLoadImbalance
Defines the vertices of a single hexahedral grid cell.
A 3D point or vector with PetscScalar components.
The master context for the entire simulation.
User-defined context containing data specific to a single computational grid level.
PetscErrorCode VerificationFieldCompile(const char *text, VerificationFieldConfig *field)
Compiles a verification field's expression, in physical x, y, z and t, and enables the field.