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
18#include "logging.h" // Logging macros and definitions
19#include "walkingsearch.h" // Walking search function for particle migration
20
21/**
22 * @brief Updates a single particle's field based on its state and physics model.
23 *
24 * Implements the IEM (Interaction by Exchange with the Mean) model for scalar mixing.
25 * Physics: dPsi/dt = -Omega * (Psi - Psi_mean)
26 * Solution: Psi_new = Psi_mean + (Psi_old - Psi_mean) * exp(-Omega * dt)
27 *
28 * @param fieldName Name
29 * @param dt Time
30 * @param psi_io Pointer
31 * @param diffusivity Particle
32 * @param mean_val Local
33 * @param cell_vol Volume
34 * @param C_model Model
35 * @return PetscErrorCode 0 on success.
36 */
37PetscErrorCode UpdateParticleField(const char *fieldName,
38 PetscReal dt,
39 PetscReal *psi_io,
40 PetscReal diffusivity,
41 PetscReal mean_val,
42 PetscReal cell_vol,
43 PetscReal C_model);
44
45
46/**
47 * @brief Loops over all local particles and updates a specified field.
48 *
49 * This function orchestrates the update of a single particle field across the entire
50 * local swarm. It gets access to the necessary particle data arrays and calls the
51 * `UpdateParticleField` kernel for each particle.
52 *
53 * @param[in,out] user Pointer to the UserCtx containing the swarm and simulation context.
54 * @param[in] fieldName The name of the field to update (e.g., "Psi").
55 *
56 * @return PetscErrorCode 0 on success.
57 */
58PetscErrorCode UpdateFieldForAllParticles(UserCtx *user, const char *fieldName);
59
60
61/**
62 * @brief Orchestrates the update of all physical properties for particles.
63 *
64 * This function serves as the top-level entry point for updating particle-specific
65 * physical quantities after their position and the surrounding fluid velocity are known.
66 * It calls a sequence of more specific update routines for each property.
67 *
68 * For example, it can be configured to update:
69 * - Particle kinetic energy (stored in "Psi")
70 * - Particle accumulated shear stress
71 * - Particle temperature
72 * - etc.
73 *
74 * @param[in,out] user Pointer to the UserCtx containing the swarm and simulation context.
75 *
76 * @return PetscErrorCode 0 on success.
77 */
78PetscErrorCode UpdateAllParticleFields(UserCtx *user);
79
80#endif // PARTICLE_PHYSICS_H
PetscErrorCode UpdateParticleField(const char *fieldName, 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 UpdateFieldForAllParticles(UserCtx *user, const char *fieldName)
Loops over all local particles and updates a specified field.
PetscErrorCode UpdateAllParticleFields(UserCtx *user)
Orchestrates the update of all physical properties for particles.
Logging utilities and macros for PETSc-based applications.
Main header file for a complex fluid dynamics solver.
User-defined context containing data specific to a single computational grid level.
Definition variables.h:811
Header file for particle location functions using the walking search algorithm.