Skip to content

Commit

Permalink
Replace "std::endl" with "\n" (except for error messages) (#5183)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* Update Source/Diagnostics/FlushFormats/FlushFormatCatalyst.cpp

Co-authored-by: Axel Huebl <[email protected]>

* Update Source/Diagnostics/ReducedDiags/ChargeOnEB.cpp

Co-authored-by: Axel Huebl <[email protected]>

* Update Source/Diagnostics/ReducedDiags/ChargeOnEB.cpp

Co-authored-by: Axel Huebl <[email protected]>

* Update Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.cpp

Co-authored-by: Axel Huebl <[email protected]>

* Update Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp

Co-authored-by: Axel Huebl <[email protected]>

* Update Source/Particles/PhysicalParticleContainer.cpp

Co-authored-by: Axel Huebl <[email protected]>

* Update Tools/QedTablesUtils/Source/ArgParser/QedTablesArgParser.cpp

Co-authored-by: Axel Huebl <[email protected]>

* Update Tools/QedTablesUtils/Source/QedTableGenerator.cpp

Co-authored-by: Axel Huebl <[email protected]>

* Update Tools/QedTablesUtils/Source/QedTableReader.cpp

Co-authored-by: Axel Huebl <[email protected]>

---------

Co-authored-by: Axel Huebl <[email protected]>
  • Loading branch information
lucafedeli88 and ax3l committed Sep 13, 2024
1 parent 3974fac commit 5c1603e
Show file tree
Hide file tree
Showing 31 changed files with 77 additions and 80 deletions.
6 changes: 3 additions & 3 deletions Source/Diagnostics/BTDiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>::max() && warpx.stopTime() == std::numeric_limits<amrex::Real>::max()) {
amrex::Print()<<"max_step unspecified and stop time unspecified. Setting max step to "
<<final_snapshot_fill_iteration<< " to fill all BTD snapshots." << std::endl;
<<final_snapshot_fill_iteration<< " to fill all BTD snapshots.\n";
warpx.updateMaxStep(final_snapshot_fill_iteration);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/FlushFormats/FlushFormatCatalyst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ FlushFormatCatalyst::~FlushFormatCatalyst() {
amrex::Abort(message);
} else {
// Temporary, remove for final
std::cout << "Successfully finalized Catalyst" << std::endl;
std::cout << "Successfully finalized Catalyst\n";
}

}
Expand Down
6 changes: 3 additions & 3 deletions Source/Diagnostics/ReducedDiags/BeamRelevant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ BeamRelevant::BeamRelevant (const std::string& rd_name)
ofs << "[" << c++ << "]alpha_y()"; ofs << m_sep;
ofs << "[" << c++ << "]beta_x(m)"; ofs << m_sep;
ofs << "[" << c++ << "]beta_y(m)"; ofs << m_sep;
ofs << "[" << c++ << "]charge(C)"; ofs << std::endl;
ofs << "[" << c++ << "]charge(C)"; ofs << "\n";
#elif (defined WARPX_DIM_XZ)
int c = 0;
ofs << "#";
Expand All @@ -131,7 +131,7 @@ BeamRelevant::BeamRelevant (const std::string& rd_name)
ofs << "[" << c++ << "]emittance_z(m)"; ofs << m_sep;
ofs << "[" << c++ << "]alpha_x()"; ofs << m_sep;
ofs << "[" << c++ << "]beta_x(m)"; ofs << m_sep;
ofs << "[" << c++ << "]charge(C)"; ofs << std::endl;
ofs << "[" << c++ << "]charge(C)"; ofs << "\n";
#elif (defined WARPX_DIM_1D_Z)
int c = 0;
ofs << "#";
Expand All @@ -148,7 +148,7 @@ BeamRelevant::BeamRelevant (const std::string& rd_name)
ofs << "[" << c++ << "]pz_rms(kg*m/s)"; ofs << m_sep;
ofs << "[" << c++ << "]gamma_rms()"; ofs << m_sep;
ofs << "[" << c++ << "]emittance_z(m)"; ofs << m_sep;
ofs << "[" << c++ << "]charge(C)"; ofs << std::endl;
ofs << "[" << c++ << "]charge(C)"; ofs << "\n";
#endif
// close file
ofs.close();
Expand Down
3 changes: 1 addition & 2 deletions Source/Diagnostics/ReducedDiags/ChargeOnEB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ ChargeOnEB::ChargeOnEB (const std::string& rd_name)
ofs << m_sep;
ofs << "[" << c++ << "]time(s)";
ofs << m_sep;
ofs << "[" << c++ << "]Charge (C)";
ofs << std::endl;
ofs << "[" << c++ << "]Charge (C)\n";
// close file
ofs.close();
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/ColliderRelevant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ ColliderRelevant::ColliderRelevant (const std::string& rd_name)
const auto& el = m_headers_indices[name];
ofs << m_sep << "[" << el.idx + off << "]" << el.header;
}
ofs << std::endl;
ofs << "\n";
// close file
ofs.close();
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/DifferentialLuminosity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ DifferentialLuminosity::DifferentialLuminosity (const std::string& rd_name)
const Real b = m_bin_min + m_bin_size*(Real(i)+0.5_rt);
ofs << "bin" << 1+i << "=" << b << "(eV)";
}
ofs << std::endl;
ofs << "\n";
// close file
ofs.close();
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/FieldEnergy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ FieldEnergy::FieldEnergy (const std::string& rd_name)
ofs << m_sep;
ofs << "[" << c++ << "]B_lev" + std::to_string(lev) + "(J)";
}
ofs << std::endl;
ofs << "\n";
// close file
ofs.close();
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/FieldMaximum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ FieldMaximum::FieldMaximum (const std::string& rd_name)
ofs << m_sep;
ofs << "[" << c++ << "]max_|B|_lev" + std::to_string(lev) + "(T)";
}
ofs << std::endl;
ofs << "\n";
// close file
ofs.close();
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/FieldMomentum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ FieldMomentum::FieldMomentum (const std::string& rd_name)
ofs << "momentum_z_lev" << lev << "(kg*m/s)";
}

