#include "ParticleMotion.h"#include "particle_field_catalog.h"#include "ParticleInitialConditions.h"Go to the source code of this file.
Macros | |
| #define | ERROR_MSG_BUFFER_SIZE 256 |
Functions | |
| PetscErrorCode | CalculateBrownianDisplacement (UserCtx *user, PetscInt64 pid, PetscReal diff_eff, Cmpnts *displacement) |
| Implementation of CalculateBrownianDisplacement(). | |
| PetscErrorCode | UpdateParticlePosition (UserCtx *user, Particle *particle) |
| Implementation of UpdateParticlePosition(). | |
| PetscErrorCode | UpdateAllParticlePositions (UserCtx *user) |
| Implementation of UpdateAllParticlePositions(). | |
| PetscErrorCode | CheckAndRemoveLostParticles (UserCtx *user, PetscInt *removedCountLocal, PetscInt *removedCountGlobal, PetscReal *removedScalarSumGlobal, PetscInt *exitedCountGlobal, PetscReal *exitedScalarSumGlobal) |
| Implementation of CheckAndRemoveLostParticles(). | |
| PetscErrorCode | SetMigrationRanks (UserCtx *user, const MigrationInfo *migrationList, PetscInt migrationCount) |
| Implementation of SetMigrationRanks(). | |
| PetscErrorCode | RemoveFlaggedParticles (DM swarm, PetscInt n_scan, PetscBool remove[], PetscBool scan_backward) |
| Implementation of RemoveFlaggedParticles(). | |
| static PICURV_ALWAYS_INLINE void | GatherSwarmRecords (char *out, const char *in, const PetscInt *order, PetscInt n, size_t bytes) |
Copies n fixed-size records into out in the order order[] gives (out[p] = in[order[p]]). | |
| PetscErrorCode | SortParticlesByCell (DM swarm) |
| Implementation of SortParticlesByCell(). | |
| PetscErrorCode | PerformMigration (UserCtx *user, PetscInt *n_survivors) |
| Implementation of PerformMigration(). | |
| PetscErrorCode | CalculateParticleCountPerCell (UserCtx *user) |
| Implementation of CalculateParticleCountPerCell(). | |
| PetscErrorCode | ResizeSwarmGlobally (DM swarm, PetscInt N_target) |
| Implementation of ResizeSwarmGlobally(). | |
| PetscErrorCode | PreCheckAndResizeSwarm (UserCtx *user, PetscInt ti, const char *ext) |
| Implementation of PreCheckAndResizeSwarm(). | |
| PetscErrorCode | GetLocalPIDSnapshot (const PetscInt64 pid_field[], PetscInt n_local, PetscInt64 **pids_snapshot_out) |
| Implementation of GetLocalPIDSnapshot(). | |
| PetscErrorCode | AddToMigrationList (MigrationInfo **migration_list_p, PetscInt *capacity_p, PetscInt *count_p, PetscInt particle_local_idx, PetscMPIInt destination_rank) |
| Implementation of AddToMigrationList(). | |
| static PetscErrorCode | VerifyNewcomersAgainstPIDs (UserCtx *user, PetscInt n_before, const PetscInt64 pids_before[], PetscInt first_newcomer) |
| Requires the position-identified newcomers to be exactly the PID-identified ones, when -picurv_verify_ghost_updates is set. | |
| PetscErrorCode | FlagNewcomersForLocation (DM swarm, PetscInt n_local_before, PetscInt first_newcomer) |
| Implementation of FlagNewcomersForLocation(). | |
| PetscErrorCode | MigrateRestartParticlesUsingCellID (UserCtx *user) |
| Implementation of MigrateRestartParticlesUsingCellID(). | |
| static PetscErrorCode | GuessParticleOwnerWithBBox (UserCtx *user, const Particle *particle, const BoundingBox *bboxlist, PetscMPIInt *guess_rank_out) |
| Select the rank whose gathered bounding box is the best owner candidate for a particle. | |
| PetscErrorCode | LocateAllParticlesInGrid (UserCtx *user, BoundingBox *bboxlist) |
| Implementation of LocateAllParticlesInGrid(). | |
| PetscErrorCode | ResetAllParticleStatuses (UserCtx *user) |
| Implementation of ResetAllParticleStatuses(). | |
| #define ERROR_MSG_BUFFER_SIZE 256 |
Definition at line 9 of file ParticleMotion.c.
| PetscErrorCode CalculateBrownianDisplacement | ( | UserCtx * | user, |
| PetscInt64 | pid, | ||
| PetscReal | diff_eff, | ||
| Cmpnts * | displacement | ||
| ) |
Implementation of CalculateBrownianDisplacement().
Calculates the stochastic displacement vector (Brownian motion) for a single particle.
Definition at line 16 of file ParticleMotion.c.
Implementation of UpdateParticlePosition().
Updates a particle's position based on its velocity and the timestep dt (stored in user->dt).
Definition at line 43 of file ParticleMotion.c.
| PetscErrorCode UpdateAllParticlePositions | ( | UserCtx * | user | ) |
Implementation of UpdateAllParticlePositions().
Loops over all local particles in the DMSwarm, updating their positions based on velocity and the global timestep user->dt.
Definition at line 70 of file ParticleMotion.c.
| PetscErrorCode CheckAndRemoveLostParticles | ( | UserCtx * | user, |
| PetscInt * | removedCountLocal, | ||
| PetscInt * | removedCountGlobal, | ||
| PetscReal * | removedScalarSumGlobal, | ||
| PetscInt * | exitedCountGlobal, | ||
| PetscReal * | exitedScalarSumGlobal | ||
| ) |
Implementation of CheckAndRemoveLostParticles().
Removes particles that the location algorithm flagged as LOST or EXITED.
Definition at line 158 of file ParticleMotion.c.
| PetscErrorCode SetMigrationRanks | ( | UserCtx * | user, |
| const MigrationInfo * | migrationList, | ||
| PetscInt | migrationCount | ||
| ) |
Implementation of SetMigrationRanks().
Writes migration destinations into the DMSwarm rank field for marked particles.
Definition at line 254 of file ParticleMotion.c.
| PetscErrorCode RemoveFlaggedParticles | ( | DM | swarm, |
| PetscInt | n_scan, | ||
| PetscBool | remove[], | ||
| PetscBool | scan_backward | ||
| ) |
Implementation of RemoveFlaggedParticles().
Removes flagged swarm points in one pass, preserving the one-at-a-time removal order.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/ParticleMotion.h.
Definition at line 284 of file ParticleMotion.c.
|
static |
Copies n fixed-size records into out in the order order[] gives (out[p] = in[order[p]]).
Always inlined, so a literal bytes at the call site becomes a fixed-size copy. Local to this translation unit.
Definition at line 321 of file ParticleMotion.c.
| PetscErrorCode SortParticlesByCell | ( | DM | swarm | ) |
Implementation of SortParticlesByCell().
Reorders the local swarm points so that points in the same host cell are contiguous.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/ParticleMotion.h.
Definition at line 333 of file ParticleMotion.c.
| PetscErrorCode PerformMigration | ( | UserCtx * | user, |
| PetscInt * | n_survivors | ||
| ) |
Implementation of PerformMigration().
Performs particle migration based on the pre-populated DMSwarmPICField_rank field.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/ParticleMotion.h.
Definition at line 425 of file ParticleMotion.c.
| PetscErrorCode CalculateParticleCountPerCell | ( | UserCtx * | user | ) |
Implementation of CalculateParticleCountPerCell().
Counts particles in each cell of the DMDA 'da' and stores the result in user->ParticleCount.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/logging.h.
Definition at line 473 of file ParticleMotion.c.
| PetscErrorCode ResizeSwarmGlobally | ( | DM | swarm, |
| PetscInt | N_target | ||
| ) |
Implementation of ResizeSwarmGlobally().
Resizes a swarm collectively to a target global particle count.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/ParticleMotion.h.
Definition at line 602 of file ParticleMotion.c.
| PetscErrorCode PreCheckAndResizeSwarm | ( | UserCtx * | user, |
| PetscInt | ti, | ||
| const char * | ext | ||
| ) |
Implementation of PreCheckAndResizeSwarm().
Checks particle count in the reference file and resizes the swarm if needed.
Definition at line 646 of file ParticleMotion.c.
| PetscErrorCode GetLocalPIDSnapshot | ( | const PetscInt64 | pid_field[], |
| PetscInt | n_local, | ||
| PetscInt64 ** | pids_snapshot_out | ||
| ) |
Implementation of GetLocalPIDSnapshot().
Creates a sorted snapshot of all Particle IDs (PIDs) from a raw data array.
Definition at line 684 of file ParticleMotion.c.
| PetscErrorCode AddToMigrationList | ( | MigrationInfo ** | migration_list_p, |
| PetscInt * | capacity_p, | ||
| PetscInt * | count_p, | ||
| PetscInt | particle_local_idx, | ||
| PetscMPIInt | destination_rank | ||
| ) |
Implementation of AddToMigrationList().
Safely adds a new migration task to a dynamically sized list.
Definition at line 737 of file ParticleMotion.c.
|
static |
Requires the position-identified newcomers to be exactly the PID-identified ones, when -picurv_verify_ghost_updates is set.
A particle is a newcomer by PID when its PID is absent from the sorted pre-migration snapshot, and by position when it lies at or after the survivor count. The two must agree for every local particle.
| [in] | user | Block context owning the swarm. |
| [in] | n_before | Number of local particles before the migration. |
| [in] | pids_before | Sorted PIDs of those particles (NULL when the check is off or n_before is 0). |
| [in] | first_newcomer | Survivor count reported by PerformMigration(). |
Definition at line 800 of file ParticleMotion.c.
| PetscErrorCode FlagNewcomersForLocation | ( | DM | swarm, |
| PetscInt | n_local_before, | ||
| PetscInt | first_newcomer | ||
| ) |
Implementation of FlagNewcomersForLocation().
Identifies newly arrived particles after migration and flags them for a location search.
Definition at line 828 of file ParticleMotion.c.
| PetscErrorCode MigrateRestartParticlesUsingCellID | ( | UserCtx * | user | ) |
Implementation of MigrateRestartParticlesUsingCellID().
Fast-path migration for restart particles using preloaded Cell IDs.
Definition at line 860 of file ParticleMotion.c.
|
static |
Select the rank whose gathered bounding box is the best owner candidate for a particle.
Tries this rank, then the neighbour across the face, edge or corner the particle left by (from the stored DMDAGetNeighbors() ranks, wrapped on periodic axes), then, because the bounding boxes of curvilinear subdomains overlap, the face neighbours on each axis it left by, and finally every rank. The guess only picks where the walk runs next; the walk decides the owner.
Definition at line 947 of file ParticleMotion.c.
| PetscErrorCode LocateAllParticlesInGrid | ( | UserCtx * | user, |
| BoundingBox * | bboxlist | ||
| ) |
Implementation of LocateAllParticlesInGrid().
Orchestrates the complete particle location and migration process for one timestep.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/ParticleMotion.h.
Definition at line 1030 of file ParticleMotion.c.
| PetscErrorCode ResetAllParticleStatuses | ( | UserCtx * | user | ) |
Implementation of ResetAllParticleStatuses().
Marks all local particles as NEEDS_LOCATION for the next settlement pass.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/ParticleMotion.h.
Definition at line 1216 of file ParticleMotion.c.