aboutsummaryrefslogtreecommitdiff
path: root/Source/WarpX.cpp
diff options
context:
space:
mode:
authorGravatar Luca Fedeli <luca.fedeli@cea.fr> 2022-02-01 17:59:01 +0100
committerGravatar GitHub <noreply@github.com> 2022-02-01 08:59:01 -0800
commit3d4c9e84fe1d1a10d4ef29a5a9750b66492f4d65 (patch)
treecd7f48cdfcb746b42bc267a5773495cc574a0480 /Source/WarpX.cpp
parent53f590c804ea39f040bcbecb5ad7bb6ab939e06e (diff)
downloadWarpX-3d4c9e84fe1d1a10d4ef29a5a9750b66492f4d65.tar.gz
WarpX-3d4c9e84fe1d1a10d4ef29a5a9750b66492f4d65.tar.zst
WarpX-3d4c9e84fe1d1a10d4ef29a5a9750b66492f4d65.zip
Add abort on warning threshold (#2751)
* add abort on warning threshold * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add white endline * fix issue with QED tests * Update Source/WarpX.cpp Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja> * removed lines from another branch * increase abort threshold for examples with a ionizable species * fix issues with absolute tolerance for self field * Revert "fix issues with absolute tolerance for self field" This reverts commit 588e022d3edbb97ff8efc33d21439449f498a9bc. * increase threshold for some tests where a warning stating that max norm of rho equal to 0 is raised * increase threhshold for another test * setting abort on warning is now the default for CI tests Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Diffstat (limited to 'Source/WarpX.cpp')
-rw-r--r--Source/WarpX.cpp34
1 files changed, 34 insertions, 0 deletions
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()) {