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_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_K_OMEGA , FIELD_ID_K_OMEGA_O , 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_FDA2 , 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 = 1u << 2 ,
  FIELD_AVAILABILITY_RANS = 1u << 3 , FIELD_AVAILABILITY_PARTICLES = 1u << 4
}
 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
}
 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 114 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 130 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_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_K_OMEGA 
FIELD_ID_K_OMEGA_O 
FIELD_ID_COUNT 

Definition at line 23 of file field_catalog.h.

23 {
64} 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_NVERT
@ FIELD_ID_UCAT
@ FIELD_ID_NVERT_O
@ FIELD_ID_KETA
@ FIELD_ID_JAJ
@ FIELD_ID_COORDINATES
@ FIELD_ID_UCONT_O
@ FIELD_ID_K_OMEGA
@ FIELD_ID_KAJ
@ 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_ICSI
@ FIELD_ID_ETA
@ FIELD_ID_PHI
@ FIELD_ID_CS
@ FIELD_ID_CENT
@ FIELD_ID_JCSI
@ FIELD_ID_JZET
@ FIELD_ID_K_OMEGA_O
@ 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 67 of file field_catalog.h.

67 {
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_FDA2 
FIELD_DM_COORDINATES 

Definition at line 77 of file field_catalog.h.

77 {
78 FIELD_DM_DA = 0,
FieldDMKind
UserCtx DM family used to store a field.
@ FIELD_DM_FDA2
@ 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 85 of file field_catalog.h.

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

Definition at line 94 of file field_catalog.h.

94 {
98 FIELD_AVAILABILITY_LES = 1u << 2,
FieldAvailability
Conditions controlling when a field can have runtime storage.
@ FIELD_AVAILABILITY_RANS
@ FIELD_AVAILABILITY_FINEST_LEVEL
@ FIELD_AVAILABILITY_LES
@ FIELD_AVAILABILITY_PARTICLES
@ FIELD_AVAILABILITY_TURBULENCE
@ 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 

Definition at line 104 of file field_catalog.h.

104 {
FieldCapabilities
Operations supported by a catalog entry.
@ 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 149 of file field_catalog.c.

150{
151 PetscFunctionBeginUser;
152 PetscCheck(descriptor != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
153 "Field descriptor output cannot be NULL.");
154 PetscCheck(field_id >= 0 && field_id < FIELD_ID_COUNT, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE,
155 "Invalid FieldId value %d.", (int)field_id);
156 PetscCheck(gFieldCatalog[field_id].id == field_id, PETSC_COMM_SELF, PETSC_ERR_PLIB,
157 "Field catalog entry %d is not initialized consistently.", (int)field_id);
158
159 *descriptor = &gFieldCatalog[field_id];
160 PetscFunctionReturn(0);
161}
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 169 of file field_catalog.c.

170{
171 PetscFunctionBeginUser;
172 PetscCheck(field_name != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
173 "Field name cannot be NULL.");
174 PetscCheck(field_id != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
175 "FieldId output cannot be NULL.");
176
177 for (PetscInt index = 0; index < FIELD_ID_COUNT; ++index) {
178 const FieldDescriptor *descriptor = &gFieldCatalog[index];
179 PetscBool match = PETSC_FALSE;
180
181 PetscCall(PetscStrcasecmp(field_name, descriptor->canonical_name, &match));
182 if (!match && descriptor->alias_1) PetscCall(PetscStrcasecmp(field_name, descriptor->alias_1, &match));
183 if (!match && descriptor->alias_2) PetscCall(PetscStrcasecmp(field_name, descriptor->alias_2, &match));
184 if (match) {
185 *field_id = descriptor->id;
186 PetscFunctionReturn(0);
187 }
188 }
189
190 *field_id = FIELD_ID_INVALID;
191 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_UNKNOWN_TYPE,
192 "Field name '%s' is not registered in the Eulerian field catalog.", field_name);
193}
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 200 of file field_catalog.c.

201{
202 if (field_id < 0 || field_id >= FIELD_ID_COUNT) return "InvalidField";
203 if (gFieldCatalog[field_id].id != field_id) return "InvalidField";
204 return gFieldCatalog[field_id].canonical_name;
205}
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 211 of file field_catalog.c.

212{
213 switch (layout) {
214 case FIELD_LAYOUT_NODE_CENTERED: return "Node-Centered";
215 case FIELD_LAYOUT_CELL_CENTERED: return "Cell-Centered";
216 case FIELD_LAYOUT_I_FACE: return "I-Face";
217 case FIELD_LAYOUT_J_FACE: return "J-Face";
218 case FIELD_LAYOUT_K_FACE: return "K-Face";
219 case FIELD_LAYOUT_COMPONENT_STAGGERED: return "Component-Staggered";
220 default: return "Invalid-Layout";
221 }
222}
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 230 of file field_catalog.c.

231{
232 const FieldDescriptor *descriptor = NULL;
233
234 PetscFunctionBeginUser;
235 PetscCheck(user != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
236 "UserCtx cannot be NULL when resolving a field view.");
237 PetscCheck(view != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
238 "Field view output cannot be NULL.");
239 PetscCall(FieldGetDescriptor(field_id, &descriptor));
240
241 view->descriptor = descriptor;
242 view->dm = NULL;
243 view->global_vec = NULL;
244 view->local_vec = NULL;
245
246 switch (descriptor->dm_kind) {
247 case FIELD_DM_DA:
248 view->dm = user->da;
249 break;
250 case FIELD_DM_FDA:
251 view->dm = user->fda;
252 break;
253 case FIELD_DM_FDA2:
254 view->dm = user->fda2;
255 break;
257 view->dm = user->fda;
258 PetscCheck(user->da != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE,
259 "Coordinate DM is unavailable for field '%s'.", descriptor->canonical_name);
260 PetscCall(DMGetCoordinates(user->da, &view->global_vec));
261 PetscCall(DMGetCoordinatesLocal(user->da, &view->local_vec));
262 break;
263 default:
264 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_PLIB,
265 "Field '%s' has an invalid DM selector.", descriptor->canonical_name);
266 }
267
268 if (descriptor->dm_kind != FIELD_DM_COORDINATES) {
269 view->global_vec = *(Vec *)((char *)user + descriptor->global_vec_offset);
270 view->local_vec = *(Vec *)((char *)user + descriptor->local_vec_offset);
271 }
272
273 PetscCheck(view->dm != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE,
274 "DM for field '%s' is unavailable in this UserCtx.", descriptor->canonical_name);
275 PetscCheck(view->global_vec != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE,
276 "Global vector for field '%s' is unavailable in this UserCtx.", descriptor->canonical_name);
277 PetscCheck(view->local_vec != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE,
278 "Local vector for field '%s' is unavailable in this UserCtx.", descriptor->canonical_name);
279
280 PetscFunctionReturn(0);
281}
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: