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

Make error norm calculation optional #1755

Merged
merged 21 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
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
11 changes: 9 additions & 2 deletions src/callbacks_step/analysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,15 @@ function (analysis_callback::AnalysisCallback)(io, du, u, u_ode, t, semi)
println()
end

# Calculate L2/Linf errors, which are also returned
l2_error, linf_error = calc_error_norms(u_ode, t, analyzer, semi, cache_analysis)
if :l2_error in analysis_errors || :linf_error in analysis_errors
# Calculate L2/Linf errors, which are also returned
DanielDoehring marked this conversation as resolved.
Show resolved Hide resolved
l2_error, linf_error = calc_error_norms(u_ode, t, analyzer, semi,
cache_analysis)
else
# Names `l2_error`, `linf_error` need to be defined
l2_error = nothing
linf_error = nothing
DanielDoehring marked this conversation as resolved.
Show resolved Hide resolved
end

if mpi_isroot()
# L2 error
Expand Down
14 changes: 14 additions & 0 deletions test/test_tree_1d_advection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ end
end
end

@trixi_testset "elixir_advection_basic.jl (No errors)" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"),
analysis_callback=AnalysisCallback(semi, interval = 42,
analysis_errors = Symbol[]))
ranocha marked this conversation as resolved.
Show resolved Hide resolved
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
end
end

@trixi_testset "elixir_advection_finite_volume.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_finite_volume.jl"),
l2=[0.011662300515980219],
Expand Down
Loading