Skip to content

Commit 824f7a8

Browse files
Time StepCallbacks for custom integrators (trixi-framework#2182)
1 parent 897c1cd commit 824f7a8

File tree

3 files changed

+25
-18
lines changed

3 files changed

+25
-18
lines changed

src/time_integration/methods_2N.jl

+8-6
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,15 @@ function step!(integrator::SimpleIntegrator2N)
189189
integrator.iter += 1
190190
integrator.t += integrator.dt
191191

192-
# handle callbacks
193-
if callbacks isa CallbackSet
194-
foreach(callbacks.discrete_callbacks) do cb
195-
if cb.condition(integrator.u, integrator.t, integrator)
196-
cb.affect!(integrator)
192+
@trixi_timeit timer() "Step-Callbacks" begin
193+
# handle callbacks
194+
if callbacks isa CallbackSet
195+
foreach(callbacks.discrete_callbacks) do cb
196+
if cb.condition(integrator.u, integrator.t, integrator)
197+
cb.affect!(integrator)
198+
end
199+
return nothing
197200
end
198-
return nothing
199201
end
200202
end
201203

src/time_integration/methods_3Sstar.jl

+8-6
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,15 @@ function step!(integrator::SimpleIntegrator3Sstar)
265265
integrator.iter += 1
266266
integrator.t += integrator.dt
267267

268-
# handle callbacks
269-
if callbacks isa CallbackSet
270-
foreach(callbacks.discrete_callbacks) do cb
271-
if cb.condition(integrator.u, integrator.t, integrator)
272-
cb.affect!(integrator)
268+
@trixi_timeit timer() "Step-Callbacks" begin
269+
# handle callbacks
270+
if callbacks isa CallbackSet
271+
foreach(callbacks.discrete_callbacks) do cb
272+
if cb.condition(integrator.u, integrator.t, integrator)
273+
cb.affect!(integrator)
274+
end
275+
return nothing
273276
end
274-
return nothing
275277
end
276278
end
277279

src/time_integration/methods_SSP.jl

+9-6
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ struct SimpleSSPRK33{StageCallbacks} <: SimpleAlgorithmSSP
3939
c = SVector(0.0, 1.0, 1 / 2)
4040

4141
# Butcher tableau
42-
# c | a
42+
# c | A
4343
# 0 |
4444
# 1 | 1
4545
# 1/2 | 1/4 1/4
@@ -208,11 +208,14 @@ function solve!(integrator::SimpleIntegratorSSP)
208208
integrator.iter += 1
209209
integrator.t += integrator.dt
210210

211-
# handle callbacks
212-
if callbacks isa CallbackSet
213-
foreach(callbacks.discrete_callbacks) do cb
214-
if cb.condition(integrator.u, integrator.t, integrator)
215-
cb.affect!(integrator)
211+
@trixi_timeit timer() "Step-Callbacks" begin
212+
# handle callbacks
213+
if callbacks isa CallbackSet
214+
foreach(callbacks.discrete_callbacks) do cb
215+
if cb.condition(integrator.u, integrator.t, integrator)
216+
cb.affect!(integrator)
217+
end
218+
return nothing
216219
end
217220
end
218221
end

0 commit comments

Comments
 (0)