From 02096d079680a2f7125db230bcde872dde63732c Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Wed, 20 Oct 2021 21:02:22 +0200 Subject: ⚠️ Add warning logger (#2113) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * improve error msg * eliminate final dot * initial layout of the main classes * progress * progress with warnings * print local errors * progress with warning logger * improved MsgLogger * added file to test warnings * added method to read debug warnings from inputfile * progress towards collective gather of warnings * add missing blank line in warning message * move misplaced file * refactoring * fixed bugs * progress * fixed bugs * fixed some bugs * it finally works! * add comments in WarpX.H * add missing comment * added comments to WarpX.cpp * add profiler to WarpX.cpp * expose option to enable 'warn immediately' feature in cmake * Add comment to main.cpp * add missing comment in WarpX.cpp * add copyright and include guards to WarnManager_fwd.H * cleaning and added comments to WarnManager.H * updated test * added fwd file for MsgLogger * cleaning * Added copyright in WarnManager.cpp * Cleaning * cleaning * Add missing copyright * cleaning * clean and add comments to MsgLoggerSerialization.H * cleaning MsgLogger_fwd.H * cleaning * continue cleaning MsgLogger * added comments & bugfixing * removed test file * fixed bugs * Update Source/Utils/MsgLogger/MsgLogger.H Co-authored-by: Neïl Zaim <49716072+NeilZaim@users.noreply.github.com> * Update Source/WarpX.H Co-authored-by: Neïl Zaim <49716072+NeilZaim@users.noreply.github.com> * Update Source/Utils/MsgLogger/MsgLogger.H Co-authored-by: Neïl Zaim <49716072+NeilZaim@users.noreply.github.com> * Update Source/Utils/MsgLogger/MsgLogger.H Co-authored-by: Neïl Zaim <49716072+NeilZaim@users.noreply.github.com> * Update Source/Utils/MsgLogger/MsgLogger.cpp Co-authored-by: Neïl Zaim <49716072+NeilZaim@users.noreply.github.com> * Update Source/Utils/MsgLogger/MsgLoggerSerialization.H Co-authored-by: Neïl Zaim <49716072+NeilZaim@users.noreply.github.com> * Update Source/Utils/MsgLogger/MsgLoggerSerialization.H Co-authored-by: Neïl Zaim <49716072+NeilZaim@users.noreply.github.com> * Update Source/Utils/MsgLogger/MsgLoggerSerialization.H Co-authored-by: Neïl Zaim <49716072+NeilZaim@users.noreply.github.com> * Update Source/Utils/MsgLogger/MsgLoggerSerialization.H Co-authored-by: Neïl Zaim <49716072+NeilZaim@users.noreply.github.com> * Update Source/Utils/MsgLogger/MsgLoggerSerialization.H Co-authored-by: Neïl Zaim <49716072+NeilZaim@users.noreply.github.com> * Update Source/Utils/WarnManager.cpp Co-authored-by: Neïl Zaim <49716072+NeilZaim@users.noreply.github.com> * Update Source/Utils/WarnManager.H Co-authored-by: Neïl Zaim <49716072+NeilZaim@users.noreply.github.com> * Update Source/Utils/WarnManager.H Co-authored-by: Neïl Zaim <49716072+NeilZaim@users.noreply.github.com> * Update Source/Utils/WarnManager.cpp Co-authored-by: Neïl Zaim <49716072+NeilZaim@users.noreply.github.com> * fixed bugs * Update Source/Utils/MsgLogger/MsgLogger.cpp Co-authored-by: Neïl Zaim <49716072+NeilZaim@users.noreply.github.com> * Added comment to explain rotation * use last value computed by partial_sum * fix bug * now use error stream * using anonymous namespace for helper functions * print on both stderr and stdout * now using runtime parameter to always print warnings * added documentation * using long int for counter * sort affected warnings list * add doc entry * removed doc * added documentation * fixed bug * fixed bug * removing unnecessary text * reformatting * reformatting * fixed bug * fixed bug * correction * add warning_logger.rst to toctree in developers.rst Co-authored-by: Neïl Zaim <49716072+NeilZaim@users.noreply.github.com> --- .../MacroscopicProperties/MacroscopicProperties.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp') diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp index 7166eb99d..577fe9de7 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp @@ -19,6 +19,7 @@ #include #include +#include using namespace amrex; @@ -90,7 +91,11 @@ MacroscopicProperties::ReadParameters () sigma_specified = true; } if (!sigma_specified) { - amrex::Print() << "WARNING: Material conductivity is not specified. Using default vacuum value of " << m_sigma << " in the simulation\n"; + std::stringstream warnMsg; + warnMsg << "Material conductivity is not specified. Using default vacuum value of " << + m_sigma << " in the simulation."; + WarpX::GetInstance().RecordWarning("Macroscopic properties", + warnMsg.str()); } // initialization of sigma (conductivity) with parser if (m_sigma_s == "parse_sigma_function") { @@ -109,7 +114,11 @@ MacroscopicProperties::ReadParameters () epsilon_specified = true; } if (!epsilon_specified) { - amrex::Print() << "WARNING: Material permittivity is not specified. Using default vacuum value of " << m_epsilon << " in the simulation\n"; + std::stringstream warnMsg; + warnMsg << "Material permittivity is not specified. Using default vacuum value of " << + m_epsilon << " in the simulation."; + WarpX::GetInstance().RecordWarning("Macroscopic properties", + warnMsg.str()); } // initialization of epsilon (permittivity) with parser @@ -130,7 +139,11 @@ MacroscopicProperties::ReadParameters () mu_specified = true; } if (!mu_specified) { - amrex::Print() << "WARNING: Material permittivity is not specified. Using default vacuum value of " << m_mu << " in the simulation\n"; + std::stringstream warnMsg; + warnMsg << "Material permittivity is not specified. Using default vacuum value of " << + m_mu << " in the simulation."; + WarpX::GetInstance().RecordWarning("Macroscopic properties", + warnMsg.str()); } // initialization of mu (permeability) with parser -- cgit v1.2.3