PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
 
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions
field_catalog.h File Reference

Authoritative identities and storage metadata for persistent Eulerian fields. More...

#include <stddef.h>
#include "variables.h"
Include dependency graph for field_catalog.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  FieldDimension
 Physical dimension as exponents of the reference length, velocity, and density. More...
 
struct  FieldDescriptor
 Immutable metadata for one field identity. More...
 
struct  FieldView
 Non-owning runtime objects resolved for one field and UserCtx. More...
 

Macros

#define FIELD_DIM_DIMENSIONLESS   {FIELD_DIMENSION_FIXED, 0, 0, 0}
 
#define FIELD_DIM_LENGTH   {FIELD_DIMENSION_FIXED, 1, 0, 0}
 
#define FIELD_DIM_AREA   {FIELD_DIMENSION_FIXED, 2, 0, 0}
 
#define FIELD_DIM_INVERSE_VOLUME   {FIELD_DIMENSION_FIXED, -3, 0, 0}
 
#define FIELD_DIM_TIME   {FIELD_DIMENSION_FIXED, 1, -1, 0}
 
#define FIELD_DIM_VELOCITY   {FIELD_DIMENSION_FIXED, 0, 1, 0}
 
#define FIELD_DIM_VOLUME_FLUX   {FIELD_DIMENSION_FIXED, 2, 1, 0}
 
#define FIELD_DIM_DIFFUSIVITY   {FIELD_DIMENSION_FIXED, 1, 1, 0}
 
#define FIELD_DIM_PRESSURE   {FIELD_DIMENSION_FIXED, 0, 2, 1}
 
#define FIELD_DIM_VELOCITY_SQUARED   {FIELD_DIMENSION_FIXED, 0, 2, 0}
 
#define FIELD_DIM_INVERSE_TIME_SQUARED   {FIELD_DIMENSION_FIXED, -2, 2, 0}
 
#define FIELD_DIM_NOT_A_QUANTITY   {FIELD_DIMENSION_NOT_A_QUANTITY, 0, 0, 0}
 
#define FIELD_DIM_FROM_SOURCE   {FIELD_DIMENSION_FROM_SOURCE, 0, 0, 0}
 

Enumerations

enum  FieldId {
  FIELD_ID_INVALID = -1 , FIELD_ID_COORDINATES = 0 , FIELD_ID_UCAT , FIELD_ID_UCONT ,
  FIELD_ID_UCONT_O , FIELD_ID_UCONT_RM1 , FIELD_ID_P , FIELD_ID_NU_T ,
  FIELD_ID_CS , FIELD_ID_U_TAU , FIELD_ID_WALL_STRESS , FIELD_ID_INFLOW_FLUCTUATION ,
  FIELD_ID_DIFFUSIVITY , FIELD_ID_DIFFUSIVITY_GRADIENT , FIELD_ID_CSI , FIELD_ID_ETA ,
  FIELD_ID_ZET , FIELD_ID_NVERT , FIELD_ID_AJ , FIELD_ID_CENT ,
  FIELD_ID_CENTX , FIELD_ID_CENTY , FIELD_ID_CENTZ , FIELD_ID_ICSI ,
  FIELD_ID_IETA , FIELD_ID_IZET , FIELD_ID_JCSI , FIELD_ID_JETA ,
  FIELD_ID_JZET , FIELD_ID_KCSI , FIELD_ID_KETA , FIELD_ID_KZET ,
  FIELD_ID_IAJ , FIELD_ID_JAJ , FIELD_ID_KAJ , FIELD_ID_PHI ,
  FIELD_ID_PSI , FIELD_ID_NVERT_O , FIELD_ID_PARTICLE_COUNT , FIELD_ID_CELL_SCALAR_AT_CORNER ,
  FIELD_ID_CELL_VECTOR_AT_CORNER , FIELD_ID_POST_SCALAR , FIELD_ID_POST_VECTOR , FIELD_ID_QCRIT ,
  FIELD_ID_PLANE_NORMAL_I , FIELD_ID_PLANE_NORMAL_J , FIELD_ID_PLANE_NORMAL_K , FIELD_ID_PLANE_CENTROID_I ,
  FIELD_ID_PLANE_CENTROID_J , FIELD_ID_PLANE_CENTROID_K , FIELD_ID_SEARCH_CELL_SIZE , FIELD_ID_DUAL_PLANE_NORMAL_I ,
  FIELD_ID_DUAL_PLANE_NORMAL_J , FIELD_ID_DUAL_PLANE_NORMAL_K , FIELD_ID_DUAL_PLANE_CENTROID_I , FIELD_ID_DUAL_PLANE_CENTROID_J ,
  FIELD_ID_DUAL_PLANE_CENTROID_K , FIELD_ID_COUNT
}
 Compile-time identity for a catalogued Eulerian field. More...
 
