From ed020be2d529038fa3357988c696519ae6dacf7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20M=C3=B8yner?= Date: Fri, 5 Apr 2024 14:59:06 +0200 Subject: [PATCH 1/4] Timestep selector: Override for when time-step is nearly done --- src/simulator/simulator.jl | 2 +- src/simulator/timesteps.jl | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/simulator/simulator.jl b/src/simulator/simulator.jl index e12d2750..34688748 100644 --- a/src/simulator/simulator.jl +++ b/src/simulator/simulator.jl @@ -258,7 +258,7 @@ function solve_timestep!(sim, dT, forces, max_its, config; dt = dT, reports = no break else # Pick another for the next step... - dt = pick_timestep(sim, config, dt, dT, forces, reports, ministep_reports, step_index = step_no, new_step = false) + dt = pick_timestep(sim, config, dt, dT, forces, reports, ministep_reports, step_index = step_no, new_step = false, remaining_time = dT - t_local) end else dt_old = dt diff --git a/src/simulator/timesteps.jl b/src/simulator/timesteps.jl index f4898758..fba29ae5 100644 --- a/src/simulator/timesteps.jl +++ b/src/simulator/timesteps.jl @@ -1,4 +1,4 @@ -function pick_timestep(sim, config, dt_prev, dT, forces, reports, current_reports; step_index = NaN, new_step = false) +function pick_timestep(sim, config, dt_prev, dT, forces, reports, current_reports; step_index = NaN, new_step = false, remaining_time = dT) # Try to do the full step, unless one of our selectors/limits tells us otherwise. # No need to limit to whatever remains of the interval since that is fixed on the outside. dt = dT @@ -23,6 +23,12 @@ function pick_timestep(sim, config, dt_prev, dT, forces, reports, current_report for sel in selectors dt = valid_timestep(sel, dt) end + # If we are not going to reach the end anyway, we split the remaining part + # into two to avoid a long step and a very short step. + half_remain = remaining_time/2.0 + if dt > half_remain && dt < remaining_time + dt = half_remain + end dt = min(dt, config[:max_timestep]) if config[:info_level] > 1 ratio = dt/dt_prev @@ -37,7 +43,6 @@ function pick_timestep(sim, config, dt_prev, dT, forces, reports, current_report else t_sym = "🔄" end - # @info "Selected new sub-timestep $(get_tstr(dt)) from previous $(get_tstr(dt_prev)) $t_sym" jutul_message("Next mini-step", "Δt = $(get_tstr(dt)) from previous $(get_tstr(dt_prev)) $t_sym", color = :default) end return dt From b425755f4f2d857469c6559bdd7f9ba63a39465a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20M=C3=B8yner?= Date: Fri, 5 Apr 2024 20:34:04 +0200 Subject: [PATCH 2/4] Make relaxation less verbose and warning-like --- src/simulator/simulator.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/simulator/simulator.jl b/src/simulator/simulator.jl index 34688748..b2175bcf 100644 --- a/src/simulator/simulator.jl +++ b/src/simulator/simulator.jl @@ -669,8 +669,8 @@ function apply_nonlinear_strategy!(sim, dt, forces, it, max_iter, cfg, e, step_r report = step_reports[end] w0 = relaxation relaxation = select_nonlinear_relaxation(sim, cfg[:relaxation], step_reports, relaxation) - if cfg[:info_level] > 1 && relaxation != w0 - jutul_message("Relaxation", "Changed from $w0 to $relaxation at iteration $it.", color = :yellow) + if cfg[:info_level] > 2 && relaxation != w0 + jutul_message("Relaxation", "Changed from $w0 to $relaxation at iteration $it.", color = :green) end failure = false max_res = cfg[:max_residual] From 307e328154771094d8087d915bfb9e01fec2b27e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20M=C3=B8yner?= Date: Fri, 12 Apr 2024 13:58:54 +0200 Subject: [PATCH 3/4] States are not ordered (fix depwarn) --- src/simulator/simulator.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simulator/simulator.jl b/src/simulator/simulator.jl index b2175bcf..388bcdb4 100644 --- a/src/simulator/simulator.jl +++ b/src/simulator/simulator.jl @@ -532,7 +532,7 @@ function initial_setup!(sim, config, timesteps; restart = nothing, parameters = end # Set up storage reports = [] - states = Vector{JUTUL_OUTPUT_TYPE}() + states = Vector{Dict{Symbol, Any}}() pth = config[:output_path] initialize_io(pth) has_restart = !(isnothing(restart) || restart === 0 || restart === 1 || restart == false) From 746844521654d5368b8798c478f2d7d9e74f9369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20M=C3=B8yner?= Date: Fri, 12 Apr 2024 14:11:36 +0200 Subject: [PATCH 4/4] Bump version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 2044f059..4fd09abc 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Jutul" uuid = "2b460a1a-8a2b-45b2-b125-b5c536396eb9" authors = ["Olav Møyner "] -version = "0.2.28" +version = "0.2.29" [deps] AlgebraicMultigrid = "2169fc97-5a83-5252-b627-83903c6c433c"