Skip to content

Commit 3ed2f3a

Browse files
DanielDoehringranochasloedeJoshuaLampert
authored
Print Analysis in Full Precision to File (#2155)
* Print in Full Precision * Apply suggestions from code review * detect digits automatically * cons with old vrsion * cut down whitespaces * print instead of @printf * Update src/callbacks_step/analysis.jl Co-authored-by: Michael Schlottke-Lakemper <[email protected]> * News entry * Apply suggestions from code review Co-authored-by: Joshua Lampert <[email protected]> * Update NEWS.md * Bring back comment symbol * Update NEWS.md * Update NEWS.md --------- Co-authored-by: Hendrik Ranocha <[email protected]> Co-authored-by: Michael Schlottke-Lakemper <[email protected]> Co-authored-by: Joshua Lampert <[email protected]>
1 parent 9f2a5be commit 3ed2f3a

File tree

2 files changed

+25
-20
lines changed

2 files changed

+25
-20
lines changed

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ for human readability.
1515
[RecursiveArrayTools.jl](https://github.com/SciML/RecursiveArrayTools.jl)
1616
for `DGMulti` solvers ([#2150]). You can use `Base.parent` to unwrap
1717
the original data.
18+
- The `AnalysisCallback` output generated with the `save_analysis = true` option now prints
19+
floating point numbers in their respective (full) precision.
20+
Previously, only the first 8 digits were printed to file.
21+
Furthermore, the names of the printed fields are now only separated by a single white space,
22+
in contrast to before where this were multiple, depending on the actual name of the printed data.
1823

1924
#### Deprecated
2025

src/callbacks_step/analysis.jl

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -163,42 +163,42 @@ function initialize!(cb::DiscreteCallback{Condition, Affect!}, u_ode, du_ode, t,
163163

164164
# write header of output file
165165
open(joinpath(output_directory, analysis_filename), "w") do io
166-
@printf(io, "#%-8s", "timestep")
167-
@printf(io, " %-14s", "time")
168-
@printf(io, " %-14s", "dt")
166+
print(io, "#timestep ")
167+
print(io, "time ")
168+
print(io, "dt ")
169169
if :l2_error in analysis_errors
170170
for v in varnames(cons2cons, equations)
171-
@printf(io, " %-14s", "l2_"*v)
171+
print(io, "l2_" * v * " ")
172172
end
173173
end
174174
if :linf_error in analysis_errors
175175
for v in varnames(cons2cons, equations)
176-
@printf(io, " %-14s", "linf_"*v)
176+
print(io, "linf_" * v * " ")
177177
end
178178
end
179179
if :conservation_error in analysis_errors
180180
for v in varnames(cons2cons, equations)
181-
@printf(io, " %-14s", "cons_"*v)
181+
print(io, "cons_" * v * " ")
182182
end
183183
end
184184
if :residual in analysis_errors
185185
for v in varnames(cons2cons, equations)
186-
@printf(io, " %-14s", "res_"*v)
186+
print(io, "res_" * v * " ")
187187
end
188188
end
189189
if :l2_error_primitive in analysis_errors
190190
for v in varnames(cons2prim, equations)
191-
@printf(io, " %-14s", "l2_"*v)
191+
print(io, "l2_" * v * " ")
192192
end
193193
end
194194
if :linf_error_primitive in analysis_errors
195195
for v in varnames(cons2prim, equations)
196-
@printf(io, " %-14s", "linf_"*v)
196+
print(io, "linf_" * v * " ")
197197
end
198198
end
199199

200200
for quantity in analysis_integrals
201-
@printf(io, " %-14s", pretty_form_ascii(quantity))
201+
print(io, pretty_form_ascii(quantity), " ")
202202
end
203203

204204
println(io)
@@ -322,9 +322,9 @@ function (analysis_callback::AnalysisCallback)(u_ode, du_ode, integrator, semi)
322322
if mpi_isroot() && analysis_callback.save_analysis
323323
io = open(joinpath(analysis_callback.output_directory,
324324
analysis_callback.analysis_filename), "a")
325-
@printf(io, "% 9d", iter)
326-
@printf(io, " %10.8e", t)
327-
@printf(io, " %10.8e", dt)
325+
print(io, iter)
326+
print(io, " ", t)
327+
print(io, " ", dt)
328328
else
329329
io = devnull
330330
end
@@ -393,7 +393,7 @@ function (analysis_callback::AnalysisCallback)(io, du, u, u_ode, t, semi)
393393
print(" L2 error: ")
394394
for v in eachvariable(equations)
395395
@printf(" % 10.8e", l2_error[v])
396-
@printf(io, " % 10.8e", l2_error[v])
396+
print(io, " ", l2_error[v])
397397
end
398398
println()
399399
end
@@ -403,7 +403,7 @@ function (analysis_callback::AnalysisCallback)(io, du, u, u_ode, t, semi)
403403
print(" Linf error: ")
404404
for v in eachvariable(equations)
405405
@printf(" % 10.8e", linf_error[v])
406-
@printf(io, " % 10.8e", linf_error[v])
406+
print(io, " ", linf_error[v])
407407
end
408408
println()
409409
end
@@ -420,7 +420,7 @@ function (analysis_callback::AnalysisCallback)(io, du, u, u_ode, t, semi)
420420
for v in eachvariable(equations)
421421
err = abs(state_integrals[v] - initial_state_integrals[v])
422422
@printf(" % 10.8e", err)
423-
@printf(io, " % 10.8e", err)
423+
print(io, " ", err)
424424
end
425425
println()
426426
end
@@ -442,7 +442,7 @@ function (analysis_callback::AnalysisCallback)(io, du, u, u_ode, t, semi)
442442
end
443443
if mpi_isroot()
444444
@printf(" % 10.8e", res)
445-
@printf(io, " % 10.8e", res)
445+
print(io, " ", res)
446446
end
447447
end
448448
mpi_println()
@@ -466,7 +466,7 @@ function (analysis_callback::AnalysisCallback)(io, du, u, u_ode, t, semi)
466466
print(" L2 error prim.: ")
467467
for v in eachvariable(equations)
468468
@printf("%10.8e ", l2_error_prim[v])
469-
@printf(io, " % 10.8e", l2_error_prim[v])
469+
print(io, " ", l2_error_prim[v])
470470
end
471471
println()
472472
end
@@ -476,7 +476,7 @@ function (analysis_callback::AnalysisCallback)(io, du, u, u_ode, t, semi)
476476
print(" Linf error pri.:")
477477
for v in eachvariable(equations)
478478
@printf("%10.8e ", linf_error_prim[v])
479-
@printf(io, " % 10.8e", linf_error_prim[v])
479+
print(io, " ", linf_error_prim[v])
480480
end
481481
println()
482482
end
@@ -581,7 +581,7 @@ function analyze_integrals(analysis_integrals::NTuple{N, Any}, io, du, u, t,
581581
if mpi_isroot()
582582
@printf(" %-12s:", pretty_form_utf(quantity))
583583
@printf(" % 10.8e", res)
584-
@printf(io, " % 10.8e", res)
584+
print(io, " ", res)
585585
end
586586
mpi_println()
587587

0 commit comments

Comments
 (0)