PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
 
Loading...
Searching...
No Matches
field_catalog.h
Go to the documentation of this file.
1/**
2 * @file field_catalog.h
3 * @brief Authoritative identities and storage metadata for persistent Eulerian fields.
4 *
5 * Field identifiers describe conceptual fields at compile time. They do not own,
6 * allocate, or modify PETSc objects. A FieldView resolves one identifier against
7 * an existing UserCtx after the normal setup lifecycle has created its DMs and
8 * vectors.
9 */
10
11#ifndef FIELD_CATALOG_H
12#define FIELD_CATALOG_H
13
14#include <stddef.h>
15
16#include "variables.h"
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22/** @brief Compile-time identity for a catalogued Eulerian field. */
83
84/** @brief Logical storage topology of a field. */
93
94/** @brief UserCtx DM family used to store a field. */
99
100/** @brief Extra repair required after the normal PETSc global-to-local scatter. */
108
109/** @brief Conditions controlling when a field can have runtime storage. */
119
120/** @brief Operations supported by a catalog entry. */
121typedef enum {
129 /** Defined only where a cell holds particles; elsewhere the stored value is a
130 * placeholder, not a measurement, and statistics skip it. */
133
134/** @brief How a field's physical dimension is known. */
135typedef enum {
136 FIELD_DIMENSION_FIXED = 0, /**< The exponents are the field's dimension. */
137 FIELD_DIMENSION_NOT_A_QUANTITY, /**< Integer bookkeeping: identities, flags, ranks. */
138 FIELD_DIMENSION_FROM_SOURCE /**< Staging storage: carries whatever was written into it. */
140
141/**
142 * @brief Physical dimension as exponents of the reference length, velocity, and density.
143 *
144 * A solver value of dimension (a, b, c) becomes physical when multiplied by
145 * `L_ref^a U_ref^b rho_ref^c`. The launcher records input dimensions with the same
146 * triple (`picurv_cli/core.py`, `INPUT_QUANTITIES`), so input and output conversion use
147 * one vocabulary. See docs/pages/19_Nondimensionalization.md.
148 */
149typedef struct {
151 signed char length;
152 signed char velocity;
153 signed char density;
155
156/* Named dimensions for catalog entries. Each expands to a brace initializer, so it can
157 * be passed through an entry macro as one argument. */
158#define FIELD_DIM_DIMENSIONLESS {FIELD_DIMENSION_FIXED, 0, 0, 0}
159#define FIELD_DIM_LENGTH {FIELD_DIMENSION_FIXED, 1, 0, 0}
160#define FIELD_DIM_AREA {FIELD_DIMENSION_FIXED, 2, 0, 0}
161#define FIELD_DIM_INVERSE_VOLUME {FIELD_DIMENSION_FIXED, -3, 0, 0}
162#define FIELD_DIM_TIME {FIELD_DIMENSION_FIXED, 1, -1, 0}
163#define FIELD_DIM_VELOCITY {FIELD_DIMENSION_FIXED, 0, 1, 0}
164#define FIELD_DIM_VOLUME_FLUX {FIELD_DIMENSION_FIXED, 2, 1, 0}
165#define FIELD_DIM_DIFFUSIVITY {FIELD_DIMENSION_FIXED, 1, 1, 0}
166#define FIELD_DIM_PRESSURE {FIELD_DIMENSION_FIXED, 0, 2, 1}
167#define FIELD_DIM_VELOCITY_SQUARED {FIELD_DIMENSION_FIXED, 0, 2, 0}
168#define FIELD_DIM_INVERSE_TIME_SQUARED {FIELD_DIMENSION_FIXED, -2, 2, 0}
169#define FIELD_DIM_NOT_A_QUANTITY {FIELD_DIMENSION_NOT_A_QUANTITY, 0, 0, 0}
170#define FIELD_DIM_FROM_SOURCE {FIELD_DIMENSION_FROM_SOURCE, 0, 0, 0}
171
172/** @brief Immutable metadata for one field identity. */
188
189/** @brief Non-owning runtime objects resolved for one field and UserCtx. */
190typedef struct {
192 DM dm;
195} FieldView;
196
197/**
198 * @brief Return immutable metadata for a valid field identifier.
199 * @param[in] field_id Compile-time field identity.
200 * @param[out] descriptor Catalog entry owned by the field-catalog module.
201 * @return Zero on success; PETSc error for an invalid ID or null output.
202 */
203PetscErrorCode FieldGetDescriptor(FieldId field_id, const FieldDescriptor **descriptor);
204
205/**
206 * @brief Resolve a user-facing field name once into its typed identity.
207 * @param[in] field_name Canonical name or registered alias.
208 * @param[out] field_id Resolved field identity.
209 * @return Zero on success; PETSc unknown-type error for an unregistered name.
210 */
211PetscErrorCode FieldIdFromName(const char *field_name, FieldId *field_id);
212
213/**
214 * @brief Look a name up without treating an unknown name as an error.
215 * @details For callers that consult more than one catalog, such as a name that may be an
216 * Eulerian or a particle field.
217 * @param[in] field_name Canonical name or registered alias.
218 * @param[out] field_id Resolved identity, or `FIELD_ID_INVALID` when not found.
219 * @param[out] found Whether the name is registered.
220 * @return Zero on success; PETSc error only for null arguments.
221 */
222PetscErrorCode FieldTryIdFromName(const char *field_name, FieldId *field_id, PetscBool *found);
223
224/**
225 * @brief Return the factor that turns a solver value of one dimension into physical units.
226 * @param[in] scaling Reference scales of the run.
227 * @param[in] dimension Dimension to scale.
228 * @param[out] scale `L_ref^a U_ref^b rho_ref^c` for a fixed dimension `(a, b, c)`.
229 * @return Zero on success; `PETSC_ERR_ARG_WRONGSTATE` for a dimension that is not fixed,
230 * since bookkeeping and staging storage have no scale of their own.
231 */
232PetscErrorCode FieldDimensionReferenceScale(const ScalingCtx *scaling, FieldDimension dimension,
233 PetscReal *scale);
234
235/**
236 * @brief Write a printable form of a dimension, such as `L^2 U` or `dimensionless`.
237 * @param[in] dimension Dimension to describe.
238 * @param[out] label Destination buffer.
239 * @param[in] length Buffer length.
240 * @return Zero on success.
241 */
242PetscErrorCode FieldDimensionLabel(FieldDimension dimension, char *label, size_t length);
243
244/**
245 * @brief Return the canonical printable name for an ID.
246 * @param[in] field_id Field identity.
247 * @return Canonical name, or "InvalidField" for an invalid ID.
248 */
249const char *FieldCanonicalName(FieldId field_id);
250
251/**
252 * @brief Return a stable printable label for a field layout.
253 * @param[in] layout Layout enum to describe.
254 * @return Catalog-owned label, or `Invalid-Layout` for an invalid enum.
255 */
256const char *FieldLayoutName(FieldLayout layout);
257
258/**
259 * @brief Resolve the existing DM and global/local vectors for one field.
260 *
261 * This function never creates storage. Optional fields whose setup conditions
262 * were not enabled retain valid descriptors but return PETSC_ERR_ARG_WRONGSTATE
263 * because their runtime vectors are absent.
264 *
265 * @param[in] user Existing per-grid context.
266 * @param[in] field_id Field identity to resolve.
267 * @param[out] view Non-owning runtime view.
268 * @return Zero on success or a PETSc argument/state error.
269 */
270PetscErrorCode FieldGetView(UserCtx *user, FieldId field_id, FieldView *view);
271
272#ifdef __cplusplus
273}
274#endif
275
276#endif /* FIELD_CATALOG_H */
FieldLayout layout
PetscErrorCode FieldIdFromName(const char *field_name, FieldId *field_id)
Resolve a user-facing field name once into its typed identity.
const char * alias_1
FieldDimensionKind
How a field's physical dimension is known.
@ FIELD_DIMENSION_FROM_SOURCE
Staging storage: carries whatever was written into it.
@ FIELD_DIMENSION_NOT_A_QUANTITY
Integer bookkeeping: identities, flags, ranks.
@ FIELD_DIMENSION_FIXED
The exponents are the field's dimension.
PetscErrorCode FieldDimensionReferenceScale(const ScalingCtx *scaling, FieldDimension dimension, PetscReal *scale)
Return the factor that turns a solver value of one dimension into physical units.
FieldCapabilities
Operations supported by a catalog entry.
@ FIELD_CAPABILITY_CHECKPOINT
@ FIELD_CAPABILITY_PARTICLE_SAMPLED
Defined only where a cell holds particles; elsewhere the stored value is a placeholder,...
@ FIELD_CAPABILITY_GHOST_UPDATE
@ FIELD_CAPABILITY_PERIODIC_GEOMETRY_SHIFT
@ FIELD_CAPABILITY_PERIODIC_CELL_SYNC
@ FIELD_CAPABILITY_NONE
@ FIELD_CAPABILITY_PERIODIC_FACE_SYNC
@ FIELD_CAPABILITY_PERIODIC_STAGGERED_SYNC
FieldAvailability
Conditions controlling when a field can have runtime storage.
@ FIELD_AVAILABILITY_WALL_MODEL
@ FIELD_AVAILABILITY_FINEST_LEVEL
@ FIELD_AVAILABILITY_PARTICLES
@ FIELD_AVAILABILITY_TURBULENCE
@ FIELD_AVAILABILITY_LES_DYNAMIC
@ FIELD_AVAILABILITY_ALWAYS
@ FIELD_AVAILABILITY_INFLOW_FLUCTUATION
FieldSyncClass
Extra repair required after the normal PETSc global-to-local scatter.
@ FIELD_SYNC_STANDARD
@ FIELD_SYNC_K_FACE
@ FIELD_SYNC_J_FACE
@ FIELD_SYNC_COMPONENT_STAGGERED
@ FIELD_SYNC_I_FACE
unsigned int capabilities
const FieldDescriptor * descriptor
const char * FieldCanonicalName(FieldId field_id)
Return the canonical printable name for an ID.
unsigned int availability
signed char velocity
PetscErrorCode FieldGetView(UserCtx *user, FieldId field_id, FieldView *view)
Resolve the existing DM and global/local vectors for one field.
signed char density
FieldDMKind dm_kind
PetscErrorCode FieldTryIdFromName(const char *field_name, FieldId *field_id, PetscBool *found)
Look a name up without treating an unknown name as an error.
signed char length
FieldLayout
Logical storage topology of a field.
@ FIELD_LAYOUT_K_FACE
@ FIELD_LAYOUT_I_FACE
@ FIELD_LAYOUT_CELL_CENTERED
@ FIELD_LAYOUT_COMPONENT_STAGGERED
@ FIELD_LAYOUT_NODE_CENTERED
@ FIELD_LAYOUT_J_FACE
FieldDimension dimension
FieldDimensionKind kind
const char * canonical_name
const char * alias_2
const char * FieldLayoutName(FieldLayout layout)
Return a stable printable label for a field layout.
FieldSyncClass sync_class
PetscErrorCode FieldDimensionLabel(FieldDimension dimension, char *label, size_t length)
Write a printable form of a dimension, such as L^2 U or dimensionless.
PetscErrorCode FieldGetDescriptor(FieldId field_id, const FieldDescriptor **descriptor)
Return immutable metadata for a valid field identifier.
FieldDMKind
UserCtx DM family used to store a field.
@ FIELD_DM_FDA
@ FIELD_DM_DA
FieldId
Compile-time identity for a catalogued Eulerian field.
@ FIELD_ID_DUAL_PLANE_CENTROID_I
@ FIELD_ID_PLANE_NORMAL_J
@ FIELD_ID_PSI
@ FIELD_ID_JETA
@ FIELD_ID_CENTZ
@ FIELD_ID_PLANE_CENTROID_I
@ FIELD_ID_CSI
@ FIELD_ID_IAJ
@ FIELD_ID_CELL_SCALAR_AT_CORNER
@ FIELD_ID_NVERT
@ FIELD_ID_PLANE_NORMAL_K
@ FIELD_ID_UCAT
@ FIELD_ID_NVERT_O
@ FIELD_ID_KETA
@ FIELD_ID_PLANE_CENTROID_K
@ FIELD_ID_JAJ
@ FIELD_ID_COORDINATES
@ FIELD_ID_PLANE_NORMAL_I
@ FIELD_ID_UCONT_O
@ FIELD_ID_KAJ
@ FIELD_ID_CELL_VECTOR_AT_CORNER
@ FIELD_ID_AJ
@ FIELD_ID_NU_T
@ FIELD_ID_CENTY
@ FIELD_ID_DUAL_PLANE_CENTROID_J
@ FIELD_ID_INFLOW_FLUCTUATION
@ FIELD_ID_DUAL_PLANE_CENTROID_K
@ FIELD_ID_KZET
@ FIELD_ID_IETA
@ FIELD_ID_DIFFUSIVITY_GRADIENT
@ FIELD_ID_UCONT
@ FIELD_ID_U_TAU
@ FIELD_ID_ICSI
@ FIELD_ID_POST_VECTOR
@ FIELD_ID_ETA
@ FIELD_ID_PHI
@ FIELD_ID_POST_SCALAR
@ FIELD_ID_WALL_STRESS
@ FIELD_ID_CS
@ FIELD_ID_CENT
@ FIELD_ID_QCRIT
@ FIELD_ID_JCSI
@ FIELD_ID_JZET
@ FIELD_ID_PLANE_CENTROID_J
@ FIELD_ID_DUAL_PLANE_NORMAL_I
@ FIELD_ID_INVALID
@ FIELD_ID_DUAL_PLANE_NORMAL_J
@ FIELD_ID_DUAL_PLANE_NORMAL_K
@ FIELD_ID_P
@ FIELD_ID_IZET
@ FIELD_ID_UCONT_RM1
@ FIELD_ID_ZET
@ FIELD_ID_KCSI
@ FIELD_ID_CENTX
@ FIELD_ID_PARTICLE_COUNT
@ FIELD_ID_COUNT
@ FIELD_ID_DIFFUSIVITY
@ FIELD_ID_SEARCH_CELL_SIZE
Immutable metadata for one field identity.
Physical dimension as exponents of the reference length, velocity, and density.
Non-owning runtime objects resolved for one field and UserCtx.
Main header file for a complex fluid dynamics solver.
User-defined context containing data specific to a single computational grid level.
Definition variables.h:1157