9#ifndef PARTICLE_SWARM_H
10#define PARTICLE_SWARM_H
14#include <petscdmswarm.h>
64PetscErrorCode
RegisterSwarmField(DM swarm,
const char *fieldName, PetscInt fieldDim, PetscDataType dtype);
93 PetscInt particlesPerProcess);
109PetscErrorCode
DistributeParticles(PetscInt numParticles, PetscMPIInt rank, PetscMPIInt size, PetscInt* particlesPerProcess, PetscInt* remainder);
134PetscErrorCode
UnpackSwarmFields(PetscInt i,
const PetscInt64 *PIDs,
const PetscReal *weights,
135 const PetscReal *positions,
const PetscInt *cellIndices,
136 PetscReal *velocities,PetscInt *LocStatus,PetscReal *diffusivity,
Cmpnts *diffusivitygradient, PetscReal *psi,
Particle *particle);
159 PetscReal *positions,
160 PetscReal *velocities,
162 PetscInt *cellIndices,
164 PetscReal *diffusivity,
165 Cmpnts *diffusivitygradient,
PetscErrorCode UpdateParticleWeights(PetscReal *d, Particle *particle)
Updates a particle's interpolation weights based on distances to cell faces.
PetscErrorCode CreateParticleSwarm(UserCtx *user, PetscInt numParticles, PetscInt *particlesPerProcess)
Creates the particle swarm, registers its fields and sizes it for this rank's share.
PetscErrorCode InjectParticlesAtInlets(UserCtx *user)
Add the particles that entered through each injecting inlet during this step.
PetscErrorCode DistributeParticles(PetscInt numParticles, PetscMPIInt rank, PetscMPIInt size, PetscInt *particlesPerProcess, PetscInt *remainder)
Distributes particles evenly across MPI processes, handling any remainders.
PetscErrorCode ParticleInletsDestroy(SimCtx *simCtx)
Release what ParticleInletsCreate() and InjectParticlesAtInlets() allocated.
PetscErrorCode UnpackSwarmFields(PetscInt i, const PetscInt64 *PIDs, const PetscReal *weights, const PetscReal *positions, const PetscInt *cellIndices, PetscReal *velocities, PetscInt *LocStatus, PetscReal *diffusivity, Cmpnts *diffusivitygradient, PetscReal *psi, Particle *particle)
Initializes a Particle struct with data from DMSwarm fields.
PetscErrorCode ParticleInletsCreate(SimCtx *simCtx)
Read the inlets that inject particles from the options database.
PetscErrorCode InitializeSwarm(UserCtx *user)
Initializes the DMSwarm object within the UserCtx structure.
PetscErrorCode AssignInitialPropertiesToSwarm(UserCtx *user, PetscInt particlesPerProcess)
Initializes all particle properties in the swarm.
PetscErrorCode UpdateSwarmFields(PetscInt i, const Particle *particle, PetscReal *positions, PetscReal *velocities, PetscReal *weights, PetscInt *cellIndices, PetscInt *status, PetscReal *diffusivity, Cmpnts *diffusivitygradient, PetscReal *psi)
Updates DMSwarm data arrays from a Particle struct.
PetscErrorCode InitializeParticleSwarm(SimCtx *simCtx)
High-level particle initialization orchestrator for a simulation run.
PetscErrorCode RegisterSwarmField(DM swarm, const char *fieldName, PetscInt fieldDim, PetscDataType dtype)
Registers a swarm field without finalizing registration.
PetscErrorCode RegisterParticleFields(DM swarm)
Registers necessary particle fields within the DMSwarm.
Public interface for data input/output routines.
Logging utilities and macros for PETSc-based applications.
Typed identities and metadata for persistent solver-particle fields.
Main header file for a complex fluid dynamics solver.
A 3D point or vector with PetscScalar components.
Defines a particle's core properties for Lagrangian tracking.
The master context for the entire simulation.
User-defined context containing data specific to a single computational grid level.
Header file for particle location functions using the walking search algorithm.