|
PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
|
Window lifecycle, scheduling, and weighting for the field-statistics pipeline. More...
#include <petscsys.h>Go to the source code of this file.
Data Structures | |
| struct | PicurvWindowFieldRequest |
| One field a window accumulates. More... | |
| struct | PicurvWindowCovarianceRequest |
| One cross-field covariance a window accumulates. More... | |
| struct | PicurvWindowDefinition |
| The scientifically immutable definition of one window. More... | |
| struct | PicurvWindow |
| Runtime state of one window. More... | |
Macros | |
| #define | PICURV_WINDOW_NAME_LENGTH 64 |
| Maximum stored length of a window name, including the terminator. | |
| #define | PICURV_WINDOW_MAX_REQUESTS 16 |
| Maximum fields or covariance pairs one window may request. | |
| #define | PICURV_WINDOW_HASH_GROUP_COUNT 8 |
| Number of independently hashed property groups in a window definition. | |
| #define | PICURV_WINDOW_HASH_GROUP_LENGTH 17 |
| Stored length of one truncated group digest, including the terminator. | |
Typedefs | |
| typedef struct PicurvWindow | PicurvWindow |
| Runtime state of one window. | |
Enumerations | |
| enum | PicurvWindowState { PICURV_WINDOW_PENDING = 0 , PICURV_WINDOW_ACTIVE , PICURV_WINDOW_COMPLETE } |
| Lifecycle state of one window. More... | |
| enum | PicurvWeighting { PICURV_WEIGHTING_SAMPLE = 0 , PICURV_WEIGHTING_PHYSICAL_TIME } |
| How an accepted state's weight is determined. More... | |
| enum | PicurvCadenceKind { PICURV_CADENCE_STEP = 0 , PICURV_CADENCE_TIME } |
| Which schedule selects due states. More... | |
Functions | |
| PetscErrorCode | PicurvWindowInit (PicurvWindow *window, const PicurvWindowDefinition *definition) |
| Validates a definition and initializes a window to the pending state. | |
| PetscErrorCode | PicurvWindowOfferState (PicurvWindow *window, PetscInt step, PetscReal time, PetscBool *accepted, PetscReal *weight) |
| Offers one completed state to a window and reports the decision. | |
| PetscErrorCode | PicurvWindowComputeHash (const PicurvWindowDefinition *definition, char digest_hex[65], char group_digest_hex[][17]) |
| Computes the resolved identity hash of one window definition. | |
| PetscErrorCode | PicurvWindowFirstHashDifference (const PicurvWindowDefinition *definition, const char *saved_group_digests, PetscInt *group) |
| Reports which hashed property group first differs from saved group digests. | |
| const char * | PicurvWindowHashGroupName (PetscInt group) |
| Returns the stable name of one hashed property group. | |
| PetscReal | PicurvWindowProgress (const PicurvWindow *window) |
| Reports the fraction of a bounded window's span that has been represented. | |
| const char * | PicurvWindowStateName (PicurvWindowState state) |
| Returns a stable human-readable name for a window state. | |
| PetscBool | FieldStatisticsIsActive (const struct SimCtx *simCtx) |
| Reports whether this run has live field-statistics state. | |
| PetscErrorCode | FieldStatisticsUpdateWindows (struct SimCtx *simCtx, PetscInt step, PetscReal time) |
| Offers one completed state to every configured window. | |
Window lifecycle, scheduling, and weighting for the field-statistics pipeline.
Implements the window semantics fixed in Field Statistics Phase 2 Implementation Specification sections 2 and 4: right-rectangle weighting, final-interval clipping, and the rule that a state representing a zero-length interval is not a sample.
This module decides whether a completed state is accepted and what weight it carries. It holds no PETSc objects and performs no field accumulation; the caller applies the returned weight through the moment kernels.
Definition in file statistics_window.h.
| struct PicurvWindowFieldRequest |
One field a window accumulates.
The first moment is always kept.
Definition at line 48 of file statistics_window.h.
| Data Fields | ||
|---|---|---|
| PetscInt | field_id | Catalogued Eulerian field identity. |
| PetscBool | want_second | Also keep the centered second moment. |
| struct PicurvWindowCovarianceRequest |
One cross-field covariance a window accumulates.
Definition at line 54 of file statistics_window.h.
| Data Fields | ||
|---|---|---|
| PetscInt | first | First member; must also appear in the field list. |
| PetscInt | second | Second member; must also appear in the field list. |
| struct PicurvWindowDefinition |
The scientifically immutable definition of one window.
Definition at line 60 of file statistics_window.h.
| Data Fields | ||
|---|---|---|
| char | name[64] | |
| PetscReal | start_time | Requested start. |
| PetscReal | end_time |
Requested end; ignored when bounded is false. |
| PetscBool | bounded | False for an open-ended window. |
| PicurvWeighting | weighting | |
| PicurvCadenceKind | cadence_kind | |
| PetscInt | step_cadence | Used when cadence_kind is step; must be positive. |
| PetscReal | time_cadence | Used when cadence_kind is time; must be positive. |
| PetscInt | field_count | |
| PicurvWindowFieldRequest | fields[16] | |
| PetscInt | covariance_count | |
| PicurvWindowCovarianceRequest | covariances[16] | |
| struct PicurvWindow |
Runtime state of one window.
Definition at line 76 of file statistics_window.h.
| Data Fields | ||
|---|---|---|
| PicurvWindowDefinition | definition | |
| PicurvWindowState | state | |
| PetscReal | effective_start | Origin of the first represented interval. |
| PetscReal | effective_end | End of the last represented interval. |
| PetscReal | last_accepted_time | Right edge of the last represented interval. |
| PetscInt | sample_count | |
| PetscReal | total_weight | |
| PetscReal | represented_time | Physical time the window covers. |
| PetscInt | activation_step | Step at which the window became active. |
| PetscInt | last_event_step | Guards against a step being offered twice. |
| PetscInt | next_time_target | k in effective_start + k*time_cadence. |
| PetscInt | restart_count | Restart segments this state descends from. |
| #define PICURV_WINDOW_NAME_LENGTH 64 |
Maximum stored length of a window name, including the terminator.
Definition at line 23 of file statistics_window.h.
| #define PICURV_WINDOW_MAX_REQUESTS 16 |
Maximum fields or covariance pairs one window may request.
Definition at line 45 of file statistics_window.h.
| #define PICURV_WINDOW_HASH_GROUP_COUNT 8 |
Number of independently hashed property groups in a window definition.
Definition at line 126 of file statistics_window.h.
| #define PICURV_WINDOW_HASH_GROUP_LENGTH 17 |
Stored length of one truncated group digest, including the terminator.
Definition at line 129 of file statistics_window.h.
| typedef struct PicurvWindow PicurvWindow |
Runtime state of one window.
| enum PicurvWindowState |
Lifecycle state of one window.
| Enumerator | |
|---|---|
| PICURV_WINDOW_PENDING | Requested start not yet reached. |
| PICURV_WINDOW_ACTIVE | Accepting due states. |
| PICURV_WINDOW_COMPLETE | Bounded end reached; accepts nothing further. |
Definition at line 26 of file statistics_window.h.
| enum PicurvWeighting |
How an accepted state's weight is determined.
| Enumerator | |
|---|---|
| PICURV_WEIGHTING_SAMPLE | Equal weight per accepted state. |
| PICURV_WEIGHTING_PHYSICAL_TIME | Weight is the represented interval. |
Definition at line 33 of file statistics_window.h.
| enum PicurvCadenceKind |
Which schedule selects due states.
Exactly one is used.
| Enumerator | |
|---|---|
| PICURV_CADENCE_STEP | Every n completed steps from activation. |
| PICURV_CADENCE_TIME | First state at or past each nominal time target. |
Definition at line 39 of file statistics_window.h.
| PetscErrorCode PicurvWindowInit | ( | PicurvWindow * | window, |
| const PicurvWindowDefinition * | definition | ||
| ) |
Validates a definition and initializes a window to the pending state.
| [out] | window | Window to initialize. |
| [in] | definition | Requested definition; copied into the window. |
PETSC_ERR_ARG_OUTOFRANGE for a non-positive cadence, an empty name, or a bounded window whose end does not exceed its start.Validates a definition and initializes a window to the pending state.
Definition at line 37 of file statistics_window.c.
| PetscErrorCode PicurvWindowOfferState | ( | PicurvWindow * | window, |
| PetscInt | step, | ||
| PetscReal | time, | ||
| PetscBool * | accepted, | ||
| PetscReal * | weight | ||
| ) |
Offers one completed state to a window and reports the decision.
Applies the interval convention in full: the state carries the interval ending at it, measured from the previous accepted state or from the effective start; a zero-length interval is not a sample; and a bounded window clips its final interval to the requested end and then completes.
When accepted is returned true the window's bookkeeping has already been advanced, and the caller applies weight through the moment kernels. When it is false the window is scientifically unchanged.
Offering the same step twice is rejected, so a completed state cannot be counted more than once.
| [in,out] | window | Window to offer the state to. |
| [in] | step | Completed step number. |
| [in] | time | Physical time of the completed state. |
| [out] | accepted | Whether the state became a sample. |
| [out] | weight | Weight to apply; zero when not accepted. |
Offers one completed state to a window and reports the decision.
Definition at line 113 of file statistics_window.c.
| PetscErrorCode PicurvWindowComputeHash | ( | const PicurvWindowDefinition * | definition, |
| char | digest_hex[65], | ||
| char | group_digest_hex[][17] | ||
| ) |
Computes the resolved identity hash of one window definition.
Hashes the canonical serialization defined in Field Statistics Phase 2 Implementation Specification section 7, in that fixed order, so a saved window can be matched against a resolved one without storing the definition itself.
end_time and the enabled flag are deliberately excluded, which is what lets a bounded window be extended forward and lets statistics be switched off and on without invalidating saved state.
Field and covariance entries are serialized in catalog order rather than the order the user listed them, so a reordered but otherwise identical configuration continues rather than being rejected.
Each property group is additionally hashed on its own. A restart that finds a mismatched full digest compares the group digests to name the first differing property, which a single digest could not do.
| [in] | definition | Window definition to hash. |
| [out] | digest_hex | Full 64-character digest plus terminator. |
| [out] | group_digest_hex | Optional per-group truncated digests; pass NULL to skip. |
| PetscErrorCode PicurvWindowFirstHashDifference | ( | const PicurvWindowDefinition * | definition, |
| const char * | saved_group_digests, | ||
| PetscInt * | group | ||
| ) |
Reports which hashed property group first differs from saved group digests.
A checkpoint stores the group digests but never the definition itself, so this is what turns "two hashes differ" into a message naming the property that changed.
| [in] | definition | Resolved definition to compare against. |
| [in] | saved_group_digests | Comma-separated group digests from a checkpoint. |
| [out] | group | First differing group index, or -1 when the saved digests match or are too malformed to compare. |
Reports which hashed property group first differs from saved group digests.
Definition at line 366 of file statistics_window.c.
| const char * PicurvWindowHashGroupName | ( | PetscInt | group | ) |
Returns the stable name of one hashed property group.
| [in] | group | Group index in [0, PICURV_WINDOW_HASH_GROUP_COUNT). |
"unknown" for an out-of-range index, never NULL.Returns the stable name of one hashed property group.
Definition at line 193 of file statistics_window.c.
| PetscReal PicurvWindowProgress | ( | const PicurvWindow * | window | ) |
Reports the fraction of a bounded window's span that has been represented.
| [in] | window | Window to query. |
Reports the fraction of a bounded window's span that has been represented.
Definition at line 406 of file statistics_window.c.
| const char * PicurvWindowStateName | ( | PicurvWindowState | state | ) |
Returns a stable human-readable name for a window state.
| [in] | state | Window lifecycle state. |
Returns a stable human-readable name for a window state.
Definition at line 23 of file statistics_window.c.
| PetscBool FieldStatisticsIsActive | ( | const struct SimCtx * | simCtx | ) |
Reports whether this run has live field-statistics state.
The subsystem is active only when it is enabled, at least one window is configured, and the window array exists. Every caller that touches window or accumulator state asks this rather than restating the condition, so the three parts cannot drift apart between the runloop, the checkpoint writer, and the console monitor.
| [in] | simCtx | Simulation context; may be NULL. |
PETSC_TRUE when window state exists and may be touched. | PetscErrorCode FieldStatisticsUpdateWindows | ( | SimCtx * | simCtx, |
| PetscInt | step, | ||
| PetscReal | time | ||
| ) |
Offers one completed state to every configured window.
Called once per completed step from the runloop. Each due window advances its own bookkeeping independently; windows share the source state but never share accumulator state. Does nothing when field statistics are disabled or no window is configured, which is the case until configuration ingress exists.
| [in,out] | simCtx | Simulation context carrying the window array. |
| [in] | step | Completed step number. |
| [in] | time | Physical time of the completed state. |
Offers one completed state to every configured window.
Definition at line 431 of file statistics_window.c.