9#define PARTICLE_FIELD_ENTRY(field_id_, name_, alias1_, alias2_, components_, type_, registration_, capabilities_, default_, scatter_target_, dimension_) \
11 field_id_, name_, alias1_, alias2_, components_, type_, registration_, capabilities_, default_, scatter_target_, dimension_ \
66 "Particle field catalog must contain one entry per ParticleFieldId.");
75 PetscFunctionBeginUser;
77 PetscCheck(descriptor != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
78 "Particle field descriptor output cannot be NULL.");
80 PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE,
81 "Invalid ParticleFieldId value %d.", (
int)field_id);
83 PETSC_COMM_SELF, PETSC_ERR_PLIB,
84 "Particle field catalog entry %d is not initialized consistently.", (
int)field_id);
88 PetscFunctionReturn(0);
97 PetscFunctionBeginUser;
99 PetscCheck(field_id != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
100 "ParticleFieldId output cannot be NULL.");
106 PetscFunctionReturn(0);
109 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG,
120 PetscBool found = PETSC_FALSE;
122 PetscFunctionBeginUser;
125 PetscCheck(found, PETSC_COMM_SELF, PETSC_ERR_ARG_UNKNOWN_TYPE,
126 "Particle field name '%s' is not registered in the persistent particle field catalog.",
129 PetscFunctionReturn(0);
139 PetscFunctionBeginUser;
141 PetscCheck(field_name != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
142 "Particle field name cannot be NULL.");
143 PetscCheck(field_id != NULL && found != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
144 "ParticleFieldId and found outputs cannot be NULL.");
147 *found = PETSC_FALSE;
150 PetscBool match = PETSC_FALSE;
152 PetscCall(PetscStrcasecmp(field_name, descriptor->
canonical_name, &match));
153 if (!match && descriptor->
alias_1) PetscCall(PetscStrcasecmp(field_name, descriptor->
alias_1, &match));
154 if (!match && descriptor->
alias_2) PetscCall(PetscStrcasecmp(field_name, descriptor->
alias_2, &match));
156 *field_id = descriptor->
id;
162 PetscFunctionReturn(0);
178#undef PARTICLE_FIELD_ENTRY
#define FIELD_DIM_DIFFUSIVITY
const char * FieldCanonicalName(FieldId field_id)
Return the canonical printable name for an ID.
#define FIELD_DIM_DIMENSIONLESS
#define FIELD_DIM_NOT_A_QUANTITY
#define FIELD_DIM_VELOCITY
FieldId
Compile-time identity for a catalogued Eulerian field.
Logging utilities and macros for PETSc-based applications.
#define PROFILE_HELPER_BEGIN
Marks the beginning of a profiled helper: timed only when enabled by name.
#define PROFILE_HELPER_END
Alias of PROFILE_FUNCTION_END for a function that began with PROFILE_HELPER_BEGIN.
#define PROFILE_FUNCTION_END
Marks the end of a profiled code block.
#define PROFILE_FUNCTION_BEGIN
Marks the beginning of a profiled function: an always-on aggregate timer.
const char * ParticleFieldName(ParticleFieldId field_id)
Returns the canonical PETSc name without performing name lookup.
PetscErrorCode ParticleFieldIdFromName(const char *field_name, ParticleFieldId *field_id)
Resolves particle field text once by searching canonical names and aliases.
#define PARTICLE_FIELD_ENTRY(field_id_, name_, alias1_, alias2_, components_, type_, registration_, capabilities_, default_, scatter_target_, dimension_)
static const ParticleFieldDescriptor gParticleFieldCatalog[PARTICLE_FIELD_ID_COUNT]
PetscErrorCode ParticleFieldIdFromScatterTarget(FieldId target, ParticleFieldId *field_id)
Returns the particle field scattering to one Eulerian field.
PetscErrorCode ParticleFieldGetDescriptor(ParticleFieldId field_id, const ParticleFieldDescriptor **descriptor)
Validates and returns one immutable particle-field descriptor.
PetscErrorCode ParticleFieldTryIdFromName(const char *field_name, ParticleFieldId *field_id, PetscBool *found)
Searches canonical names and aliases, reporting a miss instead of failing.
Typed identities and metadata for persistent solver-particle fields.
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_CELL_ID
@ PARTICLE_FIELD_ID_DIFFUSIVITY_GRADIENT
@ PARTICLE_FIELD_ID_COUNT
@ PARTICLE_FIELD_ID_DIFFUSIVITY
@ PARTICLE_FIELD_ID_INVALID
@ PARTICLE_FIELD_ID_VELOCITY
@ PARTICLE_FIELD_CAPABILITY_MODEL_UPDATE
@ PARTICLE_FIELD_CAPABILITY_USER_INITIALIZE
The particle carries the value, so a configured initial value survives: nothing re-derives it from th...
@ PARTICLE_FIELD_CAPABILITY_DEFAULT_INITIALIZE
@ PARTICLE_FIELD_CAPABILITY_CHECKPOINT
@ PARTICLE_FIELD_CAPABILITY_EULERIAN_SCATTER
@ PARTICLE_FIELD_CAPABILITY_NONE
@ PARTICLE_FIELD_REGISTRATION_PETSC
@ PARTICLE_FIELD_REGISTRATION_PICURV
const char * canonical_name
Immutable metadata for one persistent particle field.