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

Typed identities and metadata for persistent solver-particle fields. More...

#include <petscdmswarm.h>
#include "field_catalog.h"
Include dependency graph for particle_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  ParticleFieldDescriptor
 Immutable metadata for one persistent particle field. More...
 

Enumerations

enum  ParticleFieldId {
  PARTICLE_FIELD_ID_INVALID = -1 , PARTICLE_FIELD_ID_POSITION = 0 , PARTICLE_FIELD_ID_VELOCITY , PARTICLE_FIELD_ID_CELL_ID ,
  PARTICLE_FIELD_ID_WEIGHT , PARTICLE_FIELD_ID_DIFFUSIVITY , PARTICLE_FIELD_ID_DIFFUSIVITY_GRADIENT , PARTICLE_FIELD_ID_PSI ,
  PARTICLE_FIELD_ID_LOCATION_STATUS , PARTICLE_FIELD_ID_PID , PARTICLE_FIELD_ID_RANK , PARTICLE_FIELD_ID_COUNT
}
 Compile-time identity for a persistent solver-particle field. More...
 
enum  ParticleFieldRegistration { PARTICLE_FIELD_REGISTRATION_PICURV = 0 , PARTICLE_FIELD_REGISTRATION_PETSC }
 Owner of a field's DMSwarm registration. More...
 
enum  ParticleFieldCapabilities { PARTICLE_FIELD_CAPABILITY_NONE = 0u , PARTICLE_FIELD_CAPABILITY_DEFAULT_INITIALIZE = 1u << 0 , PARTICLE_FIELD_CAPABILITY_MODEL_UPDATE = 1u << 1 , PARTICLE_FIELD_CAPABILITY_EULERIAN_SCATTER = 1u << 2 }
 Operations supported by a particle-field catalog entry. More...
 

Functions

PetscErrorCode ParticleFieldGetDescriptor (ParticleFieldId field_id, const ParticleFieldDescriptor **descriptor)
 Return immutable metadata for a valid particle field ID.
 
PetscErrorCode ParticleFieldIdFromName (const char *field_name, ParticleFieldId *field_id)
 Resolve a canonical name or registered alias at a text-ingress boundary.
 
const char * ParticleFieldName (ParticleFieldId field_id)
 Return the canonical PETSc DMSwarm name for an ID.
 

Detailed Description

Typed identities and metadata for persistent solver-particle fields.

Particle fields intentionally use a catalog separate from Eulerian fields. They are registered on a DMSwarm, may use integer storage, and do not own a global/local Vec pair in UserCtx. Text is translated only where PETSc or a user/file interface requires a registered DMSwarm name.

Definition in file particle_field_catalog.h.


Data Structure Documentation

◆ ParticleFieldDescriptor

struct ParticleFieldDescriptor

Immutable metadata for one persistent particle field.

Definition at line 53 of file particle_field_catalog.h.

Data Fields
ParticleFieldId id
const char * canonical_name
const char * alias_1
const char * alias_2
PetscInt components
PetscDataType data_type
ParticleFieldRegistration registration
unsigned int capabilities
PetscReal default_real_value
FieldId eulerian_scatter_target

Enumeration Type Documentation

◆ ParticleFieldId

Compile-time identity for a persistent solver-particle field.

Enumerator
PARTICLE_FIELD_ID_INVALID 
PARTICLE_FIELD_ID_POSITION 
PARTICLE_FIELD_ID_VELOCITY 
PARTICLE_FIELD_ID_CELL_ID 
PARTICLE_FIELD_ID_WEIGHT 
PARTICLE_FIELD_ID_DIFFUSIVITY 
PARTICLE_FIELD_ID_DIFFUSIVITY_GRADIENT 
PARTICLE_FIELD_ID_PSI 
PARTICLE_FIELD_ID_LOCATION_STATUS 
PARTICLE_FIELD_ID_PID 
PARTICLE_FIELD_ID_RANK 
PARTICLE_FIELD_ID_COUNT 

Definition at line 23 of file particle_field_catalog.h.

