Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Outsource saving of bounds check errors #1824

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f34c38e
Outsource saving of bounds check errors
bennibolm Jan 31, 2024
34eaafa
Merge branch 'main' into subcell-limiting-outsource-saving-errors
bennibolm Feb 1, 2024
5e5fecf
Increase coverage by activate saving of bounds check errors for local…
bennibolm Feb 1, 2024
d4a3e4b
Fix test for saving errors with coverage
bennibolm Feb 1, 2024
bf9fb62
Merge branch 'main' into subcell-limiting-outsource-saving-errors
bennibolm Feb 2, 2024
cad2c0a
Merge branch 'main' into subcell-limiting-outsource-saving-errors
bennibolm Feb 5, 2024
af1b407
Remove empty line
bennibolm Feb 6, 2024
ab4688f
Merge branch 'main' into subcell-limiting-outsource-saving-errors
bennibolm Mar 6, 2024
4179a7e
Merge branch 'main' into subcell-limiting-outsource-saving-errors
bennibolm Mar 19, 2024
bc61d69
Implement suggestions
bennibolm Mar 19, 2024
6ba4dd6
Merge branch 'main' into subcell-limiting-outsource-saving-errors
bennibolm Apr 5, 2024
7d8bcf5
Merge branch 'main' into subcell-limiting-outsource-saving-errors
bennibolm Apr 5, 2024
b09a0bb
Merge branch 'main' into subcell-limiting-outsource-saving-errors
bennibolm May 7, 2024
c196ec3
Use `joinpath`
bennibolm May 7, 2024
b268f2f
Add test with coverage
bennibolm May 7, 2024
b8bfd54
Merge branch 'main' into subcell-limiting-outsource-saving-errors
bennibolm May 8, 2024
60249f5
Fix I/O test for modified elixir
bennibolm May 8, 2024
9ccfd9e
Add more accurate test
bennibolm May 8, 2024
50472c8
Redo last change; Default maxiters with coverage is 1
bennibolm May 8, 2024
27f049c
Change order of lines
bennibolm May 8, 2024
a6d5986
Save deviations if maxiters is reached
bennibolm May 8, 2024
02bdb14
Add comment
bennibolm May 8, 2024
3b513ed
Save deviations at correct time steps
bennibolm May 8, 2024
424edaa
Merge branch 'main' into subcell-limiting-outsource-saving-errors
sloede May 10, 2024
e5b24cd
Merge branch 'main' into subcell-limiting-outsource-saving-errors
bennibolm May 10, 2024
7586a71
Merge branch 'main' into subcell-limiting-outsource-saving-errors
bennibolm May 10, 2024
8111037
Add test for saving deviations for positivity limiter (non-linear)
bennibolm May 11, 2024
b590233
Add comment
bennibolm May 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions src/callbacks_stage/subcell_bounds_check.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,35 @@ function (callback::BoundsCheckCallback)(u_ode, integrator, stage)
(stage == length(alg.c)) &&
(iter % callback.interval == 0 || integrator.finalstep)
@trixi_timeit timer() "check_bounds" check_bounds(u, mesh, equations, solver, cache,
solver.volume_integral, t,
iter + 1,
callback.output_directory,
save_errors)
solver.volume_integral)

if save_errors
@trixi_timeit timer() "save_errors" save_bounds_check_errors(callback.output_directory,
u, t, iter + 1,
equations,
solver.volume_integral)
end
end

@inline function check_bounds(u, mesh, equations, solver, cache,
volume_integral::AbstractVolumeIntegral)
return nothing
end
bennibolm marked this conversation as resolved.
Show resolved Hide resolved

@inline function check_bounds(u, mesh, equations, solver, cache,
volume_integral::VolumeIntegralSubcellLimiting)
check_bounds(u, mesh, equations, solver, cache, volume_integral.limiter)
end

