Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SummaryCallback #75

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ SimpleUnPack = "ce78b400-467f-4804-87d8-8f486da07d0a"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
SummationByPartsOperators = "9f78cca6-572e-554e-b819-917d2f1cf240"
TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"

[compat]
DiffEqBase = "6.121"
Expand All @@ -32,4 +33,5 @@ SimpleUnPack = "1.1"
SparseArrays = "1"
StaticArrays = "1"
SummationByPartsOperators = "0.5.41"
TimerOutputs = "0.5"
julia = "1.8"
3 changes: 2 additions & 1 deletion examples/bbm_bbm_1d/bbm_bbm_1d_basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ semi = Semidiscretization(mesh, equations, initial_condition, solver,
# Create `ODEProblem` and run the simulation
tspan = (0.0, 30.0)
ode = semidiscretize(semi, tspan)
summary_callback = SummaryCallback()
analysis_callback = AnalysisCallback(semi; interval = 10,
extra_analysis_errors = (:conservation_error,),
extra_analysis_integrals = (waterheight_total,
velocity, entropy))
callbacks = CallbackSet(analysis_callback)
callbacks = CallbackSet(analysis_callback, summary_callback)

saveat = range(tspan..., length = 100)
sol = solve(ode, Tsit5(), abstol = 1e-7, reltol = 1e-7,
Expand Down
3 changes: 2 additions & 1 deletion examples/bbm_bbm_1d/bbm_bbm_1d_dg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ semi = Semidiscretization(mesh, equations, initial_condition, solver,

tspan = (0.0, 30.0)
ode = semidiscretize(semi, tspan)
summary_callback = SummaryCallback()
analysis_callback = AnalysisCallback(semi; interval = 10,
extra_analysis_errors = (:conservation_error,),
extra_analysis_integrals = (waterheight_total,
velocity, entropy))
callbacks = CallbackSet(analysis_callback)
callbacks = CallbackSet(analysis_callback, summary_callback)

saveat = range(tspan..., length = 100)
sol = solve(ode, Tsit5(), abstol = 1e-7, reltol = 1e-7,
Expand Down
3 changes: 2 additions & 1 deletion examples/bbm_bbm_1d/bbm_bbm_1d_manufactured.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ semi = Semidiscretization(mesh, equations, initial_condition, solver,
# Create `ODEProblem` and run the simulation
tspan = (0.0, 1.0)
ode = semidiscretize(semi, tspan)
summary_callback = SummaryCallback()
analysis_callback = AnalysisCallback(semi; interval = 10,
extra_analysis_errors = (:conservation_error,),
extra_analysis_integrals = (waterheight_total,
velocity, entropy))
callbacks = CallbackSet(analysis_callback)
callbacks = CallbackSet(analysis_callback, summary_callback)

saveat = range(tspan..., length = 100)
sol = solve(ode, Tsit5(), abstol = 1e-7, reltol = 1e-7,
Expand Down
3 changes: 2 additions & 1 deletion examples/bbm_bbm_1d/bbm_bbm_1d_relaxation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ semi = Semidiscretization(mesh, equations, initial_condition, solver,
# Create `ODEProblem` and run the simulation
tspan = (0.0, 30.0)
ode = semidiscretize(semi, tspan)
summary_callback = SummaryCallback()
analysis_callback = AnalysisCallback(semi; interval = 10,
extra_analysis_errors = (:conservation_error,),
extra_analysis_integrals = (waterheight_total,
velocity, entropy))
relaxation_callback = RelaxationCallback(invariant = entropy)
# Always put relaxation_callback before analysis_callback to guarantee conservation of the invariant
callbacks = CallbackSet(relaxation_callback, analysis_callback)
callbacks = CallbackSet(relaxation_callback, analysis_callback, summary_callback)

saveat = range(tspan..., length = 100)
sol = solve(ode, Tsit5(), abstol = 1e-7, reltol = 1e-7,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ semi = Semidiscretization(mesh, equations, initial_condition, solver,
# Create `ODEProblem` and run the simulation
tspan = (0.0, 30.0)
ode = semidiscretize(semi, tspan)
summary_callback = SummaryCallback()
analysis_callback = AnalysisCallback(semi; interval = 10,
extra_analysis_errors = (:conservation_error,),
extra_analysis_integrals = (waterheight_total,
velocity, entropy))
callbacks = CallbackSet(analysis_callback)
callbacks = CallbackSet(analysis_callback, summary_callback)

saveat = range(tspan..., length = 100)
sol = solve(ode, Tsit5(), abstol = 1e-7, reltol = 1e-7,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ semi = Semidiscretization(mesh, equations, initial_condition, solver,
# Create `ODEProblem` and run the simulation
tspan = (0.0, 30.0)
ode = semidiscretize(semi, tspan)
summary_callback = SummaryCallback()
analysis_callback = AnalysisCallback(semi; interval = 10,
extra_analysis_errors = (:conservation_error,),
extra_analysis_integrals = (waterheight_total,
velocity, entropy))
relaxation_callback = RelaxationCallback(invariant = entropy)
# Always put relaxation_callback before analysis_callback to guarantee conservation of the invariant
callbacks = CallbackSet(relaxation_callback, analysis_callback)
callbacks = CallbackSet(relaxation_callback, analysis_callback, summary_callback)

saveat = range(tspan..., length = 100)
sol = solve(ode, Tsit5(), abstol = 1e-7, reltol = 1e-7,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ semi = Semidiscretization(mesh, equations, initial_condition, solver,
# Create `ODEProblem` and run the simulation
tspan = (0.0, 70.0)
ode = semidiscretize(semi, tspan)
summary_callback = SummaryCallback()
analysis_callback = AnalysisCallback(semi; interval = 10,
extra_analysis_errors = (:conservation_error,),
extra_analysis_integrals = (waterheight_total,
velocity, entropy))
callbacks = CallbackSet(analysis_callback)
callbacks = CallbackSet(analysis_callback, summary_callback)

saveat = range(tspan..., length = 500)
sol = solve(ode, Tsit5(), abstol = 1e-7, reltol = 1e-7,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ semi = Semidiscretization(mesh, equations, initial_condition, solver,
# Create `ODEProblem` and run the simulation
tspan = (0.0, 1.0)
ode = semidiscretize(semi, tspan)
summary_callback = SummaryCallback()
analysis_callback = AnalysisCallback(semi; interval = 10,
extra_analysis_errors = (:conservation_error,),
extra_analysis_integrals = (waterheight_total,
velocity, entropy))
callbacks = CallbackSet(analysis_callback)
callbacks = CallbackSet(analysis_callback, summary_callback)

saveat = range(tspan..., length = 100)
sol = solve(ode, Tsit5(), abstol = 1e-7, reltol = 1e-7,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ semi = Semidiscretization(mesh, equations, initial_condition, solver,
# Create `ODEProblem` and run the simulation
tspan = (0.0, 30.0)
ode = semidiscretize(semi, tspan)
summary_callback = SummaryCallback()
analysis_callback = AnalysisCallback(semi; interval = 10,
extra_analysis_errors = (:conservation_error,),
extra_analysis_integrals = (waterheight_total,
velocity, entropy))
relaxation_callback = RelaxationCallback(invariant = entropy)
# Always put relaxation_callback before analysis_callback to guarantee conservation of the invariant
callbacks = CallbackSet(relaxation_callback, analysis_callback)
callbacks = CallbackSet(relaxation_callback, analysis_callback, summary_callback)

saveat = range(tspan..., length = 100)
sol = solve(ode, Tsit5(), abstol = 1e-7, reltol = 1e-7,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ semi = Semidiscretization(mesh, equations, initial_condition, solver,
# Create `ODEProblem` and run the simulation
tspan = (0.0, 30.0)
ode = semidiscretize(semi, tspan)
summary_callback = SummaryCallback()
analysis_callback = AnalysisCallback(semi; interval = 10,
extra_analysis_errors = (:conservation_error,),
extra_analysis_integrals = (waterheight_total,
velocity, entropy))
relaxation_callback = RelaxationCallback(invariant = entropy)
# Always put relaxation_callback before analysis_callback to guarantee conservation of the invariant
callbacks = CallbackSet(relaxation_callback, analysis_callback)
callbacks = CallbackSet(relaxation_callback, analysis_callback, summary_callback)

saveat = range(tspan..., length = 100)
sol = solve(ode, Tsit5(), abstol = 1e-7, reltol = 1e-7,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ semi = Semidiscretization(mesh, equations, initial_condition, solver,
# Create `ODEProblem` and run the simulation
tspan = (0.0, 30.0)
ode = semidiscretize(semi, tspan)
summary_callback = SummaryCallback()
analysis_callback = AnalysisCallback(semi; interval = 10,
extra_analysis_errors = (:conservation_error,),
extra_analysis_integrals = (waterheight_total,
velocity, entropy,
lake_at_rest_error))
# Always put relaxation_callback before analysis_callback to guarantee conservation of the invariant
callbacks = CallbackSet(analysis_callback)
callbacks = CallbackSet(analysis_callback, summary_callback)

dt = 0.5
saveat = range(tspan..., length = 100)
Expand Down
3 changes: 2 additions & 1 deletion examples/svaerd_kalisch_1d/svaerd_kalisch_1d_dingemans.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ semi = Semidiscretization(mesh, equations, initial_condition, solver,
# Create `ODEProblem` and run the simulation
tspan = (0.0, 70.0)
ode = semidiscretize(semi, tspan)
summary_callback = SummaryCallback()
analysis_callback = AnalysisCallback(semi; interval = 10,
extra_analysis_errors = (:conservation_error,),
extra_analysis_integrals = (waterheight_total,
entropy,
entropy_modified))
callbacks = CallbackSet(analysis_callback)
callbacks = CallbackSet(analysis_callback, summary_callback)

saveat = range(tspan..., length = 500)
sol = solve(ode, Tsit5(), abstol = 1e-7, reltol = 1e-7,
Expand Down
3 changes: 2 additions & 1 deletion examples/svaerd_kalisch_1d/svaerd_kalisch_1d_dingemans_cg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ semi = Semidiscretization(mesh, equations, initial_condition, solver,
# Create `ODEProblem` and run the simulation
tspan = (0.0, 70.0)
ode = semidiscretize(semi, tspan)
summary_callback = SummaryCallback()
analysis_callback = AnalysisCallback(semi; interval = 10,
extra_analysis_errors = (:conservation_error,),
extra_analysis_integrals = (waterheight_total,
entropy,
entropy_modified))
callbacks = CallbackSet(analysis_callback)
callbacks = CallbackSet(analysis_callback, summary_callback)

saveat = range(tspan..., length = 500)
sol = solve(ode, Tsit5(), abstol = 1e-7, reltol = 1e-7,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ semi = Semidiscretization(mesh, equations, initial_condition, solver,
# Create `ODEProblem` and run the simulation
tspan = (0.0, 70.0)
ode = semidiscretize(semi, tspan)
summary_callback = SummaryCallback()
analysis_callback = AnalysisCallback(semi; interval = 10,
extra_analysis_errors = (:conservation_error,),
extra_analysis_integrals = (waterheight_total,
entropy,
entropy_modified))
relaxation_callback = RelaxationCallback(invariant = entropy_modified)
# Always put relaxation_callback before analysis_callback to guarantee conservation of the invariant
callbacks = CallbackSet(relaxation_callback, analysis_callback)
callbacks = CallbackSet(relaxation_callback, analysis_callback, summary_callback)

saveat = range(tspan..., length = 500)
sol = solve(ode, Tsit5(), abstol = 1e-7, reltol = 1e-7,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ semi = Semidiscretization(mesh, equations, initial_condition, solver,
# Create `ODEProblem` and run the simulation
tspan = (0.0, 70.0)
ode = semidiscretize(semi, tspan)
summary_callback = SummaryCallback()
analysis_callback = AnalysisCallback(semi; interval = 10,
extra_analysis_errors = (:conservation_error,),
extra_analysis_integrals = (waterheight_total,
entropy,
entropy_modified))

callbacks = CallbackSet(analysis_callback)
callbacks = CallbackSet(analysis_callback, summary_callback)

saveat = range(tspan..., length = 500)
sol = solve(ode, Tsit5(), abstol = 1e-7, reltol = 1e-7,
Expand Down
3 changes: 2 additions & 1 deletion examples/svaerd_kalisch_1d/svaerd_kalisch_1d_manufactured.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ semi = Semidiscretization(mesh, equations, initial_condition, solver,
# Create `ODEProblem` and run the simulation
tspan = (0.0, 1.0)
ode = semidiscretize(semi, tspan)
summary_callback = SummaryCallback()
analysis_callback = AnalysisCallback(semi; interval = 10,
extra_analysis_errors = (:conservation_error,),
extra_analysis_integrals = (waterheight_total,
velocity, entropy))
callbacks = CallbackSet(analysis_callback)
callbacks = CallbackSet(analysis_callback, summary_callback)

saveat = range(tspan..., length = 100)
sol = solve(ode, Tsit5(), abstol = 1e-7, reltol = 1e-7,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ semi = Semidiscretization(mesh, equations, initial_condition, solver,
# Create `ODEProblem` and run the simulation
tspan = (0.0, 10.0)
ode = semidiscretize(semi, tspan)
summary_callback = SummaryCallback()
analysis_callback = AnalysisCallback(semi; interval = 10,
extra_analysis_errors = (:conservation_error,),
extra_analysis_integrals = (waterheight_total,
momentum, entropy,
lake_at_rest_error))
callbacks = CallbackSet(analysis_callback)
callbacks = CallbackSet(analysis_callback, summary_callback)

# Need a very small time step for stability
dt = 0.0002
Expand Down
3 changes: 2 additions & 1 deletion src/DispersiveShallowWater.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ using SummationByPartsOperators: AbstractDerivativeOperator,
periodic_derivative_operator,
derivative_order, integrate
import SummationByPartsOperators: grid, xmin, xmax
using TimerOutputs: TimerOutputs, TimerOutput, @timeit, print_timer, reset_timer!

include("boundary_conditions.jl")
include("mesh.jl")
Expand Down Expand Up @@ -52,7 +53,7 @@ export initial_condition_convergence_test,
initial_condition_manufactured, source_terms_manufactured,
initial_condition_dingemans

export AnalysisCallback, RelaxationCallback
export AnalysisCallback, RelaxationCallback, SummaryCallback
export tstops, errors, integrals

end
Loading