ofs << std::endl;
ofs << "\n";
ofs.close();
}
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ FieldProbe::FieldProbe (const std::string& rd_name)
ofs << m_sep;
ofs << "[" << c++ << "]part_S_lev" + std::to_string(lev) + u_map[FieldProbePIdx::S];
}
ofs << std::endl;
ofs << "\n";

// close file
ofs.close();
Expand Down Expand Up @@ -678,7 +678,7 @@ void FieldProbe::WriteToFile (int step) const
ofs << m_sep;
ofs << sorted_data[i * noutputs + k];
}
ofs << std::endl;
ofs << "\n";
} // end loop over data size
// close file
ofs.close();
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/FieldReduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ FieldReduction::FieldReduction (const std::string& rd_name)
ofs << m_sep;
ofs << "[" << c++ << "]" + amrex::getEnumNameString(m_reduction_type) + " of " + parser_string + " (SI units)";

ofs << std::endl;
ofs << "\n";
// close file
ofs.close();
}
Expand Down
6 changes: 3 additions & 3 deletions Source/Diagnostics/ReducedDiags/LoadBalanceCosts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ void LoadBalanceCosts::WriteToFile (int step) const
// end loop over data size

// end line
ofs << std::endl;
ofs << "\n";

// close file
ofs.close();
Expand Down Expand Up @@ -329,7 +329,7 @@ void LoadBalanceCosts::WriteToFile (int step) const
ofstmp << m_sep;
ofstmp << "[" << c++ << "]hostname_box_" + std::to_string(boxNumber) + "()";
}
ofstmp << std::endl;
ofstmp << "\n";

