From a975a25fb8465de0f61d3bb8aa31df823368aec8 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Wed, 15 Mar 2023 18:39:32 +0200 Subject: [PATCH 001/102] Create test.jl --- docs/literate/src/files/test.jl | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/literate/src/files/test.jl diff --git a/docs/literate/src/files/test.jl b/docs/literate/src/files/test.jl new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/docs/literate/src/files/test.jl @@ -0,0 +1 @@ + From 4680a7e8db55d4ece3dd0320ad90e0dfb4909738 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Wed, 15 Mar 2023 18:51:43 +0200 Subject: [PATCH 002/102] Delete test.jl --- docs/literate/src/files/test.jl | 1 - 1 file changed, 1 deletion(-) delete mode 100644 docs/literate/src/files/test.jl diff --git a/docs/literate/src/files/test.jl b/docs/literate/src/files/test.jl deleted file mode 100644 index 8b137891791..00000000000 --- a/docs/literate/src/files/test.jl +++ /dev/null @@ -1 +0,0 @@ - From ff59a97b81c30528c963db67f7f451066cc9af76 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Thu, 13 Jul 2023 22:11:30 +0300 Subject: [PATCH 003/102] loadcallback --- Project.toml | 1 + src/Trixi.jl | 4 +- src/callbacks_step/callbacks_step.jl | 1 + src/callbacks_step/load_restart.jl | 84 +++++++++++++++++++++++++++ src/callbacks_step/save_restart.jl | 3 + src/callbacks_step/save_restart_dg.jl | 33 +++++++++++ 6 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 src/callbacks_step/load_restart.jl diff --git a/Project.toml b/Project.toml index 828f4778f74..7b5bc81606e 100644 --- a/Project.toml +++ b/Project.toml @@ -19,6 +19,7 @@ MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" MuladdMacro = "46d2c3a1-f734-5fdb-9937-b9b9aeba4221" Octavian = "6fd5a793-0b7e-452c-907f-f8bfe9c57db4" OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" +OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" P4est = "7d669430-f675-4ae7-b43e-fab78ec5a902" Polyester = "f517fe37-dbe3-4b94-8317-1923a5111588" PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" diff --git a/src/Trixi.jl b/src/Trixi.jl index 66878f4b459..957cec39736 100644 --- a/src/Trixi.jl +++ b/src/Trixi.jl @@ -30,7 +30,7 @@ using Reexport: @reexport # MPI needs to be imported before HDF5 to be able to use parallel HDF5 # as long as HDF5.jl uses Requires.jl to enable parallel HDF5 with MPI using MPI: MPI - +using OrdinaryDiffEq using SciMLBase: CallbackSet, DiscreteCallback, ODEProblem, ODESolution, ODEFunction, SplitODEProblem @@ -239,7 +239,7 @@ export SummaryCallback, SteadyStateCallback, AnalysisCallback, AliveCallback, AveragingCallback, AMRCallback, StepsizeCallback, GlmSpeedCallback, LBMCollisionCallback, EulerAcousticsCouplingCallback, - TrivialCallback, AnalysisCallbackCoupled + TrivialCallback, AnalysisCallbackCoupled, LoadRestartCallback export load_mesh, load_time diff --git a/src/callbacks_step/callbacks_step.jl b/src/callbacks_step/callbacks_step.jl index 09d197bf225..7195bb7a260 100644 --- a/src/callbacks_step/callbacks_step.jl +++ b/src/callbacks_step/callbacks_step.jl @@ -54,6 +54,7 @@ include("steady_state.jl") include("analysis.jl") include("alive.jl") include("save_restart.jl") +include("load_restart.jl") include("save_solution.jl") include("time_series.jl") include("visualization.jl") diff --git a/src/callbacks_step/load_restart.jl b/src/callbacks_step/load_restart.jl new file mode 100644 index 00000000000..52b17b5a54c --- /dev/null +++ b/src/callbacks_step/load_restart.jl @@ -0,0 +1,84 @@ +# By default, Julia/LLVM does not use fused multiply-add operations (FMAs). +# Since these FMAs can increase the performance of many numerical algorithms, +# we need to opt-in explicitly. +# See https://ranocha.de/blog/Optimizing_EC_Trixi for further details. +@muladd begin + +#! format: noindent + + +mutable struct LoadRestartCallback + restart_file::String +end + +function Base.show(io::IO, cb::DiscreteCallback{<:Any, <:LoadRestartCallback}) + @nospecialize cb # reduce precompilation time + + load_callback = cb.affect! + print(io, "LoadRestartCallback(restart file=", load_callback.restart_file, ")") +end + +function Base.show(io::IO, ::MIME"text/plain", + cb::DiscreteCallback{<:Any, <:LoadRestartCallback}) + @nospecialize cb # reduce precompilation time + + if get(io, :compact, false) + show(io, cb) + else + save_load_callback = cb.affect! + setup = [ + "restart file" => save_load_callback.restart_file] + summary_box(io, "LoadRestartCallback", setup) + end +end + +function LoadRestartCallback(; restart_file="out.h5") + load_callback = LoadRestartCallback(restart_file) + + DiscreteCallback(load_callback, load_callback, # the first one is the condition, the second the affect! + save_positions = (false, false), + initialize = initialize!) +end + +function initialize!(cb::DiscreteCallback{Condition, Affect!}, u, t, + integrator) where {Condition, Affect! <: LoadRestartCallback} + load_callback = cb.affect! + if integrator.opts.adaptive + load_integrator!(load_callback.restart_file, integrator, integrator.opts.controller, integrator.alg) + end + return nothing +end + + +function load_integrator!(restart_file::String, integrator, controller::PIController, alg) + h5open(restart_file, "r") do file + integrator.qold=read(attributes(file)["qold"]) + integrator.dt=read(attributes(file)["dtpropose"]) + end +end + +function load_integrator!(restart_file::String, integrator, controller::PIDController, alg) + h5open(restart_file, "r") do file + integrator.qold=read(attributes(file)["qold"]) + integrator.dt=read(attributes(file)["dtpropose"]) + err=read(file["controller_err"]) + controller.err[1]=err[1] + controller.err[2]=err[2] + controller.err[3]=err[3] + end +end + +function load_integrator!(restart_file::String, integrator, controller, alg) + h5open(restart_file, "r") do file + integrator.dt=read(attributes(file)["dtpropose"]) + end +end + +# this method is called to determine whether the callback should be activated +(load_callback::LoadRestartCallback)(u, t, integrator) = false + +# this method is called when the callback is activated +(load_callback::LoadRestartCallback)(integrator) = nothing + + +end # @muladd diff --git a/src/callbacks_step/save_restart.jl b/src/callbacks_step/save_restart.jl index e23f58f26ea..44fff16a5d7 100644 --- a/src/callbacks_step/save_restart.jl +++ b/src/callbacks_step/save_restart.jl @@ -105,6 +105,9 @@ function (restart_callback::SaveRestartCallback)(integrator) end save_restart_file(u_ode, t, dt, iter, semi, restart_callback) + if integrator.opts.adaptive + save_restart_controller(integrator, integrator.opts.controller, restart_callback) + end end # avoid re-evaluating possible FSAL stages diff --git a/src/callbacks_step/save_restart_dg.jl b/src/callbacks_step/save_restart_dg.jl index 5695eb8bede..57938150406 100644 --- a/src/callbacks_step/save_restart_dg.jl +++ b/src/callbacks_step/save_restart_dg.jl @@ -326,4 +326,37 @@ function load_restart_file_on_root(mesh::Union{ParallelTreeMesh, ParallelP4estMe return u_ode end + +function save_restart_controller(integrator, controller::PIController, restart_callback) + @unpack output_directory = restart_callback + timestep = integrator.stats.naccept + filename = joinpath(output_directory, @sprintf("restart_%06d.h5", timestep)) + # Open file (preserve existing content) + h5open(filename, "cw") do file + attributes(file)["qold"] = integrator.qold + attributes(file)["dtpropose"] = integrator.dtpropose + end +end + +function save_restart_controller(integrator, controller::PIDController, restart_callback) + @unpack output_directory = restart_callback + timestep = integrator.stats.naccept + filename = joinpath(output_directory, @sprintf("restart_%06d.h5", timestep)) + # Open file (preserve existing content) + h5open(filename, "cw") do file + attributes(file)["qold"] = integrator.qold + attributes(file)["dtpropose"] = integrator.dtpropose + file["controller_err"]=controller.err + end +end + +function save_restart_controller(integrator, controller, restart_callback) + @unpack output_directory = restart_callback + timestep = integrator.stats.naccept + filename = joinpath(output_directory, @sprintf("restart_%06d.h5", timestep)) + # Open file (preserve existing content) + h5open(filename, "cw") do file + attributes(file)["dtpropose"] = integrator.dtpropose + end +end end # @muladd From 68f35985359856d6063170010ab00535576d19f0 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Fri, 14 Jul 2023 19:41:29 +0300 Subject: [PATCH 004/102] adding_parallel_support --- src/callbacks_step/load_restart.jl | 49 +++++++++++++++++++++------ src/callbacks_step/save_restart.jl | 2 +- src/callbacks_step/save_restart_dg.jl | 10 ++++++ 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/src/callbacks_step/load_restart.jl b/src/callbacks_step/load_restart.jl index 52b17b5a54c..18518302cd3 100644 --- a/src/callbacks_step/load_restart.jl +++ b/src/callbacks_step/load_restart.jl @@ -51,20 +51,39 @@ end function load_integrator!(restart_file::String, integrator, controller::PIController, alg) - h5open(restart_file, "r") do file - integrator.qold=read(attributes(file)["qold"]) - integrator.dt=read(attributes(file)["dtpropose"]) + if mpi_isroot() + h5open(restart_file, "r") do file + integrator.qold=read(attributes(file)["qold"]) + integrator.dt=read(attributes(file)["dtpropose"]) + end + end + if mpi_isparallel() + recv_buf = [integrator.qold, integrator.dt] + MPI.Bcast!(recv_buf, mpi_root(), mpi_comm()) + integrator.qold, integrator.dt = recv_buf end end function load_integrator!(restart_file::String, integrator, controller::PIDController, alg) - h5open(restart_file, "r") do file - integrator.qold=read(attributes(file)["qold"]) - integrator.dt=read(attributes(file)["dtpropose"]) - err=read(file["controller_err"]) - controller.err[1]=err[1] - controller.err[2]=err[2] - controller.err[3]=err[3] + if mpi_isroot() + h5open(restart_file, "r") do file + integrator.qold=read(attributes(file)["qold"]) + integrator.dt=read(attributes(file)["dtpropose"]) + err=read(file["controller_err"]) + controller.err[1]=err[1] + controller.err[2]=err[2] + controller.err[3]=err[3] + end + end + if mpi_isparallel() + recv_buf = [integrator.qold, integrator.dt] + append!(recv_buf, controller.err) + MPI.Bcast!(recv_buf, mpi_root(), mpi_comm()) + integrator.qold = recv_buf[1] + integrator.dt = recv_buf[2] + controller.err[1] = recv_buf[3] + controller.err[2] = recv_buf[4] + controller.err[3] = recv_buf[5] end end @@ -72,6 +91,16 @@ function load_integrator!(restart_file::String, integrator, controller, alg) h5open(restart_file, "r") do file integrator.dt=read(attributes(file)["dtpropose"]) end + if mpi_isroot() + h5open(restart_file, "r") do file + integrator.dt=read(attributes(file)["dtpropose"]) + end + end + if mpi_isparallel() + recv_buf = [integrator.dt] + MPI.Bcast!(recv_buf, mpi_root(), mpi_comm()) + integrator.dt = recv_buf[1] + end end # this method is called to determine whether the callback should be activated diff --git a/src/callbacks_step/save_restart.jl b/src/callbacks_step/save_restart.jl index 44fff16a5d7..58bbffc8fc3 100644 --- a/src/callbacks_step/save_restart.jl +++ b/src/callbacks_step/save_restart.jl @@ -106,7 +106,7 @@ function (restart_callback::SaveRestartCallback)(integrator) save_restart_file(u_ode, t, dt, iter, semi, restart_callback) if integrator.opts.adaptive - save_restart_controller(integrator, integrator.opts.controller, restart_callback) + save_restart_controller(mesh,integrator, integrator.opts.controller, restart_callback) end end diff --git a/src/callbacks_step/save_restart_dg.jl b/src/callbacks_step/save_restart_dg.jl index 57938150406..17882823656 100644 --- a/src/callbacks_step/save_restart_dg.jl +++ b/src/callbacks_step/save_restart_dg.jl @@ -327,6 +327,16 @@ function load_restart_file_on_root(mesh::Union{ParallelTreeMesh, ParallelP4estMe return u_ode end +function save_restart_controller(mesh, integrator, + controller, restart_callback) + if mpi_isroot() + save_restart_controller(integrator, controller, restart_callback) + end + if mpi_isparallel() + MPI.Barrier(mpi_comm()) + end +end + function save_restart_controller(integrator, controller::PIController, restart_callback) @unpack output_directory = restart_callback timestep = integrator.stats.naccept From 5354faf8f7cb88a74f898f6913397427f936778f Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Fri, 21 Jul 2023 15:35:10 +0300 Subject: [PATCH 005/102] formatting --- src/callbacks_step/load_restart.jl | 185 +++++++++++++------------- src/callbacks_step/save_restart.jl | 3 +- src/callbacks_step/save_restart_dg.jl | 5 +- 3 files changed, 97 insertions(+), 96 deletions(-) diff --git a/src/callbacks_step/load_restart.jl b/src/callbacks_step/load_restart.jl index 18518302cd3..d5154024cc0 100644 --- a/src/callbacks_step/load_restart.jl +++ b/src/callbacks_step/load_restart.jl @@ -4,110 +4,109 @@ # See https://ranocha.de/blog/Optimizing_EC_Trixi for further details. @muladd begin -#! format: noindent + #! format: noindent - -mutable struct LoadRestartCallback - restart_file::String -end - -function Base.show(io::IO, cb::DiscreteCallback{<:Any, <:LoadRestartCallback}) - @nospecialize cb # reduce precompilation time - - load_callback = cb.affect! - print(io, "LoadRestartCallback(restart file=", load_callback.restart_file, ")") -end - -function Base.show(io::IO, ::MIME"text/plain", - cb::DiscreteCallback{<:Any, <:LoadRestartCallback}) - @nospecialize cb # reduce precompilation time - - if get(io, :compact, false) - show(io, cb) - else - save_load_callback = cb.affect! - setup = [ - "restart file" => save_load_callback.restart_file] - summary_box(io, "LoadRestartCallback", setup) + mutable struct LoadRestartCallback + restart_file::String end -end -function LoadRestartCallback(; restart_file="out.h5") - load_callback = LoadRestartCallback(restart_file) + function Base.show(io::IO, cb::DiscreteCallback{<:Any, <:LoadRestartCallback}) + @nospecialize cb # reduce precompilation time - DiscreteCallback(load_callback, load_callback, # the first one is the condition, the second the affect! - save_positions = (false, false), - initialize = initialize!) -end + load_callback = cb.affect! + print(io, "LoadRestartCallback(restart file=", load_callback.restart_file, ")") + end -function initialize!(cb::DiscreteCallback{Condition, Affect!}, u, t, - integrator) where {Condition, Affect! <: LoadRestartCallback} - load_callback = cb.affect! - if integrator.opts.adaptive - load_integrator!(load_callback.restart_file, integrator, integrator.opts.controller, integrator.alg) - end - return nothing -end + function Base.show(io::IO, ::MIME"text/plain", + cb::DiscreteCallback{<:Any, <:LoadRestartCallback}) + @nospecialize cb # reduce precompilation time + + if get(io, :compact, false) + show(io, cb) + else + save_load_callback = cb.affect! + setup = [ + "restart file" => save_load_callback.restart_file] + summary_box(io, "LoadRestartCallback", setup) + end + end + function LoadRestartCallback(; restart_file = "out.h5") + load_callback = LoadRestartCallback(restart_file) -function load_integrator!(restart_file::String, integrator, controller::PIController, alg) - if mpi_isroot() - h5open(restart_file, "r") do file - integrator.qold=read(attributes(file)["qold"]) - integrator.dt=read(attributes(file)["dtpropose"]) - end - end - if mpi_isparallel() - recv_buf = [integrator.qold, integrator.dt] - MPI.Bcast!(recv_buf, mpi_root(), mpi_comm()) - integrator.qold, integrator.dt = recv_buf - end -end + DiscreteCallback(load_callback, load_callback, # the first one is the condition, the second the affect! + save_positions = (false, false), + initialize = initialize!) + end -function load_integrator!(restart_file::String, integrator, controller::PIDController, alg) - if mpi_isroot() - h5open(restart_file, "r") do file - integrator.qold=read(attributes(file)["qold"]) - integrator.dt=read(attributes(file)["dtpropose"]) - err=read(file["controller_err"]) - controller.err[1]=err[1] - controller.err[2]=err[2] - controller.err[3]=err[3] - end - end - if mpi_isparallel() - recv_buf = [integrator.qold, integrator.dt] - append!(recv_buf, controller.err) - MPI.Bcast!(recv_buf, mpi_root(), mpi_comm()) - integrator.qold = recv_buf[1] - integrator.dt = recv_buf[2] - controller.err[1] = recv_buf[3] - controller.err[2] = recv_buf[4] - controller.err[3] = recv_buf[5] - end -end + function initialize!(cb::DiscreteCallback{Condition, Affect!}, u, t, + integrator) where {Condition, Affect! <: LoadRestartCallback} + load_callback = cb.affect! + if integrator.opts.adaptive + load_integrator!(load_callback.restart_file, integrator, + integrator.opts.controller, integrator.alg) + end + return nothing + end -function load_integrator!(restart_file::String, integrator, controller, alg) - h5open(restart_file, "r") do file - integrator.dt=read(attributes(file)["dtpropose"]) - end - if mpi_isroot() - h5open(restart_file, "r") do file - integrator.dt=read(attributes(file)["dtpropose"]) - end - end - if mpi_isparallel() - recv_buf = [integrator.dt] - MPI.Bcast!(recv_buf, mpi_root(), mpi_comm()) - integrator.dt = recv_buf[1] - end -end + function load_integrator!(restart_file::String, integrator, controller::PIController, + alg) + if mpi_isroot() + h5open(restart_file, "r") do file + integrator.qold = read(attributes(file)["qold"]) + integrator.dt = read(attributes(file)["dtpropose"]) + end + end + if mpi_isparallel() + recv_buf = [integrator.qold, integrator.dt] + MPI.Bcast!(recv_buf, mpi_root(), mpi_comm()) + integrator.qold, integrator.dt = recv_buf + end + end -# this method is called to determine whether the callback should be activated -(load_callback::LoadRestartCallback)(u, t, integrator) = false + function load_integrator!(restart_file::String, integrator, controller::PIDController, + alg) + if mpi_isroot() + h5open(restart_file, "r") do file + integrator.qold = read(attributes(file)["qold"]) + integrator.dt = read(attributes(file)["dtpropose"]) + err = read(file["controller_err"]) + controller.err[1] = err[1] + controller.err[2] = err[2] + controller.err[3] = err[3] + end + end + if mpi_isparallel() + recv_buf = [integrator.qold, integrator.dt] + append!(recv_buf, controller.err) + MPI.Bcast!(recv_buf, mpi_root(), mpi_comm()) + integrator.qold = recv_buf[1] + integrator.dt = recv_buf[2] + controller.err[1] = recv_buf[3] + controller.err[2] = recv_buf[4] + controller.err[3] = recv_buf[5] + end + end -# this method is called when the callback is activated -(load_callback::LoadRestartCallback)(integrator) = nothing + function load_integrator!(restart_file::String, integrator, controller, alg) + h5open(restart_file, "r") do file + integrator.dt = read(attributes(file)["dtpropose"]) + end + if mpi_isroot() + h5open(restart_file, "r") do file + integrator.dt = read(attributes(file)["dtpropose"]) + end + end + if mpi_isparallel() + recv_buf = [integrator.dt] + MPI.Bcast!(recv_buf, mpi_root(), mpi_comm()) + integrator.dt = recv_buf[1] + end + end + # this method is called to determine whether the callback should be activated + (load_callback::LoadRestartCallback)(u, t, integrator) = false + # this method is called when the callback is activated + (load_callback::LoadRestartCallback)(integrator) = nothing end # @muladd diff --git a/src/callbacks_step/save_restart.jl b/src/callbacks_step/save_restart.jl index 68fffca0322..81918613b33 100644 --- a/src/callbacks_step/save_restart.jl +++ b/src/callbacks_step/save_restart.jl @@ -106,7 +106,8 @@ function (restart_callback::SaveRestartCallback)(integrator) save_restart_file(u_ode, t, dt, iter, semi, restart_callback) if integrator.opts.adaptive - save_restart_controller(mesh,integrator, integrator.opts.controller, restart_callback) + save_restart_controller(mesh, integrator, integrator.opts.controller, + restart_callback) end end diff --git a/src/callbacks_step/save_restart_dg.jl b/src/callbacks_step/save_restart_dg.jl index 17882823656..a3bf56e39f2 100644 --- a/src/callbacks_step/save_restart_dg.jl +++ b/src/callbacks_step/save_restart_dg.jl @@ -348,7 +348,8 @@ function save_restart_controller(integrator, controller::PIController, restart_c end end -function save_restart_controller(integrator, controller::PIDController, restart_callback) +function save_restart_controller(integrator, controller::PIDController, + restart_callback) @unpack output_directory = restart_callback timestep = integrator.stats.naccept filename = joinpath(output_directory, @sprintf("restart_%06d.h5", timestep)) @@ -356,7 +357,7 @@ function save_restart_controller(integrator, controller::PIDController, restart_ h5open(filename, "cw") do file attributes(file)["qold"] = integrator.qold attributes(file)["dtpropose"] = integrator.dtpropose - file["controller_err"]=controller.err + file["controller_err"] = controller.err end end From 163a9b9737bab2fdf9f106e69ef352d7848a7ab1 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Fri, 28 Jul 2023 11:00:30 +0300 Subject: [PATCH 006/102] minimize dependencies --- src/Trixi.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Trixi.jl b/src/Trixi.jl index 0cf4c909e0e..cf03f6dacf6 100644 --- a/src/Trixi.jl +++ b/src/Trixi.jl @@ -30,7 +30,7 @@ using Reexport: @reexport # MPI needs to be imported before HDF5 to be able to use parallel HDF5 # as long as HDF5.jl uses Requires.jl to enable parallel HDF5 with MPI using MPI: MPI -using OrdinaryDiffEq +using OrdinaryDiffEq: IController, PIController, PIDController using SciMLBase: CallbackSet, DiscreteCallback, ODEProblem, ODESolution, ODEFunction, SplitODEProblem From dd6bd1a95682d6dcf8821464e449835cb6cf4e78 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Sun, 30 Jul 2023 12:41:43 +0300 Subject: [PATCH 007/102] combine loadrestart and saverestart --- .../elixir_euler_density_wave_extended.jl | 55 +++++++++ .../elixir_euler_density_wave_restart.jl | 44 +++++++ src/Trixi.jl | 6 +- src/callbacks_step/load_restart.jl | 112 ------------------ src/callbacks_step/save_restart.jl | 53 +++++++++ src/callbacks_step/save_restart_dg.jl | 15 ++- test/test_mpi_tree.jl | 15 +++ test/test_tree_2d_euler.jl | 13 ++ 8 files changed, 193 insertions(+), 120 deletions(-) create mode 100644 examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl create mode 100644 examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl delete mode 100644 src/callbacks_step/load_restart.jl diff --git a/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl b/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl new file mode 100644 index 00000000000..426fe01484a --- /dev/null +++ b/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl @@ -0,0 +1,55 @@ + +using OrdinaryDiffEq +using Trixi + +############################################################################### +# semidiscretization of the compressible Euler equations +gamma = 1.4 +equations = CompressibleEulerEquations2D(gamma) + +initial_condition = initial_condition_density_wave + +solver = DGSEM(polydeg = 5, surface_flux = flux_central) + +coordinates_min = (-1.0, -1.0) +coordinates_max = (1.0, 1.0) +mesh = TreeMesh(coordinates_min, coordinates_max, + initial_refinement_level = 2, + n_cells_max = 30_000) + +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + +############################################################################### +# ODE solvers, callbacks etc. + +tspan = (0.0, 4.0) +ode = semidiscretize(semi, tspan) + +summary_callback = SummaryCallback() + +analysis_interval = 100 +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) + +alive_callback = AliveCallback(analysis_interval = analysis_interval) + +save_restart = SaveRestartCallback(interval = 1000, + save_final_restart = false) + +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) + +stepsize_callback = StepsizeCallback(cfl = 1.6) + +callbacks = CallbackSet(summary_callback, + analysis_callback, alive_callback, + save_restart, save_solution, + stepsize_callback) + +############################################################################### +# run the simulation + +sol = solve(ode, SSPRK43(); + ode_default_options()..., callback = callbacks); +summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl b/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl new file mode 100644 index 00000000000..c03b0e2296a --- /dev/null +++ b/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl @@ -0,0 +1,44 @@ + +using OrdinaryDiffEq +using Trixi + +############################################################################### +# create a restart file + +trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_euler_density_wave_extended.jl"), + tspan = (0.0, 2.0)) + +############################################################################### +# adapt the parameters that have changed compared to "elixir_euler_density_wave_extended.jl" + +# Note: If you get a restart file from somewhere else, you need to provide +# appropriate setups in the elixir loading a restart file + +restart_filename = joinpath("out", "restart_001000.h5") +mesh = load_mesh(restart_filename) + +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + +tspan = (load_time(restart_filename), 4.0) +dt = load_dt(restart_filename) +ode = semidiscretize(semi, tspan, restart_filename); + +# Do not overwrite the initial snapshot written by elixir_euler_density_wave_extended.jl. +save_solution.condition.save_initial_solution = false + +alg = SSPRK43() +integrator = init(ode, alg, + dt = dt; # solve needs some value here but it will be overwritten by the stepsize_callback + save_everystep = false, callback = callbacks, ode_default_options()...) +load_controller!(integrator, restart_filename) + +# Get the last time index and work with that. +integrator.iter = load_timestep(restart_filename) +integrator.stats.naccept = integrator.iter + +############################################################################### +# run the simulation + +sol = solve!(integrator) + +summary_callback() # print the timer summary diff --git a/src/Trixi.jl b/src/Trixi.jl index cf03f6dacf6..2c6a9a9efcc 100644 --- a/src/Trixi.jl +++ b/src/Trixi.jl @@ -30,7 +30,7 @@ using Reexport: @reexport # MPI needs to be imported before HDF5 to be able to use parallel HDF5 # as long as HDF5.jl uses Requires.jl to enable parallel HDF5 with MPI using MPI: MPI -using OrdinaryDiffEq: IController, PIController, PIDController +using OrdinaryDiffEq: IController, PIController, PIDController using SciMLBase: CallbackSet, DiscreteCallback, ODEProblem, ODESolution, ODEFunction, SplitODEProblem @@ -245,9 +245,9 @@ export SummaryCallback, SteadyStateCallback, AnalysisCallback, AliveCallback, AveragingCallback, AMRCallback, StepsizeCallback, GlmSpeedCallback, LBMCollisionCallback, EulerAcousticsCouplingCallback, - TrivialCallback, AnalysisCallbackCoupled, LoadRestartCallback + TrivialCallback, AnalysisCallbackCoupled -export load_mesh, load_time, load_timestep, load_dt +export load_mesh, load_time, load_timestep, load_dt, load_controller! export ControllerThreeLevel, ControllerThreeLevelCombined, IndicatorLöhner, IndicatorLoehner, IndicatorMax, diff --git a/src/callbacks_step/load_restart.jl b/src/callbacks_step/load_restart.jl deleted file mode 100644 index d5154024cc0..00000000000 --- a/src/callbacks_step/load_restart.jl +++ /dev/null @@ -1,112 +0,0 @@ -# By default, Julia/LLVM does not use fused multiply-add operations (FMAs). -# Since these FMAs can increase the performance of many numerical algorithms, -# we need to opt-in explicitly. -# See https://ranocha.de/blog/Optimizing_EC_Trixi for further details. -@muladd begin - - #! format: noindent - - mutable struct LoadRestartCallback - restart_file::String - end - - function Base.show(io::IO, cb::DiscreteCallback{<:Any, <:LoadRestartCallback}) - @nospecialize cb # reduce precompilation time - - load_callback = cb.affect! - print(io, "LoadRestartCallback(restart file=", load_callback.restart_file, ")") - end - - function Base.show(io::IO, ::MIME"text/plain", - cb::DiscreteCallback{<:Any, <:LoadRestartCallback}) - @nospecialize cb # reduce precompilation time - - if get(io, :compact, false) - show(io, cb) - else - save_load_callback = cb.affect! - setup = [ - "restart file" => save_load_callback.restart_file] - summary_box(io, "LoadRestartCallback", setup) - end - end - - function LoadRestartCallback(; restart_file = "out.h5") - load_callback = LoadRestartCallback(restart_file) - - DiscreteCallback(load_callback, load_callback, # the first one is the condition, the second the affect! - save_positions = (false, false), - initialize = initialize!) - end - - function initialize!(cb::DiscreteCallback{Condition, Affect!}, u, t, - integrator) where {Condition, Affect! <: LoadRestartCallback} - load_callback = cb.affect! - if integrator.opts.adaptive - load_integrator!(load_callback.restart_file, integrator, - integrator.opts.controller, integrator.alg) - end - return nothing - end - - function load_integrator!(restart_file::String, integrator, controller::PIController, - alg) - if mpi_isroot() - h5open(restart_file, "r") do file - integrator.qold = read(attributes(file)["qold"]) - integrator.dt = read(attributes(file)["dtpropose"]) - end - end - if mpi_isparallel() - recv_buf = [integrator.qold, integrator.dt] - MPI.Bcast!(recv_buf, mpi_root(), mpi_comm()) - integrator.qold, integrator.dt = recv_buf - end - end - - function load_integrator!(restart_file::String, integrator, controller::PIDController, - alg) - if mpi_isroot() - h5open(restart_file, "r") do file - integrator.qold = read(attributes(file)["qold"]) - integrator.dt = read(attributes(file)["dtpropose"]) - err = read(file["controller_err"]) - controller.err[1] = err[1] - controller.err[2] = err[2] - controller.err[3] = err[3] - end - end - if mpi_isparallel() - recv_buf = [integrator.qold, integrator.dt] - append!(recv_buf, controller.err) - MPI.Bcast!(recv_buf, mpi_root(), mpi_comm()) - integrator.qold = recv_buf[1] - integrator.dt = recv_buf[2] - controller.err[1] = recv_buf[3] - controller.err[2] = recv_buf[4] - controller.err[3] = recv_buf[5] - end - end - - function load_integrator!(restart_file::String, integrator, controller, alg) - h5open(restart_file, "r") do file - integrator.dt = read(attributes(file)["dtpropose"]) - end - if mpi_isroot() - h5open(restart_file, "r") do file - integrator.dt = read(attributes(file)["dtpropose"]) - end - end - if mpi_isparallel() - recv_buf = [integrator.dt] - MPI.Bcast!(recv_buf, mpi_root(), mpi_comm()) - integrator.dt = recv_buf[1] - end - end - - # this method is called to determine whether the callback should be activated - (load_callback::LoadRestartCallback)(u, t, integrator) = false - - # this method is called when the callback is activated - (load_callback::LoadRestartCallback)(integrator) = nothing -end # @muladd diff --git a/src/callbacks_step/save_restart.jl b/src/callbacks_step/save_restart.jl index 81918613b33..7dd2795439e 100644 --- a/src/callbacks_step/save_restart.jl +++ b/src/callbacks_step/save_restart.jl @@ -160,5 +160,58 @@ function load_restart_file(semi::AbstractSemidiscretization, restart_file) load_restart_file(mesh_equations_solver_cache(semi)..., restart_file) end +function load_controller!(integrator, restart_file::AbstractString) + controller_type = "" + h5open(restart_file, "r") do file + if "controller_type" in keys(attributes(file)) + controller_type = read(attributes(file)["controller_type"]) + end + end + if controller_type == "PID" + load_PIDController!(integrator, restart_file) + elseif controller_type == "PI" || controller_type == "I" + load_PI_I_Controller!(integrator, restart_file) + end + integrator.accept_step = true +end + +function load_PIDController!(integrator, restart_file::AbstractString) + controller = integrator.opts.controller + if mpi_isroot() + h5open(restart_file, "r") do file + integrator.qold = read(attributes(file)["qold"]) + integrator.dtpropose = read(attributes(file)["dtpropose"]) + err = read(file["controller_err"]) + controller.err[1] = err[1] + controller.err[2] = err[2] + controller.err[3] = err[3] + end + end + if mpi_isparallel() + recv_buf = [integrator.qold, integrator.dtpropose] + append!(recv_buf, controller.err) + MPI.Bcast!(recv_buf, mpi_root(), mpi_comm()) + integrator.qold = recv_buf[1] + integrator.dtpropose = recv_buf[2] + controller.err[1] = recv_buf[3] + controller.err[2] = recv_buf[4] + controller.err[3] = recv_buf[5] + end +end +function load_PI_I_Controller!(integrator, restart_file::AbstractString) + controller = integrator.opts.controller + if mpi_isroot() + h5open(restart_file, "r") do file + integrator.qold = read(attributes(file)["qold"]) + integrator.dtpropose = read(attributes(file)["dtpropose"]) + end + end + if mpi_isparallel() + recv_buf = [integrator.qold, integrator.dtpropose] + MPI.Bcast!(recv_buf, mpi_root(), mpi_comm()) + integrator.qold, integrator.dtpropose = recv_buf + end +end + include("save_restart_dg.jl") end # @muladd diff --git a/src/callbacks_step/save_restart_dg.jl b/src/callbacks_step/save_restart_dg.jl index a3bf56e39f2..f983a169ee7 100644 --- a/src/callbacks_step/save_restart_dg.jl +++ b/src/callbacks_step/save_restart_dg.jl @@ -337,37 +337,42 @@ function save_restart_controller(mesh, integrator, end end -function save_restart_controller(integrator, controller::PIController, restart_callback) +function save_restart_controller(integrator, controller::PIDController, + restart_callback) @unpack output_directory = restart_callback timestep = integrator.stats.naccept filename = joinpath(output_directory, @sprintf("restart_%06d.h5", timestep)) # Open file (preserve existing content) h5open(filename, "cw") do file + attributes(file)["controller_type"] = "PID" attributes(file)["qold"] = integrator.qold attributes(file)["dtpropose"] = integrator.dtpropose + file["controller_err"] = controller.err end end -function save_restart_controller(integrator, controller::PIDController, - restart_callback) +function save_restart_controller(integrator, controller::PIController, restart_callback) @unpack output_directory = restart_callback timestep = integrator.stats.naccept filename = joinpath(output_directory, @sprintf("restart_%06d.h5", timestep)) # Open file (preserve existing content) h5open(filename, "cw") do file + attributes(file)["controller_type"] = "PI" attributes(file)["qold"] = integrator.qold attributes(file)["dtpropose"] = integrator.dtpropose - file["controller_err"] = controller.err end end -function save_restart_controller(integrator, controller, restart_callback) +function save_restart_controller(integrator, controller::IController, restart_callback) @unpack output_directory = restart_callback timestep = integrator.stats.naccept filename = joinpath(output_directory, @sprintf("restart_%06d.h5", timestep)) # Open file (preserve existing content) h5open(filename, "cw") do file + attributes(file)["controller_type"] = "I" + attributes(file)["qold"] = integrator.qold attributes(file)["dtpropose"] = integrator.dtpropose end end +save_restart_controller(integrator, controller, restart_callback) = nothing end # @muladd diff --git a/test/test_mpi_tree.jl b/test/test_mpi_tree.jl index 84d2609cbb1..7d35ef41f1e 100644 --- a/test/test_mpi_tree.jl +++ b/test/test_mpi_tree.jl @@ -183,6 +183,21 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() rtol = 0.001) end end + + @trixi_testset "elixir_euler_density_wave_extended.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), + # Expected errors are exactly the same as in the serial test! + l2 = [0.0012049974095327037, 0.00012066222768628522, 0.00024111367644905207, 0.0005962045363712651], + linf = [0.004212631542717782, 0.00042010775917775047, 0.0008412890054608387, 0.007078383889172812]) + end + + @trixi_testset "elixir_euler_density_wave_restart.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), + # Expected errors are exactly the same as in the serial test! + # and in the elixir_euler_density_wave_extended.jl + l2 = [0.0012049974095327037, 0.00012066222768628522, 0.00024111367644905207, 0.0005962045363712651], + linf = [0.004212631542717782, 0.00042010775917775047, 0.0008412890054608387, 0.007078383889172812]) + end end end # TreeMesh MPI diff --git a/test/test_tree_2d_euler.jl b/test/test_tree_2d_euler.jl index 6de380288db..cbcf7696e21 100644 --- a/test/test_tree_2d_euler.jl +++ b/test/test_tree_2d_euler.jl @@ -26,6 +26,19 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") linf = [0.006614198043413566, 0.0006614198043973507, 0.001322839608837334, 0.000165354951256802], tspan = (0.0, 0.5)) end + + @trixi_testset "elixir_euler_density_wave_extended.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), + l2 = [0.0012049974095327037, 0.00012066222768628522, 0.00024111367644905207, 0.0005962045363712651], + linf = [0.004212631542717782, 0.00042010775917775047, 0.0008412890054608387, 0.007078383889172812]) + end + + @trixi_testset "elixir_euler_density_wave_restart.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), + # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl + l2 = [0.0012049974095327037, 0.00012066222768628522, 0.00024111367644905207, 0.0005962045363712651], + linf = [0.004212631542717782, 0.00042010775917775047, 0.0008412890054608387, 0.007078383889172812]) + end @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic.jl"), From 68df7b68a12a177243896d8f7711623c162670ab Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Sun, 30 Jul 2023 15:02:16 +0300 Subject: [PATCH 008/102] fix --- src/callbacks_step/callbacks_step.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/callbacks_step/callbacks_step.jl b/src/callbacks_step/callbacks_step.jl index 7195bb7a260..09d197bf225 100644 --- a/src/callbacks_step/callbacks_step.jl +++ b/src/callbacks_step/callbacks_step.jl @@ -54,7 +54,6 @@ include("steady_state.jl") include("analysis.jl") include("alive.jl") include("save_restart.jl") -include("load_restart.jl") include("save_solution.jl") include("time_series.jl") include("visualization.jl") From 05c1246ef44a5ead7ff5867fdcc7e1c36ae1c6c9 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Sun, 30 Jul 2023 17:26:52 +0300 Subject: [PATCH 009/102] Update test_threaded.jl --- test/test_threaded.jl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/test_threaded.jl b/test/test_threaded.jl index 323d12d7091..843dd092132 100644 --- a/test/test_threaded.jl +++ b/test/test_threaded.jl @@ -59,6 +59,21 @@ Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) linf = [2.3040850347877395e-5] ) end + + @trixi_testset "elixir_euler_density_wave_extended.jl" begin + @test_trixi_include(joinpath(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_extended.jl"), + # Expected errors are exactly the same as in the serial test! + l2 = [0.0012049974095327037, 0.00012066222768628522, 0.00024111367644905207, 0.0005962045363712651], + linf = [0.004212631542717782, 0.00042010775917775047, 0.0008412890054608387, 0.007078383889172812]) + end + + @trixi_testset "elixir_euler_density_wave_restart.jl" begin + @test_trixi_include(joinpath(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_restart.jl"), + # Expected errors are exactly the same as in the serial test! + # and in the elixir_euler_density_wave_extended.jl + l2 = [0.0012049974095327037, 0.00012066222768628522, 0.00024111367644905207, 0.0005962045363712651], + linf = [0.004212631542717782, 0.00042010775917775047, 0.0008412890054608387, 0.007078383889172812]) + end end From 65517dcf050e4504433674f1d0abbbc3bc6c8a88 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Sun, 30 Jul 2023 18:11:20 +0300 Subject: [PATCH 010/102] fix --- test/test_threaded.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_threaded.jl b/test/test_threaded.jl index 843dd092132..f76e091e5c3 100644 --- a/test/test_threaded.jl +++ b/test/test_threaded.jl @@ -61,14 +61,14 @@ Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) end @trixi_testset "elixir_euler_density_wave_extended.jl" begin - @test_trixi_include(joinpath(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_extended.jl"), + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_extended.jl"), # Expected errors are exactly the same as in the serial test! l2 = [0.0012049974095327037, 0.00012066222768628522, 0.00024111367644905207, 0.0005962045363712651], linf = [0.004212631542717782, 0.00042010775917775047, 0.0008412890054608387, 0.007078383889172812]) end @trixi_testset "elixir_euler_density_wave_restart.jl" begin - @test_trixi_include(joinpath(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_restart.jl"), + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_restart.jl"), # Expected errors are exactly the same as in the serial test! # and in the elixir_euler_density_wave_extended.jl l2 = [0.0012049974095327037, 0.00012066222768628522, 0.00024111367644905207, 0.0005962045363712651], From b61021ea713c75b460a321a68a365aa8b7c9774c Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Sun, 30 Jul 2023 20:51:15 +0300 Subject: [PATCH 011/102] test fix --- test/test_mpi_tree.jl | 15 ++++----------- test/test_threaded.jl | 18 +++++------------- test/test_tree_2d_euler.jl | 11 +++-------- 3 files changed, 12 insertions(+), 32 deletions(-) diff --git a/test/test_mpi_tree.jl b/test/test_mpi_tree.jl index 7d35ef41f1e..384af3a9123 100644 --- a/test/test_mpi_tree.jl +++ b/test/test_mpi_tree.jl @@ -184,19 +184,12 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() end end - @trixi_testset "elixir_euler_density_wave_extended.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), - # Expected errors are exactly the same as in the serial test! - l2 = [0.0012049974095327037, 0.00012066222768628522, 0.00024111367644905207, 0.0005962045363712651], - linf = [0.004212631542717782, 0.00042010775917775047, 0.0008412890054608387, 0.007078383889172812]) - end - @trixi_testset "elixir_euler_density_wave_restart.jl" begin + trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl")) + l2_exact, linf_exact = analysis_callback(sol) @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), - # Expected errors are exactly the same as in the serial test! - # and in the elixir_euler_density_wave_extended.jl - l2 = [0.0012049974095327037, 0.00012066222768628522, 0.00024111367644905207, 0.0005962045363712651], - linf = [0.004212631542717782, 0.00042010775917775047, 0.0008412890054608387, 0.007078383889172812]) + # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl + l2 = l2_exact, linf = linf_exact) end end diff --git a/test/test_threaded.jl b/test/test_threaded.jl index f76e091e5c3..b4baf4952f0 100644 --- a/test/test_threaded.jl +++ b/test/test_threaded.jl @@ -59,20 +59,12 @@ Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) linf = [2.3040850347877395e-5] ) end - - @trixi_testset "elixir_euler_density_wave_extended.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_extended.jl"), - # Expected errors are exactly the same as in the serial test! - l2 = [0.0012049974095327037, 0.00012066222768628522, 0.00024111367644905207, 0.0005962045363712651], - linf = [0.004212631542717782, 0.00042010775917775047, 0.0008412890054608387, 0.007078383889172812]) - end - @trixi_testset "elixir_euler_density_wave_restart.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_restart.jl"), - # Expected errors are exactly the same as in the serial test! - # and in the elixir_euler_density_wave_extended.jl - l2 = [0.0012049974095327037, 0.00012066222768628522, 0.00024111367644905207, 0.0005962045363712651], - linf = [0.004212631542717782, 0.00042010775917775047, 0.0008412890054608387, 0.007078383889172812]) + trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl")) + l2_exact, linf_exact = analysis_callback(sol) + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), + # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl + l2 = l2_exact, linf = linf_exact) end end diff --git a/test/test_tree_2d_euler.jl b/test/test_tree_2d_euler.jl index cbcf7696e21..204766b19e2 100644 --- a/test/test_tree_2d_euler.jl +++ b/test/test_tree_2d_euler.jl @@ -27,17 +27,12 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") tspan = (0.0, 0.5)) end - @trixi_testset "elixir_euler_density_wave_extended.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), - l2 = [0.0012049974095327037, 0.00012066222768628522, 0.00024111367644905207, 0.0005962045363712651], - linf = [0.004212631542717782, 0.00042010775917775047, 0.0008412890054608387, 0.007078383889172812]) - end - @trixi_testset "elixir_euler_density_wave_restart.jl" begin + trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl")) + l2_exact, linf_exact = analysis_callback(sol) @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl - l2 = [0.0012049974095327037, 0.00012066222768628522, 0.00024111367644905207, 0.0005962045363712651], - linf = [0.004212631542717782, 0.00042010775917775047, 0.0008412890054608387, 0.007078383889172812]) + l2 = l2_exact, linf = linf_exact) end @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin From 3b9600508f480dc76dc22ca067934a4a7a0d3bde Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Sun, 30 Jul 2023 21:23:56 +0300 Subject: [PATCH 012/102] fix --- test/test_threaded.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_threaded.jl b/test/test_threaded.jl index b4baf4952f0..dc61429a16f 100644 --- a/test/test_threaded.jl +++ b/test/test_threaded.jl @@ -60,7 +60,7 @@ Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) ) end @trixi_testset "elixir_euler_density_wave_restart.jl" begin - trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl")) + trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_extended.jl")) l2_exact, linf_exact = analysis_callback(sol) @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl From 85bcd87e65638025ff0f3bc03e747acf2582e3c3 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Sun, 30 Jul 2023 21:33:51 +0300 Subject: [PATCH 013/102] MODULE add --- test/test_mpi_tree.jl | 2 +- test/test_threaded.jl | 2 +- test/test_tree_2d_euler.jl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test_mpi_tree.jl b/test/test_mpi_tree.jl index 384af3a9123..045f86e61e2 100644 --- a/test/test_mpi_tree.jl +++ b/test/test_mpi_tree.jl @@ -185,7 +185,7 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() end @trixi_testset "elixir_euler_density_wave_restart.jl" begin - trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl")) + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl")) l2_exact, linf_exact = analysis_callback(sol) @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl diff --git a/test/test_threaded.jl b/test/test_threaded.jl index dc61429a16f..b7c85540ec2 100644 --- a/test/test_threaded.jl +++ b/test/test_threaded.jl @@ -60,7 +60,7 @@ Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) ) end @trixi_testset "elixir_euler_density_wave_restart.jl" begin - trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_extended.jl")) + trixi_include(@__MODULE__, joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_extended.jl")) l2_exact, linf_exact = analysis_callback(sol) @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl diff --git a/test/test_tree_2d_euler.jl b/test/test_tree_2d_euler.jl index 204766b19e2..c20632e3e93 100644 --- a/test/test_tree_2d_euler.jl +++ b/test/test_tree_2d_euler.jl @@ -28,7 +28,7 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") end @trixi_testset "elixir_euler_density_wave_restart.jl" begin - trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl")) + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl")) l2_exact, linf_exact = analysis_callback(sol) @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl From be1f86838bc8d56c43aec91569e974b769e1e6d7 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Sun, 30 Jul 2023 22:02:59 +0300 Subject: [PATCH 014/102] fix --- test/test_threaded.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_threaded.jl b/test/test_threaded.jl index b7c85540ec2..8c026ad3720 100644 --- a/test/test_threaded.jl +++ b/test/test_threaded.jl @@ -62,7 +62,7 @@ Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) @trixi_testset "elixir_euler_density_wave_restart.jl" begin trixi_include(@__MODULE__, joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_extended.jl")) l2_exact, linf_exact = analysis_callback(sol) - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_restart.jl"), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl l2 = l2_exact, linf = linf_exact) end From 8dd33025b5eef978a73e32435e880528890c8538 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Sun, 30 Jul 2023 23:53:26 +0300 Subject: [PATCH 015/102] runtime macros --- test/test_mpi_tree.jl | 6 +++--- test/test_threaded.jl | 6 +++--- test/test_tree_2d_euler.jl | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/test/test_mpi_tree.jl b/test/test_mpi_tree.jl index 045f86e61e2..64fbd1a07e2 100644 --- a/test/test_mpi_tree.jl +++ b/test/test_mpi_tree.jl @@ -186,10 +186,10 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() @trixi_testset "elixir_euler_density_wave_restart.jl" begin trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl")) - l2_exact, linf_exact = analysis_callback(sol) - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), + l2, linf = analysis_callback(sol) + eval(:(@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl - l2 = l2_exact, linf = linf_exact) + l2 = $l2, linf = $linf))) end end diff --git a/test/test_threaded.jl b/test/test_threaded.jl index 8c026ad3720..342b7c71be1 100644 --- a/test/test_threaded.jl +++ b/test/test_threaded.jl @@ -61,10 +61,10 @@ Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) end @trixi_testset "elixir_euler_density_wave_restart.jl" begin trixi_include(@__MODULE__, joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_extended.jl")) - l2_exact, linf_exact = analysis_callback(sol) - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_restart.jl"), + l2, linf = analysis_callback(sol) + eval(:(@test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_restart.jl"), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl - l2 = l2_exact, linf = linf_exact) + l2 = $l2_exact, linf = $linf))) end end diff --git a/test/test_tree_2d_euler.jl b/test/test_tree_2d_euler.jl index c20632e3e93..7cfbbc59666 100644 --- a/test/test_tree_2d_euler.jl +++ b/test/test_tree_2d_euler.jl @@ -29,10 +29,10 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @trixi_testset "elixir_euler_density_wave_restart.jl" begin trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl")) - l2_exact, linf_exact = analysis_callback(sol) - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), + l2, linf = analysis_callback(sol) + eval(:(@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl - l2 = l2_exact, linf = linf_exact) + l2 = $l2, linf = $linf))) end @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin From 9b6cc489e90be35721a3378cdf34078a355abdb5 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Sun, 30 Jul 2023 23:56:24 +0300 Subject: [PATCH 016/102] Update test_threaded.jl --- test/test_threaded.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_threaded.jl b/test/test_threaded.jl index 342b7c71be1..99e62ad47f3 100644 --- a/test/test_threaded.jl +++ b/test/test_threaded.jl @@ -64,7 +64,7 @@ Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) l2, linf = analysis_callback(sol) eval(:(@test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_restart.jl"), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl - l2 = $l2_exact, linf = $linf))) + l2 = $l2, linf = $linf))) end end From 0f9439bb4291bca391605f9cf968d2dd982da5f8 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Mon, 31 Jul 2023 15:40:27 +0300 Subject: [PATCH 017/102] handle MPI issues --- src/callbacks_step/save_restart.jl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/callbacks_step/save_restart.jl b/src/callbacks_step/save_restart.jl index 7dd2795439e..7faabfae991 100644 --- a/src/callbacks_step/save_restart.jl +++ b/src/callbacks_step/save_restart.jl @@ -162,11 +162,16 @@ end function load_controller!(integrator, restart_file::AbstractString) controller_type = "" - h5open(restart_file, "r") do file - if "controller_type" in keys(attributes(file)) - controller_type = read(attributes(file)["controller_type"]) + if mpi_isroot() + h5open(restart_file, "r") do file + if "controller_type" in keys(attributes(file)) + controller_type = read(attributes(file)["controller_type"]) + end end end + if mpi_isparallel() + controller_type = MPI.bcast(controller_type, mpi_root(), mpi_comm()) + end if controller_type == "PID" load_PIDController!(integrator, restart_file) elseif controller_type == "PI" || controller_type == "I" From 7f65b3eb20e5210fcd22b11e857453e09f467c1e Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Tue, 1 Aug 2023 11:25:33 +0300 Subject: [PATCH 018/102] enable PIDController test --- .../elixir_euler_density_wave_extended.jl | 5 ++++- .../elixir_euler_density_wave_restart.jl | 11 +++++++---- test/test_mpi_tree.jl | 5 +++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl b/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl index 426fe01484a..61ac786410f 100644 --- a/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl +++ b/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl @@ -47,9 +47,12 @@ callbacks = CallbackSet(summary_callback, save_restart, save_solution, stepsize_callback) +# create timestep controller +controller = PIController(7 // 30, 2 // 15) + ############################################################################### # run the simulation sol = solve(ode, SSPRK43(); - ode_default_options()..., callback = callbacks); + ode_default_options()..., callback = callbacks, controller = controller); summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl b/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl index c03b0e2296a..e7ef8b73e4e 100644 --- a/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl +++ b/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl @@ -1,12 +1,14 @@ - ++ using OrdinaryDiffEq using Trixi ############################################################################### -# create a restart file +# create timestep controller +controller = PIController(7 // 30, 2 // 15) +# create a restart file trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_euler_density_wave_extended.jl"), - tspan = (0.0, 2.0)) + tspan = (0.0, 2.0), controller = controller) ############################################################################### # adapt the parameters that have changed compared to "elixir_euler_density_wave_extended.jl" @@ -29,7 +31,8 @@ save_solution.condition.save_initial_solution = false alg = SSPRK43() integrator = init(ode, alg, dt = dt; # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks, ode_default_options()...) + save_everystep = false, callback = callbacks, controller = controller, + ode_default_options()...) load_controller!(integrator, restart_filename) # Get the last time index and work with that. diff --git a/test/test_mpi_tree.jl b/test/test_mpi_tree.jl index d916d6917da..fc8c1c0ef6d 100644 --- a/test/test_mpi_tree.jl +++ b/test/test_mpi_tree.jl @@ -2,6 +2,7 @@ module TestExamplesMPITreeMesh using Test using Trixi +using OrdinaryDiffEq: PIDController include("test_trixi.jl") @@ -191,9 +192,9 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() end @trixi_testset "elixir_euler_density_wave_restart.jl" begin - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl")) + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl", controller = PIDController(1.0, 0.5, 0.2))) l2, linf = analysis_callback(sol) - eval(:(@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), + eval(:(@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), controller = PIDController(1.0, 0.5, 0.2), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl l2 = $l2, linf = $linf))) end From 53cb00004eba1ee50d3009cd3611d7ffd62cd5a3 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Tue, 1 Aug 2023 13:17:39 +0300 Subject: [PATCH 019/102] Update test_mpi_tree.jl --- test/test_mpi_tree.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_mpi_tree.jl b/test/test_mpi_tree.jl index fc8c1c0ef6d..1d51ccbeb6b 100644 --- a/test/test_mpi_tree.jl +++ b/test/test_mpi_tree.jl @@ -2,7 +2,6 @@ module TestExamplesMPITreeMesh using Test using Trixi -using OrdinaryDiffEq: PIDController include("test_trixi.jl") @@ -192,7 +191,8 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() end @trixi_testset "elixir_euler_density_wave_restart.jl" begin - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl", controller = PIDController(1.0, 0.5, 0.2))) + using OrdinaryDiffEq: PIDController + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), controller = PIDController(1.0, 0.5, 0.2)) l2, linf = analysis_callback(sol) eval(:(@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), controller = PIDController(1.0, 0.5, 0.2), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl From b240c9c142eac5bc594cdb5aab9d9492a849e13a Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Tue, 1 Aug 2023 17:18:59 +0300 Subject: [PATCH 020/102] fix --- examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl b/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl index e7ef8b73e4e..6dd42927842 100644 --- a/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl +++ b/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl @@ -23,6 +23,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) tspan = (load_time(restart_filename), 4.0) dt = load_dt(restart_filename) + ode = semidiscretize(semi, tspan, restart_filename); # Do not overwrite the initial snapshot written by elixir_euler_density_wave_extended.jl. From e3813b25e2fc78251dd3c0865a9f5491561e42c5 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Tue, 1 Aug 2023 20:09:00 +0300 Subject: [PATCH 021/102] add asserts --- src/callbacks_step/save_restart.jl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/callbacks_step/save_restart.jl b/src/callbacks_step/save_restart.jl index 7faabfae991..38814f2b3d5 100644 --- a/src/callbacks_step/save_restart.jl +++ b/src/callbacks_step/save_restart.jl @@ -173,8 +173,15 @@ function load_controller!(integrator, restart_file::AbstractString) controller_type = MPI.bcast(controller_type, mpi_root(), mpi_comm()) end if controller_type == "PID" + if !(typeof(integrator.opts.controller) <: PIDController) + error("restart mismatch: controller differ from value in restart file") + end load_PIDController!(integrator, restart_file) elseif controller_type == "PI" || controller_type == "I" + if !(typeof(integrator.opts.controller) <: PIController) && + !(typeof(integrator.opts.controller) <: IController) + error("restart mismatch: controller differ from value in restart file") + end load_PI_I_Controller!(integrator, restart_file) end integrator.accept_step = true From 8315b5e7aff61ff3ccc1fd413725ea79061841fb Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Tue, 1 Aug 2023 21:18:19 +0300 Subject: [PATCH 022/102] Update save_restart.jl --- src/callbacks_step/save_restart.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/callbacks_step/save_restart.jl b/src/callbacks_step/save_restart.jl index 38814f2b3d5..9cc9ee55834 100644 --- a/src/callbacks_step/save_restart.jl +++ b/src/callbacks_step/save_restart.jl @@ -210,6 +210,7 @@ function load_PIDController!(integrator, restart_file::AbstractString) controller.err[3] = recv_buf[5] end end + function load_PI_I_Controller!(integrator, restart_file::AbstractString) controller = integrator.opts.controller if mpi_isroot() From b78b93240d93ba27af25f434edf1ad4c6e4cb4ed Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Wed, 2 Aug 2023 15:53:49 +0300 Subject: [PATCH 023/102] add IController tests --- test/test_threaded.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/test_threaded.jl b/test/test_threaded.jl index f0f3142c6ee..4c729171f30 100644 --- a/test/test_threaded.jl +++ b/test/test_threaded.jl @@ -146,9 +146,10 @@ Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) end end @trixi_testset "elixir_euler_density_wave_restart.jl" begin - trixi_include(@__MODULE__, joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_extended.jl")) + using OrdinaryDiffEq: IController + trixi_include(@__MODULE__, joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_extended.jl"), controller = IController()) l2, linf = analysis_callback(sol) - eval(:(@test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_restart.jl"), + eval(:(@test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_restart.jl"), controller = IController(), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl l2 = $l2, linf = $linf))) end From 556e91a9f088eea778805520d6aba8b4d39e11d4 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Wed, 2 Aug 2023 19:21:28 +0300 Subject: [PATCH 024/102] enable HDF5 parallel --- .github/workflows/ci.yml | 10 ++++++++++ test/configure_packages.jl | 22 ++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 test/configure_packages.jl diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4790f93d913..032eb53a55c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -101,6 +101,11 @@ jobs: arch: x64 trixi_test: threaded steps: + - name: Install libraries + run: | + sudo apt-get update + sudo apt-get install mpich libhdf5-mpich-dev + echo "JULIA_HDF5_PATH=/usr/lib/x86_64-linux-gnu/hdf5/mpich/" >> $GITHUB_ENV - uses: actions/checkout@v3 - uses: julia-actions/setup-julia@v1 with: @@ -111,6 +116,11 @@ jobs: - uses: julia-actions/julia-buildpkg@v1 env: PYTHON: "" + - name: Configure MPI.jl + shell: julia --color=yes {0} + run: | + @show pwd() + include(joinpath(pwd(), "test", "configure_packages.jl")) - name: Run tests without coverage uses: julia-actions/julia-runtest@v1 with: diff --git a/test/configure_packages.jl b/test/configure_packages.jl new file mode 100644 index 00000000000..73b08731189 --- /dev/null +++ b/test/configure_packages.jl @@ -0,0 +1,22 @@ +using Pkg, Libdl +Pkg.activate(dirname(@__DIR__)) +Pkg.instantiate() + +# Configure the test setup based on environment variables set in CI. +# First, we get the settings and remove all local preference configurations +# that may still exist. +const JULIA_HDF5_PATH = get(ENV, "JULIA_HDF5_PATH", "") +rm(joinpath(dirname(@__DIR__), "LocalPreferences.toml"); force=true) + +# Next, we configure MPI.jl appropriately. +import MPIPreferences +MPIPreferences.use_system_binary() + +# Finally, we configure HDF5.jl as desired. +import UUIDs, Preferences +Preferences.set_preferences!( + UUIDs.UUID("f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"), # UUID of HDF5.jl + "libhdf5" => joinpath(JULIA_HDF5_PATH, "libhdf5." * Libdl.dlext), + "libhdf5_hl" => joinpath(JULIA_HDF5_PATH, "libhdf5_hl." * Libdl.dlext); + force=true +) \ No newline at end of file From 88d9c574aa45f5cd31491f145116660bd21986dc Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Wed, 2 Aug 2023 19:39:20 +0300 Subject: [PATCH 025/102] fix shot --- .github/workflows/ci.yml | 10 +++++----- test/configure_packages.jl | 7 ++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 032eb53a55c..62205381fce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -111,16 +111,16 @@ jobs: with: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - - run: julia -e 'using InteractiveUtils; versioninfo(verbose=true)' - - uses: julia-actions/cache@v1 - - uses: julia-actions/julia-buildpkg@v1 - env: - PYTHON: "" - name: Configure MPI.jl shell: julia --color=yes {0} run: | @show pwd() include(joinpath(pwd(), "test", "configure_packages.jl")) + - run: julia -e 'using InteractiveUtils; versioninfo(verbose=true)' + - uses: julia-actions/cache@v1 + - uses: julia-actions/julia-buildpkg@v1 + env: + PYTHON: "" - name: Run tests without coverage uses: julia-actions/julia-runtest@v1 with: diff --git a/test/configure_packages.jl b/test/configure_packages.jl index 73b08731189..888436598a7 100644 --- a/test/configure_packages.jl +++ b/test/configure_packages.jl @@ -1,4 +1,6 @@ -using Pkg, Libdl +using Pkg +Pkg.build("Libdl") +using Libdl Pkg.activate(dirname(@__DIR__)) Pkg.instantiate() @@ -9,6 +11,9 @@ const JULIA_HDF5_PATH = get(ENV, "JULIA_HDF5_PATH", "") rm(joinpath(dirname(@__DIR__), "LocalPreferences.toml"); force=true) # Next, we configure MPI.jl appropriately. +Pkg.build("MPIPreferences") +Pkg.build("Preferences") +Pkg.build("UUIDs") import MPIPreferences MPIPreferences.use_system_binary() From 84133ee7f4f25c5846cad640120aded96ef2691c Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Wed, 2 Aug 2023 19:42:51 +0300 Subject: [PATCH 026/102] fix shot 2 --- test/configure_packages.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/configure_packages.jl b/test/configure_packages.jl index 888436598a7..913de9e083f 100644 --- a/test/configure_packages.jl +++ b/test/configure_packages.jl @@ -1,5 +1,5 @@ using Pkg -Pkg.build("Libdl") +Pkg.add("Libdl") using Libdl Pkg.activate(dirname(@__DIR__)) Pkg.instantiate() @@ -11,9 +11,9 @@ const JULIA_HDF5_PATH = get(ENV, "JULIA_HDF5_PATH", "") rm(joinpath(dirname(@__DIR__), "LocalPreferences.toml"); force=true) # Next, we configure MPI.jl appropriately. -Pkg.build("MPIPreferences") -Pkg.build("Preferences") -Pkg.build("UUIDs") +Pkg.add("MPIPreferences") +Pkg.add("Preferences") +Pkg.add("UUIDs") import MPIPreferences MPIPreferences.use_system_binary() From 4ec808f292b29e0c77d3b39742c0075163fe1284 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Wed, 2 Aug 2023 19:47:14 +0300 Subject: [PATCH 027/102] fix shot 3 --- test/configure_packages.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/test/configure_packages.jl b/test/configure_packages.jl index 913de9e083f..0a9c73e2dc7 100644 --- a/test/configure_packages.jl +++ b/test/configure_packages.jl @@ -2,7 +2,6 @@ using Pkg Pkg.add("Libdl") using Libdl Pkg.activate(dirname(@__DIR__)) -Pkg.instantiate() # Configure the test setup based on environment variables set in CI. # First, we get the settings and remove all local preference configurations From 55ba995686e1d44cdb9179205599335c03939ac9 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Wed, 2 Aug 2023 20:14:25 +0300 Subject: [PATCH 028/102] fix shot 4 --- test/configure_packages.jl | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/test/configure_packages.jl b/test/configure_packages.jl index 0a9c73e2dc7..acab200f4ca 100644 --- a/test/configure_packages.jl +++ b/test/configure_packages.jl @@ -1,23 +1,19 @@ -using Pkg -Pkg.add("Libdl") -using Libdl +using Pkg, Libdl Pkg.activate(dirname(@__DIR__)) +Pkg.instantiate() # Configure the test setup based on environment variables set in CI. # First, we get the settings and remove all local preference configurations # that may still exist. -const JULIA_HDF5_PATH = get(ENV, "JULIA_HDF5_PATH", "") rm(joinpath(dirname(@__DIR__), "LocalPreferences.toml"); force=true) # Next, we configure MPI.jl appropriately. -Pkg.add("MPIPreferences") -Pkg.add("Preferences") -Pkg.add("UUIDs") import MPIPreferences MPIPreferences.use_system_binary() # Finally, we configure HDF5.jl as desired. import UUIDs, Preferences +const JULIA_HDF5_PATH = get(ENV, "JULIA_HDF5_PATH", "") Preferences.set_preferences!( UUIDs.UUID("f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"), # UUID of HDF5.jl "libhdf5" => joinpath(JULIA_HDF5_PATH, "libhdf5." * Libdl.dlext), From 46f51fd196dc1d8a9ce23e1a81dab9e8790da768 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Wed, 2 Aug 2023 20:26:23 +0300 Subject: [PATCH 029/102] fix shot 5 --- test/configure_packages.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/test/configure_packages.jl b/test/configure_packages.jl index acab200f4ca..90527cdba83 100644 --- a/test/configure_packages.jl +++ b/test/configure_packages.jl @@ -1,6 +1,5 @@ using Pkg, Libdl Pkg.activate(dirname(@__DIR__)) -Pkg.instantiate() # Configure the test setup based on environment variables set in CI. # First, we get the settings and remove all local preference configurations From 8e9cfa356341677bebae86d0ae5e4ec3c5521ce9 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Wed, 2 Aug 2023 20:29:16 +0300 Subject: [PATCH 030/102] fix shot 6 --- test/configure_packages.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/configure_packages.jl b/test/configure_packages.jl index 90527cdba83..db9ae311403 100644 --- a/test/configure_packages.jl +++ b/test/configure_packages.jl @@ -1,5 +1,7 @@ using Pkg, Libdl Pkg.activate(dirname(@__DIR__)) +Pkg.rm("HDF5") +Pkg.instantiate() # Configure the test setup based on environment variables set in CI. # First, we get the settings and remove all local preference configurations @@ -12,6 +14,7 @@ MPIPreferences.use_system_binary() # Finally, we configure HDF5.jl as desired. import UUIDs, Preferences +Pkg.add("HDF5") const JULIA_HDF5_PATH = get(ENV, "JULIA_HDF5_PATH", "") Preferences.set_preferences!( UUIDs.UUID("f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"), # UUID of HDF5.jl From 3b090a12df85fcd53b973e3b97feddfc863bbc95 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Wed, 2 Aug 2023 22:02:38 +0300 Subject: [PATCH 031/102] fix shot 7 --- .github/workflows/ci.yml | 16 ++++++++-------- test/configure_packages.jl | 4 +--- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 62205381fce..b9a26727089 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -101,24 +101,24 @@ jobs: arch: x64 trixi_test: threaded steps: - - name: Install libraries - run: | - sudo apt-get update - sudo apt-get install mpich libhdf5-mpich-dev - echo "JULIA_HDF5_PATH=/usr/lib/x86_64-linux-gnu/hdf5/mpich/" >> $GITHUB_ENV - uses: actions/checkout@v3 - uses: julia-actions/setup-julia@v1 with: version: ${{ matrix.version }} arch: ${{ matrix.arch }} + - run: julia -e 'using InteractiveUtils; versioninfo(verbose=true)' + - uses: julia-actions/cache@v1 + - uses: julia-actions/julia-buildpkg@v1 + - name: Install libraries + run: | + sudo apt-get update + sudo apt-get install mpich libhdf5-mpich-dev + echo "JULIA_HDF5_PATH=/usr/lib/x86_64-linux-gnu/hdf5/mpich/" >> $GITHUB_ENV - name: Configure MPI.jl shell: julia --color=yes {0} run: | @show pwd() include(joinpath(pwd(), "test", "configure_packages.jl")) - - run: julia -e 'using InteractiveUtils; versioninfo(verbose=true)' - - uses: julia-actions/cache@v1 - - uses: julia-actions/julia-buildpkg@v1 env: PYTHON: "" - name: Run tests without coverage diff --git a/test/configure_packages.jl b/test/configure_packages.jl index db9ae311403..fbcd49ee38a 100644 --- a/test/configure_packages.jl +++ b/test/configure_packages.jl @@ -1,6 +1,5 @@ using Pkg, Libdl Pkg.activate(dirname(@__DIR__)) -Pkg.rm("HDF5") Pkg.instantiate() # Configure the test setup based on environment variables set in CI. @@ -14,11 +13,10 @@ MPIPreferences.use_system_binary() # Finally, we configure HDF5.jl as desired. import UUIDs, Preferences -Pkg.add("HDF5") const JULIA_HDF5_PATH = get(ENV, "JULIA_HDF5_PATH", "") Preferences.set_preferences!( UUIDs.UUID("f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"), # UUID of HDF5.jl "libhdf5" => joinpath(JULIA_HDF5_PATH, "libhdf5." * Libdl.dlext), "libhdf5_hl" => joinpath(JULIA_HDF5_PATH, "libhdf5_hl." * Libdl.dlext); force=true -) \ No newline at end of file +) From e8f28e44184e85734bdfe632e5a5394e36305108 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Wed, 2 Aug 2023 22:20:13 +0300 Subject: [PATCH 032/102] fix shot 8 --- test/configure_packages.jl | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/test/configure_packages.jl b/test/configure_packages.jl index fbcd49ee38a..0bbaa2f0665 100644 --- a/test/configure_packages.jl +++ b/test/configure_packages.jl @@ -1,22 +1,20 @@ using Pkg, Libdl -Pkg.activate(dirname(@__DIR__)) -Pkg.instantiate() - # Configure the test setup based on environment variables set in CI. # First, we get the settings and remove all local preference configurations # that may still exist. +const JULIA_HDF5_PATH = get(ENV, "JULIA_HDF5_PATH", "") rm(joinpath(dirname(@__DIR__), "LocalPreferences.toml"); force=true) # Next, we configure MPI.jl appropriately. -import MPIPreferences -MPIPreferences.use_system_binary() +import MPI +MPI.MPIPreferences.use_system_binary() # Finally, we configure HDF5.jl as desired. -import UUIDs, Preferences -const JULIA_HDF5_PATH = get(ENV, "JULIA_HDF5_PATH", "") -Preferences.set_preferences!( +import UUIDs +MPI.MPIPreferences.Preferences.set_preferences!( UUIDs.UUID("f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"), # UUID of HDF5.jl "libhdf5" => joinpath(JULIA_HDF5_PATH, "libhdf5." * Libdl.dlext), "libhdf5_hl" => joinpath(JULIA_HDF5_PATH, "libhdf5_hl." * Libdl.dlext); force=true ) +Pkg.build("HDF5") \ No newline at end of file From 0dcabc14645d6618376fa7cec5675eefb59cdedd Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Wed, 2 Aug 2023 22:23:24 +0300 Subject: [PATCH 033/102] fix shot 9 --- test/configure_packages.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/configure_packages.jl b/test/configure_packages.jl index 0bbaa2f0665..26c34f3b0b0 100644 --- a/test/configure_packages.jl +++ b/test/configure_packages.jl @@ -1,4 +1,6 @@ using Pkg, Libdl +Pkg.activate(dirname(@__DIR__)) +Pkg.instantiate() # Configure the test setup based on environment variables set in CI. # First, we get the settings and remove all local preference configurations # that may still exist. From 32965f656ab8314acd156bbc38843c2ca1761c77 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Wed, 2 Aug 2023 22:41:48 +0300 Subject: [PATCH 034/102] fix shot 10 --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b9a26727089..7981a49aaa8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -107,8 +107,9 @@ jobs: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - run: julia -e 'using InteractiveUtils; versioninfo(verbose=true)' - - uses: julia-actions/cache@v1 - uses: julia-actions/julia-buildpkg@v1 + env: + PYTHON: "" - name: Install libraries run: | sudo apt-get update @@ -119,8 +120,7 @@ jobs: run: | @show pwd() include(joinpath(pwd(), "test", "configure_packages.jl")) - env: - PYTHON: "" + - uses: julia-actions/cache@v1 - name: Run tests without coverage uses: julia-actions/julia-runtest@v1 with: From 008ca58427ce54379f2bfc7ca405a84551606ebc Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Wed, 2 Aug 2023 23:20:26 +0300 Subject: [PATCH 035/102] fix shot 11 --- .github/workflows/ci.yml | 46 +++++++++++++++++++++++++++++--------- Project.toml | 13 ++++++----- test/configure_packages.jl | 6 ++--- 3 files changed, 45 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7981a49aaa8..de772a339a5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,6 +41,40 @@ concurrency: cancel-in-progress: true jobs: + + HDF5-system-libs: + name: julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} (system libhdf5 + mpich) + runs-on: ${{ matrix.os }} + timeout-minutes: 20 + strategy: + matrix: + version: + - '1.9' + os: + - ubuntu-latest + arch: + - x64 + steps: + - uses: actions/checkout@v3 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - run: julia -e 'using InteractiveUtils; versioninfo(verbose=true)' + - uses: julia-actions/julia-buildpkg@v1 + env: + PYTHON: "" + - name: Install libraries + run: | + sudo apt-get update + sudo apt-get install mpich libhdf5-mpich-dev + echo "JULIA_HDF5_PATH=/usr/lib/x86_64-linux-gnu/hdf5/mpich/" >> $GITHUB_ENV + - name: Configure MPI.jl + shell: julia --color=yes {0} + run: | + @show pwd() + include(joinpath(pwd(), "test", "configure_packages.jl")) + test: if: "!contains(github.event.head_commit.message, 'skip ci')" # We could also include the Julia version as in @@ -107,20 +141,10 @@ jobs: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - run: julia -e 'using InteractiveUtils; versioninfo(verbose=true)' + - uses: julia-actions/cache@v1 - uses: julia-actions/julia-buildpkg@v1 env: PYTHON: "" - - name: Install libraries - run: | - sudo apt-get update - sudo apt-get install mpich libhdf5-mpich-dev - echo "JULIA_HDF5_PATH=/usr/lib/x86_64-linux-gnu/hdf5/mpich/" >> $GITHUB_ENV - - name: Configure MPI.jl - shell: julia --color=yes {0} - run: | - @show pwd() - include(joinpath(pwd(), "test", "configure_packages.jl")) - - uses: julia-actions/cache@v1 - name: Run tests without coverage uses: julia-actions/julia-runtest@v1 with: diff --git a/Project.toml b/Project.toml index a2164b37dc4..0defc61f613 100644 --- a/Project.toml +++ b/Project.toml @@ -16,6 +16,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" LinearMaps = "7a12625a-238d-50fd-b39a-03d52299707e" LoopVectorization = "bdcacae8-1622-11e9-2a5c-532679323890" MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" +MPIPreferences = "3da0fdf6-3ccc-4f1b-acd9-58baa6c99267" MuladdMacro = "46d2c3a1-f734-5fdb-9937-b9b9aeba4221" Octavian = "6fd5a793-0b7e-452c-907f-f8bfe9c57db4" OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" @@ -44,12 +45,6 @@ Triangulate = "f7e6ffb2-c36d-4f8f-a77e-16e897189344" TriplotBase = "981d1d27-644d-49a2-9326-4793e63143c3" TriplotRecipes = "808ab39a-a642-4abf-81ff-4cb34ebbffa3" -[weakdeps] -Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" - -[extensions] -TrixiMakieExt = "Makie" - [compat] CodeTracking = "1.0.5" ConstructionBase = "1.3" @@ -89,5 +84,11 @@ TriplotBase = "0.1" TriplotRecipes = "0.1" julia = "1.8" +[extensions] +TrixiMakieExt = "Makie" + [extras] Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" + +[weakdeps] +Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" diff --git a/test/configure_packages.jl b/test/configure_packages.jl index 26c34f3b0b0..29da932724f 100644 --- a/test/configure_packages.jl +++ b/test/configure_packages.jl @@ -8,12 +8,12 @@ const JULIA_HDF5_PATH = get(ENV, "JULIA_HDF5_PATH", "") rm(joinpath(dirname(@__DIR__), "LocalPreferences.toml"); force=true) # Next, we configure MPI.jl appropriately. -import MPI -MPI.MPIPreferences.use_system_binary() +using MPIPreferences +MPIPreferences.use_system_binary() # Finally, we configure HDF5.jl as desired. import UUIDs -MPI.MPIPreferences.Preferences.set_preferences!( +MPIPreferences.Preferences.set_preferences!( UUIDs.UUID("f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"), # UUID of HDF5.jl "libhdf5" => joinpath(JULIA_HDF5_PATH, "libhdf5." * Libdl.dlext), "libhdf5_hl" => joinpath(JULIA_HDF5_PATH, "libhdf5_hl." * Libdl.dlext); From 3a41ca935c59c082805855091913ccb9ea9a7610 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Wed, 2 Aug 2023 23:37:18 +0300 Subject: [PATCH 036/102] fix shot 12 --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index de772a339a5..f57547cdee0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,6 +55,11 @@ jobs: arch: - x64 steps: + - name: Install libraries + run: | + sudo apt-get update + sudo apt-get install mpich libhdf5-mpich-dev + echo "JULIA_HDF5_PATH=/usr/lib/x86_64-linux-gnu/hdf5/mpich/" >> $GITHUB_ENV - uses: actions/checkout@v3 - uses: julia-actions/setup-julia@v1 with: @@ -64,11 +69,6 @@ jobs: - uses: julia-actions/julia-buildpkg@v1 env: PYTHON: "" - - name: Install libraries - run: | - sudo apt-get update - sudo apt-get install mpich libhdf5-mpich-dev - echo "JULIA_HDF5_PATH=/usr/lib/x86_64-linux-gnu/hdf5/mpich/" >> $GITHUB_ENV - name: Configure MPI.jl shell: julia --color=yes {0} run: | From 7576665b0a8ed541c77a0de1d9d718e79ee59521 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Wed, 2 Aug 2023 23:48:07 +0300 Subject: [PATCH 037/102] fix shot 13 --- .github/workflows/ci.yml | 3 --- test/configure_packages.jl | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f57547cdee0..44894736b1c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,9 +66,6 @@ jobs: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - run: julia -e 'using InteractiveUtils; versioninfo(verbose=true)' - - uses: julia-actions/julia-buildpkg@v1 - env: - PYTHON: "" - name: Configure MPI.jl shell: julia --color=yes {0} run: | diff --git a/test/configure_packages.jl b/test/configure_packages.jl index 29da932724f..d91576a96d6 100644 --- a/test/configure_packages.jl +++ b/test/configure_packages.jl @@ -18,5 +18,4 @@ MPIPreferences.Preferences.set_preferences!( "libhdf5" => joinpath(JULIA_HDF5_PATH, "libhdf5." * Libdl.dlext), "libhdf5_hl" => joinpath(JULIA_HDF5_PATH, "libhdf5_hl." * Libdl.dlext); force=true -) -Pkg.build("HDF5") \ No newline at end of file +) \ No newline at end of file From 9dac2da13f1ae6c9d28dd4aa252a2ccf5bfaed00 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Wed, 2 Aug 2023 23:52:17 +0300 Subject: [PATCH 038/102] fix shot 14 --- test/configure_packages.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/test/configure_packages.jl b/test/configure_packages.jl index d91576a96d6..8e9a5e14b79 100644 --- a/test/configure_packages.jl +++ b/test/configure_packages.jl @@ -1,6 +1,5 @@ using Pkg, Libdl Pkg.activate(dirname(@__DIR__)) -Pkg.instantiate() # Configure the test setup based on environment variables set in CI. # First, we get the settings and remove all local preference configurations # that may still exist. From aa5447ef2b91b986efc44ae6c063842ce53e6957 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Thu, 3 Aug 2023 00:08:39 +0300 Subject: [PATCH 039/102] fix shot 15 --- test/configure_packages.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/configure_packages.jl b/test/configure_packages.jl index 8e9a5e14b79..1f38c5d513d 100644 --- a/test/configure_packages.jl +++ b/test/configure_packages.jl @@ -1,5 +1,8 @@ using Pkg, Libdl Pkg.activate(dirname(@__DIR__)) +Pkg.rm("HDF5") +Pkg.resolve() +Pkg.instantiate() # Configure the test setup based on environment variables set in CI. # First, we get the settings and remove all local preference configurations # that may still exist. @@ -17,4 +20,6 @@ MPIPreferences.Preferences.set_preferences!( "libhdf5" => joinpath(JULIA_HDF5_PATH, "libhdf5." * Libdl.dlext), "libhdf5_hl" => joinpath(JULIA_HDF5_PATH, "libhdf5_hl." * Libdl.dlext); force=true -) \ No newline at end of file +) +Pkg.add("HDF5") +Pkg.resolve() \ No newline at end of file From 0fcfff2f8c3b6048a0b5443862cf161380b99497 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Thu, 3 Aug 2023 00:34:19 +0300 Subject: [PATCH 040/102] fix shot 16 --- .github/workflows/ci.yml | 5 ----- test/configure_packages.jl | 5 +++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 44894736b1c..781aecffb46 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,11 +55,6 @@ jobs: arch: - x64 steps: - - name: Install libraries - run: | - sudo apt-get update - sudo apt-get install mpich libhdf5-mpich-dev - echo "JULIA_HDF5_PATH=/usr/lib/x86_64-linux-gnu/hdf5/mpich/" >> $GITHUB_ENV - uses: actions/checkout@v3 - uses: julia-actions/setup-julia@v1 with: diff --git a/test/configure_packages.jl b/test/configure_packages.jl index 1f38c5d513d..488b8f84d33 100644 --- a/test/configure_packages.jl +++ b/test/configure_packages.jl @@ -1,11 +1,12 @@ using Pkg, Libdl Pkg.activate(dirname(@__DIR__)) -Pkg.rm("HDF5") -Pkg.resolve() Pkg.instantiate() # Configure the test setup based on environment variables set in CI. # First, we get the settings and remove all local preference configurations # that may still exist. +run(`sudo apt-get update`) +run(`sudo apt-get install mpich libhdf5-mpich-dev`) +run(`echo "JULIA_HDF5_PATH=/usr/lib/x86_64-linux-gnu/hdf5/mpich/" \>\> $GITHUB_ENV`) const JULIA_HDF5_PATH = get(ENV, "JULIA_HDF5_PATH", "") rm(joinpath(dirname(@__DIR__), "LocalPreferences.toml"); force=true) From 63e607ac26c4350031ec411ea33f1e03038e8c9f Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Thu, 3 Aug 2023 00:55:40 +0300 Subject: [PATCH 041/102] fix shot 17 --- .github/workflows/ci.yml | 31 +++++-------------------------- test/configure_packages.jl | 9 +++++---- 2 files changed, 10 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 781aecffb46..b93ac0c7125 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,32 +41,6 @@ concurrency: cancel-in-progress: true jobs: - - HDF5-system-libs: - name: julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} (system libhdf5 + mpich) - runs-on: ${{ matrix.os }} - timeout-minutes: 20 - strategy: - matrix: - version: - - '1.9' - os: - - ubuntu-latest - arch: - - x64 - steps: - - uses: actions/checkout@v3 - - uses: julia-actions/setup-julia@v1 - with: - version: ${{ matrix.version }} - arch: ${{ matrix.arch }} - - run: julia -e 'using InteractiveUtils; versioninfo(verbose=true)' - - name: Configure MPI.jl - shell: julia --color=yes {0} - run: | - @show pwd() - include(joinpath(pwd(), "test", "configure_packages.jl")) - test: if: "!contains(github.event.head_commit.message, 'skip ci')" # We could also include the Julia version as in @@ -133,6 +107,11 @@ jobs: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - run: julia -e 'using InteractiveUtils; versioninfo(verbose=true)' + - name: Configure MPI.jl + shell: julia --color=yes {0} + run: | + @show pwd() + include(joinpath(pwd(), "test", "configure_packages.jl")) - uses: julia-actions/cache@v1 - uses: julia-actions/julia-buildpkg@v1 env: diff --git a/test/configure_packages.jl b/test/configure_packages.jl index 488b8f84d33..e317c48b715 100644 --- a/test/configure_packages.jl +++ b/test/configure_packages.jl @@ -1,3 +1,6 @@ +if !Sys.islinux() + return nothing +end using Pkg, Libdl Pkg.activate(dirname(@__DIR__)) Pkg.instantiate() @@ -6,7 +9,7 @@ Pkg.instantiate() # that may still exist. run(`sudo apt-get update`) run(`sudo apt-get install mpich libhdf5-mpich-dev`) -run(`echo "JULIA_HDF5_PATH=/usr/lib/x86_64-linux-gnu/hdf5/mpich/" \>\> $GITHUB_ENV`) +run(`echo "JULIA_HDF5_PATH=/usr/lib/x86_64-linux-gnu/hdf5/mpich/" \>\> \$GITHUB_ENV`) const JULIA_HDF5_PATH = get(ENV, "JULIA_HDF5_PATH", "") rm(joinpath(dirname(@__DIR__), "LocalPreferences.toml"); force=true) @@ -21,6 +24,4 @@ MPIPreferences.Preferences.set_preferences!( "libhdf5" => joinpath(JULIA_HDF5_PATH, "libhdf5." * Libdl.dlext), "libhdf5_hl" => joinpath(JULIA_HDF5_PATH, "libhdf5_hl." * Libdl.dlext); force=true -) -Pkg.add("HDF5") -Pkg.resolve() \ No newline at end of file +) \ No newline at end of file From 43e240bfb4838b1e88b80f49eda459dd8a33d0c5 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Thu, 3 Aug 2023 01:10:45 +0300 Subject: [PATCH 042/102] fix shot 18 --- test/configure_packages.jl | 49 +++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/test/configure_packages.jl b/test/configure_packages.jl index e317c48b715..7fd5a8a0b12 100644 --- a/test/configure_packages.jl +++ b/test/configure_packages.jl @@ -1,27 +1,26 @@ -if !Sys.islinux() - return nothing -end -using Pkg, Libdl -Pkg.activate(dirname(@__DIR__)) -Pkg.instantiate() -# Configure the test setup based on environment variables set in CI. -# First, we get the settings and remove all local preference configurations -# that may still exist. -run(`sudo apt-get update`) -run(`sudo apt-get install mpich libhdf5-mpich-dev`) -run(`echo "JULIA_HDF5_PATH=/usr/lib/x86_64-linux-gnu/hdf5/mpich/" \>\> \$GITHUB_ENV`) -const JULIA_HDF5_PATH = get(ENV, "JULIA_HDF5_PATH", "") -rm(joinpath(dirname(@__DIR__), "LocalPreferences.toml"); force=true) +if Sys.islinux() + using Pkg, Libdl + Pkg.activate(dirname(@__DIR__)) + Pkg.instantiate() + # Configure the test setup based on environment variables set in CI. + # First, we get the settings and remove all local preference configurations + # that may still exist. + run(`sudo apt-get update`) + run(`sudo apt-get install mpich libhdf5-mpich-dev`) + run(`echo "JULIA_HDF5_PATH=/usr/lib/x86_64-linux-gnu/hdf5/mpich/" \>\> \$GITHUB_ENV`) + const JULIA_HDF5_PATH = get(ENV, "JULIA_HDF5_PATH", "") + rm(joinpath(dirname(@__DIR__), "LocalPreferences.toml"); force=true) -# Next, we configure MPI.jl appropriately. -using MPIPreferences -MPIPreferences.use_system_binary() + # Next, we configure MPI.jl appropriately. + using MPIPreferences + MPIPreferences.use_system_binary() -# Finally, we configure HDF5.jl as desired. -import UUIDs -MPIPreferences.Preferences.set_preferences!( - UUIDs.UUID("f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"), # UUID of HDF5.jl - "libhdf5" => joinpath(JULIA_HDF5_PATH, "libhdf5." * Libdl.dlext), - "libhdf5_hl" => joinpath(JULIA_HDF5_PATH, "libhdf5_hl." * Libdl.dlext); - force=true -) \ No newline at end of file + # Finally, we configure HDF5.jl as desired. + import UUIDs + MPIPreferences.Preferences.set_preferences!( + UUIDs.UUID("f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"), # UUID of HDF5.jl + "libhdf5" => joinpath(JULIA_HDF5_PATH, "libhdf5." * Libdl.dlext), + "libhdf5_hl" => joinpath(JULIA_HDF5_PATH, "libhdf5_hl." * Libdl.dlext); + force=true + ) +end \ No newline at end of file From d15c7c743f5146e3637774f8ba052ddfee74905c Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Thu, 3 Aug 2023 10:01:40 +0300 Subject: [PATCH 043/102] enable additional configuration only in mpi test on linux --- test/configure_packages.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/configure_packages.jl b/test/configure_packages.jl index 7fd5a8a0b12..b4c398b7c6b 100644 --- a/test/configure_packages.jl +++ b/test/configure_packages.jl @@ -1,4 +1,5 @@ -if Sys.islinux() +const TRIXI_TEST = get(ENV, "TRIXI_TEST", "threaded") +if Sys.islinux() && (TRIXI_TEST == "all" || TRIXI_TEST == "mpi") using Pkg, Libdl Pkg.activate(dirname(@__DIR__)) Pkg.instantiate() From 451e42dd76edd7b1cafce7e40dccc23477b99a94 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Thu, 3 Aug 2023 10:26:58 +0300 Subject: [PATCH 044/102] enable environment --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b93ac0c7125..878f4b0d813 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -108,6 +108,9 @@ jobs: arch: ${{ matrix.arch }} - run: julia -e 'using InteractiveUtils; versioninfo(verbose=true)' - name: Configure MPI.jl + env: + PYTHON: "" + TRIXI_TEST: ${{ matrix.trixi_test }} shell: julia --color=yes {0} run: | @show pwd() From a4b3544d3cb07b762fd6d7504aac9b91441bd5c7 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Thu, 3 Aug 2023 15:32:20 +0300 Subject: [PATCH 045/102] test coverage issue --- test/configure_packages.jl | 2 ++ test/test_mpi_tree.jl | 6 +++--- test/test_threaded.jl | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/test/configure_packages.jl b/test/configure_packages.jl index b4c398b7c6b..e769cdbdb0a 100644 --- a/test/configure_packages.jl +++ b/test/configure_packages.jl @@ -24,4 +24,6 @@ if Sys.islinux() && (TRIXI_TEST == "all" || TRIXI_TEST == "mpi") "libhdf5_hl" => joinpath(JULIA_HDF5_PATH, "libhdf5_hl." * Libdl.dlext); force=true ) +using HDF5 +println(HDF5.has_parallel()) end \ No newline at end of file diff --git a/test/test_mpi_tree.jl b/test/test_mpi_tree.jl index 1d51ccbeb6b..f3abd1e284e 100644 --- a/test/test_mpi_tree.jl +++ b/test/test_mpi_tree.jl @@ -191,10 +191,10 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() end @trixi_testset "elixir_euler_density_wave_restart.jl" begin - using OrdinaryDiffEq: PIDController - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), controller = PIDController(1.0, 0.5, 0.2)) + using OrdinaryDiffEq: IController + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), controller = IController()) l2, linf = analysis_callback(sol) - eval(:(@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), controller = PIDController(1.0, 0.5, 0.2), + eval(:(@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), controller = IController(), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl l2 = $l2, linf = $linf))) end diff --git a/test/test_threaded.jl b/test/test_threaded.jl index 4c729171f30..50d0729d50d 100644 --- a/test/test_threaded.jl +++ b/test/test_threaded.jl @@ -146,10 +146,10 @@ Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) end end @trixi_testset "elixir_euler_density_wave_restart.jl" begin - using OrdinaryDiffEq: IController - trixi_include(@__MODULE__, joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_extended.jl"), controller = IController()) + using OrdinaryDiffEq: PIDController + trixi_include(@__MODULE__, joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_extended.jl"), controller = PIDController(1.0,0.5,0.2)) l2, linf = analysis_callback(sol) - eval(:(@test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_restart.jl"), controller = IController(), + eval(:(@test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_restart.jl"), controller = PIDController(1.0,0.5,0.2), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl l2 = $l2, linf = $linf))) end From f66a1a20665f86091d603d7b9c35f4492f26c590 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Thu, 3 Aug 2023 16:13:59 +0300 Subject: [PATCH 046/102] disable mpi macOs CI because of failure --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 878f4b0d813..24a2fc6015a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,10 +84,10 @@ jobs: os: ubuntu-latest arch: x64 trixi_test: threaded_legacy - - version: '1.9' - os: macOS-latest - arch: x64 - trixi_test: mpi + # - version: '1.9' + # os: macOS-latest + # arch: x64 + # trixi_test: mpi - version: '1.9' os: macOS-latest arch: x64 From c8393fd5a2c84e08c55f4faba9eaaf56b6f44427 Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Thu, 3 Aug 2023 22:41:11 +0300 Subject: [PATCH 047/102] disable new configurations to test coverage --- .github/workflows/ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 24a2fc6015a..004225f1850 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -107,14 +107,14 @@ jobs: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - run: julia -e 'using InteractiveUtils; versioninfo(verbose=true)' - - name: Configure MPI.jl - env: - PYTHON: "" - TRIXI_TEST: ${{ matrix.trixi_test }} - shell: julia --color=yes {0} - run: | - @show pwd() - include(joinpath(pwd(), "test", "configure_packages.jl")) + # - name: Configure MPI.jl + # env: + # PYTHON: "" + # TRIXI_TEST: ${{ matrix.trixi_test }} + # shell: julia --color=yes {0} + # run: | + # @show pwd() + # include(joinpath(pwd(), "test", "configure_packages.jl")) - uses: julia-actions/cache@v1 - uses: julia-actions/julia-buildpkg@v1 env: From 93a39add1b7e8e63770af25ccb70f439b2e4789c Mon Sep 17 00:00:00 2001 From: ArseniyKholod Date: Fri, 4 Aug 2023 00:32:37 +0300 Subject: [PATCH 048/102] disable PID and I test to test coverage issue --- test/test_mpi_tree.jl | 6 +++--- test/test_threaded.jl | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/test_mpi_tree.jl b/test/test_mpi_tree.jl index f3abd1e284e..0ddb2c5f4f5 100644 --- a/test/test_mpi_tree.jl +++ b/test/test_mpi_tree.jl @@ -191,10 +191,10 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() end @trixi_testset "elixir_euler_density_wave_restart.jl" begin - using OrdinaryDiffEq: IController - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), controller = IController()) + # using OrdinaryDiffEq: IController + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl")) l2, linf = analysis_callback(sol) - eval(:(@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), controller = IController(), + eval(:(@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl l2 = $l2, linf = $linf))) end diff --git a/test/test_threaded.jl b/test/test_threaded.jl index 50d0729d50d..a9efaa8c14c 100644 --- a/test/test_threaded.jl +++ b/test/test_threaded.jl @@ -146,10 +146,10 @@ Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) end end @trixi_testset "elixir_euler_density_wave_restart.jl" begin - using OrdinaryDiffEq: PIDController - trixi_include(@__MODULE__, joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_extended.jl"), controller = PIDController(1.0,0.5,0.2)) + # using OrdinaryDiffEq: PIDController + trixi_include(@__MODULE__, joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_extended.jl")) l2, linf = analysis_callback(sol) - eval(:(@test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_restart.jl"), controller = PIDController(1.0,0.5,0.2), + eval(:(@test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_restart.jl"), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl l2 = $l2, linf = $linf))) end From 5b7594470609beddf0666da72619312d5bff5797 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Fri, 4 Aug 2023 10:08:43 +0300 Subject: [PATCH 049/102] enable old coverage all --- .github/workflows/ci.yml | 86 ++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 004225f1850..e8df2287be5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -136,24 +136,24 @@ jobs: - uses: julia-actions/julia-processcoverage@v1 with: directories: src,examples,ext - - uses: codecov/codecov-action@v3 - with: - file: ./lcov.info - flags: unittests - name: codecov-umbrella - fail_ci_if_error: false - token: ${{ secrets.CODECOV_TOKEN }} + # - uses: codecov/codecov-action@v3 + # with: + # file: ./lcov.info + # flags: unittests + # name: codecov-umbrella + # fail_ci_if_error: false + # token: ${{ secrets.CODECOV_TOKEN }} # The standard setup of Coveralls is just annoying for parallel builds, see, e.g., # https://github.com/trixi-framework/Trixi.jl/issues/691 # https://github.com/coverallsapp/github-action/issues/47 # https://github.com/coverallsapp/github-action/issues/67 # This standard setup is reproduced below for completeness. - # - uses: coverallsapp/github-action@master - # with: - # github-token: ${{ secrets.GITHUB_TOKEN }} - # flag-name: run-${{ matrix.trixi_test }}-${{ matrix.os }}-${{ matrix.version }}-${{ matrix.arch }}-${{ github.run_id }} - # parallel: true - # path-to-lcov: ./lcov.info + - uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + flag-name: run-${{ matrix.trixi_test }}-${{ matrix.os }}-${{ matrix.version }}-${{ matrix.arch }}-${{ github.run_id }} + parallel: true + path-to-lcov: ./lcov.info # Instead, we use a more tedious approach: # - Store all individual coverage files as artifacts (directly below) # - Download and merge individual coverage reports in another step @@ -175,41 +175,41 @@ jobs: # https://github.com/coverallsapp/github-action/issues/47 # https://github.com/coverallsapp/github-action/issues/67 # This standard setup is reproduced below for completeness. - # - name: Coveralls Finished - # uses: coverallsapp/github-action@master - # with: - # github-token: ${{ secrets.GITHUB_TOKEN }} - # parallel-finished: true + - name: Coveralls Finished + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + parallel-finished: true # Instead, we use the more tedious approach described above. # At first, we check out the repository and download all artifacts # (and list files for debugging). - - uses: actions/checkout@v3 - - uses: actions/download-artifact@v3 - - run: ls -R + # - uses: actions/checkout@v3 + # - uses: actions/download-artifact@v3 + # - run: ls -R # Next, we merge the individual coverage files and upload # the combined results to Coveralls. - - name: Merge lcov files using Coverage.jl - shell: julia --color=yes {0} - run: | - using Pkg - Pkg.activate(temp=true) - Pkg.add("Coverage") - using Coverage - coverage = LCOV.readfolder(".") - for cov in coverage - cov.filename = replace(cov.filename, "\\" => "/") - end - coverage = merge_coverage_counts(coverage) - @show covered_lines, total_lines = get_summary(coverage) - LCOV.writefile("./lcov.info", coverage) - - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - path-to-lcov: ./lcov.info + # - name: Merge lcov files using Coverage.jl + # shell: julia --color=yes {0} + # run: | + # using Pkg + # Pkg.activate(temp=true) + # Pkg.add("Coverage") + # using Coverage + # coverage = LCOV.readfolder(".") + # for cov in coverage + # cov.filename = replace(cov.filename, "\\" => "/") + # end + # coverage = merge_coverage_counts(coverage) + # @show covered_lines, total_lines = get_summary(coverage) + # LCOV.writefile("./lcov.info", coverage) + # - uses: coverallsapp/github-action@master + # with: + # github-token: ${{ secrets.GITHUB_TOKEN }} + # path-to-lcov: ./lcov.info # Upload merged coverage data as artifact for debugging - - uses: actions/upload-artifact@v3 - with: - name: lcov - path: ./lcov.info + # - uses: actions/upload-artifact@v3 + # with: + # name: lcov + # path: ./lcov.info # That's it - run: echo "Finished testing Trixi" From 460c8df82f594257515d5147abb8adfbda116344 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Fri, 4 Aug 2023 10:45:48 +0300 Subject: [PATCH 050/102] undo last commit and enable coverage on windows --- .github/workflows/ci.yml | 86 ++++++++++++++++++++-------------------- test/runtests.jl | 2 +- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e8df2287be5..004225f1850 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -136,24 +136,24 @@ jobs: - uses: julia-actions/julia-processcoverage@v1 with: directories: src,examples,ext - # - uses: codecov/codecov-action@v3 - # with: - # file: ./lcov.info - # flags: unittests - # name: codecov-umbrella - # fail_ci_if_error: false - # token: ${{ secrets.CODECOV_TOKEN }} + - uses: codecov/codecov-action@v3 + with: + file: ./lcov.info + flags: unittests + name: codecov-umbrella + fail_ci_if_error: false + token: ${{ secrets.CODECOV_TOKEN }} # The standard setup of Coveralls is just annoying for parallel builds, see, e.g., # https://github.com/trixi-framework/Trixi.jl/issues/691 # https://github.com/coverallsapp/github-action/issues/47 # https://github.com/coverallsapp/github-action/issues/67 # This standard setup is reproduced below for completeness. - - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - flag-name: run-${{ matrix.trixi_test }}-${{ matrix.os }}-${{ matrix.version }}-${{ matrix.arch }}-${{ github.run_id }} - parallel: true - path-to-lcov: ./lcov.info + # - uses: coverallsapp/github-action@master + # with: + # github-token: ${{ secrets.GITHUB_TOKEN }} + # flag-name: run-${{ matrix.trixi_test }}-${{ matrix.os }}-${{ matrix.version }}-${{ matrix.arch }}-${{ github.run_id }} + # parallel: true + # path-to-lcov: ./lcov.info # Instead, we use a more tedious approach: # - Store all individual coverage files as artifacts (directly below) # - Download and merge individual coverage reports in another step @@ -175,41 +175,41 @@ jobs: # https://github.com/coverallsapp/github-action/issues/47 # https://github.com/coverallsapp/github-action/issues/67 # This standard setup is reproduced below for completeness. - - name: Coveralls Finished - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - parallel-finished: true + # - name: Coveralls Finished + # uses: coverallsapp/github-action@master + # with: + # github-token: ${{ secrets.GITHUB_TOKEN }} + # parallel-finished: true # Instead, we use the more tedious approach described above. # At first, we check out the repository and download all artifacts # (and list files for debugging). - # - uses: actions/checkout@v3 - # - uses: actions/download-artifact@v3 - # - run: ls -R + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 + - run: ls -R # Next, we merge the individual coverage files and upload # the combined results to Coveralls. - # - name: Merge lcov files using Coverage.jl - # shell: julia --color=yes {0} - # run: | - # using Pkg - # Pkg.activate(temp=true) - # Pkg.add("Coverage") - # using Coverage - # coverage = LCOV.readfolder(".") - # for cov in coverage - # cov.filename = replace(cov.filename, "\\" => "/") - # end - # coverage = merge_coverage_counts(coverage) - # @show covered_lines, total_lines = get_summary(coverage) - # LCOV.writefile("./lcov.info", coverage) - # - uses: coverallsapp/github-action@master - # with: - # github-token: ${{ secrets.GITHUB_TOKEN }} - # path-to-lcov: ./lcov.info + - name: Merge lcov files using Coverage.jl + shell: julia --color=yes {0} + run: | + using Pkg + Pkg.activate(temp=true) + Pkg.add("Coverage") + using Coverage + coverage = LCOV.readfolder(".") + for cov in coverage + cov.filename = replace(cov.filename, "\\" => "/") + end + coverage = merge_coverage_counts(coverage) + @show covered_lines, total_lines = get_summary(coverage) + LCOV.writefile("./lcov.info", coverage) + - uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: ./lcov.info # Upload merged coverage data as artifact for debugging - # - uses: actions/upload-artifact@v3 - # with: - # name: lcov - # path: ./lcov.info + - uses: actions/upload-artifact@v3 + with: + name: lcov + path: ./lcov.info # That's it - run: echo "Finished testing Trixi" diff --git a/test/runtests.jl b/test/runtests.jl index 1b0c745dbfd..9f6d4295cda 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -28,7 +28,7 @@ const TRIXI_NTHREADS = clamp(Sys.CPU_THREADS, 2, 3) cmd = string(Base.julia_cmd()) coverage = occursin("--code-coverage", cmd) && !occursin("--code-coverage=none", cmd) - if !(coverage && Sys.iswindows()) && !(coverage && Sys.islinux()) + if !(coverage && Sys.iswindows()) # && !(coverage && Sys.islinux()) # We provide a `--heap-size-hint` to avoid/reduce out-of-memory errors during CI testing mpiexec() do cmd run(`$cmd -n $TRIXI_MPI_NPROCS $(Base.julia_cmd()) --threads=1 --check-bounds=yes --heap-size-hint=1G $(abspath("test_mpi.jl"))`) From 903f27e5a7c05005cede442b09174e8ab22b2ac3 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Fri, 4 Aug 2023 12:26:07 +0300 Subject: [PATCH 051/102] enable new tests, mpi macOs and HDF5 parallel --- .github/workflows/ci.yml | 24 ++++++++++++------------ test/test_mpi_tree.jl | 6 +++--- test/test_threaded.jl | 6 +++--- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 004225f1850..878f4b0d813 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,10 +84,10 @@ jobs: os: ubuntu-latest arch: x64 trixi_test: threaded_legacy - # - version: '1.9' - # os: macOS-latest - # arch: x64 - # trixi_test: mpi + - version: '1.9' + os: macOS-latest + arch: x64 + trixi_test: mpi - version: '1.9' os: macOS-latest arch: x64 @@ -107,14 +107,14 @@ jobs: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - run: julia -e 'using InteractiveUtils; versioninfo(verbose=true)' - # - name: Configure MPI.jl - # env: - # PYTHON: "" - # TRIXI_TEST: ${{ matrix.trixi_test }} - # shell: julia --color=yes {0} - # run: | - # @show pwd() - # include(joinpath(pwd(), "test", "configure_packages.jl")) + - name: Configure MPI.jl + env: + PYTHON: "" + TRIXI_TEST: ${{ matrix.trixi_test }} + shell: julia --color=yes {0} + run: | + @show pwd() + include(joinpath(pwd(), "test", "configure_packages.jl")) - uses: julia-actions/cache@v1 - uses: julia-actions/julia-buildpkg@v1 env: diff --git a/test/test_mpi_tree.jl b/test/test_mpi_tree.jl index 0ddb2c5f4f5..9f2b823a371 100644 --- a/test/test_mpi_tree.jl +++ b/test/test_mpi_tree.jl @@ -191,10 +191,10 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() end @trixi_testset "elixir_euler_density_wave_restart.jl" begin - # using OrdinaryDiffEq: IController - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl")) + using OrdinaryDiffEq: PIDController + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), controller = PIDController(1.0,0.5,0.2)) l2, linf = analysis_callback(sol) - eval(:(@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), + eval(:(@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), controller = PIDController(1.0,0.5,0.2), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl l2 = $l2, linf = $linf))) end diff --git a/test/test_threaded.jl b/test/test_threaded.jl index a9efaa8c14c..b5fcb2f8916 100644 --- a/test/test_threaded.jl +++ b/test/test_threaded.jl @@ -146,10 +146,10 @@ Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) end end @trixi_testset "elixir_euler_density_wave_restart.jl" begin - # using OrdinaryDiffEq: PIDController - trixi_include(@__MODULE__, joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_extended.jl")) + # using OrdinaryDiffEq: IController + trixi_include(@__MODULE__, joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_extended.jl"), controller = IController()) l2, linf = analysis_callback(sol) - eval(:(@test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_restart.jl"), + eval(:(@test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_restart.jl"), controller = IController(), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl l2 = $l2, linf = $linf))) end From 6eb1bcc5d912e03873259bcc595707e39b993c1c Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Fri, 4 Aug 2023 12:52:44 +0300 Subject: [PATCH 052/102] fix --- test/test_threaded.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_threaded.jl b/test/test_threaded.jl index b5fcb2f8916..4c729171f30 100644 --- a/test/test_threaded.jl +++ b/test/test_threaded.jl @@ -146,7 +146,7 @@ Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) end end @trixi_testset "elixir_euler_density_wave_restart.jl" begin - # using OrdinaryDiffEq: IController + using OrdinaryDiffEq: IController trixi_include(@__MODULE__, joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_extended.jl"), controller = IController()) l2, linf = analysis_callback(sol) eval(:(@test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_restart.jl"), controller = IController(), From 2ab9cb3ea7c37b3f53757a204b8e84e9c7dbbfcf Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Fri, 4 Aug 2023 14:53:25 +0300 Subject: [PATCH 053/102] enable coverage on threads --- test/runtests.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 9f6d4295cda..3faca7b1856 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -42,8 +42,7 @@ const TRIXI_NTHREADS = clamp(Sys.CPU_THREADS, 2, 3) # If the process errors out the testset would error out as well, # cf. https://github.com/JuliaParallel/MPI.jl/pull/391 @test true - - run(`$(Base.julia_cmd()) --threads=$TRIXI_NTHREADS --check-bounds=yes --code-coverage=none $(abspath("test_threaded.jl"))`) + run(`$(Base.julia_cmd()) --threads=$TRIXI_NTHREADS --check-bounds=yes $(abspath("test_threaded.jl"))`) end @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part1" From e020129afbc4716b148793bb525e94c3826ee45d Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Fri, 4 Aug 2023 17:02:15 +0300 Subject: [PATCH 054/102] test HDF5 parallel --- src/callbacks_step/save_restart_dg.jl | 2 +- test/runtests.jl | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/callbacks_step/save_restart_dg.jl b/src/callbacks_step/save_restart_dg.jl index c6b687a55ba..8b0b753ddef 100644 --- a/src/callbacks_step/save_restart_dg.jl +++ b/src/callbacks_step/save_restart_dg.jl @@ -94,7 +94,7 @@ function save_restart_file(u, time, dt, timestep, @unpack output_directory = restart_callback # Filename based on current time step filename = joinpath(output_directory, @sprintf("restart_%06d.h5", timestep)) - + println( get(ENV, "JULIA_HDF5_PATH", ""), " ", HDF5.has_parallel()) if HDF5.has_parallel() save_restart_file_parallel(u, time, dt, timestep, mesh, equations, dg, cache, filename) diff --git a/test/runtests.jl b/test/runtests.jl index 3faca7b1856..0ccf559c6a2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,5 +1,7 @@ using Test using MPI: mpiexec +using HDF5: has_parallel +println( get(ENV, "JULIA_HDF5_PATH", ""), " ", HDF5.has_parallel()) # We run tests in parallel with CI jobs setting the `TRIXI_TEST` environment # variable to determine the subset of tests to execute. From 9377349bccc1faef93f0281a0eeff2979881447a Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Fri, 4 Aug 2023 21:16:52 +0300 Subject: [PATCH 055/102] test HDF5 parallel 2 --- test/runtests.jl | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 0ccf559c6a2..3faca7b1856 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,7 +1,5 @@ using Test using MPI: mpiexec -using HDF5: has_parallel -println( get(ENV, "JULIA_HDF5_PATH", ""), " ", HDF5.has_parallel()) # We run tests in parallel with CI jobs setting the `TRIXI_TEST` environment # variable to determine the subset of tests to execute. From 40e5d454599858bf9943a97b8529d4b871bc7d33 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Fri, 4 Aug 2023 23:04:43 +0300 Subject: [PATCH 056/102] test HDF5 parallel 3 --- .github/workflows/ci.yml | 41 ++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 878f4b0d813..d5f4e1f9565 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,6 +41,31 @@ concurrency: cancel-in-progress: true jobs: + HDF5-system-libs: + name: julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} (system libhdf5 + mpich) + runs-on: ${{ matrix.os }} + timeout-minutes: 40 + strategy: + matrix: + version: + - '1.9' + os: + - ubuntu-20.04 # required for libhdf5 v1.10.4 support + arch: + - x64 + steps: + - uses: actions/checkout@v3 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - uses: julia-actions/julia-buildpkg@v1 + - name: Configure MPI.jl + shell: julia --color=yes {0} + run: | + @show pwd() + include(joinpath(pwd(), "test", "configure_packages.jl")) + - uses: julia-actions/julia-runtest@v1 test: if: "!contains(github.event.head_commit.message, 'skip ci')" # We could also include the Julia version as in @@ -107,14 +132,14 @@ jobs: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - run: julia -e 'using InteractiveUtils; versioninfo(verbose=true)' - - name: Configure MPI.jl - env: - PYTHON: "" - TRIXI_TEST: ${{ matrix.trixi_test }} - shell: julia --color=yes {0} - run: | - @show pwd() - include(joinpath(pwd(), "test", "configure_packages.jl")) + # - name: Configure MPI.jl + # env: + # PYTHON: "" + # TRIXI_TEST: ${{ matrix.trixi_test }} + # shell: julia --color=yes {0} + # run: | + # @show pwd() + # include(joinpath(pwd(), "test", "configure_packages.jl")) - uses: julia-actions/cache@v1 - uses: julia-actions/julia-buildpkg@v1 env: From 68f41c32d449721341c37ea1fb66cbb1e9ffbf2c Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Fri, 4 Aug 2023 23:10:47 +0300 Subject: [PATCH 057/102] fix --- test/configure_packages.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/configure_packages.jl b/test/configure_packages.jl index e769cdbdb0a..98c6eb100ab 100644 --- a/test/configure_packages.jl +++ b/test/configure_packages.jl @@ -1,5 +1,5 @@ const TRIXI_TEST = get(ENV, "TRIXI_TEST", "threaded") -if Sys.islinux() && (TRIXI_TEST == "all" || TRIXI_TEST == "mpi") +if Sys.islinux() # && (TRIXI_TEST == "all" || TRIXI_TEST == "mpi") using Pkg, Libdl Pkg.activate(dirname(@__DIR__)) Pkg.instantiate() From 21d97023757e28fe496e81e1f3093ee575485a73 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Sat, 5 Aug 2023 00:08:25 +0300 Subject: [PATCH 058/102] Update save_restart_dg.jl --- src/callbacks_step/save_restart_dg.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/callbacks_step/save_restart_dg.jl b/src/callbacks_step/save_restart_dg.jl index 8b0b753ddef..a24dbaf7a08 100644 --- a/src/callbacks_step/save_restart_dg.jl +++ b/src/callbacks_step/save_restart_dg.jl @@ -94,7 +94,7 @@ function save_restart_file(u, time, dt, timestep, @unpack output_directory = restart_callback # Filename based on current time step filename = joinpath(output_directory, @sprintf("restart_%06d.h5", timestep)) - println( get(ENV, "JULIA_HDF5_PATH", ""), " ", HDF5.has_parallel()) + println(get(ENV, "JULIA_HDF5_PATH", ""), " ", HDF5.has_parallel()) if HDF5.has_parallel() save_restart_file_parallel(u, time, dt, timestep, mesh, equations, dg, cache, filename) From a0b5b3b924d711ad0db2c449ec691c19476f155e Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Sat, 5 Aug 2023 00:13:59 +0300 Subject: [PATCH 059/102] test HDF5 parallel 4 --- .github/workflows/ci.yml | 41 ++++++++------------------------------ test/configure_packages.jl | 2 +- 2 files changed, 9 insertions(+), 34 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d5f4e1f9565..a811ba3378e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,31 +41,6 @@ concurrency: cancel-in-progress: true jobs: - HDF5-system-libs: - name: julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} (system libhdf5 + mpich) - runs-on: ${{ matrix.os }} - timeout-minutes: 40 - strategy: - matrix: - version: - - '1.9' - os: - - ubuntu-20.04 # required for libhdf5 v1.10.4 support - arch: - - x64 - steps: - - uses: actions/checkout@v3 - - uses: julia-actions/setup-julia@v1 - with: - version: ${{ matrix.version }} - arch: ${{ matrix.arch }} - - uses: julia-actions/julia-buildpkg@v1 - - name: Configure MPI.jl - shell: julia --color=yes {0} - run: | - @show pwd() - include(joinpath(pwd(), "test", "configure_packages.jl")) - - uses: julia-actions/julia-runtest@v1 test: if: "!contains(github.event.head_commit.message, 'skip ci')" # We could also include the Julia version as in @@ -132,18 +107,18 @@ jobs: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - run: julia -e 'using InteractiveUtils; versioninfo(verbose=true)' - # - name: Configure MPI.jl - # env: - # PYTHON: "" - # TRIXI_TEST: ${{ matrix.trixi_test }} - # shell: julia --color=yes {0} - # run: | - # @show pwd() - # include(joinpath(pwd(), "test", "configure_packages.jl")) - uses: julia-actions/cache@v1 - uses: julia-actions/julia-buildpkg@v1 env: PYTHON: "" + - name: Configure MPI.jl + env: + PYTHON: "" + TRIXI_TEST: ${{ matrix.trixi_test }} + shell: julia --color=yes {0} + run: | + @show pwd() + include(joinpath(pwd(), "test", "configure_packages.jl")) - name: Run tests without coverage uses: julia-actions/julia-runtest@v1 with: diff --git a/test/configure_packages.jl b/test/configure_packages.jl index 98c6eb100ab..e769cdbdb0a 100644 --- a/test/configure_packages.jl +++ b/test/configure_packages.jl @@ -1,5 +1,5 @@ const TRIXI_TEST = get(ENV, "TRIXI_TEST", "threaded") -if Sys.islinux() # && (TRIXI_TEST == "all" || TRIXI_TEST == "mpi") +if Sys.islinux() && (TRIXI_TEST == "all" || TRIXI_TEST == "mpi") using Pkg, Libdl Pkg.activate(dirname(@__DIR__)) Pkg.instantiate() From 714ca915543726c6996afad5eec675e18595b8ee Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Sat, 5 Aug 2023 00:59:27 +0300 Subject: [PATCH 060/102] test HDF5 parallel 5 --- test/configure_packages.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/configure_packages.jl b/test/configure_packages.jl index e769cdbdb0a..57db3c0426e 100644 --- a/test/configure_packages.jl +++ b/test/configure_packages.jl @@ -24,6 +24,7 @@ if Sys.islinux() && (TRIXI_TEST == "all" || TRIXI_TEST == "mpi") "libhdf5_hl" => joinpath(JULIA_HDF5_PATH, "libhdf5_hl." * Libdl.dlext); force=true ) +using MPI using HDF5 println(HDF5.has_parallel()) end \ No newline at end of file From 32c3939b5d64619929fd9f33afbee2de1828bc29 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Sat, 5 Aug 2023 09:46:06 +0200 Subject: [PATCH 061/102] Update configure_packages.jl --- test/configure_packages.jl | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/configure_packages.jl b/test/configure_packages.jl index 57db3c0426e..01251cc7562 100644 --- a/test/configure_packages.jl +++ b/test/configure_packages.jl @@ -24,7 +24,4 @@ if Sys.islinux() && (TRIXI_TEST == "all" || TRIXI_TEST == "mpi") "libhdf5_hl" => joinpath(JULIA_HDF5_PATH, "libhdf5_hl." * Libdl.dlext); force=true ) -using MPI -using HDF5 -println(HDF5.has_parallel()) -end \ No newline at end of file +end From 27666c75cf7e7a42d23f2f6d5cc90a1b9ce40116 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Sat, 5 Aug 2023 10:56:04 +0300 Subject: [PATCH 062/102] delete unnecessary changes --- .github/workflows/ci.yml | 8 -------- Project.toml | 13 ++++++------- test/configure_packages.jl | 30 ------------------------------ 3 files changed, 6 insertions(+), 45 deletions(-) delete mode 100644 test/configure_packages.jl diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a811ba3378e..4790f93d913 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -111,14 +111,6 @@ jobs: - uses: julia-actions/julia-buildpkg@v1 env: PYTHON: "" - - name: Configure MPI.jl - env: - PYTHON: "" - TRIXI_TEST: ${{ matrix.trixi_test }} - shell: julia --color=yes {0} - run: | - @show pwd() - include(joinpath(pwd(), "test", "configure_packages.jl")) - name: Run tests without coverage uses: julia-actions/julia-runtest@v1 with: diff --git a/Project.toml b/Project.toml index 0defc61f613..a2164b37dc4 100644 --- a/Project.toml +++ b/Project.toml @@ -16,7 +16,6 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" LinearMaps = "7a12625a-238d-50fd-b39a-03d52299707e" LoopVectorization = "bdcacae8-1622-11e9-2a5c-532679323890" MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" -MPIPreferences = "3da0fdf6-3ccc-4f1b-acd9-58baa6c99267" MuladdMacro = "46d2c3a1-f734-5fdb-9937-b9b9aeba4221" Octavian = "6fd5a793-0b7e-452c-907f-f8bfe9c57db4" OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" @@ -45,6 +44,12 @@ Triangulate = "f7e6ffb2-c36d-4f8f-a77e-16e897189344" TriplotBase = "981d1d27-644d-49a2-9326-4793e63143c3" TriplotRecipes = "808ab39a-a642-4abf-81ff-4cb34ebbffa3" +[weakdeps] +Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" + +[extensions] +TrixiMakieExt = "Makie" + [compat] CodeTracking = "1.0.5" ConstructionBase = "1.3" @@ -84,11 +89,5 @@ TriplotBase = "0.1" TriplotRecipes = "0.1" julia = "1.8" -[extensions] -TrixiMakieExt = "Makie" - [extras] Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" - -[weakdeps] -Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" diff --git a/test/configure_packages.jl b/test/configure_packages.jl deleted file mode 100644 index 57db3c0426e..00000000000 --- a/test/configure_packages.jl +++ /dev/null @@ -1,30 +0,0 @@ -const TRIXI_TEST = get(ENV, "TRIXI_TEST", "threaded") -if Sys.islinux() && (TRIXI_TEST == "all" || TRIXI_TEST == "mpi") - using Pkg, Libdl - Pkg.activate(dirname(@__DIR__)) - Pkg.instantiate() - # Configure the test setup based on environment variables set in CI. - # First, we get the settings and remove all local preference configurations - # that may still exist. - run(`sudo apt-get update`) - run(`sudo apt-get install mpich libhdf5-mpich-dev`) - run(`echo "JULIA_HDF5_PATH=/usr/lib/x86_64-linux-gnu/hdf5/mpich/" \>\> \$GITHUB_ENV`) - const JULIA_HDF5_PATH = get(ENV, "JULIA_HDF5_PATH", "") - rm(joinpath(dirname(@__DIR__), "LocalPreferences.toml"); force=true) - - # Next, we configure MPI.jl appropriately. - using MPIPreferences - MPIPreferences.use_system_binary() - - # Finally, we configure HDF5.jl as desired. - import UUIDs - MPIPreferences.Preferences.set_preferences!( - UUIDs.UUID("f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"), # UUID of HDF5.jl - "libhdf5" => joinpath(JULIA_HDF5_PATH, "libhdf5." * Libdl.dlext), - "libhdf5_hl" => joinpath(JULIA_HDF5_PATH, "libhdf5_hl." * Libdl.dlext); - force=true - ) -using MPI -using HDF5 -println(HDF5.has_parallel()) -end \ No newline at end of file From 7de973be97e4f5ad8424fe608edad8a1dd875483 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Sat, 5 Aug 2023 13:29:48 +0200 Subject: [PATCH 063/102] Update save_restart_dg.jl --- src/callbacks_step/save_restart_dg.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/callbacks_step/save_restart_dg.jl b/src/callbacks_step/save_restart_dg.jl index a24dbaf7a08..214c58cf25d 100644 --- a/src/callbacks_step/save_restart_dg.jl +++ b/src/callbacks_step/save_restart_dg.jl @@ -94,7 +94,7 @@ function save_restart_file(u, time, dt, timestep, @unpack output_directory = restart_callback # Filename based on current time step filename = joinpath(output_directory, @sprintf("restart_%06d.h5", timestep)) - println(get(ENV, "JULIA_HDF5_PATH", ""), " ", HDF5.has_parallel()) + if HDF5.has_parallel() save_restart_file_parallel(u, time, dt, timestep, mesh, equations, dg, cache, filename) From 5c91748e4f75d5ad5a3fd2053be34bda4f1715ff Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Sat, 5 Aug 2023 13:51:29 +0300 Subject: [PATCH 064/102] Update save_restart_dg.jl --- src/callbacks_step/save_restart_dg.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/callbacks_step/save_restart_dg.jl b/src/callbacks_step/save_restart_dg.jl index 214c58cf25d..c6b687a55ba 100644 --- a/src/callbacks_step/save_restart_dg.jl +++ b/src/callbacks_step/save_restart_dg.jl @@ -94,7 +94,7 @@ function save_restart_file(u, time, dt, timestep, @unpack output_directory = restart_callback # Filename based on current time step filename = joinpath(output_directory, @sprintf("restart_%06d.h5", timestep)) - + if HDF5.has_parallel() save_restart_file_parallel(u, time, dt, timestep, mesh, equations, dg, cache, filename) From d76653e5e12ff50c7701cd5112faf6b3e86022da Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Tue, 15 Aug 2023 13:38:48 +0300 Subject: [PATCH 065/102] remove dependency on OrdinaryDiffEq --- Project.toml | 1 - .../elixir_euler_density_wave_extended.jl | 6 +- .../elixir_euler_density_wave_restart.jl | 3 +- src/Trixi.jl | 1 - src/callbacks_step/save_restart.jl | 69 ++++--------------- src/callbacks_step/save_restart_dg.jl | 52 ++++---------- 6 files changed, 30 insertions(+), 102 deletions(-) diff --git a/Project.toml b/Project.toml index a2164b37dc4..c22d4b90642 100644 --- a/Project.toml +++ b/Project.toml @@ -19,7 +19,6 @@ MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" MuladdMacro = "46d2c3a1-f734-5fdb-9937-b9b9aeba4221" Octavian = "6fd5a793-0b7e-452c-907f-f8bfe9c57db4" OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" -OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" P4est = "7d669430-f675-4ae7-b43e-fab78ec5a902" Polyester = "f517fe37-dbe3-4b94-8317-1923a5111588" PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" diff --git a/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl b/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl index 61ac786410f..438ffbd94e0 100644 --- a/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl +++ b/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl @@ -40,12 +40,10 @@ save_solution = SaveSolutionCallback(interval = 100, save_final_solution = true, solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.6) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, - save_restart, save_solution, - stepsize_callback) + save_restart, save_solution) # create timestep controller controller = PIController(7 // 30, 2 // 15) @@ -54,5 +52,5 @@ controller = PIController(7 // 30, 2 // 15) # run the simulation sol = solve(ode, SSPRK43(); - ode_default_options()..., callback = callbacks, controller = controller); + callback = callbacks, controller = controller, ode_default_options()...); summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl b/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl index 6dd42927842..12850e21943 100644 --- a/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl +++ b/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl @@ -1,4 +1,3 @@ -+ using OrdinaryDiffEq using Trixi @@ -31,7 +30,7 @@ save_solution.condition.save_initial_solution = false alg = SSPRK43() integrator = init(ode, alg, - dt = dt; # solve needs some value here but it will be overwritten by the stepsize_callback + dt = dt; save_everystep = false, callback = callbacks, controller = controller, ode_default_options()...) load_controller!(integrator, restart_filename) diff --git a/src/Trixi.jl b/src/Trixi.jl index 72f27ab3a07..0ae3936de06 100644 --- a/src/Trixi.jl +++ b/src/Trixi.jl @@ -30,7 +30,6 @@ using Reexport: @reexport # MPI needs to be imported before HDF5 to be able to use parallel HDF5 # as long as HDF5.jl uses Requires.jl to enable parallel HDF5 with MPI using MPI: MPI -using OrdinaryDiffEq: IController, PIController, PIDController using SciMLBase: CallbackSet, DiscreteCallback, ODEProblem, ODESolution, ODEFunction, SplitODEProblem diff --git a/src/callbacks_step/save_restart.jl b/src/callbacks_step/save_restart.jl index 9cc9ee55834..652d7d71f91 100644 --- a/src/callbacks_step/save_restart.jl +++ b/src/callbacks_step/save_restart.jl @@ -106,7 +106,7 @@ function (restart_callback::SaveRestartCallback)(integrator) save_restart_file(u_ode, t, dt, iter, semi, restart_callback) if integrator.opts.adaptive - save_restart_controller(mesh, integrator, integrator.opts.controller, + save_restart_controller(integrator, integrator.opts.controller, restart_callback) end end @@ -161,69 +161,30 @@ function load_restart_file(semi::AbstractSemidiscretization, restart_file) end function load_controller!(integrator, restart_file::AbstractString) - controller_type = "" + controller = integrator.opts.controller if mpi_isroot() h5open(restart_file, "r") do file - if "controller_type" in keys(attributes(file)) - controller_type = read(attributes(file)["controller_type"]) + if ("qold" in keys(attributes(file))) && ("dtpropose" in keys(attributes(file))) + integrator.qold = read(attributes(file)["qold"]) + integrator.dtpropose = read(attributes(file)["dtpropose"]) + integrator.accept_step = true + end + if (:err in fieldnames(typeof(controller))) && ("controller_err" in keys(attributes(file))) + controller.err[1:3] = read(attributes(file)["controller_err"]) end end end if mpi_isparallel() - controller_type = MPI.bcast(controller_type, mpi_root(), mpi_comm()) - end - if controller_type == "PID" - if !(typeof(integrator.opts.controller) <: PIDController) - error("restart mismatch: controller differ from value in restart file") - end - load_PIDController!(integrator, restart_file) - elseif controller_type == "PI" || controller_type == "I" - if !(typeof(integrator.opts.controller) <: PIController) && - !(typeof(integrator.opts.controller) <: IController) - error("restart mismatch: controller differ from value in restart file") - end - load_PI_I_Controller!(integrator, restart_file) - end - integrator.accept_step = true -end - -function load_PIDController!(integrator, restart_file::AbstractString) - controller = integrator.opts.controller - if mpi_isroot() - h5open(restart_file, "r") do file - integrator.qold = read(attributes(file)["qold"]) - integrator.dtpropose = read(attributes(file)["dtpropose"]) - err = read(file["controller_err"]) - controller.err[1] = err[1] - controller.err[2] = err[2] - controller.err[3] = err[3] + recv_buf = [integrator.qold, integrator.dtpropose, integrator.accept_step] + if :err in fieldnames(typeof(controller)) + append!(recv_buf, controller.err) end - end - if mpi_isparallel() - recv_buf = [integrator.qold, integrator.dtpropose] - append!(recv_buf, controller.err) MPI.Bcast!(recv_buf, mpi_root(), mpi_comm()) - integrator.qold = recv_buf[1] - integrator.dtpropose = recv_buf[2] - controller.err[1] = recv_buf[3] - controller.err[2] = recv_buf[4] - controller.err[3] = recv_buf[5] - end -end - -function load_PI_I_Controller!(integrator, restart_file::AbstractString) - controller = integrator.opts.controller - if mpi_isroot() - h5open(restart_file, "r") do file - integrator.qold = read(attributes(file)["qold"]) - integrator.dtpropose = read(attributes(file)["dtpropose"]) + integrator.qold, integrator.dtpropose, integrator.accept_step = recv_buf[1:3] + if :err in fieldnames(typeof(controller)) + controller.err[1:3] = recv_buf[4:6] end end - if mpi_isparallel() - recv_buf = [integrator.qold, integrator.dtpropose] - MPI.Bcast!(recv_buf, mpi_root(), mpi_comm()) - integrator.qold, integrator.dtpropose = recv_buf - end end include("save_restart_dg.jl") diff --git a/src/callbacks_step/save_restart_dg.jl b/src/callbacks_step/save_restart_dg.jl index c6b687a55ba..948ef61c746 100644 --- a/src/callbacks_step/save_restart_dg.jl +++ b/src/callbacks_step/save_restart_dg.jl @@ -328,52 +328,24 @@ function load_restart_file_on_root(mesh::Union{ParallelTreeMesh, ParallelP4estMe return u_ode end -function save_restart_controller(mesh, integrator, +function save_restart_controller(integrator, controller, restart_callback) if mpi_isroot() - save_restart_controller(integrator, controller, restart_callback) + @unpack output_directory = restart_callback + timestep = integrator.stats.naccept + filename = joinpath(output_directory, @sprintf("restart_%06d.h5", timestep)) + # Open file (preserve existing content) + h5open(filename, "cw") do file + attributes(file)["qold"] = integrator.qold + attributes(file)["dtpropose"] = integrator.dtpropose + if :err in fieldnames(typeof(controller)) + attributes(file)["controller_err"] = controller.err + end + end end if mpi_isparallel() MPI.Barrier(mpi_comm()) end end -function save_restart_controller(integrator, controller::PIDController, - restart_callback) - @unpack output_directory = restart_callback - timestep = integrator.stats.naccept - filename = joinpath(output_directory, @sprintf("restart_%06d.h5", timestep)) - # Open file (preserve existing content) - h5open(filename, "cw") do file - attributes(file)["controller_type"] = "PID" - attributes(file)["qold"] = integrator.qold - attributes(file)["dtpropose"] = integrator.dtpropose - file["controller_err"] = controller.err - end -end - -function save_restart_controller(integrator, controller::PIController, restart_callback) - @unpack output_directory = restart_callback - timestep = integrator.stats.naccept - filename = joinpath(output_directory, @sprintf("restart_%06d.h5", timestep)) - # Open file (preserve existing content) - h5open(filename, "cw") do file - attributes(file)["controller_type"] = "PI" - attributes(file)["qold"] = integrator.qold - attributes(file)["dtpropose"] = integrator.dtpropose - end -end - -function save_restart_controller(integrator, controller::IController, restart_callback) - @unpack output_directory = restart_callback - timestep = integrator.stats.naccept - filename = joinpath(output_directory, @sprintf("restart_%06d.h5", timestep)) - # Open file (preserve existing content) - h5open(filename, "cw") do file - attributes(file)["controller_type"] = "I" - attributes(file)["qold"] = integrator.qold - attributes(file)["dtpropose"] = integrator.dtpropose - end -end -save_restart_controller(integrator, controller, restart_callback) = nothing end # @muladd From 3a786d5bd6c96993b9f7dbe430310efbdb7b80be Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Tue, 15 Aug 2023 13:42:19 +0300 Subject: [PATCH 066/102] format --- .../tree_2d_dgsem/elixir_euler_density_wave_extended.jl | 1 - examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl | 2 +- src/callbacks_step/save_restart.jl | 6 ++++-- src/callbacks_step/save_restart_dg.jl | 1 - 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl b/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl index 438ffbd94e0..6fa14f9845a 100644 --- a/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl +++ b/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl @@ -40,7 +40,6 @@ save_solution = SaveSolutionCallback(interval = 100, save_final_solution = true, solution_variables = cons2prim) - callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, save_solution) diff --git a/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl b/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl index 12850e21943..918dd9de8cf 100644 --- a/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl +++ b/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl @@ -30,7 +30,7 @@ save_solution.condition.save_initial_solution = false alg = SSPRK43() integrator = init(ode, alg, - dt = dt; + dt = dt; save_everystep = false, callback = callbacks, controller = controller, ode_default_options()...) load_controller!(integrator, restart_filename) diff --git a/src/callbacks_step/save_restart.jl b/src/callbacks_step/save_restart.jl index 652d7d71f91..41b3748e8e2 100644 --- a/src/callbacks_step/save_restart.jl +++ b/src/callbacks_step/save_restart.jl @@ -164,12 +164,14 @@ function load_controller!(integrator, restart_file::AbstractString) controller = integrator.opts.controller if mpi_isroot() h5open(restart_file, "r") do file - if ("qold" in keys(attributes(file))) && ("dtpropose" in keys(attributes(file))) + if ("qold" in keys(attributes(file))) && + ("dtpropose" in keys(attributes(file))) integrator.qold = read(attributes(file)["qold"]) integrator.dtpropose = read(attributes(file)["dtpropose"]) integrator.accept_step = true end - if (:err in fieldnames(typeof(controller))) && ("controller_err" in keys(attributes(file))) + if (:err in fieldnames(typeof(controller))) && + ("controller_err" in keys(attributes(file))) controller.err[1:3] = read(attributes(file)["controller_err"]) end end diff --git a/src/callbacks_step/save_restart_dg.jl b/src/callbacks_step/save_restart_dg.jl index 948ef61c746..b182674f4c2 100644 --- a/src/callbacks_step/save_restart_dg.jl +++ b/src/callbacks_step/save_restart_dg.jl @@ -347,5 +347,4 @@ function save_restart_controller(integrator, MPI.Barrier(mpi_comm()) end end - end # @muladd From 22607d55f38984cb5c9cf6e03bb31b20df53558d Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Tue, 15 Aug 2023 13:51:12 +0300 Subject: [PATCH 067/102] discard unrelated changes --- src/Trixi.jl | 1 + test/runtests.jl | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Trixi.jl b/src/Trixi.jl index 0ae3936de06..41c9cea6f51 100644 --- a/src/Trixi.jl +++ b/src/Trixi.jl @@ -30,6 +30,7 @@ using Reexport: @reexport # MPI needs to be imported before HDF5 to be able to use parallel HDF5 # as long as HDF5.jl uses Requires.jl to enable parallel HDF5 with MPI using MPI: MPI + using SciMLBase: CallbackSet, DiscreteCallback, ODEProblem, ODESolution, ODEFunction, SplitODEProblem diff --git a/test/runtests.jl b/test/runtests.jl index 3faca7b1856..032bf8f6fa6 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -28,7 +28,7 @@ const TRIXI_NTHREADS = clamp(Sys.CPU_THREADS, 2, 3) cmd = string(Base.julia_cmd()) coverage = occursin("--code-coverage", cmd) && !occursin("--code-coverage=none", cmd) - if !(coverage && Sys.iswindows()) # && !(coverage && Sys.islinux()) + if !(coverage && Sys.iswindows()) && !(coverage && Sys.islinux()) # We provide a `--heap-size-hint` to avoid/reduce out-of-memory errors during CI testing mpiexec() do cmd run(`$cmd -n $TRIXI_MPI_NPROCS $(Base.julia_cmd()) --threads=1 --check-bounds=yes --heap-size-hint=1G $(abspath("test_mpi.jl"))`) @@ -42,7 +42,7 @@ const TRIXI_NTHREADS = clamp(Sys.CPU_THREADS, 2, 3) # If the process errors out the testset would error out as well, # cf. https://github.com/JuliaParallel/MPI.jl/pull/391 @test true - run(`$(Base.julia_cmd()) --threads=$TRIXI_NTHREADS --check-bounds=yes $(abspath("test_threaded.jl"))`) + run(`$(Base.julia_cmd()) --threads=$TRIXI_NTHREADS --check-bounds=yes --code-coverage=none $(abspath("test_threaded.jl"))`) end @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part1" From 082fca4685c14ee98a3d000f666a480cb36b9345 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Tue, 15 Aug 2023 16:39:10 +0300 Subject: [PATCH 068/102] delete barrier --- src/callbacks_step/save_restart_dg.jl | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/callbacks_step/save_restart_dg.jl b/src/callbacks_step/save_restart_dg.jl index b182674f4c2..398c4fe4b67 100644 --- a/src/callbacks_step/save_restart_dg.jl +++ b/src/callbacks_step/save_restart_dg.jl @@ -343,8 +343,5 @@ function save_restart_controller(integrator, end end end - if mpi_isparallel() - MPI.Barrier(mpi_comm()) - end end end # @muladd From 503a50fbb051b24261d54cfa5b91717569723852 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Tue, 15 Aug 2023 17:00:37 +0300 Subject: [PATCH 069/102] delete eval() --- test/test_mpi_tree.jl | 4 ++-- test/test_threaded.jl | 4 ++-- test/test_tree_2d_euler.jl | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/test_mpi_tree.jl b/test/test_mpi_tree.jl index 9f2b823a371..597c2f5d09b 100644 --- a/test/test_mpi_tree.jl +++ b/test/test_mpi_tree.jl @@ -194,9 +194,9 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() using OrdinaryDiffEq: PIDController trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), controller = PIDController(1.0,0.5,0.2)) l2, linf = analysis_callback(sol) - eval(:(@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), controller = PIDController(1.0,0.5,0.2), + :@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), controller = PIDController(1.0,0.5,0.2), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl - l2 = $l2, linf = $linf))) + l2 = l2, linf = linf) end end diff --git a/test/test_threaded.jl b/test/test_threaded.jl index 4c729171f30..ba4f97fd8bb 100644 --- a/test/test_threaded.jl +++ b/test/test_threaded.jl @@ -149,9 +149,9 @@ Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) using OrdinaryDiffEq: IController trixi_include(@__MODULE__, joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_extended.jl"), controller = IController()) l2, linf = analysis_callback(sol) - eval(:(@test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_restart.jl"), controller = IController(), + :@test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_restart.jl"), controller = IController(), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl - l2 = $l2, linf = $linf))) + l2 = l2, linf = linf) end end diff --git a/test/test_tree_2d_euler.jl b/test/test_tree_2d_euler.jl index 7cfbbc59666..a44b34ca392 100644 --- a/test/test_tree_2d_euler.jl +++ b/test/test_tree_2d_euler.jl @@ -30,9 +30,9 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @trixi_testset "elixir_euler_density_wave_restart.jl" begin trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl")) l2, linf = analysis_callback(sol) - eval(:(@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), + :@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl - l2 = $l2, linf = $linf))) + l2 = l2, linf = linf) end @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin From 047db67924e08127af7e71e79a28da6d62bcbda6 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Tue, 15 Aug 2023 17:50:37 +0300 Subject: [PATCH 070/102] comments & delete mpi_parallel --- src/callbacks_step/save_restart.jl | 35 ++++++++++----------------- src/callbacks_step/save_restart_dg.jl | 9 ++++++- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/callbacks_step/save_restart.jl b/src/callbacks_step/save_restart.jl index 41b3748e8e2..126884ea191 100644 --- a/src/callbacks_step/save_restart.jl +++ b/src/callbacks_step/save_restart.jl @@ -162,29 +162,20 @@ end function load_controller!(integrator, restart_file::AbstractString) controller = integrator.opts.controller - if mpi_isroot() - h5open(restart_file, "r") do file - if ("qold" in keys(attributes(file))) && - ("dtpropose" in keys(attributes(file))) - integrator.qold = read(attributes(file)["qold"]) - integrator.dtpropose = read(attributes(file)["dtpropose"]) - integrator.accept_step = true - end - if (:err in fieldnames(typeof(controller))) && - ("controller_err" in keys(attributes(file))) - controller.err[1:3] = read(attributes(file)["controller_err"]) - end - end - end - if mpi_isparallel() - recv_buf = [integrator.qold, integrator.dtpropose, integrator.accept_step] - if :err in fieldnames(typeof(controller)) - append!(recv_buf, controller.err) + # Read context information for controller + h5open(restart_file, "r") do file + # Ensure that necessary information was saved + if ("qold" in keys(attributes(file))) && + ("dtpropose" in keys(attributes(file))) + integrator.qold = read(attributes(file)["qold"]) + integrator.dtpropose = read(attributes(file)["dtpropose"]) + # Accept step to use dtpropose already in the first step + integrator.accept_step = true end - MPI.Bcast!(recv_buf, mpi_root(), mpi_comm()) - integrator.qold, integrator.dtpropose, integrator.accept_step = recv_buf[1:3] - if :err in fieldnames(typeof(controller)) - controller.err[1:3] = recv_buf[4:6] + # Load additional parameters for PIDController + if (:err in fieldnames(typeof(controller))) && + ("controller_err" in keys(attributes(file))) + controller.err[1:3] = read(attributes(file)["controller_err"]) end end end diff --git a/src/callbacks_step/save_restart_dg.jl b/src/callbacks_step/save_restart_dg.jl index 398c4fe4b67..ba0c53b7d47 100644 --- a/src/callbacks_step/save_restart_dg.jl +++ b/src/callbacks_step/save_restart_dg.jl @@ -330,14 +330,21 @@ end function save_restart_controller(integrator, controller, restart_callback) + # Save only on root if mpi_isroot() @unpack output_directory = restart_callback timestep = integrator.stats.naccept + + # Filename based on current time step filename = joinpath(output_directory, @sprintf("restart_%06d.h5", timestep)) + # Open file (preserve existing content) h5open(filename, "cw") do file + # Add context information as attributes attributes(file)["qold"] = integrator.qold - attributes(file)["dtpropose"] = integrator.dtpropose + # Ensure that `dtpropose` is written as a double precision scalar + attributes(file)["dtpropose"] = convert(Float64, integrator.dtpropose) + # For PIDController is necessary to save additional parameters if :err in fieldnames(typeof(controller)) attributes(file)["controller_err"] = controller.err end From 55f30afb34720e2db2d32f0c6ced941abf8e6fd1 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Tue, 15 Aug 2023 17:54:42 +0300 Subject: [PATCH 071/102] format --- src/callbacks_step/save_restart.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/callbacks_step/save_restart.jl b/src/callbacks_step/save_restart.jl index 126884ea191..1187ea2f0db 100644 --- a/src/callbacks_step/save_restart.jl +++ b/src/callbacks_step/save_restart.jl @@ -166,7 +166,7 @@ function load_controller!(integrator, restart_file::AbstractString) h5open(restart_file, "r") do file # Ensure that necessary information was saved if ("qold" in keys(attributes(file))) && - ("dtpropose" in keys(attributes(file))) + ("dtpropose" in keys(attributes(file))) integrator.qold = read(attributes(file)["qold"]) integrator.dtpropose = read(attributes(file)["dtpropose"]) # Accept step to use dtpropose already in the first step From 15cbc6803e2bc9fa60b7810df9dc70a628e056dc Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Tue, 15 Aug 2023 18:51:49 +0300 Subject: [PATCH 072/102] Update runtests.jl --- test/runtests.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/runtests.jl b/test/runtests.jl index 5c6f251fa29..7c01bd53536 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -42,6 +42,7 @@ const TRIXI_NTHREADS = clamp(Sys.CPU_THREADS, 2, 3) # If the process errors out the testset would error out as well, # cf. https://github.com/JuliaParallel/MPI.jl/pull/391 @test true + run(`$(Base.julia_cmd()) --threads=$TRIXI_NTHREADS --check-bounds=yes --code-coverage=none $(abspath("test_threaded.jl"))`) end From 8a726a481324ca8299ccfbc850b144a3de2aa365 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Tue, 15 Aug 2023 18:52:15 +0300 Subject: [PATCH 073/102] Update runtests.jl --- test/runtests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index 7c01bd53536..f1adbaaf1df 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -42,7 +42,7 @@ const TRIXI_NTHREADS = clamp(Sys.CPU_THREADS, 2, 3) # If the process errors out the testset would error out as well, # cf. https://github.com/JuliaParallel/MPI.jl/pull/391 @test true - + run(`$(Base.julia_cmd()) --threads=$TRIXI_NTHREADS --check-bounds=yes --code-coverage=none $(abspath("test_threaded.jl"))`) end From c91b68cf998ebda9e73809bb487f68668601786f Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Wed, 16 Aug 2023 11:12:02 +0300 Subject: [PATCH 074/102] simplify tests --- test/test_mpi_tree.jl | 10 ++++------ test/test_threaded.jl | 8 -------- test/test_tree_2d_euler.jl | 7 +++---- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/test/test_mpi_tree.jl b/test/test_mpi_tree.jl index 597c2f5d09b..ba6139fd01f 100644 --- a/test/test_mpi_tree.jl +++ b/test/test_mpi_tree.jl @@ -191,12 +191,10 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() end @trixi_testset "elixir_euler_density_wave_restart.jl" begin - using OrdinaryDiffEq: PIDController - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), controller = PIDController(1.0,0.5,0.2)) - l2, linf = analysis_callback(sol) - :@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), controller = PIDController(1.0,0.5,0.2), - # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl - l2 = l2, linf = linf) + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), controller = PIDController(1.0,0.5,0.2), + # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl with PIDController(1.0,0.5,0.2) + l2 = [0.0012112296845862677, 0.00012171434316587636, 0.0002425409355494199, 0.0007442936072132187], + linf = [0.004818412975783337, 0.0005313324061677338, 0.0009951418982364069, 0.009206056779305527]) end end diff --git a/test/test_threaded.jl b/test/test_threaded.jl index ba4f97fd8bb..9b30836d0ed 100644 --- a/test/test_threaded.jl +++ b/test/test_threaded.jl @@ -145,14 +145,6 @@ Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 5000 end end - @trixi_testset "elixir_euler_density_wave_restart.jl" begin - using OrdinaryDiffEq: IController - trixi_include(@__MODULE__, joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_extended.jl"), controller = IController()) - l2, linf = analysis_callback(sol) - :@test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_restart.jl"), controller = IController(), - # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl - l2 = l2, linf = linf) - end end diff --git a/test/test_tree_2d_euler.jl b/test/test_tree_2d_euler.jl index a44b34ca392..8c775f65493 100644 --- a/test/test_tree_2d_euler.jl +++ b/test/test_tree_2d_euler.jl @@ -28,11 +28,10 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") end @trixi_testset "elixir_euler_density_wave_restart.jl" begin - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl")) - l2, linf = analysis_callback(sol) - :@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl - l2 = l2, linf = linf) + l2 = [0.0012049974095327037, 0.00012066222768628522, 0.00024111367644905207, 0.0005962045363712651], + linf = [0.004212631542717782, 0.00042010775917775047, 0.0008412890054608387, 0.007078383889172812]) end @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin From 629d4da689ac7870593dfb315d992515036e932a Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Wed, 16 Aug 2023 13:27:48 +0300 Subject: [PATCH 075/102] test failing MPI on windiws and macOs --- test/test_mpi_tree.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_mpi_tree.jl b/test/test_mpi_tree.jl index ba6139fd01f..af7c590ab8e 100644 --- a/test/test_mpi_tree.jl +++ b/test/test_mpi_tree.jl @@ -191,7 +191,7 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() end @trixi_testset "elixir_euler_density_wave_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), controller = PIDController(1.0,0.5,0.2), + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), controller = PIDController(1.0,0.5,0.2), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl with PIDController(1.0,0.5,0.2) l2 = [0.0012112296845862677, 0.00012171434316587636, 0.0002425409355494199, 0.0007442936072132187], linf = [0.004818412975783337, 0.0005313324061677338, 0.0009951418982364069, 0.009206056779305527]) From 506abc54798ff68851e60ed32001a944382d9d88 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Mon, 21 Aug 2023 22:07:22 +0300 Subject: [PATCH 076/102] test with RDPK3SpFSAL49 --- .../tree_2d_dgsem/elixir_euler_density_wave_extended.jl | 2 +- .../tree_2d_dgsem/elixir_euler_density_wave_restart.jl | 2 +- test/test_mpi_tree.jl | 8 ++++---- test/test_tree_2d_euler.jl | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl b/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl index 6fa14f9845a..f0a4ca415e9 100644 --- a/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl +++ b/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl @@ -50,6 +50,6 @@ controller = PIController(7 // 30, 2 // 15) ############################################################################### # run the simulation -sol = solve(ode, SSPRK43(); +sol = solve(ode, RDPK3SpFSAL49(); callback = callbacks, controller = controller, ode_default_options()...); summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl b/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl index 918dd9de8cf..4947806ca8b 100644 --- a/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl +++ b/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl @@ -28,7 +28,7 @@ ode = semidiscretize(semi, tspan, restart_filename); # Do not overwrite the initial snapshot written by elixir_euler_density_wave_extended.jl. save_solution.condition.save_initial_solution = false -alg = SSPRK43() +alg = RDPK3SpFSAL49() integrator = init(ode, alg, dt = dt; save_everystep = false, callback = callbacks, controller = controller, diff --git a/test/test_mpi_tree.jl b/test/test_mpi_tree.jl index af7c590ab8e..99e20732b0b 100644 --- a/test/test_mpi_tree.jl +++ b/test/test_mpi_tree.jl @@ -191,10 +191,10 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() end @trixi_testset "elixir_euler_density_wave_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), controller = PIDController(1.0,0.5,0.2), - # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl with PIDController(1.0,0.5,0.2) - l2 = [0.0012112296845862677, 0.00012171434316587636, 0.0002425409355494199, 0.0007442936072132187], - linf = [0.004818412975783337, 0.0005313324061677338, 0.0009951418982364069, 0.009206056779305527]) + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), controller = PIDController(1.0,0.4,0.2), + # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl with PIDController(1.0,0.4,0.2) + l2 = [0.0012226518339058883, 0.00012562244228793448, 0.0002453719502844425, 0.0008018207037762187], + linf = [0.0047768599053406025, 0.000575479011973557, 0.0010271097171284382, 0.009192136024232411]) end end diff --git a/test/test_tree_2d_euler.jl b/test/test_tree_2d_euler.jl index 8c775f65493..06a3f759a76 100644 --- a/test/test_tree_2d_euler.jl +++ b/test/test_tree_2d_euler.jl @@ -30,8 +30,8 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @trixi_testset "elixir_euler_density_wave_restart.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl - l2 = [0.0012049974095327037, 0.00012066222768628522, 0.00024111367644905207, 0.0005962045363712651], - linf = [0.004212631542717782, 0.00042010775917775047, 0.0008412890054608387, 0.007078383889172812]) + l2 = [0.001216870805652372, 0.00012159517760160904, 0.00024340243381168144, 3.939990933215729e-5], + linf = [0.004286275727269917, 0.000429015896869972, 0.0008619270677295288, 0.00021182526808161128]) end @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin From b83904e60ca927d9b678f2ea62e61781bfa37eb5 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Mon, 21 Aug 2023 22:59:35 +0300 Subject: [PATCH 077/102] test with RDPK3SpFSAL35 --- .../tree_2d_dgsem/elixir_euler_density_wave_extended.jl | 6 +++--- .../tree_2d_dgsem/elixir_euler_density_wave_restart.jl | 8 ++++---- test/test_mpi_tree.jl | 8 ++++---- test/test_tree_2d_euler.jl | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl b/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl index f0a4ca415e9..87f961e4774 100644 --- a/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl +++ b/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl @@ -22,7 +22,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) ############################################################################### # ODE solvers, callbacks etc. -tspan = (0.0, 4.0) +tspan = (0.0, 2.0) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() @@ -32,7 +32,7 @@ analysis_callback = AnalysisCallback(semi, interval = analysis_interval) alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval = 1000, +save_restart = SaveRestartCallback(interval = 400, save_final_restart = false) save_solution = SaveSolutionCallback(interval = 100, @@ -50,6 +50,6 @@ controller = PIController(7 // 30, 2 // 15) ############################################################################### # run the simulation -sol = solve(ode, RDPK3SpFSAL49(); +sol = solve(ode, RDPK3SpFSAL35(); callback = callbacks, controller = controller, ode_default_options()...); summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl b/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl index 4947806ca8b..300b9639b13 100644 --- a/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl +++ b/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl @@ -7,7 +7,7 @@ controller = PIController(7 // 30, 2 // 15) # create a restart file trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_euler_density_wave_extended.jl"), - tspan = (0.0, 2.0), controller = controller) + tspan = (0.0, 1.0), controller = controller) ############################################################################### # adapt the parameters that have changed compared to "elixir_euler_density_wave_extended.jl" @@ -15,12 +15,12 @@ trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_euler_density_wave_extende # Note: If you get a restart file from somewhere else, you need to provide # appropriate setups in the elixir loading a restart file -restart_filename = joinpath("out", "restart_001000.h5") +restart_filename = joinpath("out", "restart_000400.h5") mesh = load_mesh(restart_filename) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) -tspan = (load_time(restart_filename), 4.0) +tspan = (load_time(restart_filename), 2.0) dt = load_dt(restart_filename) ode = semidiscretize(semi, tspan, restart_filename); @@ -28,7 +28,7 @@ ode = semidiscretize(semi, tspan, restart_filename); # Do not overwrite the initial snapshot written by elixir_euler_density_wave_extended.jl. save_solution.condition.save_initial_solution = false -alg = RDPK3SpFSAL49() +alg = RDPK3SpFSAL35() integrator = init(ode, alg, dt = dt; save_everystep = false, callback = callbacks, controller = controller, diff --git a/test/test_mpi_tree.jl b/test/test_mpi_tree.jl index 99e20732b0b..256040cd84f 100644 --- a/test/test_mpi_tree.jl +++ b/test/test_mpi_tree.jl @@ -191,10 +191,10 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() end @trixi_testset "elixir_euler_density_wave_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), controller = PIDController(1.0,0.4,0.2), - # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl with PIDController(1.0,0.4,0.2) - l2 = [0.0012226518339058883, 0.00012562244228793448, 0.0002453719502844425, 0.0008018207037762187], - linf = [0.0047768599053406025, 0.000575479011973557, 0.0010271097171284382, 0.009192136024232411]) + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), controller = PIDController(1.0,0.5,0.2), + # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl with PIDController(1.0,0.5,0.2) + l2 = [0.0013063218880701862, 0.0001321156420306584, 0.0002767849831618995, 0.008164564600925186], + linf = [0.0072404995625627855, 0.0009585625036930279, 0.0015017176517665431, 0.10856506397463761]) end end diff --git a/test/test_tree_2d_euler.jl b/test/test_tree_2d_euler.jl index 06a3f759a76..f3bcb5b5e66 100644 --- a/test/test_tree_2d_euler.jl +++ b/test/test_tree_2d_euler.jl @@ -30,8 +30,8 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @trixi_testset "elixir_euler_density_wave_restart.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl - l2 = [0.001216870805652372, 0.00012159517760160904, 0.00024340243381168144, 3.939990933215729e-5], - linf = [0.004286275727269917, 0.000429015896869972, 0.0008619270677295288, 0.00021182526808161128]) + l2 = [0.0013009966063625815, 0.00013035281976778808, 0.0002597434052551178, 0.0006677449766244259], + linf = [0.007425455419466154, 0.0007462672706272794, 0.0014860217930253716, 0.008824111935112455]) end @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin From 89d1ae702a5f69c89ff824749c01ba355ebedfa2 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Tue, 22 Aug 2023 00:22:21 +0300 Subject: [PATCH 078/102] change tests --- test/test_mpi_tree.jl | 8 ++++---- test/test_tree_2d_euler.jl | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/test_mpi_tree.jl b/test/test_mpi_tree.jl index 256040cd84f..58adef354f9 100644 --- a/test/test_mpi_tree.jl +++ b/test/test_mpi_tree.jl @@ -191,10 +191,10 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() end @trixi_testset "elixir_euler_density_wave_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), controller = PIDController(1.0,0.5,0.2), - # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl with PIDController(1.0,0.5,0.2) - l2 = [0.0013063218880701862, 0.0001321156420306584, 0.0002767849831618995, 0.008164564600925186], - linf = [0.0072404995625627855, 0.0009585625036930279, 0.0015017176517665431, 0.10856506397463761]) + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), + # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl + l2 = [0.0013009966063625815, 0.00013035281976778808, 0.0002597434052551178, 0.0006677449766244259], + linf = [0.007425455419466154, 0.0007462672706272794, 0.0014860217930253716, 0.008824111935112455]) end end diff --git a/test/test_tree_2d_euler.jl b/test/test_tree_2d_euler.jl index f3bcb5b5e66..570d7ac3094 100644 --- a/test/test_tree_2d_euler.jl +++ b/test/test_tree_2d_euler.jl @@ -28,10 +28,10 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") end @trixi_testset "elixir_euler_density_wave_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), - # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl - l2 = [0.0013009966063625815, 0.00013035281976778808, 0.0002597434052551178, 0.0006677449766244259], - linf = [0.007425455419466154, 0.0007462672706272794, 0.0014860217930253716, 0.008824111935112455]) + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), controller = PIDController(1.0,0.5,0.2), + # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl with PIDController(1.0,0.5,0.2) + l2 = [0.0013063218880701862, 0.0001321156420306584, 0.0002767849831618995, 0.008164564600925186], + linf = [0.0072404995625627855, 0.0009585625036930279, 0.0015017176517665431, 0.10856506397463761]) end @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin From d1b28027f83857b48b7d072ffe6a01fc9c32ed06 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Wed, 23 Aug 2023 14:59:40 +0300 Subject: [PATCH 079/102] fix and new test --- .../elixir_euler_density_wave_extended.jl | 11 ++++------ .../elixir_euler_density_wave_restart.jl | 11 +++++----- src/callbacks_step/save_restart.jl | 2 ++ test/test_mpi_tree.jl | 19 +++++++++++++---- test/test_tree_2d_euler.jl | 21 ++++++++++++++----- 5 files changed, 42 insertions(+), 22 deletions(-) diff --git a/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl b/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl index 87f961e4774..fb91911d8e4 100644 --- a/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl +++ b/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl @@ -32,7 +32,7 @@ analysis_callback = AnalysisCallback(semi, interval = analysis_interval) alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval = 400, +save_restart = SaveRestartCallback(interval = 200, save_final_restart = false) save_solution = SaveSolutionCallback(interval = 100, @@ -44,12 +44,9 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, save_solution) -# create timestep controller -controller = PIController(7 // 30, 2 // 15) - ############################################################################### # run the simulation - -sol = solve(ode, RDPK3SpFSAL35(); - callback = callbacks, controller = controller, ode_default_options()...); +alg = RDPK3SpFSAL49() +sol = solve(ode, alg; + callback = callbacks, ode_default_options()...); summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl b/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl index 300b9639b13..7d63adbe6fa 100644 --- a/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl +++ b/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl @@ -2,12 +2,12 @@ using OrdinaryDiffEq using Trixi ############################################################################### -# create timestep controller -controller = PIController(7 // 30, 2 // 15) +# define time integration algorithm +alg = RDPK3SpFSAL49() # create a restart file trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_euler_density_wave_extended.jl"), - tspan = (0.0, 1.0), controller = controller) + tspan = (0.0, 1.0), alg = alg) ############################################################################### # adapt the parameters that have changed compared to "elixir_euler_density_wave_extended.jl" @@ -15,7 +15,7 @@ trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_euler_density_wave_extende # Note: If you get a restart file from somewhere else, you need to provide # appropriate setups in the elixir loading a restart file -restart_filename = joinpath("out", "restart_000400.h5") +restart_filename = joinpath("out", "restart_000200.h5") mesh = load_mesh(restart_filename) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -28,10 +28,9 @@ ode = semidiscretize(semi, tspan, restart_filename); # Do not overwrite the initial snapshot written by elixir_euler_density_wave_extended.jl. save_solution.condition.save_initial_solution = false -alg = RDPK3SpFSAL35() integrator = init(ode, alg, dt = dt; - save_everystep = false, callback = callbacks, controller = controller, + save_everystep = false, callback = callbacks, ode_default_options()...) load_controller!(integrator, restart_filename) diff --git a/src/callbacks_step/save_restart.jl b/src/callbacks_step/save_restart.jl index 1187ea2f0db..6abd9c92900 100644 --- a/src/callbacks_step/save_restart.jl +++ b/src/callbacks_step/save_restart.jl @@ -171,6 +171,8 @@ function load_controller!(integrator, restart_file::AbstractString) integrator.dtpropose = read(attributes(file)["dtpropose"]) # Accept step to use dtpropose already in the first step integrator.accept_step = true + # Reevaluate integrator.fsal_first on the first step + integrator.reeval_fsal = true end # Load additional parameters for PIDController if (:err in fieldnames(typeof(controller))) && diff --git a/test/test_mpi_tree.jl b/test/test_mpi_tree.jl index 58adef354f9..eb66dcd6bf5 100644 --- a/test/test_mpi_tree.jl +++ b/test/test_mpi_tree.jl @@ -190,11 +190,22 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() end end - @trixi_testset "elixir_euler_density_wave_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), + @trixi_testset "1elixir_euler_density_wave_restart.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl - l2 = [0.0013009966063625815, 0.00013035281976778808, 0.0002597434052551178, 0.0006677449766244259], - linf = [0.007425455419466154, 0.0007462672706272794, 0.0014860217930253716, 0.008824111935112455]) + l2 = [0.0012804743998541133, 0.00012808176121491938, 0.00025927742118623533, 0.000686449461719783], + linf = [0.008680803177186391, 0.0007961219319038843, 0.0017606374685099763, 0.00922630845884953]) + end + + @trixi_testset "2elixir_euler_density_wave_restart.jl" begin + trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl")) + l2_expected, linf_expected = analysis_callback(sol) + trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl")) + l2_actual, linf_actual = analysis_callback(sol) + if Trixi.mpi_isroot() + @test l2_actual == l2_expected + @test linf_actual == linf_expected + end end end diff --git a/test/test_tree_2d_euler.jl b/test/test_tree_2d_euler.jl index 17a98aa992b..b6e7b13e581 100644 --- a/test/test_tree_2d_euler.jl +++ b/test/test_tree_2d_euler.jl @@ -27,11 +27,22 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") tspan = (0.0, 0.5)) end - @trixi_testset "elixir_euler_density_wave_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), controller = PIDController(1.0,0.5,0.2), - # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl with PIDController(1.0,0.5,0.2) - l2 = [0.0013063218880701862, 0.0001321156420306584, 0.0002767849831618995, 0.008164564600925186], - linf = [0.0072404995625627855, 0.0009585625036930279, 0.0015017176517665431, 0.10856506397463761]) + @trixi_testset "1elixir_euler_density_wave_restart.jl" begin + using OrdinaryDiffEq: SSPRK43 + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), alg = SSPRK43() + # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl + l2 = [0.001270869807336869, 0.00012722550004665238, 0.0002538810906298964, 0.0006698596265485126], + linf = [0.007144670778606033, 0.0007128834186178115, 0.001426493670855053, 0.008735160305562317]) + end + + @trixi_testset "2elixir_euler_density_wave_restart.jl" begin + using OrdinaryDiffEq: SSPRK43 + trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), alg = SSPRK43()) + l2_expected, linf_expected = analysis_callback(sol) + trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), alg = SSPRK43()) + l2_actual, linf_actual = analysis_callback(sol) + @test l2_actual == l2_expected + @test linf_actual == linf_expected end @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin From bebc1ec8ef5ac4607951053c67479c4408d1fbf0 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Wed, 23 Aug 2023 15:27:46 +0300 Subject: [PATCH 080/102] Update test_tree_2d_euler.jl --- test/test_tree_2d_euler.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_tree_2d_euler.jl b/test/test_tree_2d_euler.jl index b6e7b13e581..ae103e5f444 100644 --- a/test/test_tree_2d_euler.jl +++ b/test/test_tree_2d_euler.jl @@ -29,7 +29,7 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @trixi_testset "1elixir_euler_density_wave_restart.jl" begin using OrdinaryDiffEq: SSPRK43 - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), alg = SSPRK43() + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), alg = SSPRK43(), # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl l2 = [0.001270869807336869, 0.00012722550004665238, 0.0002538810906298964, 0.0006698596265485126], linf = [0.007144670778606033, 0.0007128834186178115, 0.001426493670855053, 0.008735160305562317]) From f085ab795d7f739262097ddc46f814bccc3c52ce Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Wed, 23 Aug 2023 16:15:28 +0300 Subject: [PATCH 081/102] fix and delete unnecessary test --- test/test_mpi_tree.jl | 13 +++---------- test/test_tree_2d_euler.jl | 14 +++----------- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/test/test_mpi_tree.jl b/test/test_mpi_tree.jl index eb66dcd6bf5..7aabf41afd4 100644 --- a/test/test_mpi_tree.jl +++ b/test/test_mpi_tree.jl @@ -190,17 +190,10 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() end end - @trixi_testset "1elixir_euler_density_wave_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), - # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl - l2 = [0.0012804743998541133, 0.00012808176121491938, 0.00025927742118623533, 0.000686449461719783], - linf = [0.008680803177186391, 0.0007961219319038843, 0.0017606374685099763, 0.00922630845884953]) - end - - @trixi_testset "2elixir_euler_density_wave_restart.jl" begin - trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl")) + @trixi_testset "elixir_euler_density_wave_restart.jl" begin + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl")) l2_expected, linf_expected = analysis_callback(sol) - trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl")) + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl")) l2_actual, linf_actual = analysis_callback(sol) if Trixi.mpi_isroot() @test l2_actual == l2_expected diff --git a/test/test_tree_2d_euler.jl b/test/test_tree_2d_euler.jl index ae103e5f444..3e684130c26 100644 --- a/test/test_tree_2d_euler.jl +++ b/test/test_tree_2d_euler.jl @@ -26,20 +26,12 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") linf = [0.006614198043413566, 0.0006614198043973507, 0.001322839608837334, 0.000165354951256802], tspan = (0.0, 0.5)) end - - @trixi_testset "1elixir_euler_density_wave_restart.jl" begin - using OrdinaryDiffEq: SSPRK43 - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), alg = SSPRK43(), - # Expected errors are exactly the same as in the elixir_euler_density_wave_extended.jl - l2 = [0.001270869807336869, 0.00012722550004665238, 0.0002538810906298964, 0.0006698596265485126], - linf = [0.007144670778606033, 0.0007128834186178115, 0.001426493670855053, 0.008735160305562317]) - end - @trixi_testset "2elixir_euler_density_wave_restart.jl" begin + @trixi_testset "elixir_euler_density_wave_restart.jl" begin using OrdinaryDiffEq: SSPRK43 - trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), alg = SSPRK43()) + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), alg = SSPRK43()) l2_expected, linf_expected = analysis_callback(sol) - trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), alg = SSPRK43()) + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), alg = SSPRK43()) l2_actual, linf_actual = analysis_callback(sol) @test l2_actual == l2_expected @test linf_actual == linf_expected From 4837f46619bd1eb2ebfe3c82e961bdebb2efa08d Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Wed, 23 Aug 2023 17:08:05 +0300 Subject: [PATCH 082/102] add printing format --- test/test_mpi_tree.jl | 5 ++++- test/test_tree_2d_euler.jl | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/test/test_mpi_tree.jl b/test/test_mpi_tree.jl index 7aabf41afd4..49a28970576 100644 --- a/test/test_mpi_tree.jl +++ b/test/test_mpi_tree.jl @@ -191,8 +191,11 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() end @trixi_testset "elixir_euler_density_wave_restart.jl" begin - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl")) + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl")); l2_expected, linf_expected = analysis_callback(sol) + Trixi.mpi_isroot() && println("═"^100) + Trixi.mpi_isroot() && println(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl")) + # Errors are exactly the same as in the elixir_euler_density_wave_extended.jl trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl")) l2_actual, linf_actual = analysis_callback(sol) if Trixi.mpi_isroot() diff --git a/test/test_tree_2d_euler.jl b/test/test_tree_2d_euler.jl index 3e684130c26..b0302c2bf3f 100644 --- a/test/test_tree_2d_euler.jl +++ b/test/test_tree_2d_euler.jl @@ -29,8 +29,11 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @trixi_testset "elixir_euler_density_wave_restart.jl" begin using OrdinaryDiffEq: SSPRK43 - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), alg = SSPRK43()) + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), alg = SSPRK43()); l2_expected, linf_expected = analysis_callback(sol) + println("═"^100) + println(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl")) + # Errors are exactly the same as in the elixir_euler_density_wave_extended.jl trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), alg = SSPRK43()) l2_actual, linf_actual = analysis_callback(sol) @test l2_actual == l2_expected From 60388d1b0398c143e3c141d8a2391126766e2c56 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Wed, 23 Aug 2023 19:01:20 +0300 Subject: [PATCH 083/102] add docstrings --- src/callbacks_step/save_restart.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/callbacks_step/save_restart.jl b/src/callbacks_step/save_restart.jl index 6abd9c92900..08516bf7411 100644 --- a/src/callbacks_step/save_restart.jl +++ b/src/callbacks_step/save_restart.jl @@ -160,6 +160,11 @@ function load_restart_file(semi::AbstractSemidiscretization, restart_file) load_restart_file(mesh_equations_solver_cache(semi)..., restart_file) end +""" + load_controller!(integrator, restart_file::AbstractString) + +Load the context information for PID- and PIControllers saved in a `restart_file`. +""" function load_controller!(integrator, restart_file::AbstractString) controller = integrator.opts.controller # Read context information for controller From 08b0ee1fbbdf96e3e56ffb35ac57053cc22f239b Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Fri, 25 Aug 2023 12:28:00 +0300 Subject: [PATCH 084/102] Update src/callbacks_step/save_restart.jl Co-authored-by: Michael Schlottke-Lakemper --- src/callbacks_step/save_restart.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/callbacks_step/save_restart.jl b/src/callbacks_step/save_restart.jl index 08516bf7411..44f228bd2d1 100644 --- a/src/callbacks_step/save_restart.jl +++ b/src/callbacks_step/save_restart.jl @@ -105,6 +105,7 @@ function (restart_callback::SaveRestartCallback)(integrator) end save_restart_file(u_ode, t, dt, iter, semi, restart_callback) + # If using an adaptive time stepping scheme, store controller values for restart if integrator.opts.adaptive save_restart_controller(integrator, integrator.opts.controller, restart_callback) From e17a61ad21b7f285906f98e20b6dc551c09f7c85 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Fri, 25 Aug 2023 13:32:20 +0300 Subject: [PATCH 085/102] Update src/callbacks_step/save_restart_dg.jl Co-authored-by: Michael Schlottke-Lakemper --- src/callbacks_step/save_restart_dg.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/callbacks_step/save_restart_dg.jl b/src/callbacks_step/save_restart_dg.jl index ba0c53b7d47..200807eaf4f 100644 --- a/src/callbacks_step/save_restart_dg.jl +++ b/src/callbacks_step/save_restart_dg.jl @@ -339,7 +339,7 @@ function save_restart_controller(integrator, filename = joinpath(output_directory, @sprintf("restart_%06d.h5", timestep)) # Open file (preserve existing content) - h5open(filename, "cw") do file + h5open(filename, "r+") do file # Add context information as attributes attributes(file)["qold"] = integrator.qold # Ensure that `dtpropose` is written as a double precision scalar From 17cb0865d455442b18292651d6aeb6ebf44011e4 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Fri, 25 Aug 2023 13:39:23 +0300 Subject: [PATCH 086/102] Update src/callbacks_step/save_restart_dg.jl Co-authored-by: Michael Schlottke-Lakemper --- src/callbacks_step/save_restart_dg.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/callbacks_step/save_restart_dg.jl b/src/callbacks_step/save_restart_dg.jl index 200807eaf4f..12ccc3fd408 100644 --- a/src/callbacks_step/save_restart_dg.jl +++ b/src/callbacks_step/save_restart_dg.jl @@ -345,7 +345,7 @@ function save_restart_controller(integrator, # Ensure that `dtpropose` is written as a double precision scalar attributes(file)["dtpropose"] = convert(Float64, integrator.dtpropose) # For PIDController is necessary to save additional parameters - if :err in fieldnames(typeof(controller)) + if hasproperty(controller, :err) attributes(file)["controller_err"] = controller.err end end From e5942e97377711250a673c0c9f82c8eb3297902d Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Fri, 25 Aug 2023 13:40:38 +0300 Subject: [PATCH 087/102] Update src/callbacks_step/save_restart.jl Co-authored-by: Michael Schlottke-Lakemper --- src/callbacks_step/save_restart.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/callbacks_step/save_restart.jl b/src/callbacks_step/save_restart.jl index 44f228bd2d1..72dfdf9a55e 100644 --- a/src/callbacks_step/save_restart.jl +++ b/src/callbacks_step/save_restart.jl @@ -181,8 +181,7 @@ function load_controller!(integrator, restart_file::AbstractString) integrator.reeval_fsal = true end # Load additional parameters for PIDController - if (:err in fieldnames(typeof(controller))) && - ("controller_err" in keys(attributes(file))) + if hasproperty(controller, :err) controller.err[1:3] = read(attributes(file)["controller_err"]) end end From c024b73dd1013131fa133577bdca7bc2b5dc36ef Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Fri, 25 Aug 2023 13:41:17 +0300 Subject: [PATCH 088/102] Update src/callbacks_step/save_restart.jl Co-authored-by: Michael Schlottke-Lakemper --- src/callbacks_step/save_restart.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/callbacks_step/save_restart.jl b/src/callbacks_step/save_restart.jl index 72dfdf9a55e..f0fec96fbe3 100644 --- a/src/callbacks_step/save_restart.jl +++ b/src/callbacks_step/save_restart.jl @@ -182,7 +182,7 @@ function load_controller!(integrator, restart_file::AbstractString) end # Load additional parameters for PIDController if hasproperty(controller, :err) - controller.err[1:3] = read(attributes(file)["controller_err"]) + controller.err[:] = read(attributes(file)["controller_err"]) end end end From 6ccd652489415ffaf673dea1662e343f36980f0c Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Fri, 25 Aug 2023 13:45:00 +0300 Subject: [PATCH 089/102] Update src/callbacks_step/save_restart.jl Co-authored-by: Michael Schlottke-Lakemper --- src/callbacks_step/save_restart.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/callbacks_step/save_restart.jl b/src/callbacks_step/save_restart.jl index f0fec96fbe3..478ef496cf6 100644 --- a/src/callbacks_step/save_restart.jl +++ b/src/callbacks_step/save_restart.jl @@ -164,7 +164,7 @@ end """ load_controller!(integrator, restart_file::AbstractString) -Load the context information for PID- and PIControllers saved in a `restart_file`. +Load the context information for error-based time integrators saved in a `restart_file`. """ function load_controller!(integrator, restart_file::AbstractString) controller = integrator.opts.controller From 24814334b631dfe54bcf9b1c359a8b23f9fd5cff Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Fri, 25 Aug 2023 13:17:13 +0300 Subject: [PATCH 090/102] suggested changes --- .../elixir_euler_density_wave_restart.jl | 2 +- src/callbacks_step/save_restart.jl | 27 ++++++++++--------- src/callbacks_step/save_restart_dg.jl | 9 ++++--- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl b/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl index 7d63adbe6fa..bf8a72a8aa5 100644 --- a/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl +++ b/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl @@ -32,7 +32,7 @@ integrator = init(ode, alg, dt = dt; save_everystep = false, callback = callbacks, ode_default_options()...) -load_controller!(integrator, restart_filename) +load_adaptive_time_integrator!(integrator, restart_filename) # Get the last time index and work with that. integrator.iter = load_timestep(restart_filename) diff --git a/src/callbacks_step/save_restart.jl b/src/callbacks_step/save_restart.jl index 478ef496cf6..5744bed9a9a 100644 --- a/src/callbacks_step/save_restart.jl +++ b/src/callbacks_step/save_restart.jl @@ -107,7 +107,7 @@ function (restart_callback::SaveRestartCallback)(integrator) save_restart_file(u_ode, t, dt, iter, semi, restart_callback) # If using an adaptive time stepping scheme, store controller values for restart if integrator.opts.adaptive - save_restart_controller(integrator, integrator.opts.controller, + save_adaptive_time_integrator(integrator, integrator.opts.controller, restart_callback) end end @@ -162,27 +162,30 @@ function load_restart_file(semi::AbstractSemidiscretization, restart_file) end """ - load_controller!(integrator, restart_file::AbstractString) + load_adaptive_time_integrator!(integrator, restart_file::AbstractString) Load the context information for error-based time integrators saved in a `restart_file`. """ -function load_controller!(integrator, restart_file::AbstractString) +function load_adaptive_time_integrator!(integrator, restart_file::AbstractString) controller = integrator.opts.controller # Read context information for controller h5open(restart_file, "r") do file # Ensure that necessary information was saved - if ("qold" in keys(attributes(file))) && - ("dtpropose" in keys(attributes(file))) - integrator.qold = read(attributes(file)["qold"]) - integrator.dtpropose = read(attributes(file)["dtpropose"]) - # Accept step to use dtpropose already in the first step - integrator.accept_step = true - # Reevaluate integrator.fsal_first on the first step - integrator.reeval_fsal = true + if !("time_integrator_qold" in keys(attributes(file))) || + !("time_integrator_dtpropose" in keys(attributes(file))) || + (hasproperty(controller, :err) && + !("time_integrator_controller_err" in keys(attributes(file)))) + error("Missing data in restart file: check the consistency of adaptive time controller with initial setup!") end + integrator.qold = read(attributes(file)["time_integrator_qold"]) + integrator.dtpropose = read(attributes(file)["time_integrator_dtpropose"]) + # Accept step to use dtpropose already in the first step + integrator.accept_step = true + # Reevaluate integrator.fsal_first on the first step + integrator.reeval_fsal = true # Load additional parameters for PIDController if hasproperty(controller, :err) - controller.err[:] = read(attributes(file)["controller_err"]) + controller.err[:] = read(attributes(file)["time_integrator_controller_err"]) end end end diff --git a/src/callbacks_step/save_restart_dg.jl b/src/callbacks_step/save_restart_dg.jl index 12ccc3fd408..fcec7ce38c5 100644 --- a/src/callbacks_step/save_restart_dg.jl +++ b/src/callbacks_step/save_restart_dg.jl @@ -328,7 +328,8 @@ function load_restart_file_on_root(mesh::Union{ParallelTreeMesh, ParallelP4estMe return u_ode end -function save_restart_controller(integrator, +# Store controller values for an adaptive time stepping scheme +function save_adaptive_time_integrator(integrator, controller, restart_callback) # Save only on root if mpi_isroot() @@ -341,12 +342,12 @@ function save_restart_controller(integrator, # Open file (preserve existing content) h5open(filename, "r+") do file # Add context information as attributes - attributes(file)["qold"] = integrator.qold + attributes(file)["time_integrator_qold"] = integrator.qold # Ensure that `dtpropose` is written as a double precision scalar - attributes(file)["dtpropose"] = convert(Float64, integrator.dtpropose) + attributes(file)["time_integrator_dtpropose"] = integrator.dtpropose # For PIDController is necessary to save additional parameters if hasproperty(controller, :err) - attributes(file)["controller_err"] = controller.err + attributes(file)["time_integrator_controller_err"] = controller.err end end end From 8cee6f13589b333da4d04cdd7c9b62976db3cf33 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Fri, 25 Aug 2023 13:19:15 +0300 Subject: [PATCH 091/102] fix --- src/Trixi.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Trixi.jl b/src/Trixi.jl index a4c5a1316c5..ea06e88c002 100644 --- a/src/Trixi.jl +++ b/src/Trixi.jl @@ -253,7 +253,7 @@ export SummaryCallback, SteadyStateCallback, AnalysisCallback, AliveCallback, GlmSpeedCallback, LBMCollisionCallback, EulerAcousticsCouplingCallback, TrivialCallback, AnalysisCallbackCoupled -export load_mesh, load_time, load_timestep, load_dt, load_controller! +export load_mesh, load_time, load_timestep, load_dt, load_adaptive_time_integrator! export ControllerThreeLevel, ControllerThreeLevelCombined, IndicatorLöhner, IndicatorLoehner, IndicatorMax, From a96c4859339275fd60c50e7256cfad8ddbe3b05d Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Fri, 25 Aug 2023 13:29:10 +0300 Subject: [PATCH 092/102] formatting --- src/callbacks_step/save_restart.jl | 4 ++-- src/callbacks_step/save_restart_dg.jl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/callbacks_step/save_restart.jl b/src/callbacks_step/save_restart.jl index 5744bed9a9a..1b72411a4ba 100644 --- a/src/callbacks_step/save_restart.jl +++ b/src/callbacks_step/save_restart.jl @@ -108,7 +108,7 @@ function (restart_callback::SaveRestartCallback)(integrator) # If using an adaptive time stepping scheme, store controller values for restart if integrator.opts.adaptive save_adaptive_time_integrator(integrator, integrator.opts.controller, - restart_callback) + restart_callback) end end @@ -174,7 +174,7 @@ function load_adaptive_time_integrator!(integrator, restart_file::AbstractString if !("time_integrator_qold" in keys(attributes(file))) || !("time_integrator_dtpropose" in keys(attributes(file))) || (hasproperty(controller, :err) && - !("time_integrator_controller_err" in keys(attributes(file)))) + !("time_integrator_controller_err" in keys(attributes(file)))) error("Missing data in restart file: check the consistency of adaptive time controller with initial setup!") end integrator.qold = read(attributes(file)["time_integrator_qold"]) diff --git a/src/callbacks_step/save_restart_dg.jl b/src/callbacks_step/save_restart_dg.jl index fcec7ce38c5..6ab323adaac 100644 --- a/src/callbacks_step/save_restart_dg.jl +++ b/src/callbacks_step/save_restart_dg.jl @@ -330,7 +330,7 @@ end # Store controller values for an adaptive time stepping scheme function save_adaptive_time_integrator(integrator, - controller, restart_callback) + controller, restart_callback) # Save only on root if mpi_isroot() @unpack output_directory = restart_callback From f4c081b24283cc95d2ab801621192737c196dd66 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Fri, 25 Aug 2023 16:03:59 +0300 Subject: [PATCH 093/102] new test --- .../elixir_advection_extended.jl | 9 ++-- .../tree_2d_dgsem/elixir_advection_restart.jl | 17 +++--- .../elixir_euler_density_wave_extended.jl | 52 ------------------- .../elixir_euler_density_wave_restart.jl | 46 ---------------- test/test_mpi_tree.jl | 35 ++++++------- test/test_threaded.jl | 40 ++++++++------ test/test_tree_2d_advection.jl | 18 +++++++ test/test_tree_2d_euler.jl | 13 ----- 8 files changed, 75 insertions(+), 155 deletions(-) delete mode 100644 examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl delete mode 100644 examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl diff --git a/examples/tree_2d_dgsem/elixir_advection_extended.jl b/examples/tree_2d_dgsem/elixir_advection_extended.jl index 8c837957ffd..632455b5f86 100644 --- a/examples/tree_2d_dgsem/elixir_advection_extended.jl +++ b/examples/tree_2d_dgsem/elixir_advection_extended.jl @@ -37,8 +37,8 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, ############################################################################### # ODE solvers, callbacks etc. -# Create ODE problem with time span from 0.0 to 1.0 -tspan = (0.0, 1.0) +# Create ODE problem with time span from 0.0 to 10.0 +tspan = (0.0, 10.0) ode = semidiscretize(semi, tspan); # At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup @@ -54,7 +54,7 @@ analysis_callback = AnalysisCallback(semi, interval=analysis_interval, alive_callback = AliveCallback(analysis_interval=analysis_interval) # The SaveRestartCallback allows to save a file from which a Trixi.jl simulation can be restarted -save_restart = SaveRestartCallback(interval=100, +save_restart = SaveRestartCallback(interval=40, save_final_restart=true) # The SaveSolutionCallback allows to save the solution to a file in regular intervals @@ -77,7 +77,8 @@ callbacks = CallbackSet(summary_callback, # run the simulation # OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), +alg = CarpenterKennedy2N54(williamson_condition=false) +sol = solve(ode, alg, dt=1.0, # solve needs some value here but it will be overwritten by the stepsize_callback save_everystep=false, callback=callbacks); diff --git a/examples/tree_2d_dgsem/elixir_advection_restart.jl b/examples/tree_2d_dgsem/elixir_advection_restart.jl index 72efb7d0c84..7896defe7f3 100644 --- a/examples/tree_2d_dgsem/elixir_advection_restart.jl +++ b/examples/tree_2d_dgsem/elixir_advection_restart.jl @@ -3,9 +3,10 @@ using OrdinaryDiffEq using Trixi ############################################################################### -# create a restart file - -trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_extended.jl")) +# Define time integration algorithm +alg = CarpenterKennedy2N54(williamson_condition=false) +# Create a restart file +trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_extended.jl"), alg = alg) ############################################################################### @@ -14,23 +15,27 @@ trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_extended.jl")) # Note: If you get a restart file from somewhere else, you need to provide # appropriate setups in the elixir loading a restart file -restart_filename = joinpath("out", "restart_000018.h5") +restart_filename = joinpath("out", "restart_000040.h5") mesh = load_mesh(restart_filename) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) -tspan = (load_time(restart_filename), 2.0) +tspan = (load_time(restart_filename), 10.0) dt = load_dt(restart_filename) ode = semidiscretize(semi, tspan, restart_filename); # Do not overwrite the initial snapshot written by elixir_advection_extended.jl. save_solution.condition.save_initial_solution = false -alg = CarpenterKennedy2N54(williamson_condition=false) integrator = init(ode, alg, dt=dt, # solve needs some value here but it will be overwritten by the stepsize_callback save_everystep=false, callback=callbacks) +# Load saved context for adaptive time integrator +if integrator.opts.adaptive + load_adaptive_time_integrator!(integrator, restart_filename) +end + # Get the last time index and work with that. integrator.iter = load_timestep(restart_filename) integrator.stats.naccept = integrator.iter diff --git a/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl b/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl deleted file mode 100644 index fb91911d8e4..00000000000 --- a/examples/tree_2d_dgsem/elixir_euler_density_wave_extended.jl +++ /dev/null @@ -1,52 +0,0 @@ - -using OrdinaryDiffEq -using Trixi - -############################################################################### -# semidiscretization of the compressible Euler equations -gamma = 1.4 -equations = CompressibleEulerEquations2D(gamma) - -initial_condition = initial_condition_density_wave - -solver = DGSEM(polydeg = 5, surface_flux = flux_central) - -coordinates_min = (-1.0, -1.0) -coordinates_max = (1.0, 1.0) -mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 30_000) - -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - -############################################################################### -# ODE solvers, callbacks etc. - -tspan = (0.0, 2.0) -ode = semidiscretize(semi, tspan) - -summary_callback = SummaryCallback() - -analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) - -alive_callback = AliveCallback(analysis_interval = analysis_interval) - -save_restart = SaveRestartCallback(interval = 200, - save_final_restart = false) - -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) - -callbacks = CallbackSet(summary_callback, - analysis_callback, alive_callback, - save_restart, save_solution) - -############################################################################### -# run the simulation -alg = RDPK3SpFSAL49() -sol = solve(ode, alg; - callback = callbacks, ode_default_options()...); -summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl b/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl deleted file mode 100644 index bf8a72a8aa5..00000000000 --- a/examples/tree_2d_dgsem/elixir_euler_density_wave_restart.jl +++ /dev/null @@ -1,46 +0,0 @@ -using OrdinaryDiffEq -using Trixi - -############################################################################### -# define time integration algorithm -alg = RDPK3SpFSAL49() - -# create a restart file -trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_euler_density_wave_extended.jl"), - tspan = (0.0, 1.0), alg = alg) - -############################################################################### -# adapt the parameters that have changed compared to "elixir_euler_density_wave_extended.jl" - -# Note: If you get a restart file from somewhere else, you need to provide -# appropriate setups in the elixir loading a restart file - -restart_filename = joinpath("out", "restart_000200.h5") -mesh = load_mesh(restart_filename) - -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - -tspan = (load_time(restart_filename), 2.0) -dt = load_dt(restart_filename) - -ode = semidiscretize(semi, tspan, restart_filename); - -# Do not overwrite the initial snapshot written by elixir_euler_density_wave_extended.jl. -save_solution.condition.save_initial_solution = false - -integrator = init(ode, alg, - dt = dt; - save_everystep = false, callback = callbacks, - ode_default_options()...) -load_adaptive_time_integrator!(integrator, restart_filename) - -# Get the last time index and work with that. -integrator.iter = load_timestep(restart_filename) -integrator.stats.naccept = integrator.iter - -############################################################################### -# run the simulation - -sol = solve!(integrator) - -summary_callback() # print the timer summary diff --git a/test/test_mpi_tree.jl b/test/test_mpi_tree.jl index 49a28970576..70cd914408b 100644 --- a/test/test_mpi_tree.jl +++ b/test/test_mpi_tree.jl @@ -22,11 +22,22 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() linf = [6.627000273229378e-5]) end - @trixi_testset "elixir_advection_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - # Expected errors are exactly the same as in the serial test! - l2 = [7.81674284320524e-6], - linf = [6.314906965243505e-5]) + @trixi_testset "elixir_euler_density_wave_restart.jl" begin + using OrdinaryDiffEq: RDPK3SpFSAL49 + Trixi.mpi_isroot() && println("═"^100) + Trixi.mpi_isroot() && println(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl")) + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), + alg = RDPK3SpFSAL49()); + l2_expected, linf_expected = analysis_callback(sol) + + Trixi.mpi_isroot() && println("═"^100) + Trixi.mpi_isroot() && println(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl")) + # Errors are exactly the same as in the elixir_euler_density_wave_extended.jl + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), + alg = RDPK3SpFSAL49()) + l2_actual, linf_actual = analysis_callback(sol) + Trixi.mpi_isroot() && @test l2_actual == l2_expected + Trixi.mpi_isroot() && @test linf_actual == linf_expected end @trixi_testset "elixir_advection_mortar.jl" begin @@ -189,20 +200,6 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() rtol = 0.001) end end - - @trixi_testset "elixir_euler_density_wave_restart.jl" begin - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl")); - l2_expected, linf_expected = analysis_callback(sol) - Trixi.mpi_isroot() && println("═"^100) - Trixi.mpi_isroot() && println(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl")) - # Errors are exactly the same as in the elixir_euler_density_wave_extended.jl - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl")) - l2_actual, linf_actual = analysis_callback(sol) - if Trixi.mpi_isroot() - @test l2_actual == l2_expected - @test linf_actual == linf_expected - end - end end end # TreeMesh MPI diff --git a/test/test_threaded.jl b/test/test_threaded.jl index 9b30836d0ed..72755e6e119 100644 --- a/test/test_threaded.jl +++ b/test/test_threaded.jl @@ -11,28 +11,38 @@ Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) @testset "Threaded tests" begin @testset "TreeMesh" begin - @trixi_testset "elixir_advection_restart.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_restart.jl"), - # Expected errors are exactly the same as in the serial test! - l2 = [7.81674284320524e-6], - linf = [6.314906965243505e-5]) + @trixi_testset "elixir_euler_density_wave_restart.jl" begin + elixir = joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_extended.jl") + Trixi.mpi_isroot() && println("═"^100) + Trixi.mpi_isroot() && println(elixir) + trixi_include(@__MODULE__, elixir) + l2_expected, linf_expected = analysis_callback(sol) + + elixir = joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_restart.jl") + Trixi.mpi_isroot() && println("═"^100) + Trixi.mpi_isroot() && println(elixir) + # Errors are exactly the same as in the elixir_euler_density_wave_extended.jl + trixi_include(@__MODULE__, elixir) + l2_actual, linf_actual = analysis_callback(sol) + Trixi.mpi_isroot() && @test l2_actual == l2_expected + Trixi.mpi_isroot() && @test linf_actual == linf_expected - # Ensure that we do not have excessive memory allocations - # (e.g., from type instabilities) - let - t = sol.t[end] - u_ode = sol.u[end] - du_ode = similar(u_ode) - @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 5000 - end + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 5000 + end end @trixi_testset "elixir_advection_restart.jl with threaded time integration" begin @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_restart.jl"), alg = CarpenterKennedy2N54(williamson_condition = false, thread = OrdinaryDiffEq.True()), # Expected errors are exactly the same as in the serial test! - l2 = [7.81674284320524e-6], - linf = [6.314906965243505e-5]) + l2 = [8.005068880114254e-6], + linf = [6.39093577996519e-5]) end @trixi_testset "elixir_advection_amr_refine_twice.jl" begin diff --git a/test/test_tree_2d_advection.jl b/test/test_tree_2d_advection.jl index 973d0caf88b..5570ba3df3e 100644 --- a/test/test_tree_2d_advection.jl +++ b/test/test_tree_2d_advection.jl @@ -30,6 +30,24 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") l2 = [7.81674284320524e-6], linf = [6.314906965243505e-5]) end + + @trixi_testset "elixir_euler_density_wave_restart.jl" begin + using OrdinaryDiffEq: SSPRK43 + println("═"^100) + println(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl")) + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + alg = SSPRK43()) + l2_expected, linf_expected = analysis_callback(sol) + + println("═"^100) + println(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl")) + # Errors are exactly the same as in the elixir_euler_density_wave_extended.jl + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), + alg = SSPRK43()) + l2_actual, linf_actual = analysis_callback(sol) + @test l2_actual == l2_expected + @test linf_actual == linf_expected + end @trixi_testset "elixir_advection_mortar.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_mortar.jl"), diff --git a/test/test_tree_2d_euler.jl b/test/test_tree_2d_euler.jl index b0302c2bf3f..e1e3ad32e7d 100644 --- a/test/test_tree_2d_euler.jl +++ b/test/test_tree_2d_euler.jl @@ -27,19 +27,6 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") tspan = (0.0, 0.5)) end - @trixi_testset "elixir_euler_density_wave_restart.jl" begin - using OrdinaryDiffEq: SSPRK43 - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), alg = SSPRK43()); - l2_expected, linf_expected = analysis_callback(sol) - println("═"^100) - println(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl")) - # Errors are exactly the same as in the elixir_euler_density_wave_extended.jl - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), alg = SSPRK43()) - l2_actual, linf_actual = analysis_callback(sol) - @test l2_actual == l2_expected - @test linf_actual == linf_expected - end - @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic.jl"), l2 = [2.259440511766445e-6, 2.318888155713922e-6, 2.3188881557894307e-6, 6.3327863238858925e-6], From ebea8c92288afee4fd82c71b2b0c74e95a8ae532 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Fri, 25 Aug 2023 16:07:09 +0300 Subject: [PATCH 094/102] fix --- test/test_tree_2d_advection.jl | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test/test_tree_2d_advection.jl b/test/test_tree_2d_advection.jl index 5570ba3df3e..e4af784e668 100644 --- a/test/test_tree_2d_advection.jl +++ b/test/test_tree_2d_advection.jl @@ -23,13 +23,6 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") linf = [0.04347734797775926], polydeg=1) end - - @trixi_testset "elixir_advection_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - # Expected errors are exactly the same as in the parallel test! - l2 = [7.81674284320524e-6], - linf = [6.314906965243505e-5]) - end @trixi_testset "elixir_euler_density_wave_restart.jl" begin using OrdinaryDiffEq: SSPRK43 From 4ca23b28f2e0acee8e53c513160f58ac09eeb965 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Fri, 25 Aug 2023 16:30:13 +0300 Subject: [PATCH 095/102] fix --- .../tree_2d_dgsem/elixir_advection_extended.jl | 4 ++-- examples/tree_2d_dgsem/elixir_advection_restart.jl | 2 +- test/test_mpi_tree.jl | 14 +++++++------- test/test_threaded.jl | 10 +++++----- test/test_tree_2d_advection.jl | 10 +++++----- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/examples/tree_2d_dgsem/elixir_advection_extended.jl b/examples/tree_2d_dgsem/elixir_advection_extended.jl index 632455b5f86..139b4493e57 100644 --- a/examples/tree_2d_dgsem/elixir_advection_extended.jl +++ b/examples/tree_2d_dgsem/elixir_advection_extended.jl @@ -37,8 +37,8 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, ############################################################################### # ODE solvers, callbacks etc. -# Create ODE problem with time span from 0.0 to 10.0 -tspan = (0.0, 10.0) +# Create ODE problem with time span from 0.0 to 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 diff --git a/examples/tree_2d_dgsem/elixir_advection_restart.jl b/examples/tree_2d_dgsem/elixir_advection_restart.jl index 7896defe7f3..251ba3c1b90 100644 --- a/examples/tree_2d_dgsem/elixir_advection_restart.jl +++ b/examples/tree_2d_dgsem/elixir_advection_restart.jl @@ -6,7 +6,7 @@ using Trixi # Define time integration algorithm alg = CarpenterKennedy2N54(williamson_condition=false) # Create a restart file -trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_extended.jl"), alg = alg) +trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_extended.jl"), alg = alg, tspan = (0.0, 5.0)) ############################################################################### diff --git a/test/test_mpi_tree.jl b/test/test_mpi_tree.jl index 70cd914408b..a9a4c0f5c01 100644 --- a/test/test_mpi_tree.jl +++ b/test/test_mpi_tree.jl @@ -22,18 +22,18 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() linf = [6.627000273229378e-5]) end - @trixi_testset "elixir_euler_density_wave_restart.jl" begin + @trixi_testset "elixir_advection_restart.jl" begin using OrdinaryDiffEq: RDPK3SpFSAL49 Trixi.mpi_isroot() && println("═"^100) - Trixi.mpi_isroot() && println(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl")) - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl"), - alg = RDPK3SpFSAL49()); + Trixi.mpi_isroot() && println(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl")) + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + alg = RDPK3SpFSAL49(), tspan = (0.0, 10.0)) l2_expected, linf_expected = analysis_callback(sol) Trixi.mpi_isroot() && println("═"^100) - Trixi.mpi_isroot() && println(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl")) - # Errors are exactly the same as in the elixir_euler_density_wave_extended.jl - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl"), + Trixi.mpi_isroot() && println(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl")) + # Errors are exactly the same as in the elixir_advection_extended.jl + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), alg = RDPK3SpFSAL49()) l2_actual, linf_actual = analysis_callback(sol) Trixi.mpi_isroot() && @test l2_actual == l2_expected diff --git a/test/test_threaded.jl b/test/test_threaded.jl index 72755e6e119..d6e13466532 100644 --- a/test/test_threaded.jl +++ b/test/test_threaded.jl @@ -11,17 +11,17 @@ Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) @testset "Threaded tests" begin @testset "TreeMesh" begin - @trixi_testset "elixir_euler_density_wave_restart.jl" begin - elixir = joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_extended.jl") + @trixi_testset "elixir_advection_restart.jl" begin + elixir = joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_extended.jl") Trixi.mpi_isroot() && println("═"^100) Trixi.mpi_isroot() && println(elixir) - trixi_include(@__MODULE__, elixir) + trixi_include(@__MODULE__, elixir, tspan = (0.0, 10.0)) l2_expected, linf_expected = analysis_callback(sol) - elixir = joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_density_wave_restart.jl") + elixir = joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_restart.jl") Trixi.mpi_isroot() && println("═"^100) Trixi.mpi_isroot() && println(elixir) - # Errors are exactly the same as in the elixir_euler_density_wave_extended.jl + # Errors are exactly the same as in the elixir_advection_extended.jl trixi_include(@__MODULE__, elixir) l2_actual, linf_actual = analysis_callback(sol) Trixi.mpi_isroot() && @test l2_actual == l2_expected diff --git a/test/test_tree_2d_advection.jl b/test/test_tree_2d_advection.jl index e4af784e668..0db15a1fe97 100644 --- a/test/test_tree_2d_advection.jl +++ b/test/test_tree_2d_advection.jl @@ -24,17 +24,17 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") polydeg=1) end - @trixi_testset "elixir_euler_density_wave_restart.jl" begin + @trixi_testset "elixir_advection_restart.jl" begin using OrdinaryDiffEq: SSPRK43 println("═"^100) - println(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_extended.jl")) + println(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl")) trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - alg = SSPRK43()) + alg = SSPRK43(), tspan = (0.0, 10.0)) l2_expected, linf_expected = analysis_callback(sol) println("═"^100) - println(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_restart.jl")) - # Errors are exactly the same as in the elixir_euler_density_wave_extended.jl + println(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl")) + # Errors are exactly the same as in the elixir_advection_extended.jl trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), alg = SSPRK43()) l2_actual, linf_actual = analysis_callback(sol) From b3141f7b04ebdb41a3bd98af7527fb721711bbc4 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Fri, 25 Aug 2023 17:39:43 +0300 Subject: [PATCH 096/102] Update test_tree_2d_advection.jl --- test/test_tree_2d_advection.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_tree_2d_advection.jl b/test/test_tree_2d_advection.jl index 0db15a1fe97..bcea8d58a7c 100644 --- a/test/test_tree_2d_advection.jl +++ b/test/test_tree_2d_advection.jl @@ -23,7 +23,7 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") linf = [0.04347734797775926], polydeg=1) end - + @trixi_testset "elixir_advection_restart.jl" begin using OrdinaryDiffEq: SSPRK43 println("═"^100) From 6303ff9c49f548a9ab30ba901bfa014ae8474689 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Fri, 25 Aug 2023 17:41:30 +0300 Subject: [PATCH 097/102] fix --- examples/tree_2d_dgsem/elixir_advection_restart.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tree_2d_dgsem/elixir_advection_restart.jl b/examples/tree_2d_dgsem/elixir_advection_restart.jl index 251ba3c1b90..6c317963c84 100644 --- a/examples/tree_2d_dgsem/elixir_advection_restart.jl +++ b/examples/tree_2d_dgsem/elixir_advection_restart.jl @@ -6,7 +6,7 @@ using Trixi # Define time integration algorithm alg = CarpenterKennedy2N54(williamson_condition=false) # Create a restart file -trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_extended.jl"), alg = alg, tspan = (0.0, 5.0)) +trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_extended.jl"), alg = alg, tspan = (0.0, 10.0)) ############################################################################### From 526408d415b72a094fe79be633112706c758e1d0 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Fri, 25 Aug 2023 18:50:49 +0300 Subject: [PATCH 098/102] fix error mpi on windows --- examples/tree_2d_dgsem/elixir_advection_extended.jl | 2 +- examples/tree_2d_dgsem/elixir_advection_restart.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/tree_2d_dgsem/elixir_advection_extended.jl b/examples/tree_2d_dgsem/elixir_advection_extended.jl index 139b4493e57..278dc85386d 100644 --- a/examples/tree_2d_dgsem/elixir_advection_extended.jl +++ b/examples/tree_2d_dgsem/elixir_advection_extended.jl @@ -80,7 +80,7 @@ callbacks = CallbackSet(summary_callback, alg = CarpenterKennedy2N54(williamson_condition=false) sol = solve(ode, alg, dt=1.0, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); + save_everystep=false, callback=callbacks; ode_default_options()...); # Print the timer summary summary_callback() diff --git a/examples/tree_2d_dgsem/elixir_advection_restart.jl b/examples/tree_2d_dgsem/elixir_advection_restart.jl index 6c317963c84..de2d055c06e 100644 --- a/examples/tree_2d_dgsem/elixir_advection_restart.jl +++ b/examples/tree_2d_dgsem/elixir_advection_restart.jl @@ -29,7 +29,7 @@ save_solution.condition.save_initial_solution = false integrator = init(ode, alg, dt=dt, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks) + save_everystep=false, callback=callbacks; ode_default_options()...) # Load saved context for adaptive time integrator if integrator.opts.adaptive From adb584623d6464be7d8d9ed611abd67aebd74f6b Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Sun, 27 Aug 2023 14:42:28 +0300 Subject: [PATCH 099/102] rerun --- test/test_mpi_tree.jl | 1 + test/test_threaded.jl | 1 + test/test_tree_2d_advection.jl | 1 + 3 files changed, 3 insertions(+) diff --git a/test/test_mpi_tree.jl b/test/test_mpi_tree.jl index a9a4c0f5c01..8f08a9d72e7 100644 --- a/test/test_mpi_tree.jl +++ b/test/test_mpi_tree.jl @@ -36,6 +36,7 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), alg = RDPK3SpFSAL49()) l2_actual, linf_actual = analysis_callback(sol) + Trixi.mpi_isroot() && @test l2_actual == l2_expected Trixi.mpi_isroot() && @test linf_actual == linf_expected end diff --git a/test/test_threaded.jl b/test/test_threaded.jl index d6e13466532..2337d73f30a 100644 --- a/test/test_threaded.jl +++ b/test/test_threaded.jl @@ -24,6 +24,7 @@ Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) # Errors are exactly the same as in the elixir_advection_extended.jl trixi_include(@__MODULE__, elixir) l2_actual, linf_actual = analysis_callback(sol) + Trixi.mpi_isroot() && @test l2_actual == l2_expected Trixi.mpi_isroot() && @test linf_actual == linf_expected diff --git a/test/test_tree_2d_advection.jl b/test/test_tree_2d_advection.jl index bcea8d58a7c..36cb1e882cc 100644 --- a/test/test_tree_2d_advection.jl +++ b/test/test_tree_2d_advection.jl @@ -38,6 +38,7 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), alg = SSPRK43()) l2_actual, linf_actual = analysis_callback(sol) + @test l2_actual == l2_expected @test linf_actual == linf_expected end From 5c8f72922739e4ef24bf295050e50ee7aae91763 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Wed, 30 Aug 2023 11:35:09 +0300 Subject: [PATCH 100/102] Update src/callbacks_step/save_restart.jl Co-authored-by: Hendrik Ranocha --- src/callbacks_step/save_restart.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/callbacks_step/save_restart.jl b/src/callbacks_step/save_restart.jl index 1b72411a4ba..39429e0be95 100644 --- a/src/callbacks_step/save_restart.jl +++ b/src/callbacks_step/save_restart.jl @@ -164,7 +164,8 @@ end """ load_adaptive_time_integrator!(integrator, restart_file::AbstractString) -Load the context information for error-based time integrators saved in a `restart_file`. +Load the context information for time integrators with error-based step size control +saved in a `restart_file`. """ function load_adaptive_time_integrator!(integrator, restart_file::AbstractString) controller = integrator.opts.controller From 05b1971b67e7c733615b02d902e612fbed39a09e Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Wed, 30 Aug 2023 11:02:08 +0300 Subject: [PATCH 101/102] Add comments --- src/callbacks_step/save_restart.jl | 5 +++-- src/callbacks_step/save_restart_dg.jl | 5 ++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/callbacks_step/save_restart.jl b/src/callbacks_step/save_restart.jl index 39429e0be95..e5935c5a6f4 100644 --- a/src/callbacks_step/save_restart.jl +++ b/src/callbacks_step/save_restart.jl @@ -171,13 +171,14 @@ function load_adaptive_time_integrator!(integrator, restart_file::AbstractString controller = integrator.opts.controller # Read context information for controller h5open(restart_file, "r") do file - # Ensure that necessary information was saved + # Ensure that the necessary information was saved if !("time_integrator_qold" in keys(attributes(file))) || !("time_integrator_dtpropose" in keys(attributes(file))) || (hasproperty(controller, :err) && !("time_integrator_controller_err" in keys(attributes(file)))) error("Missing data in restart file: check the consistency of adaptive time controller with initial setup!") end + # Load data that is required both for PIController and PIDController integrator.qold = read(attributes(file)["time_integrator_qold"]) integrator.dtpropose = read(attributes(file)["time_integrator_dtpropose"]) # Accept step to use dtpropose already in the first step @@ -185,7 +186,7 @@ function load_adaptive_time_integrator!(integrator, restart_file::AbstractString # Reevaluate integrator.fsal_first on the first step integrator.reeval_fsal = true # Load additional parameters for PIDController - if hasproperty(controller, :err) + if hasproperty(controller, :err) # Distinguish PIDController from PIController controller.err[:] = read(attributes(file)["time_integrator_controller_err"]) end end diff --git a/src/callbacks_step/save_restart_dg.jl b/src/callbacks_step/save_restart_dg.jl index 6ab323adaac..cddeef77bb2 100644 --- a/src/callbacks_step/save_restart_dg.jl +++ b/src/callbacks_step/save_restart_dg.jl @@ -341,12 +341,11 @@ function save_adaptive_time_integrator(integrator, # Open file (preserve existing content) h5open(filename, "r+") do file - # Add context information as attributes + # Add context information as attributes both for PIController and PIDController attributes(file)["time_integrator_qold"] = integrator.qold - # Ensure that `dtpropose` is written as a double precision scalar attributes(file)["time_integrator_dtpropose"] = integrator.dtpropose # For PIDController is necessary to save additional parameters - if hasproperty(controller, :err) + if hasproperty(controller, :err) # Distinguish PIDController from PIController attributes(file)["time_integrator_controller_err"] = controller.err end end From a41f45f8bd4003ddf4e4f0657dda12b1ae89137c Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Thu, 14 Sep 2023 16:12:36 +0300 Subject: [PATCH 102/102] format --- src/Trixi.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Trixi.jl b/src/Trixi.jl index 1e0cfd9ae79..b65d03e7975 100644 --- a/src/Trixi.jl +++ b/src/Trixi.jl @@ -255,7 +255,8 @@ export SummaryCallback, SteadyStateCallback, AnalysisCallback, AliveCallback, GlmSpeedCallback, LBMCollisionCallback, EulerAcousticsCouplingCallback, TrivialCallback, AnalysisCallbackCoupled -export load_mesh, load_time, load_timestep, load_timestep!, load_dt, load_adaptive_time_integrator! +export load_mesh, load_time, load_timestep, load_timestep!, load_dt, + load_adaptive_time_integrator! export ControllerThreeLevel, ControllerThreeLevelCombined, IndicatorLöhner, IndicatorLoehner, IndicatorMax,