14 #include "libmesh/threads.h" 16 #include "libmesh/print_trace.h" 17 #include "libmesh/libmesh_common.h" 22 #include <type_traits> 30 template <
size_t n,
typename... T>
34 if constexpr (n <
sizeof...(T))
38 os << std::get<n>(tup);
39 print_tuple<n + 1>(
os, tup);
42 template <
typename... T>
47 print_tuple<0>(
os, tup);
52 #if defined(LIBMESH_HAVE_MPI) 56 MPI_Abort(libMesh::GLOBAL_COMM_WORLD, 1); \ 67 #define mooseDoOnce(do_this) \ 70 static bool did_this_already = false; \ 71 if (Moose::show_multiple || !did_this_already) \ 73 did_this_already = true; \ 78 #define mooseCheckMPIErr(err) \ 81 if (err != MPI_SUCCESS) \ 83 if (libMesh::global_n_processors() == 1) \ 90 #define mooseException(...) \ 93 throw MooseException(__VA_ARGS__); \ 97 #define mooseAssert(asserted, msg) ((void)0) 99 #define mooseAssert(asserted, msg) \ 104 std::ostringstream _assert_oss_; \ 105 _assert_oss_ << COLOR_RED << "\n\nAssertion `" #asserted "' failed\n" \ 106 << msg << "\nat " << __FILE__ << ", line " << __LINE__ << COLOR_DEFAULT \ 108 if (Moose::_throw_on_error) \ 109 throw std::runtime_error(_assert_oss_.str()); \ 112 Moose::err << _assert_oss_.str() << std::flush; \ 113 if (libMesh::global_n_processors() == 1) \ 116 libMesh::write_traceout(); \ 124 template <
typename... Args>
125 [[noreturn]]
void mooseError(Args &&... args);
152 mooseMsgFmt(
const std::string & msg,
const std::string & title,
const std::string & color);
160 std::string
mooseMsgFmt(
const std::string & msg,
const std::string & color);
162 [[noreturn]]
void mooseErrorRaw(std::string msg,
const std::string prefix =
"");
171 template <
typename T,
typename... Args>
179 template <
typename S,
typename... Args>
186 std::ostringstream ss;
188 std::string msg =
mooseMsgFmt(ss.str(),
"*** Warning ***", COLOR_YELLOW);
190 throw std::runtime_error(msg);
194 oss << msg << std::flush;
198 template <
typename S,
typename... Args>
202 std::ostringstream ss;
204 std::string msg =
mooseMsgFmt(ss.str(),
"*** Warning ***", COLOR_YELLOW);
206 throw std::runtime_error(msg);
210 oss << msg << std::flush;
214 template <
typename S,
typename... Args>
218 std::ostringstream ss;
220 std::string msg =
mooseMsgFmt(ss.str(),
"*** Info ***", COLOR_CYAN);
223 oss << msg << std::flush;
227 template <
typename S,
typename... Args>
234 template <
typename S,
typename... Args>
239 mooseError(
"\n\nDeprecated code:\n", std::forward<Args>(args)...);
241 std::ostringstream ss;
244 const auto color = expired ? COLOR_RED : COLOR_YELLOW;
249 "*** Warning, This code is deprecated and will be removed in future versions:",
262 oss << ss.str() << std::endl;
282 template <
typename... Args>
286 std::ostringstream oss;
294 template <
typename... Args>
303 template <
typename... Args>
311 template <
typename... Args>
319 template <
typename... Args>
327 template <
typename... Args>
335 template <
typename... Args>
void mooseStreamAll(std::ostringstream &ss)
All of the following are not meant to be called directly - they are called by the normal macros (moos...
std::ostream & operator<<(std::ostream &os, const std::tuple< T... > &tup)
void mooseUnusedStream(S &oss, Args &&... args)
bool show_trace
Set to true (the default) to print the stack trace with error and warning messages - false to omit it...
processor_id_type global_n_processors()
std::string incompatVarMsg(MooseVariableFieldBase &var1, MooseVariableFieldBase &var2)
Builds and returns a string of the form:
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
bool _warnings_are_errors
Variable to toggle any warning into an error (includes deprecated code warnings)
void translateMetaPhysicLError(const MetaPhysicL::LogicError &)
emit a relatively clear error message when we catch a MetaPhysicL logic error
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
void mooseDeprecationExpired(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
void mooseInfoRepeated(Args &&... args)
Emit an informational message with the given stringified, concatenated args.
This class provides an interface for common operations on field variables of both FE and FV types wit...
std::basic_ostream< charT, traits > * os
void mooseInfoStream(S &oss, Args &&... args)
void mooseInfo(Args &&... args)
Emit an informational message with the given stringified, concatenated args.
void mooseUnused(Args &&... args)
Warning message used to notify the users of unused parts of their input files Really used internally ...
bool _deprecated_is_error
Variable to toggle only deprecated warnings as errors.
Threads::spin_mutex moose_stream_lock
void mooseWarningStream(S &oss, Args &&... args)
void mooseInfoStreamRepeated(S &oss, Args &&... args)
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
void mooseErrorRaw(std::string msg, const std::string prefix="")
void mooseDeprecatedStream(S &oss, const bool expired, const bool print_title, Args &&... args)
void print_trace(std::ostream &out_stream=std::cerr)
bool _throw_on_warning
Variable to turn on exceptions during mooseWarning(), should only be used in MOOSE unit tests...
void print_tuple(std::ostream &os, const std::tuple< T... > &tup)
std::string mooseMsgFmt(const std::string &msg, const std::string &title, const std::string &color)
Format a message for output with a title.