function check_bounds(u, mesh, equations, solver, cache,
volume_integral::AbstractVolumeIntegral, t, iter,
output_directory, save_errors)
@inline function save_bounds_check_errors(output_directory, u, t, iter, equations,
volume_integral::AbstractVolumeIntegral)
return nothing
end

function check_bounds(u, mesh, equations, solver, cache,
volume_integral::VolumeIntegralSubcellLimiting, t, iter,
output_directory, save_errors)
check_bounds(u, mesh, equations, solver, cache, volume_integral.limiter, t, iter,
output_directory, save_errors)
@inline function save_bounds_check_errors(output_directory, u, t, iter, equations,
volume_integral::VolumeIntegralSubcellLimiting)
save_bounds_check_errors(output_directory, u, t, iter, equations,
volume_integral.limiter)
end

function init_callback(callback::BoundsCheckCallback, semi)
Expand Down
69 changes: 38 additions & 31 deletions src/callbacks_stage/subcell_bounds_check_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
#! format: noindent

@inline function check_bounds(u, mesh::AbstractMesh{2}, equations, solver, cache,
limiter::SubcellLimiterIDP,
time, iter, output_directory, save_errors)
limiter::SubcellLimiterIDP)
(; local_minmax, positivity) = solver.volume_integral.limiter
(; variable_bounds) = limiter.cache.subcell_limiter_coefficients
(; idp_bounds_delta_local, idp_bounds_delta_global) = limiter.cache
Expand Down Expand Up @@ -85,40 +84,48 @@
idp_bounds_delta_local[key][stride_size])
end

if save_errors
# Print to output file
open("$output_directory/deviations.txt", "a") do f
print(f, iter, ", ", time)
if local_minmax
for v in limiter.local_minmax_variables_cons
v_string = string(v)
print(f, ", ",
idp_bounds_delta_local[Symbol(v_string, "_min")][stride_size],
", ",
idp_bounds_delta_local[Symbol(v_string, "_max")][stride_size])
end
return nothing
end

@inline function save_bounds_check_errors(output_directory, u, time, iter, equations,
limiter::SubcellLimiterIDP)
(; local_minmax, positivity) = limiter
(; idp_bounds_delta_local) = limiter.cache

stride_size = div(128, sizeof(eltype(u))) # = n
bennibolm marked this conversation as resolved.
Show resolved Hide resolved

# Print errors to output file
open("$output_directory/deviations.txt", "a") do f
print(f, iter, ", ", time)
if local_minmax
for v in limiter.local_minmax_variables_cons
v_string = string(v)
print(f, ", ",
idp_bounds_delta_local[Symbol(v_string, "_min")][stride_size],
", ",
idp_bounds_delta_local[Symbol(v_string, "_max")][stride_size])
end
if positivity
for v in limiter.positivity_variables_cons
if v in limiter.local_minmax_variables_cons
continue
end
print(f, ", ",
idp_bounds_delta_local[Symbol(string(v), "_min")][stride_size])
end
for variable in limiter.positivity_variables_nonlinear
print(f, ", ",
idp_bounds_delta_local[Symbol(string(variable), "_min")][stride_size])
end
if positivity
for v in limiter.positivity_variables_cons
if v in limiter.local_minmax_variables_cons
continue
end
print(f, ", ",
idp_bounds_delta_local[Symbol(string(v), "_min")][stride_size])
end
println(f)
end
# Reset local maximum deviations
for (key, _) in idp_bounds_delta_local
for i in 1:Threads.nthreads()
idp_bounds_delta_local[key][stride_size * i] = zero(eltype(idp_bounds_delta_local[key][stride_size]))
for variable in limiter.positivity_variables_nonlinear
print(f, ", ",
idp_bounds_delta_local[Symbol(string(variable), "_min")][stride_size])
end
end
println(f)
end
# Reset local maximum deviations
for (key, _) in idp_bounds_delta_local
for i in 1:Threads.nthreads()
idp_bounds_delta_local[key][stride_size * i] = zero(eltype(idp_bounds_delta_local[key][stride_size]))
end
end

return nothing
Expand Down
Loading