Skip to content

Commit

Permalink
Shorten code by relocate use of interval
Browse files Browse the repository at this point in the history
  • Loading branch information
bennibolm committed Oct 17, 2023
1 parent 20162dc commit 3c3c3da
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
18 changes: 9 additions & 9 deletions src/callbacks_stage/subcell_bounds_check.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,30 @@ function (callback::BoundsCheckCallback)(u_ode, integrator, stage)
u = wrap_array(u_ode, mesh, equations, solver, cache)

save_errors_ = callback.save_errors && (callback.interval > 0) &&
(stage == length(alg.c))
(iter % callback.interval == 0) && (stage == length(alg.c))
@trixi_timeit timer() "check_bounds" check_bounds(u, mesh, equations, solver, cache,
t, iter + 1,
callback.output_directory,
save_errors_, callback.interval)
save_errors_)
end

function check_bounds(u, mesh, equations, solver, cache, t, iter, output_directory,
save_errors, interval)
save_errors)
check_bounds(u, mesh, equations, solver, cache, solver.volume_integral, t, iter,
output_directory, save_errors, interval)
output_directory, save_errors)
end

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

function check_bounds(u, mesh, equations, solver, cache,
volume_integral::VolumeIntegralSubcellLimiting,
t, iter, output_directory, save_errors, interval)
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, interval)
output_directory, save_errors)
end

function init_callback(callback, semi)
Expand Down
9 changes: 4 additions & 5 deletions src/callbacks_stage/subcell_bounds_check_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@

@inline function check_bounds(u, mesh::AbstractMesh{2}, equations, solver, cache,
limiter::SubcellLimiterIDP,
time, iter, output_directory, save_errors, interval)
time, iter, output_directory, save_errors)
(; positivity) = solver.volume_integral.limiter
(; variable_bounds) = limiter.cache.subcell_limiter_coefficients
(; idp_bounds_delta) = limiter.cache

save_errors_ = save_errors && (iter % interval == 0)
if save_errors_
if save_errors
open("$output_directory/deviations.txt", "a") do f
print(f, iter, ", ", time)
end
Expand All @@ -30,15 +29,15 @@
variable_bounds[key][i, j, element] - var)
end
idp_bounds_delta[key] = max(idp_bounds_delta[key], deviation_min)
if save_errors_
if save_errors
deviation_min_ = deviation_min
open("$output_directory/deviations.txt", "a") do f
print(f, ", ", deviation_min_)
end
end
end
end
if save_errors_
if save_errors
open("$output_directory/deviations.txt", "a") do f
println(f)
end
Expand Down

0 comments on commit 3c3c3da

Please sign in to comment.