PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
Loading...
Searching...
No Matches
simulation.h
Go to the documentation of this file.
1#ifndef SIMULATION_H
2#define SIMULATION_H
3
4#include <petscpf.h>
5#include <petscdmswarm.h>
6#include <stdlib.h>
7#include <time.h>
8#include <math.h>
9#include <petsctime.h>
10#include <petscsys.h>
11#include <petscdmcomposite.h>
12#include <petscsystypes.h>
13
14// Include additional headers
15#include "variables.h" // Shared type definitions
16#include "ParticleSwarm.h" // Particle swarm functions
17#include "walkingsearch.h" // Particle location functions
18#include "grid.h" // Grid functions
19#include "logging.h" // Logging macros
20#include "io.h" // Data Input and Output functions
21#include "interpolation.h" // Interpolation routines
22#include "initialcondition.h" // Analytical Solution for testing
23#include "ParticleMotion.h" // Functions related to motion of particles
24#include "Boundaries.h" // Functions related to Boundary conditions
25#include "setup.h" // Functions related to setup
26#include "solvers.h"
27
28
29/**
30 * @brief Copies the current time step's solution fields into history vectors
31 * (e.g., U(t_n) -> U_o, U_o -> U_rm1) for the next time step's calculations.
32 *
33 * This function is critical for multi-step time integration schemes (like BDF2)
34 * used by the legacy solver. It must be called at the end of every time step,
35 * after the new solution has been fully computed.
36 *
37 * The order of operations is important to avoid overwriting data prematurely.
38 *
39 * @param user The UserCtx for a single block. The function modifies the history
40 * vectors (Ucont_o, Ucont_rm1, etc.) within this context.
41 * @return PetscErrorCode 0 on success.
42 */
43PetscErrorCode UpdateSolverHistoryVectors(UserCtx *user);
44
45/**
46 * @brief Executes the main time-marching loop for the particle simulation. [TEST VERSION]
47 *
48 * This version uses the new, integrated `LocateAllParticlesInGrid_TEST` orchestrator
49 * and the `ResetAllParticleStatuses` helper for a clean, robust, and understandable workflow.
50 *
51 * For each timestep, it performs:
52 * 1. Sets the background fluid velocity field (Ucat) for the current step.
53 * 2. Updates particle positions using velocity from the *previous* step's interpolation.
54 * 3. Removes any particles that have left the global domain.
55 * 4. A single call to `LocateAllParticlesInGrid_TEST`, which handles all
56 * particle location and migration until the swarm is fully settled.
57 * 5. Interpolates the current fluid velocity to the newly settled particle locations.
58 * 6. Scatters particle data back to Eulerian fields.
59 * 7. Outputs data at specified intervals.
60 *
61 * @param user Pointer to the UserCtx structure..
62 * @return PetscErrorCode 0 on success, non-zero on failure.
63 */
64PetscErrorCode AdvanceSimulation(SimCtx *simCtx);
65
66/**
67 * @brief Finalizes the simulation setup at t=0, ensuring a consistent state before time marching.
68 *
69 * This function is called from main() after the initial Eulerian and Lagrangian states have been
70 * created but before the main time loop begins. Its responsibilities are:
71 *
72 * 1. Settling the particle swarm: Migrates particles to their correct owner ranks and finds their
73 * initial host cells. This includes handling special surface initializations.
74 * 2. Coupling the fields: Interpolates the initial Eulerian fields to the settled particle locations.
75 * 3. Preparing for the first step: Scatters particle data back to the grid.
76 * 4. Writing the initial output for step 0.
77 *
78 * @param simCtx Pointer to the main simulation context structure.
79 * @return PetscErrorCode 0 on success, non-zero on failure.
80 */
81PetscErrorCode PerformInitialSetup(SimCtx *simCtx);
82
83#endif // SIMULATION_H
Header file for Particle Motion and migration related functions.
Public interface for grid, solver, and metric setup routines.
Public interface for data input/output routines.
Logging utilities and macros for PETSc-based applications.
PetscErrorCode PerformInitialSetup(SimCtx *simCtx)
Finalizes the simulation setup at t=0, ensuring a consistent state before time marching.
Definition simulation.c:95
PetscErrorCode AdvanceSimulation(SimCtx *simCtx)
Executes the main time-marching loop for the particle simulation.
Definition simulation.c:181
PetscErrorCode UpdateSolverHistoryVectors(UserCtx *user)
Copies the current time step's solution fields into history vectors (e.g., U(t_n) -> U_o,...
Definition simulation.c:23
Main header file for a complex fluid dynamics solver.
The master context for the entire simulation.
Definition variables.h:513
User-defined context containing data specific to a single computational grid level.
Definition variables.h:630
Header file for particle location functions using the walking search algorithm.