diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/WarpX.H | 3 | ||||
-rw-r--r-- | Source/WarpX.cpp | 34 |
2 files changed, 37 insertions, 0 deletions
diff --git a/Source/WarpX.H b/Source/WarpX.H index c78e457c5..aee276162 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -63,6 +63,7 @@ #include <iostream> #include <limits> #include <memory> +#include <optional> #include <string> #include <vector> @@ -1013,6 +1014,8 @@ private: std::unique_ptr<Utils::WarnManager> m_p_warn_manager; // Flag to control if WarpX has to emit a warning message as soon as a warning is recorded bool m_always_warn_immediately = false; + // Threshold to abort immediately on a warning message + std::optional<WarnPriority> m_abort_on_warning_threshold = std::nullopt; amrex::Vector<int> istep; // which step? amrex::Vector<int> nsubsteps; // how many substeps on each level? diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 76b32461f..f50f4dc9f 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -448,6 +448,22 @@ WarpX::RecordWarning( { m_p_warn_manager->record_warning(topic, text, msg_priority); } + + if(m_abort_on_warning_threshold){ + + auto abort_priority = Utils::MsgLogger::Priority::high; + if(m_abort_on_warning_threshold == WarnPriority::low) + abort_priority = Utils::MsgLogger::Priority::low; + else if(m_abort_on_warning_threshold == WarnPriority::medium) + abort_priority = Utils::MsgLogger::Priority::medium; + + if (msg_priority >= abort_priority){ + const auto t_str = "A warning with priority '" + + Utils::MsgLogger::PriorityToString(msg_priority) + + "' has been raised."; + Abort(t_str.c_str()); + } + } } void @@ -496,8 +512,26 @@ WarpX::ReadParameters () //"Synthetic" warning messages may be injected in the Warning Manager via // inputfile for debug&testing purposes. m_p_warn_manager->debug_read_warnings_from_input(pp_warpx); + + // Set the flag to control if WarpX has to emit a warning message as soon as a warning is recorded pp_warpx.query("always_warn_immediately", m_always_warn_immediately); + // Set the WarnPriority threshold to decide if WarpX has to abort when a warning is recorded + if(std::string str_abort_on_warning_threshold = ""; + pp_warpx.query("abort_on_warning_threshold", str_abort_on_warning_threshold)){ + if (str_abort_on_warning_threshold == "high") + m_abort_on_warning_threshold = WarnPriority::high; + else if (str_abort_on_warning_threshold == "medium" ) + m_abort_on_warning_threshold = WarnPriority::medium; + else if (str_abort_on_warning_threshold == "low") + m_abort_on_warning_threshold = WarnPriority::low; + else { + const auto t_str = str_abort_on_warning_threshold + + "is not a valid option for warpx.abort_on_warning_threshold (use: low, medium or high)"; + Abort(t_str.c_str()); + } + } + std::vector<int> numprocs_in; queryArrWithParser(pp_warpx, "numprocs", numprocs_in, 0, AMREX_SPACEDIM); if (not numprocs_in.empty()) { |