enum  FieldLayout {
  FIELD_LAYOUT_NODE_CENTERED = 0 , FIELD_LAYOUT_CELL_CENTERED , FIELD_LAYOUT_I_FACE , FIELD_LAYOUT_J_FACE ,
  FIELD_LAYOUT_K_FACE , FIELD_LAYOUT_COMPONENT_STAGGERED
}
 Logical storage topology of a field. More...
 
enum  FieldDMKind { FIELD_DM_DA = 0 , FIELD_DM_FDA }
 UserCtx DM family used to store a field. More...
 
enum  FieldSyncClass {
  FIELD_SYNC_STANDARD = 0 , FIELD_SYNC_I_FACE , FIELD_SYNC_J_FACE , FIELD_SYNC_K_FACE ,
  FIELD_SYNC_COMPONENT_STAGGERED
}
 Extra repair required after the normal PETSc global-to-local scatter. More...
 
enum  FieldAvailability {
  FIELD_AVAILABILITY_ALWAYS = 0u , FIELD_AVAILABILITY_FINEST_LEVEL = 1u << 0 , FIELD_AVAILABILITY_TURBULENCE = 1u << 1 , FIELD_AVAILABILITY_LES_DYNAMIC = 1u << 2 ,
  FIELD_AVAILABILITY_PARTICLES = 1u << 4 , FIELD_AVAILABILITY_WALL_MODEL = 1u << 5 , FIELD_AVAILABILITY_INFLOW_FLUCTUATION = 1u << 6
}
 Conditions controlling when a field can have runtime storage. More...
 
enum  FieldCapabilities {
  FIELD_CAPABILITY_NONE = 0u , FIELD_CAPABILITY_GHOST_UPDATE = 1u << 0 , FIELD_CAPABILITY_PERIODIC_CELL_SYNC = 1u << 1 , FIELD_CAPABILITY_PERIODIC_FACE_SYNC = 1u << 2 ,
  FIELD_CAPABILITY_PERIODIC_STAGGERED_SYNC = 1u << 3 , FIELD_CAPABILITY_PERIODIC_GEOMETRY_SHIFT = 1u << 4 , FIELD_CAPABILITY_CHECKPOINT = 1u << 5 , FIELD_CAPABILITY_PARTICLE_SAMPLED = 1u << 6
}
 Operations supported by a catalog entry. More...
 
enum  FieldDimensionKind { FIELD_DIMENSION_FIXED = 0 , FIELD_DIMENSION_NOT_A_QUANTITY , FIELD_DIMENSION_FROM_SOURCE }
 How a field's physical dimension is known. More...
 

Functions

PetscErrorCode FieldGetDescriptor (FieldId field_id, const FieldDescriptor **descriptor)
 Return immutable metadata for a valid field identifier.
 
PetscErrorCode FieldIdFromName (const char *field_name, FieldId *field_id)
 Resolve a user-facing field name once into its typed identity.
 
PetscErrorCode FieldTryIdFromName (const char *field_name, FieldId *field_id, PetscBool *found)
 Look a name up without treating an unknown name as an error.
 
PetscErrorCode FieldDimensionReferenceScale (const ScalingCtx *scaling, FieldDimension dimension, PetscReal *scale)
 Return the factor that turns a solver value of one dimension into physical units.
 
