diff options
author | 2022-05-31 02:35:30 +0200 | |
---|---|---|
committer | 2022-05-30 17:35:30 -0700 | |
commit | d5f61eafc3de4f15a02edcbb3a7b95abdc774ab7 (patch) | |
tree | 0c785e2cc1853b30c33f3c732569a352b50b8bef /Source/Initialization/TemperatureProperties.cpp | |
parent | e267ac91316d5c590f3b73af20f4c5c567068e46 (diff) | |
download | WarpX-d5f61eafc3de4f15a02edcbb3a7b95abdc774ab7.tar.gz WarpX-d5f61eafc3de4f15a02edcbb3a7b95abdc774ab7.tar.zst WarpX-d5f61eafc3de4f15a02edcbb3a7b95abdc774ab7.zip |
Use Utils::TextMsg::Err and WARPX_ALWAYS_ASSERT_WITH_MESSAGE in more files (#3117)
* use formatted error messages
* fixed bug
* fixed bug
* fixed bugs
* fixed bug
Diffstat (limited to 'Source/Initialization/TemperatureProperties.cpp')
-rw-r--r-- | Source/Initialization/TemperatureProperties.cpp | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/Source/Initialization/TemperatureProperties.cpp b/Source/Initialization/TemperatureProperties.cpp index ada58be6a..9446f72d5 100644 --- a/Source/Initialization/TemperatureProperties.cpp +++ b/Source/Initialization/TemperatureProperties.cpp @@ -5,9 +5,11 @@ * * License: BSD-3-Clause-LBNL */ - #include "TemperatureProperties.H" +#include "Utils/TextMsg.H" +#include "WarpX.H" + /* * Construct TemperatureProperties based on the passed parameters. * If temperature is a constant, store value. If a parser, make and @@ -22,28 +24,30 @@ TemperatureProperties::TemperatureProperties (amrex::ParmParse& pp) { pp.query("theta_distribution_type", temp_dist_s); pp.query("momentum_distribution_type", mom_dist_s); if (temp_dist_s == "constant") { - if (!queryWithParser(pp, "theta", theta)) { - std::string err_str = "Temperature parameter theta not specified"; - amrex::Abort(err_str); - } + WARPX_ALWAYS_ASSERT_WITH_MESSAGE(queryWithParser(pp, "theta", theta), + "Temperature parameter theta not specified"); + // Do validation on theta value - if (theta < 0) { - std::stringstream stringstream; - stringstream << "Temperature parameter theta = " << theta << - " is less than zero, which is not allowed"; - amrex::Abort(stringstream.str().c_str()); - } + + WARPX_ALWAYS_ASSERT_WITH_MESSAGE(theta >= 0, + "Temperature parameter theta = " + std::to_string(theta) + + " is less than zero, which is not allowed"); + + WARPX_ALWAYS_ASSERT_WITH_MESSAGE( + mom_dist_s != "maxwell_juttner" || + theta >= 0.1, + "Temperature parameter theta = " + + std::to_string(theta) + + " is less than minimum 0.1 allowed for Maxwell-Juttner." + ); + + if (mom_dist_s == "maxwell_boltzmann" && theta > 0.01) { - std::stringstream warnstream; - warnstream << " Warning: Maxwell-Boltzmann distribution has errors greater than 1%" - << " for temperature parameter theta > 0.01. (theta = " << theta << " given)."; - amrex::Warning(warnstream.str()); - } - else if (mom_dist_s == "maxwell_juttner" && theta < 0.1) { - std::stringstream stringstream; - stringstream << "Temperature parameter theta = " << theta << - " is less than minimum 0.1 allowed for Maxwell-Juttner."; - amrex::Abort(stringstream.str().c_str()); + WarpX::GetInstance().RecordWarning( + "Temperature", + std::string{"Maxwell-Boltzmann distribution has errors greater than 1%"} + + std::string{" for temperature parameter theta > 0.01. (theta = "} + + std::to_string(theta) + " given)"); } m_type = TempConstantValue; @@ -61,6 +65,6 @@ TemperatureProperties::TemperatureProperties (amrex::ParmParse& pp) { std::string string; stringstream << "Temperature distribution type '" << temp_dist_s << "' not recognized."; string = stringstream.str(); - amrex::Abort(string.c_str()); + amrex::Abort(Utils::TextMsg::Err(string.c_str())); } } |