// open the data-containing file
const std::string fileDataName = m_path + m_rd_name + "." + m_extension;
Expand Down Expand Up @@ -360,7 +360,7 @@ void LoadBalanceCosts::WriteToFile (int step) const
{
ofstmp << m_sep << "NaN";
}
ofstmp << std::endl;
ofstmp << "\n";
}

// close files
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/LoadBalanceEfficiency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ LoadBalanceEfficiency::LoadBalanceEfficiency (const std::string& rd_name)
ofs << m_sep;
ofs << "[" << c++ << "]lev" + std::to_string(lev);
}
ofs << std::endl;
ofs << "\n";

// close file
ofs.close();
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/ParticleEnergy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ ParticleEnergy::ParticleEnergy (const std::string& rd_name)
ofs << m_sep;
ofs << "[" << c++ << "]" << species_names[i] + "_mean(J)";
}
ofs << std::endl;
ofs << "\n";
// close file
ofs.close();
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/ParticleExtrema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ ParticleExtrema::ParticleExtrema (const std::string& rd_name)
const auto& el = m_headers_indices[name];
ofs << m_sep << "[" << el.idx + off << "]" << el.header;
}
ofs << std::endl;
ofs << "\n";
// close file
ofs.close();
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/ParticleHistogram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ ParticleHistogram::ParticleHistogram (const std::string& rd_name)
ofs << "bin" + std::to_string(1+i)
+ "=" + std::to_string(b) + "()";
}
ofs << std::endl;
ofs << "\n";
// close file
ofs.close();
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/ParticleMomentum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ ParticleMomentum::ParticleMomentum (const std::string& rd_name)
ofs << species_names[i] + "_mean_z(kg*m/s)";
}

ofs << std::endl;
ofs << "\n";
ofs.close();
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/ParticleNumber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ ParticleNumber::ParticleNumber (const std::string& rd_name)
ofs << m_sep;
ofs << "[" << c++ << "]" << species_names[i] + "_weight()";
}
ofs << std::endl;
ofs << "\n";
// close file
ofs.close();
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/ReducedDiags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void ReducedDiags::WriteToFile (int step) const
// end loop over data size

// end line
ofs << std::endl;
ofs << "\n";

// close file
ofs.close();
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/RhoMaximum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ RhoMaximum::RhoMaximum (const std::string& rd_name)
+ "_|rho|_lev" + std::to_string(lev) + "(C/m^3)";
}
}
ofs << std::endl;
ofs << "\n";
// close file
ofs.close();
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/WarpXOpenPMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ void WarpXOpenPMDPlot::CloseStep (bool isBTD, bool isLastBTDFlush)
std::string const filename = GetFileName(filepath);

std::ofstream pv_helper_file(m_dirPrefix + "/paraview.pmd");
pv_helper_file << filename << std::endl;
pv_helper_file << filename << "\n";
pv_helper_file.close();
}
}
Expand Down
19 changes: 9 additions & 10 deletions Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,20 @@ void SemiImplicitEM::Define ( WarpX* a_WarpX )
void SemiImplicitEM::PrintParameters () const
{
if (!m_WarpX->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,
Expand Down
21 changes: 10 additions & 11 deletions Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion Source/Initialization/WarpXInitData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ WarpX::computeMaxStepBoostAccelerator() {
static_cast<int>(interaction_time_boost/dt[maxLevel()]);
max_step = computed_max_step;
Print()<<"max_step computed in computeMaxStepBoostAccelerator: "
<<max_step<<std::endl;
<<max_step<<"\n";
}

void
Expand Down
28 changes: 14 additions & 14 deletions Source/NonlinearSolvers/NewtonSolver.H
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ public:

void PrintParams () const override
{
amrex::Print() << "Newton verbose: " << (this->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:
Expand Down Expand Up @@ -261,19 +261,19 @@ void NewtonSolver<Vec,Ops>::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 <<
Expand All @@ -291,7 +291,7 @@ void NewtonSolver<Vec,Ops>::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;
}

Expand Down
Loading

0 comments on commit 5c1603e

Please sign in to comment.