From e9f20ef085715472ad03c6ac1605b7a4fd265aab Mon Sep 17 00:00:00 2001 From: AlexanderSinn Date: Tue, 21 May 2024 17:14:39 +0200 Subject: [PATCH] Fix openPMD crash if beam has no particles --- src/diagnostics/OpenPMDWriter.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/diagnostics/OpenPMDWriter.cpp b/src/diagnostics/OpenPMDWriter.cpp index 4f91f039d8..71c052aad7 100644 --- a/src/diagnostics/OpenPMDWriter.cpp +++ b/src/diagnostics/OpenPMDWriter.cpp @@ -245,6 +245,12 @@ OpenPMDWriter::WriteBeamParticleData (MultiBeam& beams, openPMD::Iteration itera SetupPos(beam_species, beam, np_total, geom); SetupRealProperties(beam_species, real_names, np_total); + if (np_total == 0) { + amrex::ErrorStream() << "WARNING: Beam '" << name + << "' has no particles! No output will be written.\n"; + continue; + } + for (std::size_t idx=0; idx