14 #include "libmesh/threads.h" 16 #include "libmesh/print_trace.h" 17 #include "libmesh/libmesh_common.h" 22 #include <type_traits> 33 template <
size_t n,
typename... T>
37 if constexpr (n <
sizeof...(T))
41 os << std::get<n>(tup);
42 print_tuple<n + 1>(
os, tup);
45 template <
typename... T>
50 print_tuple<0>(
os, tup);
55 #if defined(LIBMESH_HAVE_MPI) 59 MPI_Abort(libMesh::GLOBAL_COMM_WORLD, 1); \ 70 #define mooseDoOnce(do_this) \ 73 static bool did_this_already = false; \ 74 if (Moose::show_multiple || !did_this_already) \ 76 did_this_already = true; \ 81 #define mooseCheckMPIErr(err) \ 84 if (err != MPI_SUCCESS) \ 86 if (libMesh::global_n_processors() == 1) \ 87 libMesh::print_trace(); \ 93 #define mooseException(...) \ 96 throw MooseException(__VA_ARGS__); \ 100 #define mooseAssert(asserted, msg) ((void)0) 102 #define mooseAssert(asserted, msg) \ 107 std::ostringstream _assert_oss_; \ 108 _assert_oss_ << COLOR_RED << "\n\nAssertion `" #asserted "' failed\n" \ 109 << msg << "\nat " << __FILE__ << ", line " << __LINE__ << COLOR_DEFAULT \ 111 if (Moose::_throw_on_error) \ 112 throw std::runtime_error(_assert_oss_.str()); \ 115 Moose::err << _assert_oss_.str() << std::flush; \ 116 if (libMesh::global_n_processors() == 1) \ 117 libMesh::print_trace(); \ 119 libMesh::write_traceout(); \ 127 template <
typename... Args>
128 [[noreturn]]
void mooseError(Args &&... args);
155 mooseMsgFmt(
const std::string & msg,
const std::string & title,
const std::string & color);
163 std::string
mooseMsgFmt(
const std::string & msg,
const std::string & color);
165 [[noreturn]]
void mooseErrorRaw(std::string msg,
const std::string prefix =
"");
174 template <
typename T,
typename... Args>
182 template <
typename S,
typename... Args>
189 std::ostringstream ss;
191 std::string msg =
mooseMsgFmt(ss.str(),
"*** Warning ***", COLOR_YELLOW);
193 throw std::runtime_error(msg);
197 oss << msg << std::flush;
201 template <
typename S,
typename... Args>
205 std::ostringstream ss;
207 std::string msg =
mooseMsgFmt(ss.str(),
"*** Warning ***", COLOR_YELLOW);
209 throw std::runtime_error(msg);
213 oss << msg << std::flush;
217 template <
typename S,
typename... Args>
221 std::ostringstream ss;
223 std::string msg =
mooseMsgFmt(ss.str(),
"*** Info ***", COLOR_CYAN);
226 oss << msg << std::flush;
230 template <
typename S,
typename... Args>
237 template <
typename S,
typename... Args>
242 mooseError(
"\n\nDeprecated code:\n", std::forward<Args>(args)...);
244 std::ostringstream ss;
247 const auto color = expired ? COLOR_RED : COLOR_YELLOW;
252 "*** Warning, This code is deprecated and will be removed in future versions:",
265 oss << ss.str() << std::endl;
286 const unsigned int issue_num,
287 const std::string & msg);
300 template <
typename... Args>
304 std::ostringstream oss;
321 template <
typename... Args>
325 std::ostringstream oss;
334 template <
typename... Args>
343 template <
typename... Args>
351 template <
typename... Args>
359 template <
typename... Args>
367 template <
typename... Args>
375 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.
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="")
std::string demangle(const char *name)
void mooseDeprecatedStream(S &oss, const bool expired, const bool print_title, Args &&... args)
void mooseDocumentedError(const std::string &repo_name, const unsigned int issue_num, Args &&... args)
Emit a documented error message with the given stringified, concatenated args and terminate the appli...
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...
libMesh::Threads::spin_mutex moose_stream_lock
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.
std::string formatMooseDocumentedError(const std::string &repo_name, const unsigned int issue_num, const std::string &msg)
Formats a documented error.