PetscErrorCode FieldDimensionLabel (FieldDimension dimension, char *label, size_t length)
 Write a printable form of a dimension, such as L^2 U or dimensionless.
 
const char * FieldCanonicalName (FieldId field_id)
 Return the canonical printable name for an ID.
 
const char * FieldLayoutName (FieldLayout layout)
 Return a stable printable label for a field layout.
 
PetscErrorCode FieldGetView (UserCtx *user, FieldId field_id, FieldView *view)
 Resolve the existing DM and global/local vectors for one field.
 

Detailed Description

Authoritative identities and storage metadata for persistent Eulerian fields.

Field identifiers describe conceptual fields at compile time. They do not own, allocate, or modify PETSc objects. A FieldView resolves one identifier against an existing UserCtx after the normal setup lifecycle has created its DMs and vectors.

Definition in file field_catalog.h.


Data Structure Documentation

◆ FieldDimension

struct FieldDimension

Physical dimension as exponents of the reference length, velocity, and density.

A solver value of dimension (a, b, c) becomes physical when multiplied by L_ref^a U_ref^b rho_ref^c. The launcher records input dimensions with the same triple (picurv_cli/core.py, INPUT_QUANTITIES), so input and output conversion use one vocabulary. See docs/pages/19_Nondimensionalization.md.

Definition at line 149 of file field_catalog.h.

Data Fields
FieldDimensionKind kind
signed char length
signed char velocity
signed char density

◆ FieldDescriptor

struct FieldDescriptor

Immutable metadata for one field identity.

Definition at line 173 of file field_catalog.h.

Collaboration diagram for FieldDescriptor:
[legend]
Data Fields
FieldId id
const char * canonical_name
const char * alias_1
const char * alias_2
PetscInt dof
FieldDMKind dm_kind
FieldLayout layout
FieldSyncClass sync_class
unsigned int availability
unsigned int capabilities
size_t global_vec_offset
size_t local_vec_offset
FieldDimension dimension

◆ FieldView

struct FieldView

Non-owning runtime objects resolved for one field and UserCtx.

Definition at line 190 of file field_catalog.h.

Collaboration diagram for FieldView:
[legend]
Data Fields
const FieldDescriptor * descriptor
DM dm
Vec global_vec
Vec local_vec

Macro Definition Documentation

◆ FIELD_DIM_DIMENSIONLESS

#define FIELD_DIM_DIMENSIONLESS   {FIELD_DIMENSION_FIXED, 0, 0, 0}

Definition at line 158 of file field_catalog.h.

◆ FIELD_DIM_LENGTH

#define FIELD_DIM_LENGTH   {FIELD_DIMENSION_FIXED, 1, 0, 0}

Definition at line 159 of file field_catalog.h.

◆ FIELD_DIM_AREA

#define FIELD_DIM_AREA   {FIELD_DIMENSION_FIXED, 2, 0, 0}

Definition at line 160 of file field_catalog.h.

◆ FIELD_DIM_INVERSE_VOLUME

#define FIELD_DIM_INVERSE_VOLUME   {FIELD_DIMENSION_FIXED, -3, 0, 0}

Definition at line 161 of file field_catalog.h.

◆ FIELD_DIM_TIME

#define FIELD_DIM_TIME   {FIELD_DIMENSION_FIXED, 1, -1, 0}

Definition at line 162 of file field_catalog.h.

◆ FIELD_DIM_VELOCITY

#define FIELD_DIM_VELOCITY   {FIELD_DIMENSION_FIXED, 0, 1, 0}

Definition at line 163 of file field_catalog.h.

◆ FIELD_DIM_VOLUME_FLUX

#define FIELD_DIM_VOLUME_FLUX   {FIELD_DIMENSION_FIXED, 2, 1, 0}

Definition at line 164 of file field_catalog.h.

◆ FIELD_DIM_DIFFUSIVITY

#define FIELD_DIM_DIFFUSIVITY   {FIELD_DIMENSION_FIXED, 1, 1, 0}

Definition at line 165 of file field_catalog.h.

