Test program for DMSwarm interpolation using the fdf-curvIB method. More...
#include <signal.h>#include "runloop.h"#include "statistics_window.h"#include "verification_sources.h"#include "ParticleInitialConditions.h"Go to the source code of this file.
Macros | |
| #define | __FUNCT__ "PerformInitialSetup" |
| #define | __FUNCT__ "PerformLoadedParticleSetup" |
| #define | __FUNCT__ "FinalizeRestartState" |
| #define | __FUNCT__ "AdvanceSimulation" |
Functions | |
| static void | RuntimeShutdownSignalHandler (int signum) |
| Record receipt of a termination signal for safe handling by the run loop. | |
| static void | RuntimeRequestAutoWalltimeGuard (void) |
| Request a controlled shutdown because the estimated walltime margin is exhausted. | |
| static PetscBool | RuntimeShutdownRequested (void) |
| Report whether a signal or walltime guard has requested run-loop shutdown. | |
| static PetscErrorCode | RefreshScatteredParticleState (UserCtx *user) |
| Makes the Eulerian particle averages consistent with the particles before step 1. | |
| static const char * | RuntimeShutdownSignalName (PetscInt signum) |
| Translate a recorded termination signal into a user-facing signal name. | |
| static const char * | RuntimeShutdownReasonName (void) |
| Translate the current shutdown reason into a user-facing diagnostic label. | |
| static PetscErrorCode | RegisterRuntimeSignalHandler (int signum) |
| Install the process signal handler used to request graceful simulation shutdown. | |
| PetscErrorCode | InitializeRuntimeSignalHandlers (void) |
| Implementation of InitializeRuntimeSignalHandlers(). | |
| PetscReal | RuntimeWalltimeGuardUpdateEWMA (PetscBool has_previous, PetscReal previous_ewma_seconds, PetscReal latest_step_seconds, PetscReal alpha) |
| Implementation of RuntimeWalltimeGuardUpdateEWMA(). | |
| PetscReal | RuntimeWalltimeGuardConservativeEstimate (PetscReal warmup_average_seconds, PetscReal ewma_seconds, PetscReal latest_step_seconds) |
| Implementation of RuntimeWalltimeGuardConservativeEstimate(). | |
| PetscReal | RuntimeWalltimeGuardRequiredHeadroom (PetscReal min_seconds, PetscReal multiplier, PetscReal conservative_estimate_seconds) |
| Implementation of RuntimeWalltimeGuardRequiredHeadroom(). | |
| 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) |
| Implementation of RuntimeWalltimeGuardShouldTrigger(). | |
| static PetscReal | RuntimeWalltimeGuardRemainingSeconds (const SimCtx *simCtx) |
| Estimate the remaining scheduler walltime after reserving the configured shutdown margin. | |
| static void | UpdateRuntimeWalltimeGuardEstimator (SimCtx *simCtx, PetscReal completed_step_seconds) |
| Update the timestep-duration estimate used by the automatic walltime guard. | |
| static PetscErrorCode | MaybeRequestRuntimeWalltimeGuardShutdown (SimCtx *simCtx, const char *checkpoint_name) |
| Request graceful shutdown when another timestep would exceed the walltime budget. | |
| static PetscErrorCode | WriteForcedTerminationOutput (SimCtx *simCtx, UserCtx *user, const char *phase) |
| Write restart-safe output when a controlled shutdown interrupts the run loop. | |
| PetscErrorCode | UpdateSolverHistoryVectors (UserCtx *user, PetscBool preserve_previous_state) |
Internal helper implementation: UpdateSolverHistoryVectors(). | |
| PetscErrorCode | PerformInitializedParticleSetup (SimCtx *simCtx) |
Internal helper implementation: PerformInitializedParticleSetup(). | |
| PetscErrorCode | PerformLoadedParticleSetup (SimCtx *simCtx) |
Internal helper implementation: PerformLoadedParticleSetup(). | |
| PetscErrorCode | FinalizeRestartState (SimCtx *simCtx) |
Internal helper implementation: FinalizeRestartState(). | |
| PetscErrorCode | AdvanceSimulation (SimCtx *simCtx) |
Internal helper implementation: AdvanceSimulation(). | |
Variables | |
| static volatile sig_atomic_t | g_runtime_shutdown_signal = 0 |
| static PetscBool | g_runtime_shutdown_auto_requested = PETSC_FALSE |
Test program for DMSwarm interpolation using the fdf-curvIB method.
Provides the setup to start any simulation with DMSwarm and DMDAs.
Definition in file runloop.c.
|
static |
Record receipt of a termination signal for safe handling by the run loop.
Definition at line 20 of file runloop.c.
|
static |
Request a controlled shutdown because the estimated walltime margin is exhausted.
Definition at line 30 of file runloop.c.
|
static |
|
static |
Makes the Eulerian particle averages consistent with the particles before step 1.
The first step's particle update relaxes each particle toward the scattered Eulerian mean, and its own scatter comes only after that update. So whatever the particles hold at setup - an initial condition, a loaded state, or the verification profile - must be scattered here, or step 1 relaxes toward a mean that never saw it. The verification profile, when active, is applied first. Local to this translation unit.
Definition at line 54 of file runloop.c.
|
static |
Translate a recorded termination signal into a user-facing signal name.
Definition at line 68 of file runloop.c.
|
static |
Translate the current shutdown reason into a user-facing diagnostic label.
Definition at line 87 of file runloop.c.
|
static |
Install the process signal handler used to request graceful simulation shutdown.
Definition at line 101 of file runloop.c.
| PetscErrorCode InitializeRuntimeSignalHandlers | ( | void | ) |
Implementation of InitializeRuntimeSignalHandlers().
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 126 of file runloop.c.
| PetscReal RuntimeWalltimeGuardUpdateEWMA | ( | PetscBool | has_previous, |
| PetscReal | previous_ewma_seconds, | ||
| PetscReal | latest_step_seconds, | ||
| PetscReal | alpha | ||
| ) |
Implementation of RuntimeWalltimeGuardUpdateEWMA().
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 153 of file runloop.c.
| PetscReal RuntimeWalltimeGuardConservativeEstimate | ( | PetscReal | warmup_average_seconds, |
| PetscReal | ewma_seconds, | ||
| PetscReal | latest_step_seconds | ||
| ) |
Implementation of RuntimeWalltimeGuardConservativeEstimate().
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 165 of file runloop.c.
| PetscReal RuntimeWalltimeGuardRequiredHeadroom | ( | PetscReal | min_seconds, |
| PetscReal | multiplier, | ||
| PetscReal | conservative_estimate_seconds | ||
| ) |
Implementation of RuntimeWalltimeGuardRequiredHeadroom().
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 176 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 | ||
| ) |
Implementation of RuntimeWalltimeGuardShouldTrigger().
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 187 of file runloop.c.
|
static |
Estimate the remaining scheduler walltime after reserving the configured shutdown margin.
Definition at line 204 of file runloop.c.
|
static |
Update the timestep-duration estimate used by the automatic walltime guard.
Definition at line 215 of file runloop.c.
|
static |
Request graceful shutdown when another timestep would exceed the walltime budget.
Definition at line 242 of file runloop.c.
|
static |
Write restart-safe output when a controlled shutdown interrupts the run loop.
Definition at line 286 of file runloop.c.
| PetscErrorCode UpdateSolverHistoryVectors | ( | UserCtx * | user, |
| PetscBool | preserve_previous_state | ||
| ) |
Internal helper implementation: UpdateSolverHistoryVectors().
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 314 of file runloop.c.
| PetscErrorCode PerformInitializedParticleSetup | ( | SimCtx * | simCtx | ) |
Internal helper implementation: PerformInitializedParticleSetup().
Finalizes the simulation setup at t=0, ensuring a consistent state before time marching.
Local to this translation unit.
Definition at line 364 of file runloop.c.
| PetscErrorCode PerformLoadedParticleSetup | ( | SimCtx * | simCtx | ) |
Internal helper implementation: PerformLoadedParticleSetup().
Finalizes the simulation state after particle and fluid data have been loaded from a restart.
Local to this translation unit.
Definition at line 449 of file runloop.c.
| PetscErrorCode FinalizeRestartState | ( | SimCtx * | simCtx | ) |
Internal helper implementation: FinalizeRestartState().
Performs post-load/post-init consistency checks for a restarted simulation.
Local to this translation unit.
Definition at line 511 of file runloop.c.
| PetscErrorCode AdvanceSimulation | ( | SimCtx * | simCtx | ) |
Internal helper implementation: AdvanceSimulation().
Executes the main time-marching loop for the particle simulation.
Local to this translation unit.
Definition at line 552 of file runloop.c.