|
PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
|
Per-window PETSc accumulator storage and pointwise application. More...
#include "statistics_accumulator.h"#include "statistics_moments.h"#include "statistics_target.h"#include "field_catalog.h"#include "io.h"#include "logging.h"Go to the source code of this file.
Macros | |
| #define | STATISTICS_DERIVED_OUTPUT_LENGTH 256 |
| Longest output list a recipe may request. | |
Enumerations | |
| enum | DerivedKind { DERIVED_MEAN = 0 , DERIVED_REYNOLDS_STRESS , DERIVED_RMS , DERIVED_TKE , DERIVED_FLUX , DERIVED_KIND_COUNT } |
| Output kinds a postprocessing recipe may request, in enumeration order. More... | |
Functions | |
| static PetscInt | ProductDiagonalIndex (PetscInt component) |
| Internal helper: the product index carrying one component's own variance. | |
| static PetscErrorCode | ProductComponentLabel (PetscInt index, char *out, size_t size) |
| Internal helper: writes the two-axis label of one product component. | |
| PetscErrorCode | PicurvProductComponentCount (PetscInt dof, PetscInt *count) |
| Implementation of PicurvProductComponentCount(). | |
| PetscErrorCode | PicurvCovarianceComponentCount (PetscInt dof_a, PetscInt dof_b, PetscInt *count) |
| Implementation of PicurvCovarianceComponentCount(). | |
| PetscErrorCode | PicurvStatisticsComponentDM (UserCtx *user, PetscInt components, DM *dm) |
| Implementation of PicurvStatisticsComponentDM(). | |
| PetscErrorCode | PicurvWindowStorageCreate (UserCtx *user, const PicurvWindowDefinition *definition, PicurvWindowStorage *storage) |
| Implementation of PicurvWindowStorageCreate(). | |
| PetscErrorCode | PicurvWindowStorageDestroy (PicurvWindowStorage *storage) |
| Implementation of PicurvWindowStorageDestroy(). | |
| static PetscErrorCode | FindFieldSlot (const PicurvWindowDefinition *definition, PetscInt field_id, PetscInt *slot) |
| Internal helper: locates the storage slot holding one field's running mean. | |
| PetscErrorCode | PicurvWindowStoragePayloadCount (const PicurvWindowStorage *storage, PetscInt *count) |
| Implementation of PicurvWindowStoragePayloadCount(). | |
| PetscErrorCode | PicurvWindowStoragePayload (UserCtx *user, const PicurvWindowDefinition *definition, const PicurvWindowStorage *storage, PetscInt index, PicurvStatisticsPayload *payload) |
| Implementation of PicurvWindowStoragePayload(). | |
| static PetscErrorCode | ParseDerivedKinds (const char *outputs, PetscBool wanted[DERIVED_KIND_COUNT]) |
| Internal helper: reports which output kinds a recipe requested. | |
| static PetscErrorCode | DerivedKindExtent (const PicurvWindowDefinition *definition, const PicurvWindowStorage *storage, DerivedKind kind, PetscInt *count) |
| Internal helper: counts the derived fields each kind contributes. | |
| PetscErrorCode | PicurvWindowDerivedCount (const PicurvWindowDefinition *definition, const PicurvWindowStorage *storage, const char *outputs, PetscInt *count) |
| Implementation of PicurvWindowDerivedCount(). | |
| static PetscErrorCode | SafeStandardDeviation (PetscReal variance, const char *label, PetscReal *result) |
| Internal helper: takes a square root of a variance that may be barely negative. | |
| static PetscErrorCode | ResolveDerivedIndex (const PicurvWindowDefinition *definition, const PicurvWindowStorage *storage, const PetscBool wanted[DERIVED_KIND_COUNT], PetscInt index, DerivedKind *kind, PetscInt *offset) |
| Internal helper: resolves which kind and member one derived index selects. | |
| PetscErrorCode | PicurvWindowDerive (UserCtx *user, const PicurvWindowDefinition *definition, const PicurvWindowStorage *storage, const char *outputs, PetscInt index, Vec scalar_target, Vec vector_target, PicurvDerivedField *field) |
| Implementation of PicurvWindowDerive(). | |
| PetscErrorCode | PicurvWindowSpatialMean (UserCtx *user, const PicurvWindowDefinition *definition, const PicurvWindowStorage *storage, Vec field, PetscReal *mean) |
| Implementation of PicurvWindowSpatialMean(). | |
| PetscErrorCode | PicurvWindowValidFractionRange (UserCtx *user, const PicurvWindowDefinition *definition, const PicurvWindowStorage *storage, PetscInt sample_count, PetscReal *minimum, PetscReal *maximum) |
| Implementation of PicurvWindowValidFractionRange(). | |
| PetscErrorCode | PicurvWindowAccumulate (UserCtx *user, const PicurvWindowDefinition *definition, PicurvWindowStorage *storage, PetscReal weight) |
| Implementation of PicurvWindowAccumulate(). | |
Variables | |
| static const PetscInt | kProductFirst [6] = {0, 0, 0, 1, 1, 2} |
| Upper-triangular row-major component pairs for a three-vector self-product. | |
| static const PetscInt | kProductSecond [6] = {0, 1, 2, 1, 2, 2} |
| static const char *const | kAxisName [3] = {"x", "y", "z"} |
| Axis labels indexing the pair table above. | |
| static const char *const | kDerivedKindName [DERIVED_KIND_COUNT] |
| Recipe spellings of the output kinds. | |
Per-window PETSc accumulator storage and pointwise application.
Full API contract is documented with the declarations in include/statistics_accumulator.h.
Definition in file statistics_accumulator.c.
| #define STATISTICS_DERIVED_OUTPUT_LENGTH 256 |
Longest output list a recipe may request.
Definition at line 17 of file statistics_accumulator.c.
| enum DerivedKind |
Output kinds a postprocessing recipe may request, in enumeration order.
| Enumerator | |
|---|---|
| DERIVED_MEAN | |
| DERIVED_REYNOLDS_STRESS | |
| DERIVED_RMS | |
| DERIVED_TKE | |
| DERIVED_FLUX | |
| DERIVED_KIND_COUNT | |
Definition at line 360 of file statistics_accumulator.c.
|
static |
Internal helper: the product index carrying one component's own variance.
Local to this translation unit. Found by searching the pair table for the entry pairing a component with itself, so the diagonal cannot be stated separately from the order it belongs to.
Definition at line 40 of file statistics_accumulator.c.
|
static |
Internal helper: writes the two-axis label of one product component.
Local to this translation unit. Built from the pair table, so "xy" and the slot it names can never refer to different pairs.
Definition at line 53 of file statistics_accumulator.c.
| PetscErrorCode PicurvProductComponentCount | ( | PetscInt | dof, |
| PetscInt * | count | ||
| ) |
Implementation of PicurvProductComponentCount().
Reports how many symmetric product components a field's second moment needs.
Definition at line 67 of file statistics_accumulator.c.
| PetscErrorCode PicurvCovarianceComponentCount | ( | PetscInt | dof_a, |
| PetscInt | dof_b, | ||
| PetscInt * | count | ||
| ) |
Implementation of PicurvCovarianceComponentCount().
Reports how many components a covariance between two fields needs.
Definition at line 81 of file statistics_accumulator.c.
| PetscErrorCode PicurvStatisticsComponentDM | ( | UserCtx * | user, |
| PetscInt | components, | ||
| DM * | dm | ||
| ) |
Implementation of PicurvStatisticsComponentDM().
Resolves the DM carrying a given number of accumulator components.
Definition at line 99 of file statistics_accumulator.c.
| PetscErrorCode PicurvWindowStorageCreate | ( | UserCtx * | user, |
| const PicurvWindowDefinition * | definition, | ||
| PicurvWindowStorage * | storage | ||
| ) |
Implementation of PicurvWindowStorageCreate().
Allocates the accumulator state one window owns on one block.
Definition at line 122 of file statistics_accumulator.c.
| PetscErrorCode PicurvWindowStorageDestroy | ( | PicurvWindowStorage * | storage | ) |
Implementation of PicurvWindowStorageDestroy().
Releases accumulator state previously created for one window.
Definition at line 200 of file statistics_accumulator.c.
|
static |
Internal helper: locates the storage slot holding one field's running mean.
Local to this translation unit. A covariance member must also appear in the window's field list, because the co-moment update needs that field's running mean; this is where that requirement is enforced.
Definition at line 229 of file statistics_accumulator.c.
| PetscErrorCode PicurvWindowStoragePayloadCount | ( | const PicurvWindowStorage * | storage, |
| PetscInt * | count | ||
| ) |
Implementation of PicurvWindowStoragePayloadCount().
Reports how many checkpointable vectors one window's storage holds.
Definition at line 248 of file statistics_accumulator.c.
| PetscErrorCode PicurvWindowStoragePayload | ( | UserCtx * | user, |
| const PicurvWindowDefinition * | definition, | ||
| const PicurvWindowStorage * | storage, | ||
| PetscInt | index, | ||
| PicurvStatisticsPayload * | payload | ||
| ) |
Implementation of PicurvWindowStoragePayload().
Resolves one enumerated payload of a window's storage.
Definition at line 266 of file statistics_accumulator.c.
|
static |
Internal helper: reports which output kinds a recipe requested.
Local to this translation unit.
Definition at line 378 of file statistics_accumulator.c.
|
static |
Internal helper: counts the derived fields each kind contributes.
Local to this translation unit. A kind contributes nothing when the state it needs was never accumulated, so a recipe may name every output without having to know which window carries which moment.
Definition at line 416 of file statistics_accumulator.c.
| PetscErrorCode PicurvWindowDerivedCount | ( | const PicurvWindowDefinition * | definition, |
| const PicurvWindowStorage * | storage, | ||
| const char * | outputs, | ||
| PetscInt * | count | ||
| ) |
Implementation of PicurvWindowDerivedCount().
Reports how many derived fields a requested output set produces.
Definition at line 462 of file statistics_accumulator.c.
|
static |
Internal helper: takes a square root of a variance that may be barely negative.
Local to this translation unit. Centered accumulation can leave a variance a few ulps below zero when the signal is nearly constant. Clamping is confined to this one place, applies only under a root, and never touches stored state; a genuinely negative variance is a defect and is reported.
Definition at line 490 of file statistics_accumulator.c.
|
static |
Internal helper: resolves which kind and member one derived index selects.
Local to this translation unit. Walks the same order DerivedKindExtent counts, so the enumeration and the count cannot disagree.
Definition at line 509 of file statistics_accumulator.c.
| PetscErrorCode PicurvWindowDerive | ( | UserCtx * | user, |
| const PicurvWindowDefinition * | definition, | ||
| const PicurvWindowStorage * | storage, | ||
| const char * | outputs, | ||
| PetscInt | index, | ||
| Vec | scalar_target, | ||
| Vec | vector_target, | ||
| PicurvDerivedField * | field | ||
| ) |
Implementation of PicurvWindowDerive().
Derives one output field from centered accumulator state.
Definition at line 535 of file statistics_accumulator.c.
| PetscErrorCode PicurvWindowSpatialMean | ( | UserCtx * | user, |
| const PicurvWindowDefinition * | definition, | ||
| const PicurvWindowStorage * | storage, | ||
| Vec | field, | ||
| PetscReal * | mean | ||
| ) |
Implementation of PicurvWindowSpatialMean().
Reports the spatial mean of a derived field over the points a window sampled.
Definition at line 718 of file statistics_accumulator.c.
| PetscErrorCode PicurvWindowValidFractionRange | ( | UserCtx * | user, |
| const PicurvWindowDefinition * | definition, | ||
| const PicurvWindowStorage * | storage, | ||
| PetscInt | sample_count, | ||
| PetscReal * | minimum, | ||
| PetscReal * | maximum | ||
| ) |
Implementation of PicurvWindowValidFractionRange().
Reports the range of per-point valid fraction across a window's domain.
Definition at line 766 of file statistics_accumulator.c.
| PetscErrorCode PicurvWindowAccumulate | ( | UserCtx * | user, |
| const PicurvWindowDefinition * | definition, | ||
| PicurvWindowStorage * | storage, | ||
| PetscReal | weight | ||
| ) |
Implementation of PicurvWindowAccumulate().
Applies one accepted completed state to a window's accumulators.
Definition at line 818 of file statistics_accumulator.c.
|
static |
Upper-triangular row-major component pairs for a three-vector self-product.
This pair table is the single definition of the symmetric component order. The diagonal positions and the two-axis component labels are both derived from it rather than restated, because accumulation reads the table while derivation reads what follows from it: a hand-written copy that drifted would mislabel every Reynolds stress and take the root of the wrong component, with nothing failing.
Definition at line 28 of file statistics_accumulator.c.
|
static |
Definition at line 29 of file statistics_accumulator.c.
|
static |
Axis labels indexing the pair table above.
Definition at line 32 of file statistics_accumulator.c.
|
static |
Recipe spellings of the output kinds.
Definition at line 370 of file statistics_accumulator.c.