Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add two-sided Zalesak-type IDP subcell limiting #1648

Merged
merged 35 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1a2eb00
Add two-sided limiting for conservative variables
bennibolm Sep 26, 2023
ab9e5d9
Fix visualization routines
bennibolm Sep 26, 2023
534f148
Add bounds calculation for BoundaryConditionDirichlet
bennibolm Sep 26, 2023
9b0eee9
Reduce cfl in elixir
bennibolm Sep 26, 2023
3e6f7f8
Fix test
bennibolm Sep 26, 2023
d7dcb75
Merge branch 'main' into subcell-limiting-minmax
bennibolm Oct 12, 2023
de23b58
Add comment about subcell limiting with non-conforming meshes
bennibolm Oct 13, 2023
96be070
Remove subcell visualization
bennibolm Oct 16, 2023
fb4d876
Fix last commit
bennibolm Oct 16, 2023
2d8b49d
Remove @unpack
bennibolm Oct 16, 2023
64cf39c
Add comment to `News.md`
bennibolm Oct 16, 2023
2d7ce45
Fix source for sedov blast setup; Formatting
bennibolm Oct 16, 2023
6f9d3d1
Reduce allocations
bennibolm Oct 18, 2023
39b39b6
Replace construction of Symbols
bennibolm Oct 20, 2023
9b8398c
Merge branch 'main' into subcell-limiting-minmax
bennibolm Oct 20, 2023
535f520
Add bounds check for local limiting
bennibolm Oct 22, 2023
5b2b888
Implement suggestions
bennibolm Oct 24, 2023
b7bed59
Fix format
bennibolm Oct 24, 2023
394c486
Merge branch 'main' into subcell-limiting-minmax
sloede Oct 25, 2023
09cbdae
Merge branch 'main' into subcell-limiting-minmax
bennibolm Nov 2, 2023
6d01643
Add subcell allocation tests; Add changes to minmax limiter
bennibolm Nov 2, 2023
306fb19
Undo changes in elixirs
bennibolm Nov 2, 2023
5adf14c
Implement suggestions
bennibolm Nov 2, 2023
29ed6ce
Skip positivity limiting if local limiting is more restrictive
bennibolm Nov 3, 2023
ea226d5
Reduce allocations
bennibolm Nov 3, 2023
953926a
Merge branch 'main' into subcell-limiting-minmax
bennibolm Nov 6, 2023
3afa4c1
Pass variables as strings instead of ints
bennibolm Nov 7, 2023
de20a89
Add `_nonperiodic` to elixir name
bennibolm Nov 7, 2023
50e7bc2
Merge branch 'main' into subcell-limiting-minmax
bennibolm Nov 7, 2023
fd3d531
Fix unit test
bennibolm Nov 7, 2023
5e81530
Implement suggestions
bennibolm Nov 8, 2023
07c0436
Add missing comma in export of bounds check deviation
bennibolm Nov 9, 2023
89f1b6e
Implement suggestions
bennibolm Nov 9, 2023
4b90e2e
Merge branch 'main' into subcell-limiting-minmax
sloede Nov 9, 2023
f7b8d0a
Merge branch 'main' into subcell-limiting-minmax
amrueda Nov 13, 2023
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
Prev Previous commit
Next Next commit
Add bounds check for local limiting
  • Loading branch information
