Spatial target resolution for the field-statistics pipeline. More...
Go to the source code of this file.
Data Structures | |
| struct | SpatialTargetPlan |
| Resolved iteration domain for one field on one block. More... | |
Macros | |
| #define | PICURV_STATISTICS_FLUID_THRESHOLD 0.1 |
| Threshold below which a cell counts as fluid for the default mask. | |
| #define | PICURV_SPATIAL_AVERAGE_MAX_BUFFER 4000000 |
| Largest reduction buffer a directional average will allocate, in entries. | |
Enumerations | |
| enum | PicurvTargetKind { PICURV_TARGET_POINTWISE = 0 } |
| Spatial mapping kind. More... | |
| enum | PicurvStatisticsMask { PICURV_STATISTICS_MASK_FLUID = 0 } |
| Point-eligibility mask. More... | |
Functions | |
| PetscErrorCode | PicurvLayoutDimensionIsNodeLike (FieldLayout layout, PetscInt dim, PetscBool *node_like) |
| Reports whether a layout is node-like in one dimension. | |
| PetscErrorCode | SpatialTargetPlanCreate (UserCtx *user, FieldId field_id, PicurvStatisticsMask mask, SpatialTargetPlan *plan) |
| Resolves the iteration domain for one field on one block. | |
| PetscErrorCode | SpatialTargetPlanLocalPointCount (const SpatialTargetPlan *plan, PetscInt *count) |
| Counts the points this rank contributes. | |
| PetscErrorCode | SpatialTargetPlanGlobalPointCount (const SpatialTargetPlan *plan, MPI_Comm comm, PetscInt *count) |
| Counts the points contributed across a communicator. | |
| PetscBool | SpatialTargetPlanMaskAllows (const SpatialTargetPlan *plan, PetscReal nvert_value) |
| Reports whether a point passes the plan's mask. | |
| PetscErrorCode | PicurvSpatialRatioAverage (UserCtx *user, const SpatialTargetPlan *plan, Vec numerator, Vec denominator, Vec inclusion, const PetscBool average_direction[3], MPI_Comm comm, Vec ratio, PetscReal *reduced) |
| Averages two fields over a target domain and divides the results. | |
Spatial target resolution for the field-statistics pipeline.
Implements the pointwise identity mapping described in 5. Spatial Target, Layout, and Mask. The abstraction exists with only that one mapping so later spatial bins, profiles, regions, and surfaces extend it rather than retrofit it; see Field Statistics Planned Extensions.
The central responsibility is producing an iteration domain that excludes two distinct categories which Field Identity and Layout Catalog section 4 warns must not be conflated:
Nothing here resolves field identity or layout metadata itself; that comes from the typed catalog through FieldGetDescriptor.
Definition in file statistics_target.h.
| struct SpatialTargetPlan |
Resolved iteration domain for one field on one block.
Bounds are half-open [start, end) in DMDA index order (i, j, k) and are already intersected with this rank's owned range, so iterating them touches neither halo storage nor layout boundary/dummy/duplicate-periodic indices. An empty domain on a rank is represented by end[d] <= start[d].
Definition at line 49 of file statistics_target.h.
| Data Fields | ||
|---|---|---|
| PicurvTargetKind | kind | Spatial mapping; always pointwise. |
| PicurvStatisticsMask | mask | Point-eligibility mask. |
| const FieldDescriptor * | descriptor | Catalog metadata for the targeted field. |
| PetscInt | start[3] | Inclusive start per dimension (i, j, k). |
| PetscInt | end[3] | Exclusive end per dimension (i, j, k). |
| #define PICURV_STATISTICS_FLUID_THRESHOLD 0.1 |
Threshold below which a cell counts as fluid for the default mask.
Definition at line 29 of file statistics_target.h.
| #define PICURV_SPATIAL_AVERAGE_MAX_BUFFER 4000000 |
Largest reduction buffer a directional average will allocate, in entries.
Definition at line 127 of file statistics_target.h.
| enum PicurvTargetKind |
Spatial mapping kind.
Only the pointwise identity is implemented.
| Enumerator | |
|---|---|
| PICURV_TARGET_POINTWISE | |
Definition at line 32 of file statistics_target.h.
| enum PicurvStatisticsMask |
Point-eligibility mask.
Only the fluid mask is implemented.
| Enumerator | |
|---|---|
| PICURV_STATISTICS_MASK_FLUID | |
Definition at line 37 of file statistics_target.h.
| PetscErrorCode PicurvLayoutDimensionIsNodeLike | ( | FieldLayout | layout, |
| PetscInt | dim, | ||
| PetscBool * | node_like | ||
| ) |
Reports whether a layout is node-like in one dimension.
Node-like dimensions carry one more physical entry than cell-like dimensions, because they sit on grid lines rather than between them. I_FACE is node-like in i and cell-like in j and k, and correspondingly for the other face families.
| [in] | layout | Catalog layout. |
| [in] | dim | Dimension index: 0 for i, 1 for j, 2 for k. |
| [out] | node_like | Resolved classification. |
PETSC_ERR_ARG_OUTOFRANGE for an invalid dimension, or PETSC_ERR_ARG_WRONGSTATE for a component-staggered layout, whose components do not share one classification.Reports whether a layout is node-like in one dimension.
Definition at line 16 of file statistics_target.c.
| PetscErrorCode SpatialTargetPlanCreate | ( | UserCtx * | user, |
| FieldId | field_id, | ||
| PicurvStatisticsMask | mask, | ||
| SpatialTargetPlan * | plan | ||
| ) |
Resolves the iteration domain for one field on one block.
Rejects component-staggered fields, whose x, y, and z components live on different face families and therefore cannot share a single pointwise domain. Configured statistics request only cell-centered fields, but the plan resolves node and face layouts correctly so later phases inherit a verified contract.
| [in] | user | Block context supplying the DMDA layout and periodicity. |
| [in] | field_id | Catalogued field to target. |
| [in] | mask | Point-eligibility mask. |
| [out] | plan | Resolved plan. |
Resolves the iteration domain for one field on one block.
Definition at line 81 of file statistics_target.c.
| PetscErrorCode SpatialTargetPlanLocalPointCount | ( | const SpatialTargetPlan * | plan, |
| PetscInt * | count | ||
| ) |
Counts the points this rank contributes.
| [in] | plan | Resolved plan. |
| [out] | count | Local point count; zero for an empty domain. |
PETSC_ERR_ARG_NULL for a null argument.Counts the points this rank contributes.
Definition at line 142 of file statistics_target.c.
| PetscErrorCode SpatialTargetPlanGlobalPointCount | ( | const SpatialTargetPlan * | plan, |
| MPI_Comm | comm, | ||
| PetscInt * | count | ||
| ) |
Counts the points contributed across a communicator.
The result is decomposition independent: it depends only on the layout, global dimensions, and periodicity, never on how ranks divide the domain.
| [in] | plan | Resolved plan. |
| [in] | comm | Communicator to reduce over. |
| [out] | count | Global point count. |
PETSC_ERR_ARG_NULL for a null argument.Counts the points contributed across a communicator.
Definition at line 164 of file statistics_target.c.
| PetscBool SpatialTargetPlanMaskAllows | ( | const SpatialTargetPlan * | plan, |
| PetscReal | nvert_value | ||
| ) |
Reports whether a point passes the plan's mask.
Because Nvert changes when immersed bodies move, the mask is treated as potentially moving: callers accumulate a per-point valid count and weight rather than assuming a point contributes to every accepted state.
| [in] | plan | Resolved plan. |
| [in] | nvert_value | Node-blanking value at the point. |
PETSC_TRUE when the point is eligible.Reports whether a point passes the plan's mask.
Definition at line 182 of file statistics_target.c.
| PetscErrorCode PicurvSpatialRatioAverage | ( | UserCtx * | user, |
| const SpatialTargetPlan * | plan, | ||
| Vec | numerator, | ||
| Vec | denominator, | ||
| Vec | inclusion, | ||
| const PetscBool | average_direction[3], | ||
| MPI_Comm | comm, | ||
| Vec | ratio, | ||
| PetscReal * | reduced | ||
| ) |
Averages two fields over a target domain and divides the results.
Computes ratio = <numerator> / <denominator>, where each average is taken separately over the points the plan admits, and then divides. The order matters: the mean of the pointwise quotients is a different number from the quotient of the means, and several callers need the second one. The LES dynamic procedure is one, because Lilly's least-squares closure is defined that way.
average_direction selects which logical directions collapse into the average. Selecting none makes the operation pointwise, which lets a caller express a local and an averaged formulation through one code path rather than two. Selecting all three yields one number for the whole domain. Selecting a subset retains a profile along the directions left out — averaging over xi and zeta on a plane channel, for example, leaves a wall-normal profile.
Weighting is the caller's, not this function's: scale numerator and denominator by whatever weight the average should carry before calling. A caller wanting a volume-weighted average multiplies both by the cell volume; a caller wanting each admitted point to count once passes them unscaled.
The reduction runs over comm, so a result is independent of how the domain is decomposed across ranks. The plan already excludes PETSc halo storage and the solver's boundary, dummy, and duplicate-periodic indices, so no physical point is counted twice.
| [in] | user | Block context supplying the DMDA and the solid mask. |
| [in] | plan | Resolved iteration domain, from SpatialTargetPlanCreate(). |
| [in] | numerator | Field to average in the numerator, ghosted local or global, on any DMDA sharing the block's layout. Its components are averaged independently against the one scalar denominator, so a vector or a symmetric tensor reduces in one call. |
| [in] | denominator | Ghosted local field to average in the denominator, or NULL to divide by the number of admitted points. |
| [in] | inclusion | Optional second mask: points where this field is not positive are skipped. Use it to exclude points that hold a zero meaning "never measured" rather than a measurement. NULL applies the plan's mask alone. |
| [in] | average_direction | Directions to average over, in (xi, eta, zeta) order. |
| [in] | comm | Communicator to reduce over. |
| [out] | ratio | Field on the numerator's DM receiving the quotient at every admitted point, or NULL when only reduced is wanted. Zero wherever the averaged denominator underflows. |
| [out] | reduced | Receives the quotient of every retained slot, or NULL. The same on every rank of comm. Holds dof entries per slot, slot i + mx (j + my k) over the retained global indices with an averaged direction's index taken as zero and its extent as one: one value when every direction is averaged, a profile when some are not. Slots no admitted point reached hold zero. |
PETSC_ERR_ARG_OUTOFRANGE when the retained directions would need an unreasonably large reduction buffer, or PETSC_ERR_ARG_WRONGSTATE when reduced is requested from a pointwise operation, which has no reduced form.Averages two fields over a target domain and divides the results.
Definition at line 207 of file statistics_target.c.