PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
 
Loading...
Searching...
No Matches
Data Structures | 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  FieldDescriptor
 Immutable metadata for one field identity. More...
 
struct  FieldView
 Non-owning runtime objects resolved for one field and UserCtx. More...
 

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_NU_WALL , 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_GRID_SPACE ,
  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_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 , FIELD_DM_COORDINATES }
 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
}
 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
}
 Operations supported by a catalog entry. 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.
 
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

◆ FieldDescriptor

struct FieldDescriptor

Immutable metadata for one field identity.

Definition at line 119 of file field_catalog.h.

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

◆ FieldView

struct FieldView

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

Definition at line 135 of file field_catalog.h.

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

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_NU_WALL 
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_GRID_SPACE 
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_COUNT 

Definition at line 23 of file field_catalog.h.

23 {
69} FieldId;
FieldId
Compile-time identity for a catalogued Eulerian field.
@ FIELD_ID_PSI
@ FIELD_ID_JETA
@ FIELD_ID_CENTZ
@ FIELD_ID_CSI
@ FIELD_ID_IAJ
@ FIELD_ID_CELL_SCALAR_AT_CORNER
@ FIELD_ID_NVERT
@ FIELD_ID_UCAT
@ FIELD_ID_NVERT_O
@ FIELD_ID_KETA
@ FIELD_ID_JAJ
@ FIELD_ID_COORDINATES
@ 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_GRID_SPACE
@ 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_NU_WALL
@ FIELD_ID_CS
@ FIELD_ID_CENT
@ FIELD_ID_QCRIT
@ FIELD_ID_JCSI
@ FIELD_ID_JZET
@ FIELD_ID_INVALID
@ 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

◆ 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 72 of file field_catalog.h.

72 {
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 
FIELD_DM_COORDINATES 

Definition at line 82 of file field_catalog.h.

82 {
83 FIELD_DM_DA = 0,
FieldDMKind
UserCtx DM family used to store a field.
@ FIELD_DM_FDA
@ FIELD_DM_COORDINATES
@ 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 89 of file field_catalog.h.

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

Definition at line 98 of file field_catalog.h.

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

◆ 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 

Definition at line 108 of file field_catalog.h.

108 {
FieldCapabilities
Operations supported by a catalog entry.
@ FIELD_CAPABILITY_CHECKPOINT
@ 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

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 200 of file field_catalog.c.

201{
202 PetscFunctionBeginUser;
203 PetscCheck(descriptor != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
204 "Field descriptor output cannot be NULL.");
205 PetscCheck(field_id >= 0 && field_id < FIELD_ID_COUNT, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE,
206 "Invalid FieldId value %d.", (int)field_id);
207 PetscCheck(gFieldCatalog[field_id].id == field_id, PETSC_COMM_SELF, PETSC_ERR_PLIB,
208 "Field catalog entry %d is not initialized consistently.", (int)field_id);
209
210 *descriptor = &gFieldCatalog[field_id];
211 PetscFunctionReturn(0);
212}
static const FieldDescriptor gFieldCatalog[FIELD_ID_COUNT]
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 220 of file field_catalog.c.

221{
222 PetscFunctionBeginUser;
223 PetscCheck(field_name != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
224 "Field name cannot be NULL.");
225 PetscCheck(field_id != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
226 "FieldId output cannot be NULL.");
227
228 for (PetscInt index = 0; index < FIELD_ID_COUNT; ++index) {
229 const FieldDescriptor *descriptor = &gFieldCatalog[index];
230 PetscBool match = PETSC_FALSE;
231
232 PetscCall(PetscStrcasecmp(field_name, descriptor->canonical_name, &match));
233 if (!match && descriptor->alias_1) PetscCall(PetscStrcasecmp(field_name, descriptor->alias_1, &match));
234 if (!match && descriptor->alias_2) PetscCall(PetscStrcasecmp(field_name, descriptor->alias_2, &match));
235 if (match) {
236 *field_id = descriptor->id;
237 PetscFunctionReturn(0);
238 }
239 }
240
241 *field_id = FIELD_ID_INVALID;
242 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_UNKNOWN_TYPE,
243 "Field name '%s' is not registered in the Eulerian field catalog.", field_name);
244}
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:

◆ 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 251 of file field_catalog.c.

252{
253 if (field_id < 0 || field_id >= FIELD_ID_COUNT) return "InvalidField";
254 if (gFieldCatalog[field_id].id != field_id) return "InvalidField";
255 return gFieldCatalog[field_id].canonical_name;
256}
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 262 of file field_catalog.c.

263{
264 switch (layout) {
265 case FIELD_LAYOUT_NODE_CENTERED: return "Node-Centered";
266 case FIELD_LAYOUT_CELL_CENTERED: return "Cell-Centered";
267 case FIELD_LAYOUT_I_FACE: return "I-Face";
268 case FIELD_LAYOUT_J_FACE: return "J-Face";
269 case FIELD_LAYOUT_K_FACE: return "K-Face";
270 case FIELD_LAYOUT_COMPONENT_STAGGERED: return "Component-Staggered";
271 default: return "Invalid-Layout";
272 }
273}
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 281 of file field_catalog.c.

282{
283 const FieldDescriptor *descriptor = NULL;
284
285 PetscFunctionBeginUser;
286 PetscCheck(user != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
287 "UserCtx cannot be NULL when resolving a field view.");
288 PetscCheck(view != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
289 "Field view output cannot be NULL.");
290 PetscCall(FieldGetDescriptor(field_id, &descriptor));
291
292 view->descriptor = descriptor;
293 view->dm = NULL;
294 view->global_vec = NULL;
295 view->local_vec = NULL;
296
297 switch (descriptor->dm_kind) {
298 case FIELD_DM_DA:
299 view->dm = user->da;
300 break;
301 case FIELD_DM_FDA:
302 view->dm = user->fda;
303 break;
305 view->dm = user->fda;
306 PetscCheck(user->da != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE,
307 "Coordinate DM is unavailable for field '%s'.", descriptor->canonical_name);
308 PetscCall(DMGetCoordinates(user->da, &view->global_vec));
309 PetscCall(DMGetCoordinatesLocal(user->da, &view->local_vec));
310 break;
311 default:
312 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_PLIB,
313 "Field '%s' has an invalid DM selector.", descriptor->canonical_name);
314 }
315
316 if (descriptor->dm_kind != FIELD_DM_COORDINATES) {
317 view->global_vec = *(Vec *)((char *)user + descriptor->global_vec_offset);
318 view->local_vec = *(Vec *)((char *)user + descriptor->local_vec_offset);
319 }
320
321 PetscCheck(view->dm != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE,
322 "DM for field '%s' is unavailable in this UserCtx.", descriptor->canonical_name);
323 PetscCheck(view->global_vec != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE,
324 "Global vector for field '%s' is unavailable in this UserCtx.", descriptor->canonical_name);
325 PetscCheck(view->local_vec != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE,
326 "Local vector for field '%s' is unavailable in this UserCtx.", descriptor->canonical_name);
327
328 PetscFunctionReturn(0);
329}
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: