From 5c1603ea2fe87b8fd2ea61ca0bafa220a3efccab Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Sat, 14 Sep 2024 01:13:44 +0200 Subject: [PATCH] Replace "std::endl" with "\n" (except for error messages) (#5183) * replace std::endl with \n * revert to std::endl when flushing the buffer seems intentional * Update Source/Diagnostics/BTDiagnostics.cpp Co-authored-by: Axel Huebl * Update Source/Diagnostics/FlushFormats/FlushFormatCatalyst.cpp Co-authored-by: Axel Huebl * Update Source/Diagnostics/ReducedDiags/ChargeOnEB.cpp Co-authored-by: Axel Huebl * Update Source/Diagnostics/ReducedDiags/ChargeOnEB.cpp Co-authored-by: Axel Huebl * Update Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.cpp Co-authored-by: Axel Huebl * Update Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp Co-authored-by: Axel Huebl * Update Source/Particles/PhysicalParticleContainer.cpp Co-authored-by: Axel Huebl * Update Tools/QedTablesUtils/Source/ArgParser/QedTablesArgParser.cpp Co-authored-by: Axel Huebl * Update Tools/QedTablesUtils/Source/QedTableGenerator.cpp Co-authored-by: Axel Huebl * Update Tools/QedTablesUtils/Source/QedTableReader.cpp Co-authored-by: Axel Huebl --------- Co-authored-by: Axel Huebl --- Source/Diagnostics/BTDiagnostics.cpp | 6 ++-- .../FlushFormats/FlushFormatCatalyst.cpp | 2 +- .../Diagnostics/ReducedDiags/BeamRelevant.cpp | 6 ++-- .../Diagnostics/ReducedDiags/ChargeOnEB.cpp | 3 +- .../ReducedDiags/ColliderRelevant.cpp | 2 +- .../ReducedDiags/DifferentialLuminosity.cpp | 2 +- .../Diagnostics/ReducedDiags/FieldEnergy.cpp | 2 +- .../Diagnostics/ReducedDiags/FieldMaximum.cpp | 2 +- .../ReducedDiags/FieldMomentum.cpp | 2 +- .../Diagnostics/ReducedDiags/FieldProbe.cpp | 4 +-- .../ReducedDiags/FieldReduction.cpp | 2 +- .../ReducedDiags/LoadBalanceCosts.cpp | 6 ++-- .../ReducedDiags/LoadBalanceEfficiency.cpp | 2 +- .../ReducedDiags/ParticleEnergy.cpp | 2 +- .../ReducedDiags/ParticleExtrema.cpp | 2 +- .../ReducedDiags/ParticleHistogram.cpp | 2 +- .../ReducedDiags/ParticleMomentum.cpp | 2 +- .../ReducedDiags/ParticleNumber.cpp | 2 +- .../Diagnostics/ReducedDiags/ReducedDiags.cpp | 2 +- .../Diagnostics/ReducedDiags/RhoMaximum.cpp | 2 +- Source/Diagnostics/WarpXOpenPMD.cpp | 2 +- .../ImplicitSolvers/SemiImplicitEM.cpp | 19 ++++++------- .../ImplicitSolvers/ThetaImplicitEM.cpp | 21 +++++++------- Source/Initialization/WarpXInitData.cpp | 2 +- Source/NonlinearSolvers/NewtonSolver.H | 28 +++++++++---------- Source/NonlinearSolvers/PicardSolver.H | 14 +++++----- .../Particles/PhysicalParticleContainer.cpp | 6 ++-- .../Source/ArgParser/QedTablesArgParser.cpp | 4 +-- Tools/QedTablesUtils/Source/QedTableCommons.H | 2 +- .../Source/QedTableGenerator.cpp | 2 +- .../QedTablesUtils/Source/QedTableReader.cpp | 2 +- 31 files changed, 77 insertions(+), 80 deletions(-) diff --git a/Source/Diagnostics/BTDiagnostics.cpp b/Source/Diagnostics/BTDiagnostics.cpp index 1cee9909226..6fdb605f8dc 100644 --- a/Source/Diagnostics/BTDiagnostics.cpp +++ b/Source/Diagnostics/BTDiagnostics.cpp @@ -170,18 +170,18 @@ void BTDiagnostics::DerivedInitData () if (final_snapshot_fill_iteration > warpx.maxStep()) { warpx.updateMaxStep(final_snapshot_fill_iteration); amrex::Print()<<"max_step insufficient to fill all BTD snapshots. Automatically increased to: " - << final_snapshot_fill_iteration << std::endl; + << final_snapshot_fill_iteration << "\n"; } if (final_snapshot_fill_time > warpx.stopTime()) { warpx.updateStopTime(final_snapshot_fill_time); amrex::Print()<<"stop_time insufficient to fill all BTD snapshots. Automatically increased to: " - << final_snapshot_fill_time << std::endl; + << final_snapshot_fill_time << "\n"; } if (warpx.maxStep() == std::numeric_limits::max() && warpx.stopTime() == std::numeric_limits::max()) { amrex::Print()<<"max_step unspecified and stop time unspecified. Setting max step to " - <Verbose()) { return; } - amrex::Print() << std::endl; - amrex::Print() << "-----------------------------------------------------------" << std::endl; - amrex::Print() << "----------- SEMI IMPLICIT EM SOLVER PARAMETERS ------------" << std::endl; - amrex::Print() << "-----------------------------------------------------------" << std::endl; - amrex::Print() << "max particle iterations: " << m_max_particle_iterations << std::endl; - amrex::Print() << "particle tolerance: " << m_particle_tolerance << std::endl; + amrex::Print() << "\n"; + amrex::Print() << "-----------------------------------------------------------\n"; + amrex::Print() << "----------- SEMI IMPLICIT EM SOLVER PARAMETERS ------------\n"; + amrex::Print() << "-----------------------------------------------------------\n"; + amrex::Print() << "max particle iterations: " << m_max_particle_iterations << "\n"; + amrex::Print() << "particle tolerance: " << m_particle_tolerance << "\n"; if (m_nlsolver_type==NonlinearSolverType::Picard) { - amrex::Print() << "Nonlinear solver type: Picard" << std::endl; + amrex::Print() << "Nonlinear solver type: Picard\n"; } else if (m_nlsolver_type==NonlinearSolverType::Newton) { - amrex::Print() << "Nonlinear solver type: Newton" << std::endl; + amrex::Print() << "Nonlinear solver type: Newton\n"; } m_nlsolver->PrintParams(); - amrex::Print() << "-----------------------------------------------------------" << std::endl; - amrex::Print() << std::endl; + amrex::Print() << "-----------------------------------------------------------\n\n"; } void SemiImplicitEM::OneStep ( amrex::Real a_time, diff --git a/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp b/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp index 4c86389797f..3d74ddfde69 100644 --- a/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp +++ b/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp @@ -56,22 +56,21 @@ void ThetaImplicitEM::Define ( WarpX* const a_WarpX ) void ThetaImplicitEM::PrintParameters () const { if (!m_WarpX->Verbose()) { return; } - amrex::Print() << std::endl; - amrex::Print() << "-----------------------------------------------------------" << std::endl; - amrex::Print() << "----------- THETA IMPLICIT EM SOLVER PARAMETERS -----------" << std::endl; - amrex::Print() << "-----------------------------------------------------------" << std::endl; - amrex::Print() << "Time-bias parameter theta: " << m_theta << std::endl; - amrex::Print() << "max particle iterations: " << m_max_particle_iterations << std::endl; - amrex::Print() << "particle tolerance: " << m_particle_tolerance << std::endl; + amrex::Print() << "\n"; + amrex::Print() << "-----------------------------------------------------------\n"; + amrex::Print() << "----------- THETA IMPLICIT EM SOLVER PARAMETERS -----------\n"; + amrex::Print() << "-----------------------------------------------------------\n"; + amrex::Print() << "Time-bias parameter theta: " << m_theta << "\n"; + amrex::Print() << "max particle iterations: " << m_max_particle_iterations << "\n"; + amrex::Print() << "particle tolerance: " << m_particle_tolerance << "\n"; if (m_nlsolver_type==NonlinearSolverType::Picard) { - amrex::Print() << "Nonlinear solver type: Picard" << std::endl; + amrex::Print() << "Nonlinear solver type: Picard\n"; } else if (m_nlsolver_type==NonlinearSolverType::Newton) { - amrex::Print() << "Nonlinear solver type: Newton" << std::endl; + amrex::Print() << "Nonlinear solver type: Newton\n"; } m_nlsolver->PrintParams(); - amrex::Print() << "-----------------------------------------------------------" << std::endl; - amrex::Print() << std::endl; + amrex::Print() << "-----------------------------------------------------------\n\n"; } void ThetaImplicitEM::OneStep ( const amrex::Real a_time, diff --git a/Source/Initialization/WarpXInitData.cpp b/Source/Initialization/WarpXInitData.cpp index de763831d98..49b0d439c50 100644 --- a/Source/Initialization/WarpXInitData.cpp +++ b/Source/Initialization/WarpXInitData.cpp @@ -830,7 +830,7 @@ WarpX::computeMaxStepBoostAccelerator() { static_cast(interaction_time_boost/dt[maxLevel()]); max_step = computed_max_step; Print()<<"max_step computed in computeMaxStepBoostAccelerator: " - <m_verbose?"true":"false") << std::endl; - amrex::Print() << "Newton max iterations: " << m_maxits << std::endl; - amrex::Print() << "Newton relative tolerance: " << m_rtol << std::endl; - amrex::Print() << "Newton absolute tolerance: " << m_atol << std::endl; - amrex::Print() << "Newton require convergence: " << (m_require_convergence?"true":"false") << std::endl; - amrex::Print() << "GMRES verbose: " << m_gmres_verbose_int << std::endl; - amrex::Print() << "GMRES restart length: " << m_gmres_restart_length << std::endl; - amrex::Print() << "GMRES max iterations: " << m_gmres_maxits << std::endl; - amrex::Print() << "GMRES relative tolerance: " << m_gmres_rtol << std::endl; - amrex::Print() << "GMRES absolute tolerance: " << m_gmres_atol << std::endl; + amrex::Print() << "Newton verbose: " << (this->m_verbose?"true":"false") << "\n"; + amrex::Print() << "Newton max iterations: " << m_maxits << "\n"; + amrex::Print() << "Newton relative tolerance: " << m_rtol << "\n"; + amrex::Print() << "Newton absolute tolerance: " << m_atol << "\n"; + amrex::Print() << "Newton require convergence: " << (m_require_convergence?"true":"false") << "\n"; + amrex::Print() << "GMRES verbose: " << m_gmres_verbose_int << "\n"; + amrex::Print() << "GMRES restart length: " << m_gmres_restart_length << "\n"; + amrex::Print() << "GMRES max iterations: " << m_gmres_maxits << "\n"; + amrex::Print() << "GMRES relative tolerance: " << m_gmres_rtol << "\n"; + amrex::Print() << "GMRES absolute tolerance: " << m_gmres_atol << "\n"; } private: @@ -261,19 +261,19 @@ void NewtonSolver::Solve ( Vec& a_U, if (norm_abs < m_rtol) { amrex::Print() << "Newton: exiting at iteration = " << std::setw(3) << iter - << ". Satisfied absolute tolerance " << m_atol << std::endl; + << ". Satisfied absolute tolerance " << m_atol << "\n"; break; } if (norm_rel < m_rtol) { amrex::Print() << "Newton: exiting at iteration = " << std::setw(3) << iter - << ". Satisfied relative tolerance " << m_rtol << std::endl; + << ". Satisfied relative tolerance " << m_rtol << "\n"; break; } if (norm_abs > 100._rt*norm0) { amrex::Print() << "Newton: exiting at iteration = " << std::setw(3) << iter - << ". SOLVER DIVERGED! relative tolerance = " << m_rtol << std::endl; + << ". SOLVER DIVERGED! relative tolerance = " << m_rtol << "\n"; std::stringstream convergenceMsg; convergenceMsg << "Newton: exiting at iteration " << std::setw(3) << iter << ". SOLVER DIVERGED! absolute norm = " << norm_abs << @@ -291,7 +291,7 @@ void NewtonSolver::Solve ( Vec& a_U, iter++; if (iter >= m_maxits) { amrex::Print() << "Newton: exiting at iter = " << std::setw(3) << iter - << ". Maximum iteration reached: iter = " << m_maxits << std::endl; + << ". Maximum iteration reached: iter = " << m_maxits << "\n"; break; } diff --git a/Source/NonlinearSolvers/PicardSolver.H b/Source/NonlinearSolvers/PicardSolver.H index f05b9a106e6..4eed4d6c2e0 100644 --- a/Source/NonlinearSolvers/PicardSolver.H +++ b/Source/NonlinearSolvers/PicardSolver.H @@ -55,10 +55,10 @@ public: void PrintParams () const override { - amrex::Print() << "Picard max iterations: " << m_maxits << std::endl; - amrex::Print() << "Picard relative tolerance: " << m_rtol << std::endl; - amrex::Print() << "Picard absolute tolerance: " << m_atol << std::endl; - amrex::Print() << "Picard require convergence: " << (m_require_convergence?"true":"false") << std::endl; + amrex::Print() << "Picard max iterations: " << m_maxits << "\n"; + amrex::Print() << "Picard relative tolerance: " << m_rtol << "\n"; + amrex::Print() << "Picard absolute tolerance: " << m_atol << "\n"; + amrex::Print() << "Picard require convergence: " << (m_require_convergence?"true":"false") << "\n"; } private: @@ -179,19 +179,19 @@ void PicardSolver::Solve ( Vec& a_U, if (norm_abs < m_atol) { amrex::Print() << "Picard: exiting at iter = " << std::setw(3) << iter - << ". Satisfied absolute tolerance " << m_atol << std::endl; + << ". Satisfied absolute tolerance " << m_atol << "\n"; break; } if (norm_rel < m_rtol) { amrex::Print() << "Picard: exiting at iter = " << std::setw(3) << iter - << ". Satisfied relative tolerance " << m_rtol << std::endl; + << ". Satisfied relative tolerance " << m_rtol << "\n"; break; } if (iter >= m_maxits) { amrex::Print() << "Picard: exiting at iter = " << std::setw(3) << iter - << ". Maximum iteration reached: iter = " << m_maxits << std::endl; + << ". Maximum iteration reached: iter = " << m_maxits << "\n"; break; } diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index d1a19f06993..0617b36a273 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -2976,10 +2976,10 @@ PhysicalParticleContainer::ImplicitPushXP (WarpXParIter& pti, #if !defined(AMREX_USE_GPU) std::stringstream convergenceMsg; convergenceMsg << "Picard solver for particle failed to converge after " << - iter << " iterations. " << std::endl; + iter << " iterations.\n"; convergenceMsg << "Position step norm is " << step_norm << - " and the tolerance is " << particle_tolerance << std::endl; - convergenceMsg << " ux = " << ux[ip] << ", uy = " << uy[ip] << ", uz = " << uz[ip] << std::endl; + " and the tolerance is " << particle_tolerance << "\n"; + convergenceMsg << " ux = " << ux[ip] << ", uy = " << uy[ip] << ", uz = " << uz[ip] << "\n"; convergenceMsg << " xp = " << xp << ", yp = " << yp << ", zp = " << zp; ablastr::warn_manager::WMRecordWarning("ImplicitPushXP", convergenceMsg.str()); #endif diff --git a/Tools/QedTablesUtils/Source/ArgParser/QedTablesArgParser.cpp b/Tools/QedTablesUtils/Source/ArgParser/QedTablesArgParser.cpp index 41d27477dcf..a92f191037d 100644 --- a/Tools/QedTablesUtils/Source/ArgParser/QedTablesArgParser.cpp +++ b/Tools/QedTablesUtils/Source/ArgParser/QedTablesArgParser.cpp @@ -85,7 +85,7 @@ ArgParser::ParseArgs (const std::vector& keys, const int argc, char const* void ArgParser::PrintHelp (const vector& cmd_list) { - cout << "Command line options: " << endl; + cout << "Command line options:\n"; for (const auto& el : cmd_list){ const auto type = get<1>(el); @@ -102,7 +102,7 @@ ArgParser::PrintHelp (const vector& cmd_list) cout << get<0>(el) << " " << stype << " " << get<2>(el) - << endl; + << "\n"; } } diff --git a/Tools/QedTablesUtils/Source/QedTableCommons.H b/Tools/QedTablesUtils/Source/QedTableCommons.H index 40551b9e13c..2233513bc97 100644 --- a/Tools/QedTablesUtils/Source/QedTableCommons.H +++ b/Tools/QedTablesUtils/Source/QedTableCommons.H @@ -19,7 +19,7 @@ void AbortWithMessage(const std::string& msg) void SuccessExit() { - std::cout << "___________________________" << std::endl; + std::cout << "___________________________\n"; exit(0); } diff --git a/Tools/QedTablesUtils/Source/QedTableGenerator.cpp b/Tools/QedTablesUtils/Source/QedTableGenerator.cpp index 1ea62b5c6ed..7bfa5787ec8 100644 --- a/Tools/QedTablesUtils/Source/QedTableGenerator.cpp +++ b/Tools/QedTablesUtils/Source/QedTableGenerator.cpp @@ -49,7 +49,7 @@ void GenerateTableQS (const ParsedArgs& args, const string& outfile_name); int main (int argc, char** argv) { - cout << "### QED Table Generator ###" << endl; + cout << "### QED Table Generator ###\n"; const auto args_map = ParseArgs(line_commands, argc, argv); if (args_map.empty() || Contains(args_map, "-h")){ diff --git a/Tools/QedTablesUtils/Source/QedTableReader.cpp b/Tools/QedTablesUtils/Source/QedTableReader.cpp index ba9d58775f2..27b284f34c2 100644 --- a/Tools/QedTablesUtils/Source/QedTableReader.cpp +++ b/Tools/QedTablesUtils/Source/QedTableReader.cpp @@ -57,7 +57,7 @@ class qs_photon_emission_table_wrapper : int main (int argc, char** argv) { - cout << "### QED Table Reader ###" << endl; + cout << "### QED Table Reader ###\n"; const auto args_map = ParseArgs(line_commands, argc, argv); if (args_map.empty() || Contains(args_map, "-h")){