PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
 
Loading...
Searching...
No Matches
ParticleInitialConditions.h
Go to the documentation of this file.
1/**
2 * @file ParticleInitialConditions.h
3 * @brief Configured initial values of particle-carried fields.
4 *
5 * A plan binds each configured particle field to one compiled expression per component.
6 * Expressions are written in physical units: `x`, `y`, `z` are physical coordinates,
7 * `t` is physical time, and a value is divided by its field's catalog reference scale
8 * when written. The plan is applied to a contiguous local range of swarm entries, so the
9 * t=0 population and, later, particles injected at a boundary share one path.
10 *
11 * The expressions are compiled and evaluated by the shared engine in expression.h.
12 */
13
14#ifndef PARTICLE_INITIAL_CONDITIONS_H
15#define PARTICLE_INITIAL_CONDITIONS_H
16
17#include "variables.h"
19#include "expression.h"
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/** @brief Compiled initial values for every configured particle field. */
27
28/** @brief When and why a plan is applied. */
29typedef struct {
30 PetscReal physical_time; /**< Time, in seconds, the evaluated particles appear at. */
31 PetscInt64 salt; /**< Event identity keying random draws: 0 for the t=0 population. */
33
34/**
35 * @brief Read a plan from the options database.
36 * @details Reads `-<prefix>_count`, and for each field `i`, `-<prefix>_<i>_name` and one
37 * expression per component, `-<prefix>_<i>_expr_<c>`. Every named field must be a
38 * particle-carried field of the catalog (capability `USER_INITIALIZE`).
39 * @param[in] prefix Option prefix without its dash: `particle_fields` for the t=0 population,
40 * `particle_inlet_<n>_fields` for an inlet.
41 * @param[out] plan Compiled plan, or NULL when no field is configured.
42 * @return Zero on success; `PETSC_ERR_ARG_WRONG` for an unknown or non-settable field or a
43 * malformed expression.
44 */
45PetscErrorCode ParticleFieldPlanCreate(const char *prefix, ParticleFieldPlan **plan);
46
47/**
48 * @brief Write the plan's values into swarm entries `[first, end)` of this rank.
49 * @details Each rank evaluates its own entries. Every rank calls it even with an empty range: the
50 * first call that reads a grid line's fraction or length is collective, computing them once
51 * for the plan. Those expressions need each particle's cell and weights. A value that is not finite is an error naming the
52 * particle and its position.
53 * @param[in,out] user Block owning the swarm.
54 * @param[in] plan Plan to apply; NULL does nothing.
55 * @param[in] event Time and identity of the event producing these particles.
56 * @param[in] first First local entry.
57 * @param[in] end One past the last local entry.
58 * @return Zero on success.
59 */
60PetscErrorCode ParticleFieldPlanApply(UserCtx *user, ParticleFieldPlan *plan,
61 const ParticleFieldEvent *event, PetscInt first, PetscInt end);
62
63/**
64 * @brief Log and record the realized initial values of every planned field.
65 * @details Collective. Reports count, mean, variance, minimum, maximum, and a ten-bin
66 * histogram per field component, in physical units, to the log and to
67 * `particle_initial_fields.csv` in the run's metrics directory.
68 * @param[in] user Block owning the swarm.
69 * @param[in] plan Plan whose fields are summarized; NULL does nothing.
70 * @return Zero on success.
71 */
72PetscErrorCode ParticleFieldPlanSummarize(UserCtx *user, const ParticleFieldPlan *plan);
73
74/**
75 * @brief Free a plan and its compiled expressions.
76 * @param[in,out] plan Plan to free; set to NULL.
77 * @return Zero on success.
78 */
79PetscErrorCode ParticleFieldPlanDestroy(ParticleFieldPlan **plan);
80
81#ifdef __cplusplus
82}
83#endif
84
85#endif /* PARTICLE_INITIAL_CONDITIONS_H */
PetscErrorCode ParticleFieldPlanSummarize(UserCtx *user, const ParticleFieldPlan *plan)
Log and record the realized initial values of every planned field.
PetscInt64 salt
Event identity keying random draws: 0 for the t=0 population.
PetscErrorCode ParticleFieldPlanApply(UserCtx *user, ParticleFieldPlan *plan, const ParticleFieldEvent *event, PetscInt first, PetscInt end)
Write the plan's values into swarm entries [first, end) of this rank.
PetscErrorCode ParticleFieldPlanDestroy(ParticleFieldPlan **plan)
Free a plan and its compiled expressions.
PetscErrorCode ParticleFieldPlanCreate(const char *prefix, ParticleFieldPlan **plan)
Read a plan from the options database.
PetscReal physical_time
Time, in seconds, the evaluated particles appear at.
When and why a plan is applied.
The expression language shared by every configured field, the keyed hashes its random draws and other...
Typed identities and metadata for persistent solver-particle fields.
Main header file for a complex fluid dynamics solver.
User-defined context containing data specific to a single computational grid level.
Definition variables.h:1157