|
PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
|
#include <petscpf.h>#include <petscdmswarm.h>#include <stdlib.h>#include <time.h>#include <math.h>#include <petsctime.h>#include <petscsys.h>#include <petscdmcomposite.h>#include <petscsystypes.h>#include "variables.h"#include "ParticleSwarm.h"#include "walkingsearch.h"#include "grid.h"#include "logging.h"#include "io.h"#include "interpolation.h"#include "initialcondition.h"#include "AnalyticalSolutions.h"#include "ParticleMotion.h"#include "ParticlePhysics.h"#include "Boundaries.h"#include "setup.h"#include "solvers.h"Go to the source code of this file.
Functions | |
| PetscErrorCode | InitializeRuntimeSignalHandlers (void) |
| Installs lightweight signal handlers for graceful shutdown requests. | |
| PetscReal | RuntimeWalltimeGuardUpdateEWMA (PetscBool has_previous, PetscReal previous_ewma_seconds, PetscReal latest_step_seconds, PetscReal alpha) |
| Update an EWMA estimate for timestep wall-clock duration. | |
| PetscReal | RuntimeWalltimeGuardConservativeEstimate (PetscReal warmup_average_seconds, PetscReal ewma_seconds, PetscReal latest_step_seconds) |
| Return the conservative timestep estimate used by the walltime guard. | |
| PetscReal | RuntimeWalltimeGuardRequiredHeadroom (PetscReal min_seconds, PetscReal multiplier, PetscReal conservative_estimate_seconds) |
| Compute the required shutdown headroom from timestep estimate and floor. | |
| PetscBool | RuntimeWalltimeGuardShouldTrigger (PetscInt completed_steps, PetscInt warmup_steps, PetscReal remaining_seconds, PetscReal min_seconds, PetscReal multiplier, PetscReal warmup_average_seconds, PetscReal ewma_seconds, PetscReal latest_step_seconds, PetscReal *required_headroom_seconds_out) |
| Decide whether the runtime walltime guard should stop before another step. | |
| PetscErrorCode | UpdateSolverHistoryVectors (UserCtx *user) |
| Copies the current time step's solution fields into history vectors (e.g., U(t_n) -> U_o, U_o -> U_rm1) for the next time step's calculations. | |
| PetscErrorCode | AdvanceSimulation (SimCtx *simCtx) |
| Executes the main time-marching loop for the particle simulation. | |
| PetscErrorCode | PerformInitializedParticleSetup (SimCtx *simCtx) |
| Finalizes the simulation setup at t=0, ensuring a consistent state before time marching. | |
| PetscErrorCode | PerformLoadedParticleSetup (SimCtx *simCtx) |
| Finalizes the simulation state after particle and fluid data have been loaded from a restart. | |
| PetscErrorCode | FinalizeRestartState (SimCtx *simCtx) |
| Performs post-load/post-init consistency checks for a restarted simulation. | |
| PetscErrorCode InitializeRuntimeSignalHandlers | ( | void | ) |
Installs lightweight signal handlers for graceful shutdown requests.
The handlers only record that a shutdown signal was received. The actual output flush and exit path happens later at safe checkpoints in the run loop.
Installs lightweight signal handlers for graceful shutdown requests.
Full API contract (arguments, ownership, side effects) is documented with the matching public header declaration.
Definition at line 123 of file runloop.c.
| PetscReal RuntimeWalltimeGuardUpdateEWMA | ( | PetscBool | has_previous, |
| PetscReal | previous_ewma_seconds, | ||
| PetscReal | latest_step_seconds, | ||
| PetscReal | alpha | ||
| ) |
Update an EWMA estimate for timestep wall-clock duration.
| [in] | has_previous | Whether a previous EWMA estimate exists. |
| [in] | previous_ewma_seconds | Prior EWMA estimate in seconds. |
| [in] | latest_step_seconds | Latest completed timestep duration in seconds. |
| [in] | alpha | EWMA weighting factor in (0, 1]. |
Update an EWMA estimate for timestep wall-clock duration.
Full API contract (arguments, ownership, side effects) is documented with the matching public header declaration.
Definition at line 150 of file runloop.c.
| PetscReal RuntimeWalltimeGuardConservativeEstimate | ( | PetscReal | warmup_average_seconds, |
| PetscReal | ewma_seconds, | ||
| PetscReal | latest_step_seconds | ||
| ) |
Return the conservative timestep estimate used by the walltime guard.
| [in] | warmup_average_seconds | Average duration across warmup steps. |
| [in] | ewma_seconds | Current EWMA duration estimate. |
| [in] | latest_step_seconds | Most recent completed timestep duration. |
Return the conservative timestep estimate used by the walltime guard.
Full API contract (arguments, ownership, side effects) is documented with the matching public header declaration.
Definition at line 162 of file runloop.c.
| PetscReal RuntimeWalltimeGuardRequiredHeadroom | ( | PetscReal | min_seconds, |
| PetscReal | multiplier, | ||
| PetscReal | conservative_estimate_seconds | ||
| ) |
Compute the required shutdown headroom from timestep estimate and floor.
| [in] | min_seconds | Absolute minimum shutdown headroom. |
| [in] | multiplier | Safety multiplier applied to the timestep estimate. |
| [in] | conservative_estimate_seconds | Conservative timestep estimate in seconds. |
Compute the required shutdown headroom from timestep estimate and floor.
Full API contract (arguments, ownership, side effects) is documented with the matching public header declaration.
Definition at line 173 of file runloop.c.
| PetscBool RuntimeWalltimeGuardShouldTrigger | ( | PetscInt | completed_steps, |
| PetscInt | warmup_steps, | ||
| PetscReal | remaining_seconds, | ||
| PetscReal | min_seconds, | ||
| PetscReal | multiplier, | ||
| PetscReal | warmup_average_seconds, | ||
| PetscReal | ewma_seconds, | ||
| PetscReal | latest_step_seconds, | ||
| PetscReal * | required_headroom_seconds_out | ||
| ) |
Decide whether the runtime walltime guard should stop before another step.
| [in] | completed_steps | Number of completed timesteps observed so far. |
| [in] | warmup_steps | Minimum completed timesteps required before guarding. |
| [in] | remaining_seconds | Remaining walltime in seconds. |
| [in] | min_seconds | Absolute minimum shutdown headroom. |
| [in] | multiplier | Safety multiplier applied to timestep estimate. |
| [in] | warmup_average_seconds | Average duration across warmup steps. |
| [in] | ewma_seconds | Current EWMA duration estimate. |
| [in] | latest_step_seconds | Latest completed timestep duration. |
| [out] | required_headroom_seconds_out | Computed required headroom in seconds. |
PETSC_TRUE when shutdown should be requested.Decide whether the runtime walltime guard should stop before another step.
Full API contract (arguments, ownership, side effects) is documented with the matching public header declaration.
Definition at line 184 of file runloop.c.
| PetscErrorCode UpdateSolverHistoryVectors | ( | UserCtx * | user | ) |
Copies the current time step's solution fields into history vectors (e.g., U(t_n) -> U_o, U_o -> U_rm1) for the next time step's calculations.
This function is critical for multi-step time integration schemes (like BDF2) used by the legacy solver. It must be called at the end of every time step, after the new solution has been fully computed.
The order of operations is important to avoid overwriting data prematurely.
| user | The UserCtx for a single block. The function modifies the history vectors (Ucont_o, Ucont_rm1, etc.) within this context. |
Copies the current time step's solution fields into history vectors (e.g., U(t_n) -> U_o, U_o -> U_rm1) for the next time step's calculations.
Local to this translation unit.
Definition at line 319 of file runloop.c.
| PetscErrorCode AdvanceSimulation | ( | SimCtx * | simCtx | ) |
Executes the main time-marching loop for the particle simulation.
This version uses the new, integrated LocateAllParticlesInGrid orchestrator and the ResetAllParticleStatuses helper for a clean, robust, and understandable workflow.
For each timestep, it performs:
| simCtx | Pointer to the master simulation context. |
Executes the main time-marching loop for the particle simulation.
Local to this translation unit.
Definition at line 572 of file runloop.c.
| PetscErrorCode PerformInitializedParticleSetup | ( | SimCtx * | simCtx | ) |
Finalizes the simulation setup at t=0, ensuring a consistent state before time marching.
This function is called from main() after the initial Eulerian and Lagrangian states have been created but before the main time loop begins. Its responsibilities are:
| simCtx | Pointer to the main simulation context structure. |
Finalizes the simulation setup at t=0, ensuring a consistent state before time marching.
Local to this translation unit.
Definition at line 380 of file runloop.c.
| PetscErrorCode PerformLoadedParticleSetup | ( | SimCtx * | simCtx | ) |
Finalizes the simulation state after particle and fluid data have been loaded from a restart.
This helper function performs the critical sequence of operations required to ensure the loaded Lagrangian and Eulerian states are fully consistent and the solver is ready to proceed. This includes:
| simCtx | The main simulation context. |
Finalizes the simulation state after particle and fluid data have been loaded from a restart.
Local to this translation unit.
Definition at line 456 of file runloop.c.
| PetscErrorCode FinalizeRestartState | ( | SimCtx * | simCtx | ) |
Performs post-load/post-init consistency checks for a restarted simulation.
This function is called from main() ONLY when a restart is being performed (i.e., StartStep > 0). It inspects the particle restart mode to determine the correct finalization procedure for the Lagrangian swarm.
mode == "load"), it verifies their locations within the grid to establish necessary runtime links.mode == "init"), it runs the full PerformInitialSetup sequence to migrate, locate, and couple the new particles with the existing fluid state.| simCtx | The main simulation context. |
Performs post-load/post-init consistency checks for a restarted simulation.
Local to this translation unit.
Definition at line 526 of file runloop.c.