◆ FIELD_DIM_PRESSURE

#define FIELD_DIM_PRESSURE   {FIELD_DIMENSION_FIXED, 0, 2, 1}

Definition at line 166 of file field_catalog.h.

◆ FIELD_DIM_VELOCITY_SQUARED

#define FIELD_DIM_VELOCITY_SQUARED   {FIELD_DIMENSION_FIXED, 0, 2, 0}

Definition at line 167 of file field_catalog.h.

◆ FIELD_DIM_INVERSE_TIME_SQUARED

#define FIELD_DIM_INVERSE_TIME_SQUARED   {FIELD_DIMENSION_FIXED, -2, 2, 0}

Definition at line 168 of file field_catalog.h.

◆ FIELD_DIM_NOT_A_QUANTITY

#define FIELD_DIM_NOT_A_QUANTITY   {FIELD_DIMENSION_NOT_A_QUANTITY, 0, 0, 0}

Definition at line 169 of file field_catalog.h.

◆ FIELD_DIM_FROM_SOURCE

#define FIELD_DIM_FROM_SOURCE   {FIELD_DIMENSION_FROM_SOURCE, 0, 0, 0}

Definition at line 170 of file field_catalog.h.

Enumeration Type Documentation

◆ FieldId

enum FieldId

Compile-time identity for a catalogued Eulerian field.

Enumerator
FIELD_ID_INVALID 
FIELD_ID_COORDINATES 
FIELD_ID_UCAT 
FIELD_ID_UCONT 
FIELD_ID_UCONT_O 
FIELD_ID_UCONT_RM1 
FIELD_ID_P 
FIELD_ID_NU_T 
FIELD_ID_CS 
FIELD_ID_U_TAU 
FIELD_ID_WALL_STRESS 
FIELD_ID_INFLOW_FLUCTUATION 
FIELD_ID_DIFFUSIVITY 
FIELD_ID_DIFFUSIVITY_GRADIENT 
FIELD_ID_CSI 
FIELD_ID_ETA 
FIELD_ID_ZET 
FIELD_ID_NVERT 
FIELD_ID_AJ 
FIELD_ID_CENT 
FIELD_ID_CENTX 
FIELD_ID_CENTY 
FIELD_ID_CENTZ 
FIELD_ID_ICSI 
FIELD_ID_IETA 
FIELD_ID_IZET 
FIELD_ID_JCSI 
FIELD_ID_JETA 
FIELD_ID_JZET 
FIELD_ID_KCSI 
FIELD_ID_KETA 
FIELD_ID_KZET 
FIELD_ID_IAJ 
FIELD_ID_JAJ 
FIELD_ID_KAJ 
FIELD_ID_PHI 
FIELD_ID_PSI 
FIELD_ID_NVERT_O 
FIELD_ID_PARTICLE_COUNT 
FIELD_ID_CELL_SCALAR_AT_CORNER 
FIELD_ID_CELL_VECTOR_AT_CORNER 
FIELD_ID_POST_SCALAR 
FIELD_ID_POST_VECTOR 
FIELD_ID_QCRIT 
FIELD_ID_PLANE_NORMAL_I 
FIELD_ID_PLANE_NORMAL_J 
FIELD_ID_PLANE_NORMAL_K 
FIELD_ID_PLANE_CENTROID_I 
FIELD_ID_PLANE_CENTROID_J 
FIELD_ID_PLANE_CENTROID_K 
FIELD_ID_SEARCH_CELL_SIZE 
FIELD_ID_DUAL_PLANE_NORMAL_I 
FIELD_ID_DUAL_PLANE_NORMAL_J 
FIELD_ID_DUAL_PLANE_NORMAL_K 
FIELD_ID_DUAL_PLANE_CENTROID_I 
FIELD_ID_DUAL_PLANE_CENTROID_J 
FIELD_ID_DUAL_PLANE_CENTROID_K 
FIELD_ID_COUNT 

Definition at line 23 of file field_catalog.h.

23 {
82} FieldId;
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

◆ FieldLayout

Logical storage topology of a field.