bennibolm committed Oct 22, 2023
commit 535f52004f8799c0ae936d33dcdc630a969ced68
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ callbacks = CallbackSet(summary_callback,
###############################################################################
# run the simulation

stage_callbacks = (SubcellLimiterIDPCorrection(),)
stage_callbacks = (SubcellLimiterIDPCorrection(), BoundsCheckCallback(save_errors=false))

sol = Trixi.solve(ode, Trixi.SimpleSSPRK33(stage_callbacks=stage_callbacks);
dt=1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ callbacks = CallbackSet(summary_callback,
###############################################################################
# run the simulation

stage_callbacks = (SubcellLimiterIDPCorrection(),)
stage_callbacks = (SubcellLimiterIDPCorrection(), BoundsCheckCallback(save_errors=false))

sol = Trixi.solve(ode, Trixi.SimpleSSPRK33(stage_callbacks=stage_callbacks);
dt=1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ callbacks = CallbackSet(summary_callback,
###############################################################################
# run the simulation

stage_callbacks = (SubcellLimiterIDPCorrection(),)
stage_callbacks = (SubcellLimiterIDPCorrection(), BoundsCheckCallback(save_errors=false))

sol = Trixi.solve(ode, Trixi.SimpleSSPRK33(stage_callbacks=stage_callbacks);
dt=1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
Expand Down
24 changes: 22 additions & 2 deletions src/callbacks_stage/subcell_bounds_check.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,24 @@ function init_callback(callback::BoundsCheckCallback, semi, limiter::SubcellLimi
return nothing
end

(; positivity) = limiter
(; local_minmax, positivity) = limiter
(; output_directory) = callback
variables = varnames(cons2cons, semi.equations)

mkpath(output_directory)
open("$output_directory/deviations.txt", "a") do f
print(f, "# iter, simu_time")
if local_minmax
for v in limiter.local_minmax_variables_cons
variable_string = string(variables[v])
print(f, ", " * variable_string * "_min, " * variable_string * "_max")
end
end
if positivity
for v in limiter.positivity_variables_cons
if v in limiter.local_minmax_variables_cons
continue
end
print(f, ", " * string(variables[v]) * "_min")
end
end
Expand All @@ -108,15 +117,26 @@ end

@inline function finalize_callback(callback::BoundsCheckCallback, semi,
limiter::SubcellLimiterIDP)
(; positivity) = limiter
(; local_minmax, positivity) = limiter
(; idp_bounds_delta) = limiter.cache
variables = varnames(cons2cons, semi.equations)

println("─"^100)
println("Maximum deviation from bounds:")
println("─"^100)
if local_minmax
for v in limiter.local_minmax_variables_cons
v_string = string(v)
println("$(variables[v]):")
println("-lower bound: ", idp_bounds_delta[Symbol(v_string, "_min")][2])
println("-upper bound: ", idp_bounds_delta[Symbol(v_string, "_max")][2])
end
end
if positivity
for v in limiter.positivity_variables_cons
if v in limiter.local_minmax_variables_cons
continue
end
println(string(variables[v]) * ":\n- positivity: ",
idp_bounds_delta[Symbol(string(v), "_min")][2])
end
Expand Down
38 changes: 35 additions & 3 deletions src/callbacks_stage/subcell_bounds_check_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,35 @@
@inline function check_bounds(u, mesh::AbstractMesh{2}, equations, solver, cache,
limiter::SubcellLimiterIDP,
time, iter, output_directory, save_errors)
(; positivity) = solver.volume_integral.limiter
(; local_minmax, positivity) = solver.volume_integral.limiter
(; variable_bounds) = limiter.cache.subcell_limiter_coefficients
(; idp_bounds_delta) = limiter.cache

if local_minmax
for v in limiter.local_minmax_variables_cons
v_string = string(v)
key_min = Symbol(v_string, "_min")
key_max = Symbol(v_string, "_max")
deviation_min = idp_bounds_delta[key_min]
deviation_max = idp_bounds_delta[key_max]
for element in eachelement(solver, cache), j in eachnode(solver),
i in eachnode(solver)

var = u[v, i, j, element]
deviation_min[1] = max(deviation_min[1],
variable_bounds[key_min][i, j, element] - var)
deviation_max[1] = max(deviation_max[1],
var - variable_bounds[key_max][i, j, element])
end
deviation_min[2] = max(deviation_min[2], deviation_min[1])
deviation_max[2] = max(deviation_max[2], deviation_max[1])
end
end
if positivity
for v in limiter.positivity_variables_cons
if v in limiter.local_minmax_variables_cons
continue
end
key = Symbol(string(v), "_min")
deviation = idp_bounds_delta[key]
for element in eachelement(solver, cache), j in eachnode(solver),
Expand All @@ -30,10 +53,19 @@
# 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[Symbol(v_string, "_min")][1],
idp_bounds_delta[Symbol(v_string, "_max")][1])
end
end
if positivity
for v in limiter.positivity_variables_cons
key = Symbol(string(v), "_min")
print(f, ", ", idp_bounds_delta[key][1])
if v in limiter.local_minmax_variables_cons
continue
end
print(f, ", ", idp_bounds_delta[Symbol(string(v), "_min")][1])
end
end
println(f)
Expand Down
5 changes: 3 additions & 2 deletions src/solvers/dgsem_tree/subcell_limiters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ function SubcellLimiterIDP(equations::AbstractEquations, basis;
bound_keys = ()
if local_minmax
for v in local_minmax_variables_cons
bound_keys = (bound_keys..., Symbol(string(v), "_min"),
Symbol(string(v), "_max"))
v_string = string(v)
bound_keys = (bound_keys..., Symbol(v_string, "_min"),
Symbol(v_string, "_max"))
end
end
for v in positivity_variables_cons
Expand Down