Skip to content

Commit

Permalink
Rework calculation of bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
bennibolm committed Oct 19, 2023
1 parent 5f01e42 commit 9e9e99e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/callbacks_stage/subcell_bounds_check.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ end
if positivity
for v in limiter.positivity_variables_cons
println("$(variables[v]):\n- positivity: ",
idp_bounds_delta[Symbol("$(v)_min")])
idp_bounds_delta[Symbol("$(v)_min")][2])
end
end
println(""^100 * "\n")
Expand Down
31 changes: 16 additions & 15 deletions src/callbacks_stage/subcell_bounds_check_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,36 @@
(; variable_bounds) = limiter.cache.subcell_limiter_coefficients
(; idp_bounds_delta) = limiter.cache

if save_errors
open("$output_directory/deviations.txt", "a") do f
print(f, iter, ", ", time)
end
end
if positivity
for v in limiter.positivity_variables_cons
key = Symbol("$(v)_min")
deviation_min = zero(eltype(u))
deviation = idp_bounds_delta[key]
for element in eachelement(solver, cache), j in eachnode(solver),
i in eachnode(solver)

var = u[v, i, j, element]
deviation_min = max(deviation_min,
variable_bounds[key][i, j, element] - var)
end
idp_bounds_delta[key] = max(idp_bounds_delta[key], deviation_min)
if save_errors
deviation_min_ = deviation_min
open("$output_directory/deviations.txt", "a") do f
print(f, ", ", deviation_min_)
end
deviation[1] = max(deviation[1],
variable_bounds[key][i, j, element] - var)
end
deviation[2] = max(deviation[2], deviation[1])
end
end
if save_errors
# Print to output file
open("$output_directory/deviations.txt", "a") do f
print(f, iter, ", ", time)
if positivity
for v in limiter.positivity_variables_cons
key = Symbol("$(v)_min")
print(f, ", ", idp_bounds_delta[key][1])
end
end
println(f)
end
# Reset first entries of idp_bounds_delta
for (key, _) in idp_bounds_delta
idp_bounds_delta[key][1] = zero(eltype(idp_bounds_delta[key][1]))
end
end

return nothing
Expand Down
4 changes: 2 additions & 2 deletions src/solvers/dgsem_tree/subcell_limiters_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ function create_cache(limiter::Type{SubcellLimiterIDP}, equations::AbstractEquat
nnodes(basis),
bound_keys)

idp_bounds_delta = Dict{Symbol, real(basis)}()
idp_bounds_delta = Dict{Symbol, Vector{real(basis)}}()
for key in bound_keys
idp_bounds_delta[key] = zero(real(basis))
idp_bounds_delta[key] = zeros(real(basis), 2)
end

return (; subcell_limiter_coefficients, idp_bounds_delta)
Expand Down

0 comments on commit 9e9e99e

Please sign in to comment.