Enumerator
FIELD_LAYOUT_NODE_CENTERED 
FIELD_LAYOUT_CELL_CENTERED 
FIELD_LAYOUT_I_FACE 
FIELD_LAYOUT_J_FACE 
FIELD_LAYOUT_K_FACE 
FIELD_LAYOUT_COMPONENT_STAGGERED 

Definition at line 85 of file field_catalog.h.

85 {
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

◆ FieldDMKind

UserCtx DM family used to store a field.

Enumerator
FIELD_DM_DA 
FIELD_DM_FDA 

Definition at line 95 of file field_catalog.h.

95 {
96 FIELD_DM_DA = 0,
FieldDMKind
UserCtx DM family used to store a field.
@ FIELD_DM_FDA
@ FIELD_DM_DA

◆ FieldSyncClass

Extra repair required after the normal PETSc global-to-local scatter.

Enumerator
FIELD_SYNC_STANDARD 
FIELD_SYNC_I_FACE 
FIELD_SYNC_J_FACE 
FIELD_SYNC_K_FACE 
FIELD_SYNC_COMPONENT_STAGGERED 

Definition at line 101 of file field_catalog.h.

101 {
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

◆ FieldAvailability

Conditions controlling when a field can have runtime storage.

Enumerator
FIELD_AVAILABILITY_ALWAYS 
FIELD_AVAILABILITY_FINEST_LEVEL 
FIELD_AVAILABILITY_TURBULENCE 
FIELD_AVAILABILITY_LES_DYNAMIC 
FIELD_AVAILABILITY_PARTICLES 
FIELD_AVAILABILITY_WALL_MODEL 
FIELD_AVAILABILITY_INFLOW_FLUCTUATION 

Definition at line 110 of file field_catalog.h.

110 {
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

◆ FieldCapabilities

Operations supported by a catalog entry.

Enumerator
FIELD_CAPABILITY_NONE 
FIELD_CAPABILITY_GHOST_UPDATE 
FIELD_CAPABILITY_PERIODIC_CELL_SYNC 
FIELD_CAPABILITY_PERIODIC_FACE_SYNC 
FIELD_CAPABILITY_PERIODIC_STAGGERED_SYNC 
FIELD_CAPABILITY_PERIODIC_GEOMETRY_SHIFT 
FIELD_CAPABILITY_CHECKPOINT 
FIELD_CAPABILITY_PARTICLE_SAMPLED 

Defined only where a cell holds particles; elsewhere the stored value is a placeholder, not a measurement, and statistics skip it.

Definition at line 121 of file field_catalog.h.

121 {
129 /** Defined only where a cell holds particles; elsewhere the stored value is a
130 * placeholder, not a measurement, and statistics skip it. */
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

◆ FieldDimensionKind

How a field's physical dimension is known.

Enumerator
FIELD_DIMENSION_FIXED 

The exponents are the field's dimension.

FIELD_DIMENSION_NOT_A_QUANTITY 

Integer bookkeeping: identities, flags, ranks.

FIELD_DIMENSION_FROM_SOURCE 

Staging storage: carries whatever was written into it.

Definition at line 135 of file field_catalog.h.

135 {
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. */
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.

Function Documentation

◆ FieldGetDescriptor()

PetscErrorCode FieldGetDescriptor ( FieldId  field_id,
const FieldDescriptor **  descriptor 
)

Return immutable metadata for a valid field identifier.

Parameters
[in]field_idCompile-time field identity.
[out]descriptorCatalog entry owned by the field-catalog module.
Returns
Zero on success; PETSc error for an invalid ID or null output.

Return immutable metadata for a valid field identifier.

Validates the enum range and the table's ID/index invariant before exposing the catalog-owned descriptor.

See also
FieldGetDescriptor()

Definition at line 285 of file field_catalog.c.

286{
287 PetscFunctionBeginUser;
289 PetscCheck(descriptor != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
290 "Field descriptor output cannot be NULL.");
291 PetscCheck(field_id >= 0 && field_id < FIELD_ID_COUNT, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE,
292 "Invalid FieldId value %d.", (int)field_id);
293 PetscCheck(gFieldCatalog[field_id].id == field_id, PETSC_COMM_SELF, PETSC_ERR_PLIB,
294 "Field catalog entry %d is not initialized consistently.", (int)field_id);
295
296 *descriptor = &gFieldCatalog[field_id];
298 PetscFunctionReturn(0);
299}
static const FieldDescriptor gFieldCatalog[FIELD_ID_COUNT]
#define PROFILE_HELPER_BEGIN
Marks the beginning of a profiled helper: timed only when enabled by name.
Definition logging.h:1014
#define PROFILE_HELPER_END
Alias of PROFILE_FUNCTION_END for a function that began with PROFILE_HELPER_BEGIN.
Definition logging.h:1033
Here is the caller graph for this function:

◆ FieldIdFromName()

PetscErrorCode FieldIdFromName ( const char *  field_name,
FieldId *  field_id 
)

Resolve a user-facing field name once into its typed identity.

Parameters
[in]field_nameCanonical name or registered alias.
[out]field_idResolved field identity.
Returns
Zero on success; PETSc unknown-type error for an unregistered name.

Resolve a user-facing field name once into its typed identity.

Name comparison is intentionally confined to ingress; numerical consumers receive the resolved FieldId.

See also
FieldIdFromName()

Definition at line 307 of file field_catalog.c.

308{
309 PetscBool found = PETSC_FALSE;
310
311 PetscFunctionBeginUser;
313 PetscCall(FieldTryIdFromName(field_name, field_id, &found));
314 PetscCheck(found, PETSC_COMM_SELF, PETSC_ERR_ARG_UNKNOWN_TYPE,
315 "Field name '%s' is not registered in the Eulerian field catalog.", field_name);
317 PetscFunctionReturn(0);
318}
PetscErrorCode FieldTryIdFromName(const char *field_name, FieldId *field_id, PetscBool *found)
Searches canonical names and aliases, reporting a miss instead of failing.
#define PROFILE_FUNCTION_END
Marks the end of a profiled code block.
Definition logging.h:1029
#define PROFILE_FUNCTION_BEGIN
Marks the beginning of a profiled function: an always-on aggregate timer.
Definition logging.h:1000
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FieldTryIdFromName()

PetscErrorCode FieldTryIdFromName ( const char *  field_name,
FieldId *  field_id,
PetscBool *  found 
)

Look a name up without treating an unknown name as an error.

For callers that consult more than one catalog, such as a name that may be an Eulerian or a particle field.

Parameters
[in]field_nameCanonical name or registered alias.
[out]field_idResolved identity, or FIELD_ID_INVALID when not found.
[out]foundWhether the name is registered.
Returns
Zero on success; PETSc error only for null arguments.

Look a name up without treating an unknown name as an error.

See also
FieldTryIdFromName()

Definition at line 324 of file field_catalog.c.

325{
326 PetscFunctionBeginUser;
328 PetscCheck(field_name != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
329 "Field name cannot be NULL.");
330 PetscCheck(field_id != NULL && found != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
331 "FieldId and found outputs cannot be NULL.");
332
333 *field_id = FIELD_ID_INVALID;
334 *found = PETSC_FALSE;
335 for (PetscInt index = 0; index < FIELD_ID_COUNT; ++index) {
336 const FieldDescriptor *descriptor = &gFieldCatalog[index];
337 PetscBool match = PETSC_FALSE;
338
339 PetscCall(PetscStrcasecmp(field_name, descriptor->canonical_name, &match));
340 if (!match && descriptor->alias_1) PetscCall(PetscStrcasecmp(field_name, descriptor->alias_1, &match));
341 if (!match && descriptor->alias_2) PetscCall(PetscStrcasecmp(field_name, descriptor->alias_2, &match));
342 if (match) {
343 *field_id = descriptor->id;
344 *found = PETSC_TRUE;
345 break;
346 }
347 }
349 PetscFunctionReturn(0);
350}
const char * alias_1
const char * canonical_name
const char * alias_2
Immutable metadata for one field identity.
Here is the caller graph for this function:

◆ FieldDimensionReferenceScale()

PetscErrorCode FieldDimensionReferenceScale ( const ScalingCtx *  scaling,
FieldDimension  dimension,
PetscReal *  scale 
)

Return the factor that turns a solver value of one dimension into physical units.

Parameters
[in]scalingReference scales of the run.
[in]dimensionDimension to scale.
[out]scaleL_ref^a U_ref^b rho_ref^c for a fixed dimension (a, b, c).
Returns
Zero on success; PETSC_ERR_ARG_WRONGSTATE for a dimension that is not fixed, since bookkeeping and staging storage have no scale of their own.

Return the factor that turns a solver value of one dimension into physical units.

See also
FieldDimensionReferenceScale()

Definition at line 356 of file field_catalog.c.

358{
359 PetscFunctionBeginUser;
361 PetscCheck(scaling != NULL && scale != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
362 "Scaling context and scale output cannot be NULL.");
363 PetscCheck(dimension.kind == FIELD_DIMENSION_FIXED, PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE,
364 "Only a field with a fixed physical dimension has a reference scale.");
365 *scale = PetscPowRealInt(scaling->L_ref, dimension.length) *
366 PetscPowRealInt(scaling->U_ref, dimension.velocity) *
367 PetscPowRealInt(scaling->rho_ref, dimension.density);
369 PetscFunctionReturn(0);
370}
signed char velocity
signed char density
signed char length
FieldDimensionKind kind
PetscReal L_ref
Definition variables.h:898
PetscReal rho_ref
Definition variables.h:900
PetscReal U_ref
Definition variables.h:899
Here is the caller graph for this function:

◆ FieldDimensionLabel()

PetscErrorCode FieldDimensionLabel ( FieldDimension  dimension,
char *  label,
size_t  length 
)

Write a printable form of a dimension, such as L^2 U or dimensionless.

Parameters
[in]dimensionDimension to describe.
[out]labelDestination buffer.
[in]lengthBuffer length.
Returns
Zero on success.

Write a printable form of a dimension, such as L^2 U or dimensionless.

See also
FieldDimensionLabel()

Definition at line 376 of file field_catalog.c.

377{
378 const char *symbols[3] = {"L", "U", "rho"};
379 const int exponents[3] = {dimension.length, dimension.velocity, dimension.density};
380 size_t used = 0;
381
382 PetscFunctionBeginUser;
384 PetscCheck(label != NULL && length > 0, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
385 "Dimension label buffer cannot be NULL or empty.");
386 label[0] = '\0';
387 if (dimension.kind == FIELD_DIMENSION_NOT_A_QUANTITY) {
388 PetscCall(PetscStrncpy(label, "not a physical quantity", length));
390 PetscFunctionReturn(0);
391 }
392 if (dimension.kind == FIELD_DIMENSION_FROM_SOURCE) {
393 PetscCall(PetscStrncpy(label, "dimension of its source field", length));
395 PetscFunctionReturn(0);
396 }
397 for (int index = 0; index < 3; ++index) {
398 if (!exponents[index]) continue;
399 if (exponents[index] == 1) {
400 PetscCall(PetscSNPrintf(label + used, length - used, "%s%s", used ? " " : "", symbols[index]));
401 } else {
402 PetscCall(PetscSNPrintf(label + used, length - used, "%s%s^%d", used ? " " : "",
403 symbols[index], exponents[index]));
404 }
405 PetscCall(PetscStrlen(label, &used));
406 }
407 if (!used) PetscCall(PetscStrncpy(label, "dimensionless", length));
409 PetscFunctionReturn(0);
410}
Here is the caller graph for this function:

◆ FieldCanonicalName()

const char * FieldCanonicalName ( FieldId  field_id)

Return the canonical printable name for an ID.

Parameters
[in]field_idField identity.
Returns
Canonical name, or "InvalidField" for an invalid ID.

Return the canonical printable name for an ID.

Invalid enum values return a non-null diagnostic sentinel string.

See also
FieldCanonicalName()

Definition at line 417 of file field_catalog.c.

418{
420 const char *name = (field_id >= 0 && field_id < FIELD_ID_COUNT && gFieldCatalog[field_id].id == field_id)
421 ? gFieldCatalog[field_id].canonical_name : "InvalidField";
423 return name;
424}
Here is the caller graph for this function:

◆ FieldLayoutName()

const char * FieldLayoutName ( FieldLayout  layout)

Return a stable printable label for a field layout.

Parameters
[in]layoutLayout enum to describe.
Returns
Catalog-owned label, or Invalid-Layout for an invalid enum.

Return a stable printable label for a field layout.

See also
FieldLayoutName()

Definition at line 430 of file field_catalog.c.

431{
433 const char *name;
434 switch (layout) {
435 case FIELD_LAYOUT_NODE_CENTERED: name = "Node-Centered"; break;
436 case FIELD_LAYOUT_CELL_CENTERED: name = "Cell-Centered"; break;
437 case FIELD_LAYOUT_I_FACE: name = "I-Face"; break;
438 case FIELD_LAYOUT_J_FACE: name = "J-Face"; break;
439 case FIELD_LAYOUT_K_FACE: name = "K-Face"; break;
440 case FIELD_LAYOUT_COMPONENT_STAGGERED: name = "Component-Staggered"; break;
441 default: name = "Invalid-Layout"; break;
442 }
444 return name;
445}
Here is the caller graph for this function:

◆ FieldGetView()

PetscErrorCode FieldGetView ( UserCtx *  user,
FieldId  field_id,
FieldView *  view 
)

Resolve the existing DM and global/local vectors for one field.

This function never creates storage. Optional fields whose setup conditions were not enabled retain valid descriptors but return PETSC_ERR_ARG_WRONGSTATE because their runtime vectors are absent.

Parameters
[in]userExisting per-grid context.
[in]field_idField identity to resolve.
[out]viewNon-owning runtime view.
Returns
Zero on success or a PETSc argument/state error.

Resolve the existing DM and global/local vectors for one field.

Resolves DM and Vec handles without allocating, referencing, or destroying PETSc storage.

See also
FieldGetView()

Definition at line 453 of file field_catalog.c.

454{
455 const FieldDescriptor *descriptor = NULL;
456
457 PetscFunctionBeginUser;
459 PetscCheck(user != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
460 "UserCtx cannot be NULL when resolving a field view.");
461 PetscCheck(view != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
462 "Field view output cannot be NULL.");
463 PetscCall(FieldGetDescriptor(field_id, &descriptor));
464
465 view->descriptor = descriptor;
466 view->dm = NULL;
467 view->global_vec = NULL;
468 view->local_vec = NULL;
469
470 switch (descriptor->dm_kind) {
471 case FIELD_DM_DA:
472 view->dm = user->da;
473 break;
474 case FIELD_DM_FDA:
475 view->dm = user->fda;
476 break;
477 default:
478 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_PLIB,
479 "Field '%s' has an invalid DM selector.", descriptor->canonical_name);
480 }
481
482 view->global_vec = *(Vec *)((char *)user + descriptor->global_vec_offset);
483 view->local_vec = *(Vec *)((char *)user + descriptor->local_vec_offset);
484
485 PetscCheck(view->dm != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE,
486 "DM for field '%s' is unavailable in this UserCtx.", descriptor->canonical_name);
487 PetscCheck(view->global_vec != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE,
488 "Global vector for field '%s' is unavailable in this UserCtx.", descriptor->canonical_name);
489 PetscCheck(view->local_vec != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE,
490 "Local vector for field '%s' is unavailable in this UserCtx.", descriptor->canonical_name);
491
493 PetscFunctionReturn(0);
494}
PetscErrorCode FieldGetDescriptor(FieldId field_id, const FieldDescriptor **descriptor)
Returns the immutable catalog descriptor for one typed field identity.
const FieldDescriptor * descriptor
FieldDMKind dm_kind
Here is the call graph for this function:
Here is the caller graph for this function: