Skip to content

Commit

Permalink
Merge pull request #66 from sintefmath/dev
Browse files Browse the repository at this point in the history
Better handling of short ministeps and improved printing
  • Loading branch information
moyner committed Apr 12, 2024
2 parents bf464e6 + 7468445 commit d5cc19b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Jutul"
uuid = "2b460a1a-8a2b-45b2-b125-b5c536396eb9"
authors = ["Olav Møyner <olav.moyner@gmail.com>"]
version = "0.2.28"
version = "0.2.29"

[deps]
AlgebraicMultigrid = "2169fc97-5a83-5252-b627-83903c6c433c"
Expand Down
8 changes: 4 additions & 4 deletions src/simulator/simulator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]
Expand Down
9 changes: 7 additions & 2 deletions src/simulator/timesteps.jl
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

2 comments on commit d5cc19b

@moyner
Copy link
Member Author

@moyner moyner commented on d5cc19b Apr 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/104776

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.29 -m "<description of version>" d5cc19b1a0a244cfea2397592cb96f303404ad36
git push origin v0.2.29

Please sign in to comment.