From ff0e609385ceb99913c59697430793a8f17afca3 Mon Sep 17 00:00:00 2001 From: Joshua Lampert Date: Thu, 5 Oct 2023 18:01:09 +0200 Subject: [PATCH 1/3] show percentage of simulation progress --- src/callbacks_step/alive.jl | 9 +++++++-- src/callbacks_step/analysis.jl | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/callbacks_step/alive.jl b/src/callbacks_step/alive.jl index eeacd9681d8..8ea637a30fa 100644 --- a/src/callbacks_step/alive.jl +++ b/src/callbacks_step/alive.jl @@ -86,9 +86,14 @@ function (alive_callback::AliveCallback)(integrator) println("─"^100) println() elseif mpi_isroot() + t = integrator.t + t_final = last(integrator.sol.prob.tspan) + sim_time_percentage = t / t_final * 100 runtime_absolute = 1.0e-9 * (time_ns() - alive_callback.start_time) - @printf("#timesteps: %6d │ Δt: %.4e │ sim. time: %.4e │ run time: %.4e s\n", - integrator.stats.naccept, integrator.dt, integrator.t, runtime_absolute) + println(rpad(@sprintf("#timesteps: %6d │ Δt: %.4e │ sim. time: %.4e (%5.3f%%)", + integrator.stats.naccept, integrator.dt, t, + sim_time_percentage), 71) * + @sprintf("│ run time: %.4e s", runtime_absolute)) end # avoid re-evaluating possible FSAL stages diff --git a/src/callbacks_step/analysis.jl b/src/callbacks_step/analysis.jl index fad42b11098..896b51d5193 100644 --- a/src/callbacks_step/analysis.jl +++ b/src/callbacks_step/analysis.jl @@ -232,6 +232,10 @@ function (analysis_callback::AnalysisCallback)(u_ode, du_ode, integrator, semi) @unpack dt, t = integrator iter = integrator.stats.naccept + # Compute the percentage of the simulation that is done + t_final = last(integrator.sol.prob.tspan) + sim_time_percentage = t / t_final * 100 + # Record performance measurements and compute performance index (PID) runtime_since_last_analysis = 1.0e-9 * (time_ns() - analysis_callback.start_time_last_analysis) @@ -291,8 +295,8 @@ function (analysis_callback::AnalysisCallback)(u_ode, du_ode, integrator, semi) " " * " └── GC time: " * @sprintf("%10.8e s (%5.3f%%)", gc_time_absolute, gc_time_percentage)) - mpi_println(" sim. time: " * @sprintf("%10.8e", t) * - " " * + mpi_println(rpad(" sim. time: " * + @sprintf("%10.8e (%5.3f%%)", t, sim_time_percentage), 46) * " time/DOF/rhs!: " * @sprintf("%10.8e s", runtime_relative)) mpi_println(" " * " " * " " * From d303e080d34c07a5299c573955e04045d34201d8 Mon Sep 17 00:00:00 2001 From: Joshua Lampert Date: Fri, 6 Oct 2023 16:50:16 +0200 Subject: [PATCH 2/3] add notes about AnalysisCallback in docs --- docs/src/callbacks.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/src/callbacks.md b/docs/src/callbacks.md index 7f44dfd5925..f018bcf7c39 100644 --- a/docs/src/callbacks.md +++ b/docs/src/callbacks.md @@ -30,6 +30,11 @@ An example elixir using AMR can be found at [`examples/tree_2d_dgsem/elixir_adve The [`AnalysisCallback`](@ref) can be used to analyze the numerical solution, e.g. calculate errors or user-specified integrals, and print the results to the screen. The results can also be saved in a file. An example can be found at [`examples/tree_2d_dgsem/elixir_euler_vortex.jl`](https://github.com/trixi-framework/Trixi.jl/blob/main/examples/tree_2d_dgsem/elixir_euler_vortex.jl). +Note that the errors (e.g. `L2 error` or `Linf error`) are computed with respect to the initial condition. +The percentage of the simulation time refers to the ratio of the current time and the final time, i.e. it does +not consider the maximal number of iterations. So the simulation could finish before 100% are reached. +Note that, e.g., due to AMR or smaller time step sizes, the simulation can actually take longer than +the percentage indicates. In [Performance metrics of the `AnalysisCallback`](@ref performance-metrics) you can find a detailed description of the different performance metrics the `AnalysisCallback` computes. From 0a279e15ff9fe6a09ea093ae8fe467424e61ed3f Mon Sep 17 00:00:00 2001 From: Joshua Lampert Date: Wed, 11 Oct 2023 14:38:23 +0200 Subject: [PATCH 3/3] generalize for general initial time --- src/callbacks_step/alive.jl | 3 ++- src/callbacks_step/analysis.jl | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/callbacks_step/alive.jl b/src/callbacks_step/alive.jl index 8ea637a30fa..9df7181521e 100644 --- a/src/callbacks_step/alive.jl +++ b/src/callbacks_step/alive.jl @@ -87,8 +87,9 @@ function (alive_callback::AliveCallback)(integrator) println() elseif mpi_isroot() t = integrator.t + t_initial = first(integrator.sol.prob.tspan) t_final = last(integrator.sol.prob.tspan) - sim_time_percentage = t / t_final * 100 + sim_time_percentage = (t - t_initial) / (t_final - t_initial) * 100 runtime_absolute = 1.0e-9 * (time_ns() - alive_callback.start_time) println(rpad(@sprintf("#timesteps: %6d │ Δt: %.4e │ sim. time: %.4e (%5.3f%%)", integrator.stats.naccept, integrator.dt, t, diff --git a/src/callbacks_step/analysis.jl b/src/callbacks_step/analysis.jl index 02483fc31d5..e5b4a01a885 100644 --- a/src/callbacks_step/analysis.jl +++ b/src/callbacks_step/analysis.jl @@ -233,8 +233,10 @@ function (analysis_callback::AnalysisCallback)(u_ode, du_ode, integrator, semi) iter = integrator.stats.naccept # Compute the percentage of the simulation that is done + t = integrator.t + t_initial = first(integrator.sol.prob.tspan) t_final = last(integrator.sol.prob.tspan) - sim_time_percentage = t / t_final * 100 + sim_time_percentage = (t - t_initial) / (t_final - t_initial) * 100 # Record performance measurements and compute performance index (PID) runtime_since_last_analysis = 1.0e-9 * (time_ns() -