Configured initial values of particle-carried fields, and the expression language that defines them. More...
Go to the source code of this file.
Data Structures | |
| struct | PicurvExpressionDrawKey |
| What a random draw is keyed on, besides the particle and its stream. More... | |
| struct | ParticleFieldEvent |
| When and why a plan is applied. More... | |
Typedefs | |
| typedef struct PicurvExpression | PicurvExpression |
| A compiled expression: postfix code for a small stack evaluator. | |
| typedef struct ParticleFieldPlan | ParticleFieldPlan |
| Compiled initial values for every configured particle field. | |
Functions | |
| PetscErrorCode | PicurvExpressionCompile (const char *text, const char *const *names, PetscInt name_count, PetscBool allow_random, PicurvExpression **expression) |
| Compile one expression against a list of variable names. | |
| PetscErrorCode | PicurvExpressionEvaluate (const PicurvExpression *expression, const PetscReal *values, const PicurvExpressionDrawKey *key, PetscReal *result) |
| Evaluate a compiled expression. | |
| PetscErrorCode | PicurvExpressionDestroy (PicurvExpression **expression) |
| Free a compiled expression. | |
| PetscErrorCode | ParticleFieldPlanCreate (ParticleFieldPlan **plan) |
| Read a plan from the options database. | |
| PetscErrorCode | ParticleFieldPlanApply (UserCtx *user, const ParticleFieldPlan *plan, const ParticleFieldEvent *event, PetscInt first, PetscInt end) |
Write the plan's values into swarm entries [first, end) of this rank. | |
| PetscErrorCode | ParticleFieldPlanSummarize (UserCtx *user, const ParticleFieldPlan *plan) |
| Log and record the realized initial values of every planned field. | |
| PetscErrorCode | ParticleFieldPlanDestroy (ParticleFieldPlan **plan) |
| Free a plan and its compiled expressions. | |
Configured initial values of particle-carried fields, and the expression language that defines them.
A plan binds each configured particle field to one compiled expression per component. Expressions are written in physical units: x, y, z are physical coordinates, t is physical time, and a value is divided by its field's catalog reference scale when written. The plan is applied to a contiguous local range of swarm entries, so the t=0 population and, later, particles injected at a boundary share one path.
The language is the one generators/ic.gen validates and evaluates for Eulerian expressions; tests/fixtures/expression_conformance.txt holds cases both implementations must agree on.
Definition in file ParticleInitialConditions.h.
| struct PicurvExpressionDrawKey |
What a random draw is keyed on, besides the particle and its stream.
Definition at line 31 of file ParticleInitialConditions.h.
| Data Fields | ||
|---|---|---|
| PetscInt64 | seed |
Run seed (-particle_random_seed). |
| PetscInt64 | pid | Particle identity; draws are pure functions of it. |
| PetscInt64 | salt | Event that produced the particle: 0 for the t=0 population. |
| PetscInt64 | field | Field whose expression draws, the default stream's namespace. |
| struct ParticleFieldEvent |
When and why a plan is applied.
Definition at line 79 of file ParticleInitialConditions.h.
| Data Fields | ||
|---|---|---|
| PetscReal | physical_time | Time, in seconds, the evaluated particles appear at. |
| PetscInt64 | salt | Event identity keying random draws: 0 for the t=0 population. |
| typedef struct PicurvExpression PicurvExpression |
A compiled expression: postfix code for a small stack evaluator.
Definition at line 28 of file ParticleInitialConditions.h.
| typedef struct ParticleFieldPlan ParticleFieldPlan |
Compiled initial values for every configured particle field.
Definition at line 76 of file ParticleInitialConditions.h.
| PetscErrorCode PicurvExpressionCompile | ( | const char * | text, |
| const char *const * | names, | ||
| PetscInt | name_count, | ||
| PetscBool | allow_random, | ||
| PicurvExpression ** | expression | ||
| ) |
Compile one expression against a list of variable names.
The grammar is Python's expression syntax restricted to numbers, the given names, pi, arithmetic (+ - * / % **), comparisons (chained ones included), and/or/not, and the functions abs cos exp maximum minimum sin sqrt tan where, plus uniform and normal when allow_random is true. Comparisons and logical operators yield 1 or 0; % takes the sign of the divisor; ** binds tighter than a unary minus on its left and groups to the right.
| [in] | text | Expression text. |
| [in] | names | Variable names, in the order evaluation supplies their values. |
| [in] | name_count | Number of names. |
| [in] | allow_random | Whether uniform and normal may be called. |
| [out] | expression | Compiled expression, owned by the caller. |
PETSC_ERR_ARG_WRONG for a syntax error or an unknown name or function, with the offending position in the message.Compile one expression against a list of variable names.
Definition at line 385 of file ParticleInitialConditions.c.
| PetscErrorCode PicurvExpressionEvaluate | ( | const PicurvExpression * | expression, |
| const PetscReal * | values, | ||
| const PicurvExpressionDrawKey * | key, | ||
| PetscReal * | result | ||
| ) |
Evaluate a compiled expression.
| [in] | expression | Compiled expression. |
| [in] | values | One value per compiled name, in compile order. |
| [in] | key | Draw key, required when the expression draws; may be NULL otherwise. |
| [out] | result | Value of the expression; may be non-finite, which the caller judges. |
Evaluate a compiled expression.
Definition at line 463 of file ParticleInitialConditions.c.
| PetscErrorCode PicurvExpressionDestroy | ( | PicurvExpression ** | expression | ) |
Free a compiled expression.
| [in,out] | expression | Expression to free; set to NULL. |
Free a compiled expression.
Definition at line 527 of file ParticleInitialConditions.c.
| PetscErrorCode ParticleFieldPlanCreate | ( | ParticleFieldPlan ** | plan | ) |
Read a plan from the options database.
Reads -particle_fields_count, and for each field i, -particle_fields_<i>_name and one expression per component, -particle_fields_<i>_expr_<c>. Every named field must be a particle-carried field of the catalog (capability USER_INITIALIZE).
| [out] | plan | Compiled plan, or NULL when no field is configured. |
PETSC_ERR_ARG_WRONG for an unknown or non-settable field or a malformed expression.Read a plan from the options database.
Definition at line 563 of file ParticleInitialConditions.c.
| PetscErrorCode ParticleFieldPlanApply | ( | UserCtx * | user, |
| const ParticleFieldPlan * | plan, | ||
| const ParticleFieldEvent * | event, | ||
| PetscInt | first, | ||
| PetscInt | end | ||
| ) |
Write the plan's values into swarm entries [first, end) of this rank.
Not collective: each rank evaluates its own entries, and the domain bounds for xn, yn, zn come from the replicated rank bounding boxes. A value that is not finite is an error naming the particle and its position.
| [in,out] | user | Block owning the swarm. |
| [in] | plan | Plan to apply; NULL does nothing. |
| [in] | event | Time and identity of the event producing these particles. |
| [in] | first | First local entry. |
| [in] | end | One past the last local entry. |
Write the plan's values into swarm entries [first, end) of this rank.
Definition at line 649 of file ParticleInitialConditions.c.
| PetscErrorCode ParticleFieldPlanSummarize | ( | UserCtx * | user, |
| const ParticleFieldPlan * | plan | ||
| ) |
Log and record the realized initial values of every planned field.
Collective. Reports count, mean, variance, minimum, maximum, and a ten-bin histogram per field component, in physical units, to the log and to particle_initial_fields.csv in the run's metrics directory.
| [in] | user | Block owning the swarm. |
| [in] | plan | Plan whose fields are summarized; NULL does nothing. |
Log and record the realized initial values of every planned field.
Definition at line 708 of file ParticleInitialConditions.c.
| PetscErrorCode ParticleFieldPlanDestroy | ( | ParticleFieldPlan ** | plan | ) |
Free a plan and its compiled expressions.
| [in,out] | plan | Plan to free; set to NULL. |
Free a plan and its compiled expressions.
Definition at line 790 of file ParticleInitialConditions.c.