8 #ifndef PARTICLE_MOTION_H
9 #define PARTICLE_MOTION_H
13#include <petscdmswarm.h>
114 PetscInt *removedCountLocal,
115 PetscInt *removedCountGlobal,
116 PetscReal *removedScalarSumGlobal,
117 PetscInt *exitedCountGlobal,
118 PetscReal *exitedScalarSumGlobal);
168PetscErrorCode
RemoveFlaggedParticles(DM swarm, PetscInt n_scan, PetscBool remove[], PetscBool scan_backward);
253 PetscInt64 **pids_snapshot_out);
277 PetscInt *capacity_p,
279 PetscInt particle_local_idx,
280 PetscMPIInt destination_rank);
PetscErrorCode SortParticlesByCell(DM swarm)
Reorders the local swarm points so that points in the same host cell are contiguous.
PetscErrorCode ResizeSwarmGlobally(DM swarm, PetscInt N_target)
Resizes a swarm collectively to a target global particle count.
PetscErrorCode AddToMigrationList(MigrationInfo **migration_list_p, PetscInt *capacity_p, PetscInt *count_p, PetscInt particle_local_idx, PetscMPIInt destination_rank)
Safely adds a new migration task to a dynamically sized list.
PetscErrorCode SetMigrationRanks(UserCtx *user, const MigrationInfo *migrationList, PetscInt migrationCount)
Writes migration destinations into the DMSwarm rank field for marked particles.
PetscErrorCode RemoveFlaggedParticles(DM swarm, PetscInt n_scan, PetscBool remove[], PetscBool scan_backward)
Removes flagged swarm points in one pass, preserving the one-at-a-time removal order.
PetscErrorCode GetLocalPIDSnapshot(const PetscInt64 pid_field[], PetscInt n_local, PetscInt64 **pids_snapshot_out)
Creates a sorted snapshot of all Particle IDs (PIDs) from a raw data array.
PetscErrorCode PerformMigration(UserCtx *user, PetscInt *n_survivors)
Performs particle migration based on the pre-populated DMSwarmPICField_rank field.
PetscErrorCode MigrateRestartParticlesUsingCellID(UserCtx *user)
Fast-path migration for restart particles using preloaded Cell IDs.
PetscErrorCode UpdateAllParticlePositions(UserCtx *user)
Loops over all local particles in the DMSwarm, updating their positions based on velocity and the glo...
PetscErrorCode CalculateParticleCountPerCell(UserCtx *user)
Counts particles in each cell of the DMDA 'da' and stores the result in user->ParticleCount.
PetscErrorCode LocateAllParticlesInGrid(UserCtx *user, BoundingBox *bboxlist)
Orchestrates the complete particle location and migration process for one timestep.
PetscErrorCode CheckAndRemoveLostParticles(UserCtx *user, PetscInt *removedCountLocal, PetscInt *removedCountGlobal, PetscReal *removedScalarSumGlobal, PetscInt *exitedCountGlobal, PetscReal *exitedScalarSumGlobal)
Removes particles that the location algorithm flagged as LOST or EXITED.
PetscErrorCode UpdateParticlePosition(UserCtx *user, Particle *particle)
Updates a particle's position based on its velocity and the timestep dt (stored in user->dt).
PetscErrorCode ResetAllParticleStatuses(UserCtx *user)
Marks all local particles as NEEDS_LOCATION for the next settlement pass.
PetscErrorCode FlagNewcomersForLocation(DM swarm, PetscInt n_local_before, PetscInt first_newcomer)
Identifies newly arrived particles after migration and flags them for a location search.
static PetscBool IsParticleInBox(const BoundingBox *bbox, const Cmpnts *pos)
Whether a position lies in an axis-aligned bounding box, faces included.
static void ParticleUniformsFromHash(uint64_t hash, PetscReal u[4])
Four uniforms in [0,1) from one keyed draw hash.
PetscErrorCode PreCheckAndResizeSwarm(UserCtx *user, PetscInt ti, const char *ext)
Checks particle count in the reference file and resizes the swarm if needed.
PetscErrorCode CalculateBrownianDisplacement(UserCtx *user, PetscInt64 pid, PetscReal diff_eff, Cmpnts *displacement)
Calculates the stochastic displacement vector (Brownian motion) for a single particle.
The expression language shared by every configured field, the keyed hashes its random draws and other...
uint64_t PicurvMix64(uint64_t z)
splitmix64 finalizer: a bijective mix of 64 bits.
PetscReal PicurvUnitFromHash(uint64_t hash)
Uniform on [0, 1) from the top 53 bits of a hash.
Logging utilities and macros for PETSc-based applications.
Main header file for a complex fluid dynamics solver.
Cmpnts max_coords
Maximum x, y, z coordinates of the bounding box.
Cmpnts min_coords
Minimum x, y, z coordinates of the bounding box.
Defines a 3D axis-aligned bounding box.
A 3D point or vector with PetscScalar components.
Information needed to migrate a single particle between MPI ranks.
Defines a particle's core properties for Lagrangian tracking.
User-defined context containing data specific to a single computational grid level.
Header file for particle location functions using the walking search algorithm.