#include "logging.h"#include "statistics_window.h"#include "statistics_accumulator.h"#include "AnalyticalSolutions.h"#include "particle_field_catalog.h"#include "verification_sources.h"Go to the source code of this file.
Data Structures | |
| struct | SolutionConvergenceDeterministicPass1 |
| struct | SolutionConvergenceDeterministicPass2 |
| struct | ProfiledFunctionRanks |
Macros | |
| #define | TMP_BUF_SIZE 128 |
| #define | SOLUTION_CONVERGENCE_FLUID_THRESHOLD 0.1 |
| #define | SOLUTION_CONVERGENCE_REL_EPS 1.0e-30 |
Typedefs | |
| typedef struct SolutionConvergenceDeterministicPass1 | SolutionConvergenceDeterministicPass1 |
| typedef struct SolutionConvergenceDeterministicPass2 | SolutionConvergenceDeterministicPass2 |
Functions | |
| static void | SearchMetricsReduceOp (void *invec, void *inoutvec, int *len, MPI_Datatype *datatype) |
| Internal reduction callback for packed search metrics. | |
| LogLevel | _ResolveLogLevel (void) |
| Implementation of _ResolveLogLevel(). | |
| PetscErrorCode | print_log_level (void) |
| Implementation of print_log_level(). | |
| void | set_allowed_functions (const char **functionList, int count) |
| Implementation of set_allowed_functions(). | |
| PetscBool | is_function_allowed (const char *functionName) |
| Implementation of is_function_allowed(). | |
| PetscErrorCode | LOG_CELL_VERTICES (const Cell *cell, PetscMPIInt rank) |
| Implementation of LOG_CELL_VERTICES(). | |
| PetscErrorCode | LOG_FACE_DISTANCES (PetscReal *d) |
| Implementation of LOG_FACE_DISTANCES(). | |
| static void | IntToStr (int value, char *buf, size_t bufsize) |
| static void | Int64ToStr (PetscInt64 value, char *buf, size_t bufsize) |
| static void | CellToStr (const PetscInt *cell, char *buf, size_t bufsize) |
| static void | TripleRealToStr (const PetscReal *arr, char *buf, size_t bufsize) |
| static PetscErrorCode | ComputeMaxColumnWidths (PetscInt nRows, const PetscInt *rows, const PetscMPIInt *ranks, const PetscInt64 *pids, const PetscInt *cellIDs, const PetscReal *positions, const PetscReal *velocities, const PetscReal *weights, int widths[6]) |
| static void | BuildRowFormatString (const int widths[6], char *fmtStr, size_t bufSize) |
| static void | BuildHeaderString (char *headerStr, size_t bufSize, const int widths[6]) |
| PetscErrorCode | LOG_PARTICLE_FIELDS (UserCtx *user, PetscInt printInterval) |
| Implementation of LOG_PARTICLE_FIELDS(). | |
| PetscBool | IsParticleConsoleSnapshotEnabled (const SimCtx *simCtx) |
| Implementation of IsParticleConsoleSnapshotEnabled(). | |
| PetscBool | ShouldEmitPeriodicParticleConsoleSnapshot (const SimCtx *simCtx, PetscInt completed_step) |
| Implementation of ShouldEmitPeriodicParticleConsoleSnapshot(). | |
| PetscErrorCode | EmitParticleConsoleSnapshot (UserCtx *user, SimCtx *simCtx, PetscInt step) |
| Implementation of EmitParticleConsoleSnapshot(). | |
| static void | trim (char *s) |
| Remove leading and trailing whitespace from a mutable configuration string. | |
| PetscErrorCode | LoadAllowedFunctionsFromFile (const char filename[], char ***funcsOut, PetscInt *nOut) |
| Implementation of LoadAllowedFunctionsFromFile(). | |
| PetscErrorCode | FreeAllowedFunctions (char **funcs, PetscInt n) |
| Implementation of FreeAllowedFunctions(). | |
| const char * | BCFaceToString (BCFace face) |
| Implementation of BCFaceToString(). | |
| const char * | ParticleInitializationToString (ParticleInitializationType ParticleInitialization) |
| Implementation of ParticleInitializationToString(). | |
| const char * | LESModelToString (LESModelType LESFlag) |
| Implementation of LESModelToString(). | |
| const char * | LESFilterWidthModelToString (LESFilterWidthModel model) |
| Implementation of LESFilterWidthModelToString(). | |
| const char * | LESTestFilterKernelToString (LESTestFilterKernel kernel) |
| Implementation of LESTestFilterKernelToString(). | |
| const char * | LESAveragingModeToString (LESAveragingMode mode) |
| Implementation of LESAveragingModeToString(). | |
| const char * | LESClipModeToString (LESClipMode mode) |
| Implementation of LESClipModeToString(). | |
| const char * | WallFunctionModelToString (WallFunctionModel model) |
| Implementation of WallFunctionModelToString(). | |
| const char * | MomentumSolverTypeToString (MomentumSolverType SolverFlag) |
| Implementation of MomentumSolverTypeToString(). | |
| const char * | BCTypeToString (BCType type) |
| Implementation of BCTypeToString(). | |
| const char * | ParticleBoundaryPolicyToString (ParticleBoundaryPolicy policy) |
| Implementation of ParticleBoundaryPolicyToString(). | |
| const char * | InterpolationMethodToString (InterpolationMethod method) |
| Implementation of InterpolationMethodToString(). | |
| const char * | BCHandlerTypeToString (BCHandlerType handler_type) |
| Implementation of BCHandlerTypeToString(). | |
| PetscErrorCode | DualMonitorDestroy (void **ctx) |
| Implementation of DualMonitorDestroy(). | |
| PetscErrorCode | DualKSPMonitor (KSP ksp, PetscInt it, PetscReal rnorm, void *ctx) |
| Implementation of DualKSPMonitor(). | |
| static PetscReal | SolutionConvergenceSafeRelative (PetscReal numerator, PetscReal denominator) |
| Forms a guarded relative metric for solution-convergence logging. | |
| static PetscErrorCode | ComputeCurrentFlowObservables (SimCtx *simCtx, PetscReal *mean_speed_out, PetscReal *mean_ke_out) |
| Computes instantaneous global flow observables for statistical mode. | |
| static PetscErrorCode | ComputeDeterministicSolutionMetrics (SimCtx *simCtx, PetscBool periodic_mode, PetscInt phase_step, PetscInt samples_before, PetscBool *has_reference_out, PetscReal *u_abs_l2_out, PetscReal *u_rel_l2_out, PetscReal *p_abs_l2_out, PetscReal *p_rel_l2_out, PetscReal *mean_speed_out, PetscReal *mean_speed_ref_out, PetscReal *mean_speed_abs_out, PetscReal *mean_speed_rel_out, PetscReal *mean_ke_out, PetscReal *mean_ke_ref_out, PetscReal *mean_ke_abs_out, PetscReal *mean_ke_rel_out) |
| Computes deterministic solution-drift metrics for the current step. | |
| static PetscReal | SolutionConvergenceHistoryGet (const PetscReal *history, PetscInt capacity, PetscInt samples_available, PetscInt offset_from_latest) |
| Reads one sample from the statistical ring buffer by age. | |
| static PetscErrorCode | AppendStatisticalObservableSample (SimCtx *simCtx, PetscInt samples_before, PetscReal mean_speed, PetscReal mean_ke) |
| Appends one timestep's scalar observables to the statistical history. | |
| static PetscErrorCode | ComputeStatisticalWindowMetrics (const SimCtx *simCtx, PetscInt samples_available, PetscBool *has_reference_out, PetscReal *mean_speed_window_out, PetscReal *mean_speed_window_prev_out, PetscReal *mean_speed_window_abs_out, PetscReal *mean_speed_window_rel_out, PetscReal *mean_speed_rms_window_out, PetscReal *mean_speed_rms_window_prev_out, PetscReal *mean_speed_rms_window_abs_out, PetscReal *mean_speed_rms_window_rel_out, PetscReal *mean_ke_window_out, PetscReal *mean_ke_window_prev_out, PetscReal *mean_ke_window_abs_out, PetscReal *mean_ke_window_rel_out, PetscReal *mean_ke_rms_window_out, PetscReal *mean_ke_rms_window_prev_out, PetscReal *mean_ke_rms_window_abs_out, PetscReal *mean_ke_rms_window_rel_out) |
| Computes adjacent-window drift metrics for statistical steady mode. | |
| static const char * | SolutionConvergenceModeToString (SolutionConvergenceMode mode) |
| Maps the internal solution-convergence mode enum to its log label. | |
| PetscErrorCode | LOG_SOLUTION_CONVERGENCE (SimCtx *simCtx) |
| Implementation of LOG_SOLUTION_CONVERGENCE(). | |
| PetscErrorCode | LOG_CONTINUITY_METRICS (UserCtx *user) |
| Implementation of LOG_CONTINUITY_METRICS(). | |
| const char * | ParticleLocationStatusToString (ParticleLocationStatus level) |
| Implementation of ParticleLocationStatusToString(). | |
| static PetscBool | _ProfilingNameListed (const char *name, char **names, PetscInt n) |
| Whether a name appears in a list of names. | |
| static PetscBool | _ProfilingHelperEnabled (const char *name) |
| Whether a helper function's timer is enabled. | |
| static PetscErrorCode | _ProfilingEnsureStarted (void) |
| Register the two PICurv event classes and start PETSc's default log handler, once. | |
| void | _ProfilingRegister (const char *func_name, PetscBool helper, PetscLogEvent *event) |
| Implementation of _ProfilingRegister(). | |
| static PetscBool | _ProfilingIsPicurvClass (PetscClassId classid) |
| Whether a PETSc event belongs to one of PICurv's classes. | |
| PetscErrorCode | ProfilingInitialize (SimCtx *simCtx) |
| Implementation of ProfilingInitialize(). | |
| static PetscErrorCode | _ProfilingEventTotals (PetscLogEvent event, PetscLogDouble *time, int *count) |
| Read an event's running total time and call count on this rank (main stage). | |
| static PetscErrorCode | _ProfilingSnapshotStep (void) |
| Record every event's running totals as the start of the next step. | |
| PetscErrorCode | ProfilingResetTimestepCounters (void) |
| Implementation of ProfilingResetTimestepCounters(). | |
| PetscErrorCode | ProfilingLogTimestepSummary (SimCtx *simCtx, PetscInt step) |
| Implementation of ProfilingLogTimestepSummary(). | |
| PetscErrorCode | RuntimeMemoryLogSample (SimCtx *simCtx, PetscInt step, const char *event, const char *reason) |
| Implementation of RuntimeMemoryLogSample(). | |
| static int | _CompareNames (const void *a, const void *b) |
Order C strings, for qsort over const char * arrays. | |
| static int | _CompareProfiledFunctionRanks (const void *a, const void *b) |
| Order final-summary rows by their slowest rank's total time, descending. | |
| static PetscErrorCode | _ProfilingReduceSection (FILE *f, const char *section, PetscInt nlocal, const char **names, const PetscLogDouble *times, const long long *counts) |
| Reduce one section of the final summary across ranks and print it on rank 0. | |
| PetscErrorCode | ProfilingFinalize (SimCtx *simCtx) |
| Implementation of ProfilingFinalize(). | |
| void | PrintProgressBar (PetscInt step, PetscInt startStep, PetscInt totalSteps, PetscReal currentTime, PetscReal seconds_per_step, PetscInt64 lost_cumulative) |
| Implementation of PrintProgressBar(). | |
| PetscErrorCode | LOG_FIELD_MIN_MAX (UserCtx *user, FieldId field_id) |
| Implementation of LOG_FIELD_MIN_MAX(). | |
| static PetscErrorCode | LogFieldAnatomyView (UserCtx *user, const char *field_name, const char *stage_name, DM dm, Vec vec_local, PetscInt dof, FieldLayout layout) |
| Shared architecture-aware anatomy logger for catalog and transient fields. | |
| PetscErrorCode | LOG_FIELD_ANATOMY (UserCtx *user, FieldId field_id, const char *stage_name) |
| Resolves a persistent field view and emits its layout-aware boundary anatomy. | |
| PetscBool | IsStatisticsConsoleSnapshotEnabled (const SimCtx *simCtx) |
| Implementation of IsStatisticsConsoleSnapshotEnabled(). | |
| PetscBool | ShouldEmitPeriodicStatisticsConsoleSnapshot (const SimCtx *simCtx, PetscInt completed_step) |
| Implementation of ShouldEmitPeriodicStatisticsConsoleSnapshot(). | |
| PetscErrorCode | EmitStatisticsConsoleSnapshot (UserCtx *user, const SimCtx *simCtx, PetscInt step) |
| Implementation of EmitStatisticsConsoleSnapshot(). | |
| PetscErrorCode | LOG_CORNER_FIELD_ANATOMY (UserCtx *user, FieldId corner_field_id, const char *stage_name) |
| Emits anatomy for the transient scalar or vector corner-staging field. | |
| PetscErrorCode | LOG_INTERPOLATION_ERROR (UserCtx *user) |
| Implementation of LOG_INTERPOLATION_ERROR(). | |
| PetscErrorCode | LOG_SCATTER_METRICS (UserCtx *user) |
| Implementation of LOG_SCATTER_METRICS(). | |
| PetscErrorCode | ResetSearchMetrics (SimCtx *simCtx) |
| Implementation of ResetSearchMetrics(). | |
| PetscErrorCode | LOG_SEARCH_METRICS (UserCtx *user) |
| Implementation of LOG_SEARCH_METRICS(). | |
| PetscErrorCode | CalculateAdvancedParticleMetrics (UserCtx *user) |
| Implementation of CalculateAdvancedParticleMetrics(). | |
| PetscErrorCode | PicurvOpenRunCsv (SimCtx *simCtx, const char *dir, const char *filename, const char *header, PicurvCsvLifecycle lifecycle, PetscBool required, FILE **file) |
| Implementation of PicurvOpenRunCsv(). | |
Variables | |
| static LogLevel | current_log_level = -1 |
| Static variable to cache the current logging level. | |
| const LogLevel *const | _picurv_log_level = ¤t_log_level |
| Read-only view of the cached logging level; -1 until the first get_log_level() call. | |
| static char ** | gAllowedFunctions = NULL |
| Global/static array of function names allowed to log. | |
| static int | gNumAllowed = 0 |
| Number of entries in the gAllowedFunctions array. | |
| static PetscClassId | g_profile_class_function = 0 |
| static PetscClassId | g_profile_class_helper = 0 |
| static char ** | g_profile_helpers = NULL |
| static PetscInt | g_profile_nhelpers = 0 |
| static PetscBool | g_profile_all_helpers = PETSC_FALSE |
| static PetscBool | g_profile_any_helpers = PETSC_FALSE |
| const PetscBool *const | _picurv_profile_helpers_on = &g_profile_any_helpers |
Read-only view: whether profiling.helpers enables any helper timer. | |
| static char ** | g_profile_selected = NULL |
| static PetscInt | g_profile_nselected = 0 |
| static PetscLogDouble * | g_profile_step_time = NULL |
| static int * | g_profile_step_count = NULL |
| static PetscInt | g_profile_step_capacity = 0 |
| struct SolutionConvergenceDeterministicPass1 |
| struct SolutionConvergenceDeterministicPass2 |
| struct ProfiledFunctionRanks |
| anonymous enum |
|
static |
Internal reduction callback for packed search metrics.
Local to this translation unit.
Definition at line 61 of file logging.c.
| LogLevel _ResolveLogLevel | ( | void | ) |
Implementation of _ResolveLogLevel().
Internal hook: read LOG_LEVEL from the environment and cache it, once.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 101 of file logging.c.
| PetscErrorCode print_log_level | ( | void | ) |
Implementation of print_log_level().
Prints the current logging level to the console.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 138 of file logging.c.
| void set_allowed_functions | ( | const char ** | functionList, |
| int | count | ||
| ) |
Implementation of set_allowed_functions().
Sets the global list of function names that are allowed to log.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 176 of file logging.c.
| PetscBool is_function_allowed | ( | const char * | functionName | ) |
Implementation of is_function_allowed().
Checks if a given function is in the allow-list.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 207 of file logging.c.
| PetscErrorCode LOG_CELL_VERTICES | ( | const Cell * | cell, |
| PetscMPIInt | rank | ||
| ) |
Implementation of LOG_CELL_VERTICES().
Prints the coordinates of a cell's vertices.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 229 of file logging.c.
| PetscErrorCode LOG_FACE_DISTANCES | ( | PetscReal * | d | ) |
Implementation of LOG_FACE_DISTANCES().
Prints the signed distances to each face of the cell.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 256 of file logging.c.
|
static |
Definition at line 281 of file logging.c.
|
static |
Definition at line 291 of file logging.c.
|
static |
Definition at line 301 of file logging.c.
|
static |
Definition at line 311 of file logging.c.
|
static |
Definition at line 324 of file logging.c.
|
static |
Definition at line 367 of file logging.c.
|
static |
Definition at line 379 of file logging.c.
| PetscErrorCode LOG_PARTICLE_FIELDS | ( | UserCtx * | user, |
| PetscInt | printInterval | ||
| ) |
Implementation of LOG_PARTICLE_FIELDS().
Prints particle fields in a table that automatically adjusts its column widths.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 399 of file logging.c.
| PetscBool IsParticleConsoleSnapshotEnabled | ( | const SimCtx * | simCtx | ) |
Implementation of IsParticleConsoleSnapshotEnabled().
Returns whether periodic particle console snapshots are enabled.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 484 of file logging.c.
| PetscBool ShouldEmitPeriodicParticleConsoleSnapshot | ( | const SimCtx * | simCtx, |
| PetscInt | completed_step | ||
| ) |
Implementation of ShouldEmitPeriodicParticleConsoleSnapshot().
Returns whether a particle console snapshot should be emitted for the completed timestep.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 501 of file logging.c.
Implementation of EmitParticleConsoleSnapshot().
Emits one particle console snapshot into the main solver log.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 518 of file logging.c.
|
static |
Remove leading and trailing whitespace from a mutable configuration string.
Definition at line 534 of file logging.c.
| PetscErrorCode LoadAllowedFunctionsFromFile | ( | const char | filename[], |
| char *** | funcsOut, | ||
| PetscInt * | nOut | ||
| ) |
Implementation of LoadAllowedFunctionsFromFile().
Load function names from a text file.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 561 of file logging.c.
| PetscErrorCode FreeAllowedFunctions | ( | char ** | funcs, |
| PetscInt | n | ||
| ) |
Implementation of FreeAllowedFunctions().
Free an array previously returned by LoadAllowedFunctionsFromFile().
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 619 of file logging.c.
| const char * BCFaceToString | ( | BCFace | face | ) |
Implementation of BCFaceToString().
Returns the canonical log token for a boundary-face enum value.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 640 of file logging.c.
| const char * ParticleInitializationToString | ( | ParticleInitializationType | ParticleInitialization | ) |
Implementation of ParticleInitializationToString().
Returns the canonical log token for a particle-initialization mode.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 662 of file logging.c.
| const char * LESModelToString | ( | LESModelType | LESFlag | ) |
Implementation of LESModelToString().
Returns the canonical log token for an LES model selector.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 682 of file logging.c.
| const char * LESFilterWidthModelToString | ( | LESFilterWidthModel | model | ) |
Implementation of LESFilterWidthModelToString().
Returns the user-facing name of an LES grid-filter-width model.
Full API contract is documented with the header declaration in include/logging.h.
Definition at line 704 of file logging.c.
| const char * LESTestFilterKernelToString | ( | LESTestFilterKernel | kernel | ) |
Implementation of LESTestFilterKernelToString().
Returns the user-facing name of an LES test-filter kernel.
Full API contract is documented with the header declaration in include/logging.h.
Definition at line 727 of file logging.c.
| const char * LESAveragingModeToString | ( | LESAveragingMode | mode | ) |
Implementation of LESAveragingModeToString().
Returns the user-facing name of an LES coefficient-averaging mode.
Full API contract is documented with the header declaration in include/logging.h.
Definition at line 746 of file logging.c.
| const char * LESClipModeToString | ( | LESClipMode | mode | ) |
Implementation of LESClipModeToString().
Returns the user-facing name of an LES coefficient-limiting mode.
Full API contract is documented with the header declaration in include/logging.h.
Definition at line 766 of file logging.c.
| const char * WallFunctionModelToString | ( | WallFunctionModel | model | ) |
Implementation of WallFunctionModelToString().
Returns the user-facing name of a wall-function model.
Full API contract is documented with the header declaration in include/logging.h.
Definition at line 786 of file logging.c.
| const char * MomentumSolverTypeToString | ( | MomentumSolverType | SolverFlag | ) |
Implementation of MomentumSolverTypeToString().
Returns the canonical log token for a momentum-solver selector.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 808 of file logging.c.
| const char * BCTypeToString | ( | BCType | type | ) |
Implementation of BCTypeToString().
Returns the canonical log token for a boundary mathematical type.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 828 of file logging.c.
| const char * ParticleBoundaryPolicyToString | ( | ParticleBoundaryPolicy | policy | ) |
Implementation of ParticleBoundaryPolicyToString().
Returns the configuration token for a particle boundary policy.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 850 of file logging.c.
| const char * InterpolationMethodToString | ( | InterpolationMethod | method | ) |
Implementation of InterpolationMethodToString().
Returns the display name of a grid-to-particle interpolation method.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 869 of file logging.c.
| const char * BCHandlerTypeToString | ( | BCHandlerType | handler_type | ) |
Implementation of BCHandlerTypeToString().
Converts a BCHandlerType enum to its string representation.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 888 of file logging.c.
| PetscErrorCode DualMonitorDestroy | ( | void ** | ctx | ) |
Implementation of DualMonitorDestroy().
Destroys the DualMonitorCtx.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 927 of file logging.c.
| PetscErrorCode DualKSPMonitor | ( | KSP | ksp, |
| PetscInt | it, | ||
| PetscReal | rnorm, | ||
| void * | ctx | ||
| ) |
Implementation of DualKSPMonitor().
A custom KSP monitor that logs to a file and optionally to the console.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 955 of file logging.c.
|
static |
Forms a guarded relative metric for solution-convergence logging.
This helper centralizes the divide-by-nearly-zero protection used by the solution-convergence logger when turning an absolute drift into a relative one. The denominator is clamped away from zero so warmup rows, quiescent fields, and statistically small observables do not generate infinities.
| [in] | numerator | Absolute quantity or drift magnitude. |
| [in] | denominator | Reference magnitude used for normalization. |
numerator / max(|denominator|, eps). Definition at line 1045 of file logging.c.
|
static |
Computes instantaneous global flow observables for statistical mode.
The statistical solution-convergence path does not compare full Eulerian fields. Instead, it tracks a compact history of global observables derived from the completed Eulerian state. This helper computes the current volume-weighted fluid-domain mean speed and mean kinetic energy from Ucat.
Only physical fluid cells contribute:
NvertEach MPI rank accumulates local partial sums and the routine reduces them to one global pair of observables.
| [in] | simCtx | Simulation context owning the finest-level flow fields. |
| [out] | mean_speed_out | Volume-weighted domain mean of |u|. |
| [out] | mean_ke_out | Volume-weighted domain mean of 0.5 |u|^2. |
Definition at line 1075 of file logging.c.
|
static |
Computes deterministic solution-drift metrics for the current step.
This helper powers both steady_deterministic and periodic_deterministic solution-convergence modes. It compares the completed Eulerian state against either:
Ucat_o, P_o) for steady/transient useThe routine performs two passes over the fluid cells:
Warmup behavior is handled here. If no valid reference exists yet, all drift outputs are left at zero and has_reference_out is set to PETSC_FALSE, while current observables are still reported.
| [in] | simCtx | Simulation context owning the current state. |
| [in] | periodic_mode | PETSC_TRUE when comparing against phase-aligned periodic storage. |
| [in] | phase_step | Active phase slot for periodic mode, or -1 when unused. |
| [in] | samples_before | Number of solution-convergence samples already recorded before this timestep. |
| [out] | has_reference_out | Whether a valid comparison state existed. |
| [out] | u_abs_l2_out | Absolute L2 drift of Cartesian velocity. |
| [out] | u_rel_l2_out | Relative L2 drift of Cartesian velocity. |
| [out] | p_abs_l2_out | Gauge-invariant absolute L2 pressure drift. |
| [out] | p_rel_l2_out | Gauge-invariant relative L2 pressure drift. |
| [out] | mean_speed_out | Current volume-weighted mean speed. |
| [out] | mean_speed_ref_out | Reference volume-weighted mean speed. |
| [out] | mean_speed_abs_out | Absolute drift of mean speed. |
| [out] | mean_speed_rel_out | Relative drift of mean speed. |
| [out] | mean_ke_out | Current volume-weighted mean kinetic energy. |
| [out] | mean_ke_ref_out | Reference volume-weighted mean kinetic energy. |
| [out] | mean_ke_abs_out | Absolute drift of mean kinetic energy. |
| [out] | mean_ke_rel_out | Relative drift of mean kinetic energy. |
Definition at line 1193 of file logging.c.
|
static |
Reads one sample from the statistical ring buffer by age.
The statistical logger stores scalar observables in a compact circular buffer. This helper interprets the buffer using samples_available as the logical end of the history and returns the entry offset_from_latest steps back from the newest stored sample.
Out-of-range requests return zero so warmup handling can remain simple and deterministic.
| [in] | history | Ring-buffer storage array. |
| [in] | capacity | Total ring-buffer capacity. |
| [in] | samples_available | Number of logical samples available to read. |
| [in] | offset_from_latest | 0 means newest sample, 1 previous sample, and so on. |
0.0 if unavailable. Definition at line 1438 of file logging.c.
|
static |
Appends one timestep's scalar observables to the statistical history.
Statistical solution-convergence compares adjacent windows of scalar observables rather than full fields. This helper writes the current mean_speed and mean_ke into the rolling history arrays using the current sample count to choose the circular-buffer slot.
| [in,out] | simCtx | Simulation context owning the history arrays. |
| [in] | samples_before | Number of samples present before appending the current timestep. |
| [in] | mean_speed | Current timestep mean-speed observable. |
| [in] | mean_ke | Current timestep mean-KE observable. |
Definition at line 1476 of file logging.c.
|
static |
Computes adjacent-window drift metrics for statistical steady mode.
Once enough samples have been accumulated, this helper forms:
window_steps sampleswindow_steps samplesFrom those windows it computes means, RMS values, and absolute/relative drift for both tracked observables (mean_speed and mean_ke). When the history is still warming up:
window_steps samples: no window metrics are availablewindow_steps and 2*window_steps - 1 samples: current-window metrics are available, but no reference window exists yet| [in] | simCtx | Simulation context owning the statistical history. |
| [in] | samples_available | Number of samples available after appending the current timestep. |
| [out] | has_reference_out | Whether both adjacent windows exist and drift metrics are meaningful. |
| [out] | mean_speed_window_out | Mean speed over the current window. |
| [out] | mean_speed_window_prev_out | Mean speed over the previous window. |
| [out] | mean_speed_window_abs_out | Absolute drift between current and previous window means. |
| [out] | mean_speed_window_rel_out | Relative drift between current and previous window means. |
| [out] | mean_speed_rms_window_out | RMS of mean-speed samples in the current window. |
| [out] | mean_speed_rms_window_prev_out | RMS of mean-speed samples in the previous window. |
| [out] | mean_speed_rms_window_abs_out | Absolute drift between window RMS values. |
| [out] | mean_speed_rms_window_rel_out | Relative drift between window RMS values. |
| [out] | mean_ke_window_out | Mean kinetic energy over the current window. |
| [out] | mean_ke_window_prev_out | Mean kinetic energy over the previous window. |
| [out] | mean_ke_window_abs_out | Absolute drift between current and previous KE-window means. |
| [out] | mean_ke_window_rel_out | Relative drift between current and previous KE-window means. |
| [out] | mean_ke_rms_window_out | RMS of mean-KE samples in the current window. |
| [out] | mean_ke_rms_window_prev_out | RMS of mean-KE samples in the previous window. |
| [out] | mean_ke_rms_window_abs_out | Absolute drift between KE-window RMS values. |
| [out] | mean_ke_rms_window_rel_out | Relative drift between KE-window RMS values. |
Definition at line 1558 of file logging.c.
|
static |
Maps the internal solution-convergence mode enum to its log label.
The logger writes a human-readable mode string into the solution_convergence.log banner and mode column. This helper keeps the formatting centralized so the file output stays consistent with the accepted configuration names.
| [in] | mode | Internal solution-convergence mode selector. |
Definition at line 1693 of file logging.c.
| PetscErrorCode LOG_SOLUTION_CONVERGENCE | ( | SimCtx * | simCtx | ) |
Implementation of LOG_SOLUTION_CONVERGENCE().
Logs physical solution-convergence metrics once per completed timestep.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 1714 of file logging.c.
| PetscErrorCode LOG_CONTINUITY_METRICS | ( | UserCtx * | user | ) |
Implementation of LOG_CONTINUITY_METRICS().
Logs continuity metrics for a single block to a file.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 1866 of file logging.c.
| const char * ParticleLocationStatusToString | ( | ParticleLocationStatus | level | ) |
Implementation of ParticleLocationStatusToString().
A function that outputs the name of the current level in the ParticleLocation enum.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 1905 of file logging.c.
|
static |
|
static |
Whether a helper function's timer is enabled.
Definition at line 1953 of file logging.c.
|
static |
Register the two PICurv event classes and start PETSc's default log handler, once.
The handler must run before the first event begins: an event that begins before it and ends after it is not one the handler can close.
Definition at line 1963 of file logging.c.
| void _ProfilingRegister | ( | const char * | func_name, |
| PetscBool | helper, | ||
| PetscLogEvent * | event | ||
| ) |
Implementation of _ProfilingRegister().
Internal profiling hook: register a call site's function as a PETSc log event.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 1984 of file logging.c.
|
static |
Whether a PETSc event belongs to one of PICurv's classes.
Definition at line 2004 of file logging.c.
| PetscErrorCode ProfilingInitialize | ( | SimCtx * | simCtx | ) |
Implementation of ProfilingInitialize().
Applies the profiling configuration from SimCtx to PICurv's PETSc log events.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 2015 of file logging.c.
|
static |
Read an event's running total time and call count on this rank (main stage).
Definition at line 2049 of file logging.c.
|
static |
Record every event's running totals as the start of the next step.
Definition at line 2063 of file logging.c.
| PetscErrorCode ProfilingResetTimestepCounters | ( | void | ) |
Implementation of ProfilingResetTimestepCounters().
Starts a new per-step profiling interval.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 2087 of file logging.c.
| PetscErrorCode ProfilingLogTimestepSummary | ( | SimCtx * | simCtx, |
| PetscInt | step | ||
| ) |
Implementation of ProfilingLogTimestepSummary().
Logs the performance summary for the current timestep and resets timers.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 2100 of file logging.c.
| PetscErrorCode RuntimeMemoryLogSample | ( | SimCtx * | simCtx, |
| PetscInt | step, | ||
| const char * | event, | ||
| const char * | reason | ||
| ) |
Implementation of RuntimeMemoryLogSample().
Append a reduced runtime memory sample to the configured memory log.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 2170 of file logging.c.
|
static |
|
static |
Order final-summary rows by their slowest rank's total time, descending.
Definition at line 2260 of file logging.c.
|
static |
Reduce one section of the final summary across ranks and print it on rank 0.
Collective. Every rank contributes the events it recorded (names, with their totals); the union of names over ranks is formed by name, so ranks may have recorded different sets. Each name's time is reduced to its max and min with their ranks and its mean, and its calls are summed and reduced to their min and max per rank with ranks. Rows with calls on some rank are printed, slowest rank first.
Definition at line 2278 of file logging.c.
| PetscErrorCode ProfilingFinalize | ( | SimCtx * | simCtx | ) |
Implementation of ProfilingFinalize().
Writes the end-of-run profiling summary across all ranks; collective on PETSC_COMM_WORLD.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 2380 of file logging.c.
| void PrintProgressBar | ( | PetscInt | step, |
| PetscInt | startStep, | ||
| PetscInt | totalSteps, | ||
| PetscReal | currentTime, | ||
| PetscReal | seconds_per_step, | ||
| PetscInt64 | lost_cumulative | ||
| ) |
Implementation of PrintProgressBar().
Prints a progress bar to the console.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 2446 of file logging.c.
Implementation of LOG_FIELD_MIN_MAX().
Computes and logs the local and global min/max values of a 3-component vector field.
Full API contract is documented with the header declaration in include/logging.h.
Definition at line 2501 of file logging.c.
|
static |
Shared architecture-aware anatomy logger for catalog and transient fields.
Definition at line 2631 of file logging.c.
Resolves a persistent field view and emits its layout-aware boundary anatomy.
Logs the anatomy of a specified field at key boundary locations, respecting the solver's specific grid and variable architecture.
Definition at line 2903 of file logging.c.
| PetscBool IsStatisticsConsoleSnapshotEnabled | ( | const SimCtx * | simCtx | ) |
Implementation of IsStatisticsConsoleSnapshotEnabled().
Definition at line 2921 of file logging.c.
| PetscBool ShouldEmitPeriodicStatisticsConsoleSnapshot | ( | const SimCtx * | simCtx, |
| PetscInt | completed_step | ||
| ) |
Implementation of ShouldEmitPeriodicStatisticsConsoleSnapshot().
Definition at line 2935 of file logging.c.
| PetscErrorCode EmitStatisticsConsoleSnapshot | ( | UserCtx * | user, |
| const SimCtx * | simCtx, | ||
| PetscInt | step | ||
| ) |
Implementation of EmitStatisticsConsoleSnapshot().
Definition at line 2948 of file logging.c.
| PetscErrorCode LOG_CORNER_FIELD_ANATOMY | ( | UserCtx * | user, |
| FieldId | corner_field_id, | ||
| const char * | stage_name | ||
| ) |
Emits anatomy for the transient scalar or vector corner-staging field.
Logs the node-layout anatomy of the transient center-to-corner interpolation field.
Definition at line 2997 of file logging.c.
| PetscErrorCode LOG_INTERPOLATION_ERROR | ( | UserCtx * | user | ) |
Implementation of LOG_INTERPOLATION_ERROR().
Logs the interpolation error between the analytical and computed solutions.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 3024 of file logging.c.
| PetscErrorCode LOG_SCATTER_METRICS | ( | UserCtx * | user | ) |
Implementation of LOG_SCATTER_METRICS().
Logs particle-to-grid scatter verification metrics for the prescribed scalar truth path.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 3101 of file logging.c.
| PetscErrorCode ResetSearchMetrics | ( | SimCtx * | simCtx | ) |
Implementation of ResetSearchMetrics().
Resets the aggregate per-timestep search instrumentation counters.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 3252 of file logging.c.
| PetscErrorCode LOG_SEARCH_METRICS | ( | UserCtx * | user | ) |
Implementation of LOG_SEARCH_METRICS().
Writes compact runtime search metrics to CSV and optionally to console.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 3288 of file logging.c.
| PetscErrorCode CalculateAdvancedParticleMetrics | ( | UserCtx * | user | ) |
Implementation of CalculateAdvancedParticleMetrics().
Computes advanced particle statistics and stores them in SimCtx.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 3484 of file logging.c.
| PetscErrorCode PicurvOpenRunCsv | ( | SimCtx * | simCtx, |
| const char * | dir, | ||
| const char * | filename, | ||
| const char * | header, | ||
| PicurvCsvLifecycle | lifecycle, | ||
| PetscBool | required, | ||
| FILE ** | file | ||
| ) |
Implementation of PicurvOpenRunCsv().
Opens one of the run's CSV records (diagnostics, solver history, profiling) for writing.
Full API contract is documented with the header declaration in include/logging.h.
Definition at line 3552 of file logging.c.
|
static |
| const LogLevel* const _picurv_log_level = ¤t_log_level |
Read-only view of the cached logging level; -1 until the first get_log_level() call.
Only logging.c writes the level. The view lets get_log_level() be inlined into every logging macro, so a disabled message in a per-particle loop costs a load and a compare rather than a function call.
|
static |
|
static |
| const PetscBool* const _picurv_profile_helpers_on = &g_profile_any_helpers |
Read-only view: whether profiling.helpers enables any helper timer.
False until ProfilingInitialize() applies a non-empty list. While it is false every helper event is switched off, so PROFILE_HELPER_BEGIN skips PETSc's per-event check.