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

Print Analysis in Full Precision to File #2155

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ Trixi.jl follows the interpretation of [semantic versioning (semver)](https://ju
used in the Julia ecosystem. Notable changes will be documented in this file
for human readability.

## Changes when updating to v0.10 from v0.9.x

#### Changed

- The `AnalysisCallback` output generated with the `save_analysis = true` option now prints
floating point numbers in their respective (full) precision.
Previously, only the first 8 digits were printed to file.
Furthermore, the names of the printed fields are now only separated by a single white space,
in contrast to before where this were multiple, depending on the actual name of the printed data.

## Changes in the v0.9 lifecycle

#### Added
Expand Down
40 changes: 20 additions & 20 deletions src/callbacks_step/analysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -163,42 +163,42 @@ function initialize!(cb::DiscreteCallback{Condition, Affect!}, u_ode, du_ode, t,

# write header of output file
open(joinpath(output_directory, analysis_filename), "w") do io
@printf(io, "#%-8s", "timestep")
@printf(io, " %-14s", "time")
@printf(io, " %-14s", "dt")
print(io, "#timestep ")
DanielDoehring marked this conversation as resolved.
Show resolved Hide resolved
print(io, "time ")
print(io, "dt ")
if :l2_error in analysis_errors
for v in varnames(cons2cons, equations)
@printf(io, " %-14s", "l2_"*v)
print(io, "l2_" * v * " ")
end
end
if :linf_error in analysis_errors
for v in varnames(cons2cons, equations)
@printf(io, " %-14s", "linf_"*v)
print(io, "linf_" * v * " ")
end
end
if :conservation_error in analysis_errors
for v in varnames(cons2cons, equations)
@printf(io, " %-14s", "cons_"*v)
print(io, "cons_" * v * " ")
end
end
if :residual in analysis_errors
for v in varnames(cons2cons, equations)
@printf(io, " %-14s", "res_"*v)
print(io, "res_" * v * " ")
end
end
if :l2_error_primitive in analysis_errors
for v in varnames(cons2prim, equations)
@printf(io, " %-14s", "l2_"*v)
print(io, "l2_" * v * " ")
end
end
if :linf_error_primitive in analysis_errors
for v in varnames(cons2prim, equations)
@printf(io, " %-14s", "linf_"*v)
print(io, "linf_" * v * " ")
end
end

for quantity in analysis_integrals
@printf(io, " %-14s", pretty_form_ascii(quantity))
print(io, pretty_form_ascii(quantity), " ")
end

println(io)
Expand Down Expand Up @@ -322,9 +322,9 @@ function (analysis_callback::AnalysisCallback)(u_ode, du_ode, integrator, semi)
if mpi_isroot() && analysis_callback.save_analysis
io = open(joinpath(analysis_callback.output_directory,
analysis_callback.analysis_filename), "a")
@printf(io, "% 9d", iter)
@printf(io, " %10.8e", t)
@printf(io, " %10.8e", dt)
print(io, iter)
print(io, " ", t)
print(io, " ", dt)
else
io = devnull
end
Expand Down Expand Up @@ -393,7 +393,7 @@ function (analysis_callback::AnalysisCallback)(io, du, u, u_ode, t, semi)
print(" L2 error: ")
for v in eachvariable(equations)
@printf(" % 10.8e", l2_error[v])
@printf(io, " % 10.8e", l2_error[v])
print(io, " ", l2_error[v])
end
println()
end
Expand All @@ -403,7 +403,7 @@ function (analysis_callback::AnalysisCallback)(io, du, u, u_ode, t, semi)
print(" Linf error: ")
for v in eachvariable(equations)
@printf(" % 10.8e", linf_error[v])
@printf(io, " % 10.8e", linf_error[v])
print(io, " ", linf_error[v])
end
println()
end
Expand All @@ -420,7 +420,7 @@ function (analysis_callback::AnalysisCallback)(io, du, u, u_ode, t, semi)
for v in eachvariable(equations)
err = abs(state_integrals[v] - initial_state_integrals[v])
@printf(" % 10.8e", err)
@printf(io, " % 10.8e", err)
print(io, " ", err)
end
println()
end
Expand All @@ -442,7 +442,7 @@ function (analysis_callback::AnalysisCallback)(io, du, u, u_ode, t, semi)
end
if mpi_isroot()
@printf(" % 10.8e", res)
@printf(io, " % 10.8e", res)
print(io, " ", res)
end
end
mpi_println()
Expand All @@ -466,7 +466,7 @@ function (analysis_callback::AnalysisCallback)(io, du, u, u_ode, t, semi)
print(" L2 error prim.: ")
for v in eachvariable(equations)
@printf("%10.8e ", l2_error_prim[v])
@printf(io, " % 10.8e", l2_error_prim[v])
print(io, " ", l2_error_prim[v])
end
println()
end
Expand All @@ -476,7 +476,7 @@ function (analysis_callback::AnalysisCallback)(io, du, u, u_ode, t, semi)
print(" Linf error pri.:")
for v in eachvariable(equations)
@printf("%10.8e ", linf_error_prim[v])
@printf(io, " % 10.8e", linf_error_prim[v])
print(io, " ", linf_error_prim[v])
end
println()
end
Expand Down Expand Up @@ -581,7 +581,7 @@ function analyze_integrals(analysis_integrals::NTuple{N, Any}, io, du, u, t,
if mpi_isroot()
@printf(" %-12s:", pretty_form_utf(quantity))
@printf(" % 10.8e", res)
@printf(io, " % 10.8e", res)
print(io, " ", res)
end
mpi_println()

Expand Down
Loading