Skip to content

Commit

Permalink
Text-Based Diagnostics: Increase Precision (#442)
Browse files Browse the repository at this point in the history
Converting to ASCII comes with precision loss, but at least we can
keep printing the significant digits we are provided with by our
`ParticleReal` data.
  • Loading branch information
ax3l authored Oct 19, 2023
1 parent 243f219 commit c1e691a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/particles/diagnostics/DiagnosticOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <AMReX_REAL.H> // for ParticleReal
#include <AMReX_Print.H> // for PrintToFile

#include <limits>
#include <utility>


Expand All @@ -36,6 +37,7 @@ namespace impactx::diagnostics

// keep file open as we add more and more lines
amrex::AllPrintToFile file_handler(std::move(file_name));
file_handler.SetPrecision(std::numeric_limits<amrex::ParticleReal>::max_digits10);

// write file header per MPI RANK
if (!append) {
Expand Down Expand Up @@ -75,6 +77,7 @@ namespace impactx::diagnostics
} // if( otype == OutputType::PrintReducedBeamCharacteristics)

// create a host-side particle buffer
// todo: NOT needed for OutputType::PrintRefParticle and OutputType::PrintReducedBeamCharacteristics
auto tmp = pc.make_alike<amrex::PinnedArenaAllocator>();

// copy device-to-host
Expand Down

0 comments on commit c1e691a

Please sign in to comment.