Skip to content

Commit

Permalink
timer for step callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielDoehring committed Mar 18, 2024
1 parent a1da64e commit e804a63
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
11 changes: 5 additions & 6 deletions examples/tree_1d_dgsem/elixir_advection_PERK2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergen
# ODE solvers, callbacks etc.

# Create ODE problem with time span from 0.0 to 1.0
ode = semidiscretize(semi, (0.0, 1.0));
tspan = (0.0, 1.0)
ode = semidiscretize(semi, tspan);

# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup
# and resets the timers
Expand All @@ -50,11 +51,9 @@ callbacks = CallbackSet(summary_callback,
###############################################################################
# run the simulation

# Define tspan to calculate maximum time step allowed for the bisection algorithm used in calculate polynomial coefficients in ODE algorithm
tspan = (0.0, 1.0)

# Construct second order PERK method with 6 stages for
# given simulation setup
# Construct second order PERK method with 6 stages for given simulation setup.
# Pass `tspan` to calculate maximum time step allowed for the bisection algorithm used
# in calculating the polynomial coefficients in the ODE algorithm.
ode_algorithm = PERK2(6, tspan, semi)

sol = Trixi.solve(ode, ode_algorithm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,15 @@ function solve!(integrator::PERK2Integrator)
integrator.iter += 1
integrator.t += integrator.dt

# handle callbacks
if callbacks isa CallbackSet
foreach(callbacks.discrete_callbacks) do cb
if cb.condition(integrator.u, integrator.t, integrator)
cb.affect!(integrator)
@trixi_timeit timer() "Step-Callbacks" begin
# handle callbacks
if callbacks isa CallbackSet
foreach(callbacks.discrete_callbacks) do cb
if cb.condition(integrator.u, integrator.t, integrator)
cb.affect!(integrator)
end
return nothing
end
return nothing
end
end

Expand Down

0 comments on commit e804a63

Please sign in to comment.