23 {
ParticleFieldId
Compile-time identity for a persistent solver-particle field.
@ PARTICLE_FIELD_ID_LOCATION_STATUS
@ PARTICLE_FIELD_ID_WEIGHT
@ PARTICLE_FIELD_ID_POSITION
@ PARTICLE_FIELD_ID_PID
@ PARTICLE_FIELD_ID_CELL_ID
@ PARTICLE_FIELD_ID_PSI
@ PARTICLE_FIELD_ID_RANK
@ PARTICLE_FIELD_ID_DIFFUSIVITY_GRADIENT
@ PARTICLE_FIELD_ID_COUNT
@ PARTICLE_FIELD_ID_DIFFUSIVITY
@ PARTICLE_FIELD_ID_INVALID
@ PARTICLE_FIELD_ID_VELOCITY

◆ ParticleFieldRegistration

Owner of a field's DMSwarm registration.

Enumerator
PARTICLE_FIELD_REGISTRATION_PICURV 
PARTICLE_FIELD_REGISTRATION_PETSC 

Definition at line 39 of file particle_field_catalog.h.

39 {
ParticleFieldRegistration
Owner of a field's DMSwarm registration.
@ PARTICLE_FIELD_REGISTRATION_PETSC
@ PARTICLE_FIELD_REGISTRATION_PICURV

◆ ParticleFieldCapabilities

Operations supported by a particle-field catalog entry.

Enumerator
PARTICLE_FIELD_CAPABILITY_NONE 
PARTICLE_FIELD_CAPABILITY_DEFAULT_INITIALIZE 
PARTICLE_FIELD_CAPABILITY_MODEL_UPDATE 
PARTICLE_FIELD_CAPABILITY_EULERIAN_SCATTER 

Definition at line 45 of file particle_field_catalog.h.

45 {
ParticleFieldCapabilities
Operations supported by a particle-field catalog entry.
@ PARTICLE_FIELD_CAPABILITY_MODEL_UPDATE
@ PARTICLE_FIELD_CAPABILITY_DEFAULT_INITIALIZE
@ PARTICLE_FIELD_CAPABILITY_EULERIAN_SCATTER
@ PARTICLE_FIELD_CAPABILITY_NONE

Function Documentation

◆ ParticleFieldGetDescriptor()

PetscErrorCode ParticleFieldGetDescriptor ( ParticleFieldId  field_id,
const ParticleFieldDescriptor **  descriptor 
)

Return immutable metadata for a valid particle field ID.

Parameters
[in]field_idTyped particle-field identity.
[out]descriptorCatalog-owned immutable descriptor.
Returns
Zero on success; a PETSc argument error for invalid input.

Return immutable metadata for a valid particle field ID.

See also
ParticleFieldGetDescriptor()

Definition at line 56 of file particle_field_catalog.c.

58{
59 PetscFunctionBeginUser;
60 PetscCheck(descriptor != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
61 "Particle field descriptor output cannot be NULL.");
62 PetscCheck(field_id >= 0 && field_id < PARTICLE_FIELD_ID_COUNT,
63 PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE,
64 "Invalid ParticleFieldId value %d.", (int)field_id);
65 PetscCheck(gParticleFieldCatalog[field_id].id == field_id,
66 PETSC_COMM_SELF, PETSC_ERR_PLIB,
67 "Particle field catalog entry %d is not initialized consistently.", (int)field_id);
68
69 *descriptor = &gParticleFieldCatalog[field_id];
70 PetscFunctionReturn(0);
71}
static const ParticleFieldDescriptor gParticleFieldCatalog[PARTICLE_FIELD_ID_COUNT]
Here is the caller graph for this function:

◆ ParticleFieldIdFromName()

PetscErrorCode ParticleFieldIdFromName ( const char *  field_name,
ParticleFieldId field_id 
)

Resolve a canonical name or registered alias at a text-ingress boundary.

Parameters
[in]field_nameCanonical particle name or registered alias.
[out]field_idResolved typed identity.
Returns
Zero on success; PETSC_ERR_ARG_UNKNOWN_TYPE for unknown text.

Resolve a canonical name or registered alias at a text-ingress boundary.

See also
ParticleFieldIdFromName()

Definition at line 77 of file particle_field_catalog.c.

78{
79 PetscFunctionBeginUser;
80 PetscCheck(field_name != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
81 "Particle field name cannot be NULL.");
82 PetscCheck(field_id != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
83 "ParticleFieldId output cannot be NULL.");
84
85 for (PetscInt index = 0; index < PARTICLE_FIELD_ID_COUNT; ++index) {
86 const ParticleFieldDescriptor *descriptor = &gParticleFieldCatalog[index];
87 PetscBool match = PETSC_FALSE;
88
89 PetscCall(PetscStrcasecmp(field_name, descriptor->canonical_name, &match));
90 if (!match && descriptor->alias_1) PetscCall(PetscStrcasecmp(field_name, descriptor->alias_1, &match));
91 if (!match && descriptor->alias_2) PetscCall(PetscStrcasecmp(field_name, descriptor->alias_2, &match));
92 if (match) {
93 *field_id = descriptor->id;
94 PetscFunctionReturn(0);
95 }
96 }
97
98 *field_id = PARTICLE_FIELD_ID_INVALID;
99 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_UNKNOWN_TYPE,
100 "Particle field name '%s' is not registered in the persistent particle field catalog.",
101 field_name);
102}
Immutable metadata for one persistent particle field.
Here is the caller graph for this function:

◆ ParticleFieldName()

const char * ParticleFieldName ( ParticleFieldId  field_id)

Return the canonical PETSc DMSwarm name for an ID.

Parameters
[in]field_idTyped particle-field identity.
Returns
Catalog-owned canonical name or InvalidParticleField.

Return the canonical PETSc DMSwarm name for an ID.

See also
ParticleFieldName()

Definition at line 108 of file particle_field_catalog.c.

109{
110 if (field_id < 0 || field_id >= PARTICLE_FIELD_ID_COUNT) return "InvalidParticleField";
111 if (gParticleFieldCatalog[field_id].id != field_id) return "InvalidParticleField";
112 return gParticleFieldCatalog[field_id].canonical_name;
113}
Here is the caller graph for this function: