20 #ifndef LIBMESH_LIBMESH_COMMON_H 21 #define LIBMESH_LIBMESH_COMMON_H 27 #ifdef LIBMESH_ENABLE_TIMESTAMPS 28 # define LIBMESH_TIME __TIME__ 29 # define LIBMESH_DATE __DATE__ 31 # define LIBMESH_TIME "notime" 32 # define LIBMESH_DATE "nodate" 51 #ifdef LIBMESH_HAVE_MPI 75 #ifdef LIBMESH_IS_COMPILING_ITSELF 92 namespace MacroFunctions
94 void here(
const char * file,
int line,
const char * date,
const char * time);
95 void stop(
const char * file,
int line,
const char * date,
const char * time);
96 void report_error(
const char * file,
int line,
const char * date,
const char * time);
123 DIE
A HORRIBLE DEATH HERE...
131 typedef LIBMESH_DEFAULT_SCALAR_TYPE
Real;
137 #ifndef LIBMESH_DEFAULT_SINGLE_PRECISION 138 #ifdef LIBMESH_DEFAULT_TRIPLE_PRECISION 140 # define MPI_REAL MPI_LONG_DOUBLE 143 # define MPI_REAL MPI_DOUBLE 147 # define MPI_REAL MPI_FLOAT 168 inline std::complex<T>
libmesh_conj(std::complex<T> a) {
return std::conj(a); }
176 template <
typename T>
181 template <
typename T>
184 template <
typename T>
190 #if defined (LIBMESH_USE_REAL_NUMBERS) 192 #elif defined (LIBMESH_USE_COMPLEX_NUMBERS) 195 DIE
A HORRIBLE DEATH HERE...
203 #define MPI_ERRORVECTORREAL MPI_FLOAT 206 #ifdef LIBMESH_HAVE_MPI 239 #define libmesh_here() \ 241 libMesh::MacroFunctions::here(__FILE__, __LINE__, LIBMESH_DATE, LIBMESH_TIME); \ 250 #define libmesh_stop() \ 252 libMesh::MacroFunctions::stop(__FILE__, __LINE__, LIBMESH_DATE, LIBMESH_TIME); \ 258 #define libmesh_dbg_var(var) var 260 #define libmesh_dbg_var(var) 267 #define libmesh_assert_msg(asserted, msg) ((void) 0) 268 #define libmesh_exceptionless_assert_msg(asserted, msg) ((void) 0) 269 #define libmesh_assert_equal_to_msg(expr1,expr2, msg) ((void) 0) 270 #define libmesh_assert_not_equal_to_msg(expr1,expr2, msg) ((void) 0) 271 #define libmesh_assert_less_msg(expr1,expr2, msg) ((void) 0) 272 #define libmesh_assert_greater_msg(expr1,expr2, msg) ((void) 0) 273 #define libmesh_assert_less_equal_msg(expr1,expr2, msg) ((void) 0) 274 #define libmesh_assert_greater_equal_msg(expr1,expr2, msg) ((void) 0) 278 #define libmesh_assert_msg(asserted, msg) \ 281 libMesh::err << "Assertion `" #asserted "' failed." << std::endl; \ 282 libmesh_error_msg(msg); \ 285 #define libmesh_exceptionless_assert_msg(asserted, msg) \ 288 libMesh::err << "Assertion `" #asserted "' failed." << std::endl; \ 289 libmesh_exceptionless_error(); \ 292 #define libmesh_assert_equal_to_msg(expr1,expr2, msg) \ 294 if (!(expr1 == expr2)) { \ 295 libMesh::err << "Assertion `" #expr1 " == " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << '\n' << msg << std::endl; \ 299 #define libmesh_assert_not_equal_to_msg(expr1,expr2, msg) \ 301 if (!(expr1 != expr2)) { \ 302 libMesh::err << "Assertion `" #expr1 " != " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << '\n' << msg << std::endl; \ 306 #define libmesh_assert_less_msg(expr1,expr2, msg) \ 308 if (!(expr1 < expr2)) { \ 309 libMesh::err << "Assertion `" #expr1 " < " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << '\n' << msg << std::endl; \ 313 #define libmesh_assert_greater_msg(expr1,expr2, msg) \ 315 if (!(expr1 > expr2)) { \ 316 libMesh::err << "Assertion `" #expr1 " > " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << '\n' << msg << std::endl; \ 320 #define libmesh_assert_less_equal_msg(expr1,expr2, msg) \ 322 if (!(expr1 <= expr2)) { \ 323 libMesh::err << "Assertion `" #expr1 " <= " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << '\n' << msg << std::endl; \ 327 #define libmesh_assert_greater_equal_msg(expr1,expr2, msg) \ 329 if (!(expr1 >= expr2)) { \ 330 libMesh::err << "Assertion `" #expr1 " >= " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << '\n' << msg << std::endl; \ 336 #define libmesh_assert(asserted) libmesh_assert_msg(asserted, "") 337 #define libmesh_exceptionless_assert(asserted) libmesh_exceptionless_assert_msg(asserted, "") 338 #define libmesh_assert_equal_to(expr1,expr2) libmesh_assert_equal_to_msg(expr1,expr2, "") 339 #define libmesh_assert_not_equal_to(expr1,expr2) libmesh_assert_not_equal_to_msg(expr1,expr2, "") 340 #define libmesh_assert_less(expr1,expr2) libmesh_assert_less_msg(expr1,expr2, "") 341 #define libmesh_assert_greater(expr1,expr2) libmesh_assert_greater_msg(expr1,expr2, "") 342 #define libmesh_assert_less_equal(expr1,expr2) libmesh_assert_less_equal_msg(expr1,expr2, "") 343 #define libmesh_assert_greater_equal(expr1,expr2) libmesh_assert_greater_equal_msg(expr1,expr2, "") 356 #define libmesh_error_msg(msg) \ 358 libMesh::err << msg << std::endl; \ 359 std::stringstream msg_stream; \ 361 libMesh::MacroFunctions::report_error(__FILE__, __LINE__, LIBMESH_DATE, LIBMESH_TIME); \ 362 LIBMESH_THROW(libMesh::LogicError(msg_stream.str())); \ 365 #define libmesh_error() libmesh_error_msg("") 367 #define libmesh_exceptionless_error_msg(msg) \ 369 libMesh::err << msg << std::endl; \ 370 libMesh::MacroFunctions::report_error(__FILE__, __LINE__, LIBMESH_DATE, LIBMESH_TIME); \ 374 #define libmesh_exceptionless_error() libmesh_exceptionless_error_msg("") 376 #define libmesh_not_implemented_msg(msg) \ 378 libMesh::err << msg << std::endl; \ 379 libMesh::MacroFunctions::report_error(__FILE__, __LINE__, LIBMESH_DATE, LIBMESH_TIME); \ 380 LIBMESH_THROW(libMesh::NotImplemented()); \ 383 #define libmesh_not_implemented() libmesh_not_implemented_msg("") 385 #define libmesh_file_error_msg(filename, msg) \ 387 libMesh::err << "Error with file `" << filename << "'" << std::endl; \ 388 libMesh::MacroFunctions::report_error(__FILE__, __LINE__, LIBMESH_DATE, LIBMESH_TIME); \ 389 libMesh::err << msg << std::endl; \ 390 LIBMESH_THROW(libMesh::FileError(filename)); \ 393 #define libmesh_file_error(filename) libmesh_file_error_msg(filename,"") 395 #define libmesh_convergence_failure() \ 397 LIBMESH_THROW(libMesh::ConvergenceFailure()); \ 412 #define libmesh_example_requires(condition, option) \ 414 if (!(condition)) { \ 415 libMesh::out << "Configuring libMesh with " << option << " is required to run this example." << std::endl; \ 421 #undef libmesh_do_once 422 #define libmesh_do_once(do_this) \ 424 static bool did_this_already = false; \ 425 if (!did_this_already) { \ 426 did_this_already = true; \ 433 #ifdef LIBMESH_ENABLE_WARNINGS 434 #define libmesh_warning(message) \ 435 libmesh_do_once(libMesh::out << message \ 436 << __FILE__ << ", line " << __LINE__ << ", compiled " << LIBMESH_DATE << " at " << LIBMESH_TIME << " ***" << std::endl;) 438 #define libmesh_warning(message) ((void) 0) 443 #undef libmesh_experimental 444 #define libmesh_experimental() \ 445 libmesh_warning("*** Warning, This code is untested, experimental, or likely to see future API changes: "); 449 #undef libmesh_deprecated 450 #ifndef LIBMESH_ENABLE_DEPRECATED 451 #define libmesh_deprecated() \ 452 libmesh_error_msg("*** Error, This code is deprecated, and likely to be removed in future library versions! "); 454 #define libmesh_deprecated() \ 455 libmesh_warning("*** Warning, This code is deprecated, and likely to be removed in future library versions! "); 471 template <
typename Tnew,
typename Told>
474 #if !defined(NDEBUG) && defined(LIBMESH_HAVE_RTTI) && defined(LIBMESH_ENABLE_EXCEPTIONS) 477 Tnew newvar =
dynamic_cast<Tnew
>(oldvar);
480 catch (std::bad_cast &)
483 <<
" reference to " <<
typeid(Tnew).
name()
486 <<
" appears to be a " 487 <<
typeid(*(&oldvar)).name() << std::endl;
491 return(static_cast<Tnew>(oldvar));
495 #ifdef LIBMESH_ENABLE_DEPRECATED 496 template <
typename Tnew,
typename Told>
500 libmesh_deprecated();
501 return cast_ref<Tnew>(oldvar);
507 template <
typename Tnew,
typename Told>
510 #if !defined(NDEBUG) && defined(LIBMESH_HAVE_RTTI) 511 Tnew newvar =
dynamic_cast<Tnew
>(oldvar);
515 <<
" pointer to " <<
typeid(Tnew).
name()
518 <<
" appears to be a " 519 <<
typeid(*oldvar).name() << std::endl;
524 return(static_cast<Tnew>(oldvar));
529 template <
typename Tnew,
typename Told>
533 return cast_ptr<Tnew>(oldvar);
544 template <
typename Tnew,
typename Told>
547 libmesh_assert_equal_to
548 (oldvar, static_cast<Told>(static_cast<Tnew>(oldvar)));
550 return(static_cast<Tnew>(oldvar));
554 template <
typename Tnew,
typename Told>
558 return cast_int<Tnew>(oldvar);
563 #define LIBMESH_VERSION_ID(major,minor,patch) (((major) << 16) | ((minor) << 8) | ((patch) & 0xFF)) 568 #define libmesh_override override 572 #define libmesh_delete =delete 576 #define libmesh_final final 581 #ifdef LIBMESH_HAVE_CXX17_FALLTHROUGH_ATTRIBUTE 582 #define libmesh_fallthrough() [[fallthrough]] 583 #elif defined(LIBMESH_HAVE_DOUBLE_UNDERSCORE_ATTRIBUTE_FALLTHROUGH) 584 #define libmesh_fallthrough() __attribute__((fallthrough)) 586 #define libmesh_fallthrough() ((void) 0) 598 #endif // LIBMESH_LIBMESH_COMMON_H
std::string name(const ElemQuality q)
Tnew cast_ref(Told &oldvar)
int libmesh_C_isnan_double(double a)
Tnew cast_ptr(Told *oldvar)
bool warned_about_auto_ptr
static const Real TOLERANCE
MPI_Comm GLOBAL_COMM_WORLD
Tnew libmesh_cast_ptr(Told *oldvar)
DIE A HORRIBLE DEATH HERE typedef float ErrorVectorReal
Tnew cast_int(Told oldvar)
void libmesh_ignore(const Args &...)
std::complex< Real > COMPLEX
void stop(const char *file, int line, const char *date, const char *time)
int libmesh_C_isnan_float(float a)
Tnew libmesh_cast_ref(Told &oldvar)
OStreamProxy err(std::cerr)
std::complex< Real > Complex
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
bool libmesh_isnan(float a)
static PetscErrorCode Mat * A
void here(const char *file, int line, const char *date, const char *time)
void report_error(const char *file, int line, const char *date, const char *time)
OStreamProxy out(std::cout)
Tnew libmesh_cast_int(Told oldvar)
int libmesh_C_isnan_longdouble(long double a)