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.
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 PetscErrorCode | RuntimeShutdownSynchronize (PetscBool *requested) |
| Agree across ranks on whether to stop, and on why. | |
| 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) |
| Implementation of UpdateSolverHistoryVectors(). | |
| PetscErrorCode | PerformInitializedParticleSetup (SimCtx *simCtx) |
| Implementation of PerformInitializedParticleSetup(). | |
| PetscErrorCode | PerformLoadedParticleSetup (SimCtx *simCtx) |
| Implementation of PerformLoadedParticleSetup(). | |
| PetscErrorCode | FinalizeRestartState (SimCtx *simCtx) |
| Implementation of FinalizeRestartState(). | |
| PetscErrorCode | AdvanceSimulation (SimCtx *simCtx) |
| Implementation of 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 |
Report whether a signal or walltime guard has requested run-loop shutdown.
Definition at line 42 of file runloop.c.
|
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 59 of file runloop.c.
|
static |
Agree across ranks on whether to stop, and on why.
A forwarded signal reaches the ranks at slightly different times, and the walltime guard reads each rank's own clock. A rank that stopped alone would enter the collective termination output while the others entered the next step's solves, so the loop stops on every rank or on none; every rank then reports the same reason.
| [out] | requested | Whether any rank has a shutdown request. |
Definition at line 81 of file runloop.c.
|
static |
Translate a recorded termination signal into a user-facing signal name.
Definition at line 99 of file runloop.c.
|
static |
Translate the current shutdown reason into a user-facing diagnostic label.
Definition at line 120 of file runloop.c.
|
static |
Install the process signal handler used to request graceful simulation shutdown.
Definition at line 138 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 165 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 194 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 209 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 223 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 237 of file runloop.c.
|
static |
Estimate the remaining scheduler walltime after reserving the configured shutdown margin.
Definition at line 256 of file runloop.c.
|
static |
Update the timestep-duration estimate used by the automatic walltime guard.
Definition at line 269 of file runloop.c.
|
static |
Request graceful shutdown when another timestep would exceed the walltime budget.
Definition at line 299 of file runloop.c.
|
static |
Write restart-safe output when a controlled shutdown interrupts the run loop.
Definition at line 346 of file runloop.c.
| PetscErrorCode UpdateSolverHistoryVectors | ( | UserCtx * | user, |
| PetscBool | preserve_previous_state | ||
| ) |
Implementation of 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.
Definition at line 376 of file runloop.c.
| PetscErrorCode PerformInitializedParticleSetup | ( | SimCtx * | simCtx | ) |
Implementation of PerformInitializedParticleSetup().
Finalizes the simulation setup at t=0, ensuring a consistent state before time marching.
Definition at line 426 of file runloop.c.
| PetscErrorCode PerformLoadedParticleSetup | ( | SimCtx * | simCtx | ) |
Implementation of PerformLoadedParticleSetup().
Finalizes the simulation state after particle and fluid data have been loaded from a restart.
Definition at line 500 of file runloop.c.
| PetscErrorCode FinalizeRestartState | ( | SimCtx * | simCtx | ) |
Implementation of FinalizeRestartState().
Performs post-load/post-init consistency checks for a restarted simulation.
Definition at line 562 of file runloop.c.
| PetscErrorCode AdvanceSimulation | ( | SimCtx * | simCtx | ) |
Implementation of AdvanceSimulation().
Executes the main time-marching loop for the particle simulation.
Definition at line 603 of file runloop.c.