PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
Loading...
Searching...
No Matches
ParticlePhysics.h
Go to the documentation of this file.
1/**
2 * @file ParticlePhysics.h
3 * @brief Header file for Particle related physics modules.
4 *
5 * This file contains declarations of functions responsible for solving for fields in the particle swarms within a simulation using PETSc's DMSwarm.
6 */
7
8 #ifndef PARTICLE_PHYSICS_H
9 #define PARTICLE_PHYSICS_H
10
11// Include necessary headers
12#include <petsc.h> // PETSc library header
13#include <petscdmswarm.h> // PETSc DMSwarm header
14#include <stdbool.h>
15#include <petscsys.h> // For PetscRealloc
16#include <math.h>
17#include "variables.h" // Common type definitions
19#include "logging.h" // Logging macros and definitions
20#include "walkingsearch.h" // Walking search function for particle migration
21
22/**
23 * @brief Updates a single particle's field based on its state and physics model.
24 *
25 * Implements the IEM (Interaction by Exchange with the Mean) model for scalar mixing.
26 * Physics: dPsi/dt = -Omega * (Psi - Psi_mean)
27 * Solution: Psi_new = Psi_mean + (Psi_old - Psi_mean) * exp(-Omega * dt)
28 *
29 * @param field_id Typed particle-field identity.
30 * @param dt Time
31 * @param psi_io Pointer
32 * @param diffusivity Particle
33 * @param mean_val Local
34 * @param cell_vol Volume
35 * @param C_model Model
36 * @return PetscErrorCode 0 on success.
37 */
38PetscErrorCode UpdateParticleField(ParticleFieldId field_id,
39 PetscReal dt,
40 PetscReal *psi_io,
41 PetscReal diffusivity,
42 PetscReal mean_val,
43 PetscReal cell_vol,
44 PetscReal C_model);
45
46
47/**
48 * @brief Loops over all local particles and updates a specified field.
49 *
50 * This function orchestrates the update of a single particle field across the entire
51 * local swarm. It gets access to the necessary particle data arrays and calls the
52 * `UpdateParticleField` kernel for each particle.
53 *
54 * @param[in,out] user Pointer to the UserCtx containing the swarm and simulation context.
55 * @param[in] field_id Typed identity of the field to update.
56 *
57 * @return PetscErrorCode 0 on success.
58 */
59PetscErrorCode UpdateFieldForAllParticles(UserCtx *user, ParticleFieldId field_id);
60
61
62/**
63 * @brief Orchestrates the update of all physical properties for particles.
64 *
65 * This function serves as the top-level entry point for updating particle-specific
66 * physical quantities after their position and the surrounding fluid velocity are known.
67 * It calls a sequence of more specific update routines for each property.
68 *
69 * For example, it can be configured to update:
70 * - Particle kinetic energy (stored in "Psi")
71 * - Particle accumulated shear stress
72 * - Particle temperature
73 * - etc.
74 *
75 * @param[in,out] user Pointer to the UserCtx containing the swarm and simulation context.
76 *
77 * @return PetscErrorCode 0 on success.
78 */
79PetscErrorCode UpdateAllParticleFields(UserCtx *user);
80
81#endif // PARTICLE_PHYSICS_H
PetscErrorCode UpdateFieldForAllParticles(UserCtx *user, ParticleFieldId field_id)
Loops over all local particles and updates a specified field.
PetscErrorCode UpdateParticleField(ParticleFieldId field_id, PetscReal dt, PetscReal *psi_io, PetscReal diffusivity, PetscReal mean_val, PetscReal cell_vol, PetscReal C_model)
Updates a single particle's field based on its state and physics model.
PetscErrorCode UpdateAllParticleFields(UserCtx *user)
Orchestrates the update of all physical properties for particles.
Logging utilities and macros for PETSc-based applications.
Typed identities and metadata for persistent solver-particle fields.
ParticleFieldId
Compile-time identity for a persistent solver-particle field.
Main header file for a complex fluid dynamics solver.
User-defined context containing data specific to a single computational grid level.
Definition variables.h:906
Header file for particle location functions using the walking search algorithm.