aboutsummaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/Diagnostics/ReducedDiags/FieldReduction.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/Source/Diagnostics/ReducedDiags/FieldReduction.cpp b/Source/Diagnostics/ReducedDiags/FieldReduction.cpp
index 3259e1ca8..4fc6eac67 100644
--- a/Source/Diagnostics/ReducedDiags/FieldReduction.cpp
+++ b/Source/Diagnostics/ReducedDiags/FieldReduction.cpp
@@ -9,6 +9,8 @@
#include "WarpX.H"
#include "Utils/WarpXAlgorithmSelection.H"
+#include <regex>
+
// constructor
FieldReduction::FieldReduction (std::string rd_name)
: ReducedDiags{rd_name}
@@ -41,6 +43,10 @@ FieldReduction::FieldReduction (std::string rd_name)
m_parser = std::make_unique<ParserWrapper<m_nvars>>(
makeParser(parser_string,{"x","y","z","Ex","Ey","Ez","Bx","By","Bz"}));
+ // Replace all newlines and possible following whitespaces with a single whitespace. This
+ // should avoid weird formatting when the string is written in the header of the output file.
+ parser_string = std::regex_replace(parser_string, std::regex("\n\\s*"), " ");
+
// read reduction type
std::string reduction_type_string;
pp_rd_name.get("reduction_type", reduction_type_string);