24 PetscFunctionBeginUser;
26 char *pipeline_copy, *step_token, *step_saveptr;
27 PetscBool finalize_needed = PETSC_FALSE;
29 ierr = DMCreate(PETSC_COMM_WORLD, &user->
post_swarm); CHKERRQ(ierr);
30 ierr = DMSetType(user->
post_swarm, DMSWARM); CHKERRQ(ierr);
31 ierr = DMSetDimension(user->
post_swarm, 3); CHKERRQ(ierr);
32 ierr = DMSwarmSetType(user->
post_swarm, DMSWARM_BASIC); CHKERRQ(ierr);
35 ierr = DMSwarmSetCellDM(user->
post_swarm, user->
da); CHKERRQ(ierr);
48 step_token = strtok_r(pipeline_copy,
";", &step_saveptr);
51 if (strlen(step_token) == 0) { step_token = strtok_r(NULL,
";", &step_saveptr);
continue; }
53 char *keyword = strtok(step_token,
":");
54 char *args_str = strtok(NULL,
"");
56 PetscInt output_field_dimensions = 1;
58 if (strcasecmp(keyword,
"ComputeSpecificKE") == 0) {
59 if (!args_str) SETERRQ(PETSC_COMM_SELF, 1,
"Error (ComputeSpecificKE): Missing arguments.");
60 char *input_field = strtok(args_str,
">");
61 char *output_field = strtok(NULL,
">");
62 output_field_dimensions = 1;
63 if (!input_field) SETERRQ(PETSC_COMM_SELF, 1,
"Error (ComputeSpecificKE): Missing input field in 'in>out' syntax.");
64 if (!output_field) SETERRQ(PETSC_COMM_SELF, 1,
"Error (ComputeSpecificKE): Missing output field in 'in>out' syntax.");
67 if (strlen(input_field) == 0) SETERRQ(PETSC_COMM_SELF, 1,
"Error (ComputeSpecificKE): Empty input field name.");
68 if (strlen(output_field) == 0) SETERRQ(PETSC_COMM_SELF, 1,
"Error (ComputeSpecificKE): Empty output field name.");
71 LOG_ALLOW(
GLOBAL,
LOG_INFO,
"Registered particle field '%s' (ComputeSpecificKE input='%s').\n", output_field, input_field);
72 finalize_needed = PETSC_TRUE;
79 step_token = strtok_r(NULL,
";", &step_saveptr);
82 ierr = PetscFree(pipeline_copy); CHKERRQ(ierr);
85 if (finalize_needed) {
88 LOG_ALLOW(
GLOBAL,
LOG_INFO,
"No custom particle fields requested; finalizing an empty post-processing swarm for safe use.\n");
90 ierr = DMSwarmFinalizeFieldRegister(user->
post_swarm); CHKERRQ(ierr);
95 PetscFunctionReturn(0);
108 char *pipeline_copy, *step_token, *step_saveptr;
110 PetscFunctionBeginUser;
118 PetscFunctionReturn(0);
124 ierr = PetscStrallocpy(pps->
process_pipeline, &pipeline_copy); CHKERRQ(ierr);
127 step_token = strtok_r(pipeline_copy,
";", &step_saveptr);
130 if (strlen(step_token) == 0) {
131 step_token = strtok_r(NULL,
";", &step_saveptr);
135 char *keyword = strtok(step_token,
":");
136 char *args_str = strtok(NULL,
"");
139 step_token = strtok_r(NULL,
";", &step_saveptr);
146 LOG_ALLOW(
GLOBAL,
LOG_INFO,
"Executing Transformation: '%s' on args: '%s'\n", keyword, args_str ? args_str :
"None");
149 if (strcasecmp(keyword,
"CellToNodeAverage") == 0) {
150 if (!args_str) SETERRQ(PETSC_COMM_SELF, 1,
"CellToNodeAverage requires arguments in 'in_field>out_field' format.");
151 char *in_field = strtok(args_str,
">");
152 char *out_field = strtok(NULL,
">");
153 if (!in_field || !out_field) SETERRQ(PETSC_COMM_SELF, 1,
"CellToNodeAverage requires 'in>out' syntax (e.g., P>P_nodal).");
154 if(strcmp(in_field,out_field)==0) SETERRQ(PETSC_COMM_SELF, 1,
"CellToNodeAverage input and output fields must be different.");
155 if(!
ParticlesEnabled(user->
simCtx) && (strcmp(out_field,
"Psi_nodal")==0 || strcmp(in_field,
"Psi_nodal")==0)){
156 LOG(
GLOBAL,
LOG_WARNING,
"CellToNodeAverage cannot process 'Psi_nodal' when no particles are present in the simulation.\n");
157 step_token = strtok_r(NULL,
";", &step_saveptr);
163 else if (strcasecmp(keyword,
"ComputeQCriterion") == 0) {
166 else if (strcasecmp(keyword,
"DimensionalizeAllLoadedFields") == 0) {
171 else if (strcasecmp(keyword,
"NormalizeRelativeField") == 0) {
172 if (!args_str) SETERRQ(PETSC_COMM_SELF, 1,
"NormalizePressure requires the pressure field name (e.g., 'P') as an argument.");
181 step_token = strtok_r(NULL,
";", &step_saveptr);
184 ierr = PetscFree(pipeline_copy); CHKERRQ(ierr);
187 PetscFunctionReturn(0);
203 PetscFunctionBeginUser;
207 LOG_ALLOW(
GLOBAL,
LOG_DEBUG,
"No instantaneous fields requested for output at ti=%" PetscInt_FMT
". Skipping.\n", ti);
209 PetscFunctionReturn(0);
218 LOG_ALLOW(
GLOBAL,
LOG_DEBUG,
"Using coords linearization order: fast=i mid=j slow=k (sizes: %" PetscInt_FMT
" x %" PetscInt_FMT
" x %" PetscInt_FMT
")\n",
219 meta.
mx, meta.
my, meta.
mz);
225 char *fields_copy, *field_name;
228 field_name = strtok(fields_copy,
",");
231 if (!*field_name) { field_name = strtok(NULL,
",");
continue; }
235 Vec field_vec = NULL;
236 PetscInt num_components = 0;
238 if (!strcasecmp(field_name,
"P_nodal")) {
239 field_vec = user->
P_nodal; num_components = 1;
240 }
else if (!strcasecmp(field_name,
"Ucat_nodal")) {
241 field_vec = user->
Ucat_nodal; num_components = 3;
242 }
else if (!strcasecmp(field_name,
"Qcrit_nodal")) {
244 }
else if (!strcasecmp(field_name,
"Qcrit")) {
247 SETERRQ(PETSC_COMM_WORLD, PETSC_ERR_ARG_WRONG,
248 "Field 'Qcrit' is cell-centred and cannot be written as point data. "
249 "Add a nodal_average task (input_field: Qcrit, output_field: Qcrit_nodal) and write 'Qcrit_nodal'.");
250 }
else if (!strcasecmp(field_name,
"Psi_nodal")){
253 field_name = strtok(NULL,
",");
256 field_vec = user->
Psi_nodal; num_components = 1;
259 field_name = strtok(NULL,
",");
267 field_name = strtok(NULL,
",");
270 ierr = PetscFree(fields_copy); CHKERRQ(ierr);
284 ierr = PetscSNPrintf(filename,
sizeof(filename),
"%s_%05" PetscInt_FMT
".vts", pps->
output_prefix, ti); CHKERRQ(ierr);
289 PetscFunctionReturn(0);
302 PetscBool want_vtk, PetscBool want_csv, PetscInt ti)
304 PetscFunctionBeginUser;
308 PetscInt derived_count = 0;
309 char filename[PETSC_MAX_PATH_LEN];
316 if (derived_count == 0) {
318 "Outputs '%s' produce no field for window '%s'; it accumulates none of "
319 "the state they need. Skipping.\n",
325 for (PetscInt index = 0; index < derived_count; ++index) {
328 PetscInt components = 0;
331 index, name,
sizeof(name), &nodal, &components));
336 PetscCall(PetscSNPrintf(filename,
sizeof(filename),
"%s_statistics_%s_%05" PetscInt_FMT
".vts",
349 PetscFunctionReturn(0);
365 PetscFunctionBeginUser;
374 PetscFunctionReturn(0);
387 char *windows_copy = NULL;
388 char *window_name = NULL;
389 PetscInt source_step = 0;
390 PetscBool want_vtk = PETSC_FALSE, want_csv = PETSC_FALSE;
392 PetscFunctionBeginUser;
404 token = strtok(formats,
",");
407 if (!strcasecmp(token,
"vtk")) want_vtk = PETSC_TRUE;
408 else if (!strcasecmp(token,
"csv")) want_csv = PETSC_TRUE;
410 "Unknown field-statistics format '%s'. Known formats are vtk and csv.\n", token);
411 token = strtok(NULL,
",");
418 "Field-statistics post-processing was requested, but the run's control configures "
419 "no statistics window.");
431 window_name = strtok(windows_copy,
",");
432 while (window_name) {
433 PetscInt window_index = -1;
437 if (!*window_name) { window_name = strtok(NULL,
",");
continue; }
440 PetscBool matches = PETSC_FALSE;
443 window_name, &matches); CHKERRQ(ierr);
444 if (matches) { window_index = w;
break; }
446 if (window_index < 0) {
447 ierr = PetscFree(windows_copy); CHKERRQ(ierr);
448 SETERRQ(PETSC_COMM_WORLD, PETSC_ERR_ARG_WRONG,
449 "Field-statistics post-processing requested window '%s', which this run does "
450 "not configure.", window_name);
458 "Statistics window '%s' had accumulated no sample by step %" PetscInt_FMT
459 "; nothing to derive yet.\n", window->
definition.
name, source_step);
460 window_name = strtok(NULL,
",");
465 want_vtk, want_csv, ti); CHKERRQ(ierr);
472 window_name = strtok(NULL,
",");
474 ierr = PetscFree(windows_copy); CHKERRQ(ierr);
484 ierr =
WriteWindowStatistics(user, pps, definition, &storage, want_vtk, want_csv, ti); CHKERRQ(ierr);
490 PetscFunctionReturn(0);
502 char *pipeline_copy, *step_token, *step_saveptr;
504 PetscFunctionBeginUser;
510 PetscFunctionReturn(0);
514 PetscInt n_local_source;
515 ierr = DMSwarmGetLocalSize(user->
swarm, &n_local_source); CHKERRQ(ierr);
518 ierr = DMSwarmSetLocalSizes(user->
post_swarm, n_local_source, -1); CHKERRQ(ierr);
525 step_token = strtok_r(pipeline_copy,
";", &step_saveptr);
528 if (strlen(step_token) == 0) { step_token = strtok_r(NULL,
";", &step_saveptr);
continue; }
530 char *keyword = strtok(step_token,
":");
531 char *args_str = strtok(NULL,
"");
535 LOG_ALLOW(
GLOBAL,
LOG_INFO,
"Executing Particle Transformation: '%s' on args: '%s'\n", keyword, args_str ? args_str :
"None");
537 if (strcasecmp(keyword,
"ComputeSpecificKE") == 0) {
538 if (!args_str) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
"ComputeSpecificKE requires 'input_field>output_field' arguments.");
539 char *velocity_field = strtok(args_str,
">");
540 char *ske_field = strtok(NULL,
">");
541 if (!velocity_field || !ske_field) {
542 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG,
"ComputeSpecificKE requires 'input_field>output_field' arguments.");
545 if (strlen(velocity_field) == 0 || strlen(ske_field) == 0) {
546 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG,
"ComputeSpecificKE does not allow empty input/output field names.");
555 step_token = strtok_r(NULL,
";", &step_saveptr);
557 ierr = PetscFree(pipeline_copy); CHKERRQ(ierr);
562 PetscFunctionReturn(0);
574 char *pipeline_copy, *step_token, *step_saveptr;
576 PetscFunctionBeginUser;
582 ierr = DMSwarmGetSize(user->
swarm, &n_global); CHKERRQ(ierr);
588 step_token = strtok_r(pipeline_copy,
";", &step_saveptr);
591 if (strlen(step_token) == 0) {
592 step_token = strtok_r(NULL,
";", &step_saveptr);
continue;
594 char *keyword = strtok(step_token,
":");
597 if (strcasecmp(keyword,
"ComputeMSD") == 0) {
601 "Unknown statistics keyword '%s'. Skipping.\n", keyword);
605 step_token = strtok_r(NULL,
";", &step_saveptr);
607 ierr = PetscFree(pipeline_copy); CHKERRQ(ierr);
611 PetscFunctionReturn(0);
625 PetscInt n_total_particles_before_subsample;
627 PetscFunctionBeginUser;
633 PetscFunctionReturn(0);
635 ierr = PetscMemzero(&part_meta,
sizeof(
VTKMetaData)); CHKERRQ(ierr);
639 if (n_total_particles_before_subsample == 0) {
642 PetscFunctionReturn(0);
646 LOG_ALLOW(
GLOBAL,
LOG_INFO,
"--- Starting VTP Particle File Writing for ti = %" PetscInt_FMT
" (writing %" PetscInt_FMT
" of %" PetscInt_FMT
" particles) ---\n",
647 ti, part_meta.
npoints, n_total_particles_before_subsample);
653 ierr = PetscSNPrintf(filename,
sizeof(filename),
"%s_%05" PetscInt_FMT
".vtp", pps->
particle_output_prefix, ti); CHKERRQ(ierr);
659 ierr = PetscFree(part_meta.
coords); CHKERRQ(ierr);
660 ierr = PetscFree(part_meta.
connectivity); CHKERRQ(ierr);
661 ierr = PetscFree(part_meta.
offsets); CHKERRQ(ierr);
665 PetscFunctionReturn(0);
678 PetscFunctionBeginUser;
684 PetscCall(PetscMalloc1(n > 0 ? n : 1, steps));
685 for (PetscInt k = 0; k < n; ++k) (*steps)[k] = pps->
startTime + k * pps->
timeStep;
688 PetscFunctionReturn(0);
691 rank = PetscGlobalRank;
694 PetscInt n = 0, capacity = 0;
695 PetscInt *
list = NULL;
696 char bad_line[256] =
"";
701 while (file && n >= 0 && fgets(line,
sizeof(line), file)) {
705 if (line[0] ==
'\0' || line[0] ==
'#')
continue;
706 value = strtol(line, &end, 10);
707 if (end == line || *end !=
'\0') {
708 PetscCall(PetscStrncpy(bad_line, line,
sizeof(bad_line)));
713 PetscInt *grown = NULL;
714 capacity = capacity ? 2 * capacity : 64;
715 PetscCall(PetscMalloc1(capacity, &grown));
716 if (n) PetscCall(PetscArraycpy(grown,
list, n));
717 PetscCall(PetscFree(
list));
720 list[n++] = (PetscInt)value;
722 if (file) fclose(file);
724 PetscCallMPI(MPI_Bcast(&n, 1, MPIU_INT, 0, PETSC_COMM_WORLD));
726 PetscCall(PetscFree(
list));
727 PetscCheck(n != -1, PETSC_COMM_WORLD, PETSC_ERR_FILE_OPEN,
728 "Step list file '%s' is missing. It is written when picurv launches the post "
729 "stage; launch post-processing through picurv.", pps->
step_list_file);
730 SETERRQ(PETSC_COMM_WORLD, PETSC_ERR_FILE_UNEXPECTED,
731 "Step list file '%s' has a non-integer line '%s'.", pps->
step_list_file, bad_line);
733 if (rank != 0) PetscCall(PetscMalloc1(n > 0 ? n : 1, &
list));
734 if (n > 0) PetscCallMPI(MPI_Bcast(
list, (PetscMPIInt)n, MPIU_INT, 0, PETSC_COMM_WORLD));
738 PetscFunctionReturn(0);
741#ifndef PICURV_POSTPROCESSOR_NO_MAIN
755 ierr = PetscInitialize(&argc, &argv, (
char *)0,
"Unified Post-Processing Tool"); CHKERRQ(ierr);
759 ierr = PetscPrintf(PETSC_COMM_WORLD,
"Postprocessor MPI processes: %d\n", (
int)simCtx->
size); CHKERRQ(ierr);
779 PetscBool needs_particle_ensembles = PETSC_FALSE;
784 if(needs_particle_stage) {
790 SETERRQ(PETSC_COMM_SELF,1,
791 "Particle post-processing requested (particle output, a particle statistics pipeline, "
792 "or a particle statistics ensemble) "
793 "but np=0. Please set np>0 during solver run to enable particle post-processing.");
802 PetscBool coordinates_dimensionalized = PETSC_FALSE;
805 PetscInt *steps = NULL, step_count = 0;
808 for (PetscInt k = 0; k < step_count; ++k) {
809 const PetscInt ti = steps[k];
819 coordinates_dimensionalized = PETSC_TRUE;
828 if(needs_particle_stage) {
838 if (needs_particle_ensembles) {
874 if(simCtx->
rank == 0){
875 PetscReal currentTime = (PetscReal)ti*simCtx->
dt;
883 if (simCtx->
rank == 0 && step_count > 0) {
884 PetscPrintf(PETSC_COMM_SELF,
"\n");
887 const PetscInt last_step = step_count > 0 ? steps[step_count - 1] : pps->
endTime;
888 ierr = PetscFree(steps); CHKERRQ(ierr);
898 ierr = PetscFinalize();
PetscErrorCode MigrateRestartParticlesUsingCellID(UserCtx *user)
Fast-path migration for restart particles using preloaded Cell IDs.
PetscErrorCode PreCheckAndResizeSwarm(UserCtx *user, PetscInt ti, const char *ext)
Checks particle count in the reference file and resizes the swarm if needed.
PetscErrorCode InitializeParticleSwarm(SimCtx *simCtx)
High-level particle initialization orchestrator for a simulation run.
PetscErrorCode RegisterSwarmField(DM swarm, const char *fieldName, PetscInt fieldDim, PetscDataType dtype)
Registers a swarm field without finalizing registration.
@ FIELD_DIMENSION_FIXED
The exponents are the field's dimension.
PetscErrorCode CreateVTKFileFromMetadata(const char *filename, const VTKMetaData *meta, MPI_Comm comm)
Creates a VTK file from prepared metadata and field payloads.
PetscErrorCode ReadSimulationFields(UserCtx *user, PetscInt ti)
Reads binary field data for velocity, pressure, and other required vectors.
void TrimWhitespace(char *str)
Removes leading and trailing ASCII whitespace from a mutable string.
PetscErrorCode ReadAllSwarmFields(UserCtx *user, PetscInt ti)
Reads multiple fields (positions, velocity, CellID, and weight) into a DMSwarm.
PetscErrorCode RestoreFieldStatisticsState(SimCtx *simCtx, PetscInt ti)
Restores field-statistics window state and accumulators from a checkpoint.
#define LOCAL
Logging scope definitions for controlling message output.
#define GLOBAL
Scope for global logging across all processes.
#define LOG_ALLOW(scope, level, fmt,...)
Logging macro that checks both the log level and whether the calling function is in the allowed-funct...
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.
#define LOG(scope, level, fmt,...)
Logging macro for PETSc-based applications with scope control.
PetscErrorCode RuntimeMemoryLogSample(SimCtx *simCtx, PetscInt step, const char *event, const char *reason)
Append a reduced runtime memory sample to the configured memory log.
@ LOG_ERROR
Critical errors that may halt the program.
@ LOG_INFO
Informational messages about program execution.
@ LOG_WARNING
Non-critical issues that warrant attention.
@ LOG_DEBUG
Detailed debugging information.
#define PROFILE_FUNCTION_BEGIN
Marks the beginning of a profiled function: an always-on aggregate timer.
static LogLevel get_log_level(void)
Retrieves the current logging level from the environment variable LOG_LEVEL.
ParticleFieldId
Compile-time identity for a persistent solver-particle field.
@ PARTICLE_FIELD_ID_COUNT
unsigned int capabilities
@ PARTICLE_FIELD_CAPABILITY_CHECKPOINT
PetscErrorCode ParticleFieldGetDescriptor(ParticleFieldId field_id, const ParticleFieldDescriptor **descriptor)
Return immutable metadata for a valid particle field ID.
const char * canonical_name
Immutable metadata for one persistent particle field.
PetscErrorCode ComputeParticleMSD(UserCtx *user, const char *stats_prefix, PetscInt ti)
Computes the mean-squared displacement (MSD) of a particle cloud.
PetscErrorCode ComputeQCriterion(UserCtx *user)
Computes the Q-criterion diagnostic from the local velocity-gradient tensor.
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 ComputeSpecificKE(UserCtx *user, const char *velocity_field, const char *ske_field)
Computes the specific kinetic energy (KE per unit mass) for each particle.
PetscErrorCode NormalizeRelativeField(UserCtx *user, const char *relative_field_name)
Normalizes pressure using the value at the configured logical grid point.
PetscErrorCode ComputeWindowStatisticsSummary(UserCtx *user, PetscInt window_index, const char *output_prefix, PetscInt ti)
Appends one convergence row for an accumulated window to its CSV history.
PetscErrorCode DimensionalizeField(UserCtx *user, const char *field_name)
Scales a specified field from non-dimensional to dimensional units in-place.
PetscErrorCode ComputeNodalAverage(UserCtx *user, const char *in_field_name, const char *out_field_name)
Interpolates a cell-centered field to nodal locations using local stencil averaging.
PetscErrorCode EulerianDataProcessingPipeline(UserCtx *user, PostProcessParams *pps)
Implementation of EulerianDataProcessingPipeline().
PetscErrorCode WriteEulerianFile(UserCtx *user, PostProcessParams *pps, PetscInt ti)
Implementation of WriteEulerianFile().
PetscErrorCode GlobalStatisticsPipeline(UserCtx *user, PostProcessParams *pps, PetscInt ti)
Implementation of GlobalStatisticsPipeline().
int main(int argc, char **argv)
Entry point for the postprocessor executable.
PetscErrorCode ResolvePostProcessingSteps(PostProcessParams *pps, PetscInt **steps, PetscInt *count)
Implementation of ResolvePostProcessingSteps().
PetscErrorCode ParticleDataProcessingPipeline(UserCtx *user, PostProcessParams *pps)
Implementation of ParticleDataProcessingPipeline().
static PetscErrorCode WriteWindowStatistics(UserCtx *user, PostProcessParams *pps, const PicurvWindowDefinition *definition, const PicurvWindowStorage *storage, PetscBool want_vtk, PetscBool want_csv, PetscInt ti)
Writes one window's or ensemble's derived output for a step.
PetscErrorCode WriteParticleFile(UserCtx *user, PostProcessParams *pps, PetscInt ti)
Implementation of WriteParticleFile().
PetscErrorCode FieldStatisticsPipeline(UserCtx *user, PostProcessParams *pps, PetscInt ti)
Implementation of FieldStatisticsPipeline().
static PetscErrorCode FillStatisticsEnsemble(UserCtx *user, PostProcessParams *pps, PetscInt index, PicurvWindowStorage *storage)
Fills one recipe ensemble's storage from the loaded step.
PetscErrorCode SetupPostProcessSwarm(UserCtx *user, PostProcessParams *pps)
Implementation of SetupPostProcessSwarm().
int PicurvCheckLinkedPetscIndexWidth(int argc, char **argv, const char *executable_name)
Refuse to start when the loaded libpetsc's PetscInt width differs from this build's.
PetscErrorCode SetupDomainRankInfo(SimCtx *simCtx)
Sets up the full rank communication infrastructure, including neighbor ranks and bounding box exchang...
PetscErrorCode SetupGridAndSolvers(SimCtx *simCtx)
The main orchestrator for setting up all grid-related components.
PetscErrorCode SetupSimulationEnvironment(SimCtx *simCtx)
Verifies and prepares the complete I/O environment for a simulation run.
int PicurvHandleVersionArgument(int argc, char **argv, const char *executable_name)
Print the shared native build identity when a version flag is present.
PetscErrorCode CreateSimulationContext(int argc, char **argv, SimCtx **p_simCtx)
Allocates and populates the master SimulationContext object.
PetscErrorCode SetupBoundaryConditions(SimCtx *simCtx)
(Orchestrator) Sets up all boundary conditions for the simulation.
PetscErrorCode FinalizeSimulation(SimCtx *simCtx)
Main cleanup function for the entire simulation context.
Per-window PETSc accumulator storage and pointwise application.
PetscErrorCode PicurvWindowDerivedCount(const PicurvWindowDefinition *definition, const PicurvWindowStorage *storage, const char *outputs, PetscInt *count)
Reports how many derived fields a requested output set produces.
PetscErrorCode PicurvWindowStorageCreate(UserCtx *user, const PicurvWindowDefinition *definition, PicurvWindowStorage *storage)
Allocates the accumulator state one window owns on one block.
PetscErrorCode PicurvWindowStorageFromParticles(UserCtx *user, const PicurvWindowDefinition *definition, PicurvWindowStorage *storage)
Fills a window's storage from the particles sampling each cell at one instant.
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.
PetscBool physical_units
Holds physical units, as an ensemble of a dimensionalized load does, so derivation applies no scale; ...
Independent accumulator state for one window on one block.
Window lifecycle, scheduling, and weighting for the field-statistics pipeline.
PicurvWindowDefinition definition
PetscBool FieldStatisticsIsActive(const struct SimCtx *simCtx)
Reports whether this run has live field-statistics state.
Runtime state of one window.
The scientifically immutable definition of one window.
Vec Qcrit_nodal
Q-criterion averaged to grid nodes; the field a .vts can place correctly.
PetscInt fieldStatisticsWindowCount
char statistics_output_prefix[256]
basename for CSV output, e.g.
char particle_output_prefix[256]
PetscInt num_point_data_fields
struct PicurvWindow * field_statistics_ensembles
SimCtx * simCtx
Back-pointer to the master simulation context.
PetscBool dimensionalize
Whether derived output leaves non-dimensional form, from global_operations.dimensionalize.
char field_statistics_output_prefix[PETSC_MAX_PATH_LEN]
Analysis prefix for CSV summaries; VTK continues to use output_prefix.
#define MAX_FIELD_LIST_LENGTH
char step_list_file[PETSC_MAX_PATH_LEN]
File listing the exact steps to process, one per line; empty uses the time controls.
static PetscBool ParticlesEnabled(const SimCtx *simCtx)
Whether the run carries particles: a seeded or restored population, or inlets that inject them.
#define MAX_FILENAME_LENGTH
char statistics_pipeline[1024]
e.g.
char field_statistics_formats[1024]
Comma-separated formats: vtk for derived fields, csv for the convergence history.
char output_fields_instantaneous[1024]
struct PicurvWindow * fieldStatisticsWindows
char particle_pipeline[1024]
PetscBool * field_statistics_ensemble_from_particles
Whether each ensemble samples the particles in a cell rather than the cell's state.
char process_pipeline[1024]
char particle_fields[1024]
PetscBool outputParticles
VTKFieldInfo point_data_fields[20]
struct PicurvWindowStorage * fieldStatisticsStorage
PetscInt field_statistics_ensemble_count
Recipe-defined single-instant windows, derived at every processed step.
@ EXEC_MODE_POSTPROCESSOR
PetscInt field_statistics_source_step
Committed step supplying the state; negative means the step being processed.
char field_statistics_windows[1024]
Comma-separated window names to derive; empty disables the pipeline.
char field_statistics_outputs[1024]
Comma-separated outputs: mean, reynolds_stress, rms, tke, flux, point_variance.
PetscBool field_statistics_homogeneous[3]
Directions profiles merge over, in (i, j, k) order; none selected writes no profile.
#define MAX_VTK_FIELD_NAME_LENGTH
Maximum length for VTK field names.
PetscBool fieldStatisticsContinue
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.
Head of a generic C-style linked list.
PetscErrorCode FinishStructuredVTKOutput(VTKMetaData *meta, const char *filename)
Writes an assembled structured VTK file and releases its buffers.
PetscErrorCode BeginStructuredVTKOutput(UserCtx *user, VTKMetaData *meta)
Begins one structured VTK file: clears the metadata and builds its coordinates.
PetscErrorCode AppendStructuredVTKField(UserCtx *user, VTKMetaData *meta, const char *name, Vec field_vec, PetscInt components)
Adds one point-data field to a structured VTK file being assembled.
PetscErrorCode PrepareOutputParticleData(UserCtx *user, PostProcessParams *pps, VTKMetaData *meta, PetscInt *p_n_total)
Prepares this rank's part of the subsampled particle VTK output.