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
Changes from 6 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
19 changes: 12 additions & 7 deletions src/callbacks_step/analysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ Additional errors can be computed, e.g. by passing
`extra_analysis_errors = (:l2_error_primitive, :linf_error_primitive)`
or `extra_analysis_errors = (:conservation_error,)`.

If you want to omit the computation (to safe compute-time) of the [`default_analysis_errors`](@ref), specify
DanielDoehring marked this conversation as resolved.
Show resolved Hide resolved
`analysis_errors = Symbol[]`.
Note: `default_analysis_errors` are `:l2_error`, `:linf_error` for all equations.
DanielDoehring marked this conversation as resolved.
Show resolved Hide resolved
If you want to compute `extra_analysis_errors` such as `:conservation_error` solely, i.e.,
without `:l2_error, :linf_error` you need to specify
`analysis_errors = [:conservation_error]` instead of `extra_analysis_errors = [:conservation_error]`.

Further scalar functions `func` in `extra_analysis_integrals` are applied to the numerical
solution and integrated over the computational domain. Some examples for this are
[`entropy`](@ref), [`energy_kinetic`](@ref), [`energy_internal`](@ref), and [`energy_total`](@ref).
Expand Down Expand Up @@ -332,7 +339,8 @@ function (analysis_callback::AnalysisCallback)(u_ode, du_ode, integrator, semi)
@notimeit timer() integrator.f(du_ode, u_ode, semi, t)
u = wrap_array(u_ode, mesh, equations, solver, cache)
du = wrap_array(du_ode, mesh, equations, solver, cache)
l2_error, linf_error = analysis_callback(io, du, u, u_ode, t, semi)
# Compute l2_error, linf_error
analysis_callback(io, du, u, u_ode, t, semi)

mpi_println("─"^100)
mpi_println()
Expand All @@ -354,8 +362,7 @@ function (analysis_callback::AnalysisCallback)(u_ode, du_ode, integrator, semi)
analysis_callback.start_time_last_analysis = time_ns()
analysis_callback.ncalls_rhs_last_analysis = ncalls(semi.performance_counter)

# Return errors for EOC analysis
return l2_error, linf_error
return nothing
end

# This method is just called internally from `(analysis_callback::AnalysisCallback)(integrator)`
Expand All @@ -382,9 +389,7 @@ function (analysis_callback::AnalysisCallback)(io, du, u, u_ode, t, semi)
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
return nothing
end

if mpi_isroot()
Expand Down Expand Up @@ -484,7 +489,7 @@ function (analysis_callback::AnalysisCallback)(io, du, u, u_ode, t, semi)
# additional integrals
analyze_integrals(analysis_integrals, io, du, u, t, semi)

return l2_error, linf_error
return nothing
end

# Print level information only if AMR is enabled
Expand Down
Loading