Reference documentation for deal.II version 9.2.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
exceptions.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1998 - 2020 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_exceptions_h
17 #define dealii_exceptions_h
18 
19 #include <deal.II/base/config.h>
20 
21 #include <exception>
22 #include <ostream>
23 #include <string>
24 #include <type_traits>
25 
26 #ifdef DEAL_II_WITH_CUDA
27 # include <cusolverSp.h>
28 # include <cusparse.h>
29 #endif
30 
31 
33 
34 
49 class ExceptionBase : public std::exception
50 {
51 public:
55  ExceptionBase();
56 
61 
65  virtual ~ExceptionBase() noexcept override;
66 
72  operator=(const ExceptionBase &) = delete;
73 
79  void
80  set_fields(const char *file,
81  const int line,
82  const char *function,
83  const char *cond,
84  const char *exc_name);
85 
86 
90  virtual const char *
91  what() const noexcept override;
92 
96  const char *
97  get_exc_name() const;
98 
102  void
103  print_exc_data(std::ostream &out) const;
104 
109  virtual void
110  print_info(std::ostream &out) const;
111 
116  void
117  print_stack_trace(std::ostream &out) const;
118 
119 protected:
123  const char *file;
124 
128  unsigned int line;
129 
133  const char *function;
134 
138  const char *cond;
139 
143  const char *exc;
144 
149  mutable char **stacktrace;
150 
156 
157 #ifdef DEAL_II_HAVE_GLIBC_STACKTRACE
158 
161  void *raw_stacktrace[25];
162 #endif
163 
164 private:
168  void
169  generate_message() const;
170 
175  mutable std::string what_str;
176 };
177 
178 #ifndef DOXYGEN
179 
197 # define DeclException0(Exception0) \
198  class Exception0 : public ::ExceptionBase \
199  {}
200 
201 
221 # define DeclExceptionMsg(Exception, defaulttext) \
222  class Exception : public ::ExceptionBase \
223  { \
224  public: \
225  Exception(const std::string &msg = defaulttext) \
226  : arg(msg) \
227  {} \
228  virtual ~Exception() noexcept \
229  {} \
230  virtual void \
231  print_info(std::ostream &out) const override \
232  { \
233  out << " " << arg << std::endl; \
234  } \
235  \
236  private: \
237  const std::string arg; \
238  }
239 
257 # define DeclException1(Exception1, type1, outsequence) \
258  class Exception1 : public ::ExceptionBase \
259  { \
260  public: \
261  Exception1(type1 const &a1) \
262  : arg1(a1) \
263  {} \
264  virtual ~Exception1() noexcept \
265  {} \
266  virtual void \
267  print_info(std::ostream &out) const override \
268  { \
269  out << " " outsequence << std::endl; \
270  } \
271  \
272  private: \
273  type1 const arg1; \
274  }
275 
276 
294 # define DeclException2(Exception2, type1, type2, outsequence) \
295  class Exception2 : public ::ExceptionBase \
296  { \
297  public: \
298  Exception2(type1 const &a1, type2 const &a2) \
299  : arg1(a1) \
300  , arg2(a2) \
301  {} \
302  virtual ~Exception2() noexcept \
303  {} \
304  virtual void \
305  print_info(std::ostream &out) const override \
306  { \
307  out << " " outsequence << std::endl; \
308  } \
309  \
310  private: \
311  type1 const arg1; \
312  type2 const arg2; \
313  }
314 
315 
333 # define DeclException3(Exception3, type1, type2, type3, outsequence) \
334  class Exception3 : public ::ExceptionBase \
335  { \
336  public: \
337  Exception3(type1 const &a1, type2 const &a2, type3 const &a3) \
338  : arg1(a1) \
339  , arg2(a2) \
340  , arg3(a3) \
341  {} \
342  virtual ~Exception3() noexcept \
343  {} \
344  virtual void \
345  print_info(std::ostream &out) const override \
346  { \
347  out << " " outsequence << std::endl; \
348  } \
349  \
350  private: \
351  type1 const arg1; \
352  type2 const arg2; \
353  type3 const arg3; \
354  }
355 
356 
374 # define DeclException4(Exception4, type1, type2, type3, type4, outsequence) \
375  class Exception4 : public ::ExceptionBase \
376  { \
377  public: \
378  Exception4(type1 const &a1, \
379  type2 const &a2, \
380  type3 const &a3, \
381  type4 const &a4) \
382  : arg1(a1) \
383  , arg2(a2) \
384  , arg3(a3) \
385  , arg4(a4) \
386  {} \
387  virtual ~Exception4() noexcept \
388  {} \
389  virtual void \
390  print_info(std::ostream &out) const override \
391  { \
392  out << " " outsequence << std::endl; \
393  } \
394  \
395  private: \
396  type1 const arg1; \
397  type2 const arg2; \
398  type3 const arg3; \
399  type4 const arg4; \
400  }
401 
402 
420 # define DeclException5( \
421  Exception5, type1, type2, type3, type4, type5, outsequence) \
422  class Exception5 : public ::ExceptionBase \
423  { \
424  public: \
425  Exception5(type1 const &a1, \
426  type2 const &a2, \
427  type3 const &a3, \
428  type4 const &a4, \
429  type5 const &a5) \
430  : arg1(a1) \
431  , arg2(a2) \
432  , arg3(a3) \
433  , arg4(a4) \
434  , arg5(a5) \
435  {} \
436  virtual ~Exception5() noexcept \
437  {} \
438  virtual void \
439  print_info(std::ostream &out) const override \
440  { \
441  out << " " outsequence << std::endl; \
442  } \
443  \
444  private: \
445  type1 const arg1; \
446  type2 const arg2; \
447  type3 const arg3; \
448  type4 const arg4; \
449  type5 const arg5; \
450  }
451 
452 #else /*ifndef DOXYGEN*/
453 
454 // Dummy definitions for doxygen:
455 
473 # define DeclException0(Exception0) \
474  \
475  static ::ExceptionBase &Exception0()
476 
496 # define DeclExceptionMsg(Exception, defaulttext) \
497  \
498  \
499  static ::ExceptionBase &Exception()
500 
518 # define DeclException1(Exception1, type1, outsequence) \
519  \
520  \
521  static ::ExceptionBase &Exception1(type1 arg1)
522 
523 
541 # define DeclException2(Exception2, type1, type2, outsequence) \
542  \
543  \
544  static ::ExceptionBase &Exception2(type1 arg1, type2 arg2)
545 
546 
564 # define DeclException3(Exception3, type1, type2, type3, outsequence) \
565  \
566  \
567  static ::ExceptionBase &Exception3(type1 arg1, type2 arg2, type3 arg3)
568 
569 
587 # define DeclException4(Exception4, type1, type2, type3, type4, outsequence) \
588  \
589  \
590  static ::ExceptionBase &Exception4(type1 arg1, \
591  type2 arg2, \
592  type3 arg3, \
593  type4 arg4)
594 
595 
613 # define DeclException5( \
614  Exception5, type1, type2, type3, type4, type5, outsequence) \
615  \
616  \
617  static ::ExceptionBase &Exception5( \
618  type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5)
619 
620 #endif /*ifndef DOXYGEN*/
621 
622 
635 {
640 
645  "A piece of code is attempting a division by zero. This is "
646  "likely going to lead to results that make no sense.");
647 
660  std::complex<double>,
661  << "In a significant number of places, deal.II checks that some intermediate "
662  << "value is a finite number (as opposed to plus or minus infinity, or "
663  << "NaN/Not a Number). In the current function, we encountered a number "
664  << "that is not finite (its value is " << arg1 << " and therefore "
665  << "violates the current assertion).\n\n"
666  << "This may be due to the fact that some operation in this function "
667  << "created such a value, or because one of the arguments you passed "
668  << "to the function already had this value from some previous "
669  << "operation. In the latter case, this function only triggered the "
670  << "error but may not actually be responsible for the computation of "
671  << "the number that is not finite.\n\n"
672  << "There are two common cases where this situation happens. First, your "
673  << "code (or something in deal.II) divides by zero in a place where this "
674  << "should not happen. Or, you are trying to solve a linear system "
675  << "with an unsuitable solver (such as an indefinite or non-symmetric "
676  << "linear system using a Conjugate Gradient solver); such attempts "
677  << "oftentimes yield an operation somewhere that tries to divide "
678  << "by zero or take the square root of a negative value.\n\n"
679  << "In any case, when trying to find the source of the error, "
680  << "recall that the location where you are getting this error is "
681  << "simply the first place in the program where there is a check "
682  << "that a number (e.g., an element of a solution vector) is in fact "
683  << "finite, but that the actual error that computed the number "
684  << "may have happened far earlier. To find this location, you "
685  << "may want to add checks for finiteness in places of your "
686  << "program visited before the place where this error is produced. "
687  << "One way to check for finiteness is to use the 'AssertIsFinite' "
688  << "macro.");
689 
694  std::size_t,
695  "Your program tried to allocate some memory but this "
696  "allocation failed. Typically, this either means that "
697  "you simply do not have enough memory in your system, "
698  "or that you are (erroneously) trying to allocate "
699  "a chunk of memory that is simply beyond all reasonable "
700  "size, for example because the size of the object has "
701  "been computed incorrectly."
702  "\n\n"
703  "In the current case, the request was for "
704  << arg1 << " bytes.");
705 
711  int,
712  << "Destroying memory handler while " << arg1
713  << " objects are still allocated.");
714 
719  "An input/output error has occurred. There are a number of "
720  "reasons why this may be happening, both for reading and "
721  "writing operations."
722  "\n\n"
723  "If this happens during an operation that tries to read "
724  "data: First, you may be "
725  "trying to read from a file that doesn't exist or that is "
726  "not readable given its file permissions. Second, deal.II "
727  "uses this error at times if it tries to "
728  "read information from a file but where the information "
729  "in the file does not correspond to the expected format. "
730  "An example would be a truncated file, or a mesh file "
731  "that contains not only sections that describe the "
732  "vertices and cells, but also sections for additional "
733  "data that deal.II does not understand."
734  "\n\n"
735  "If this happens during an operation that tries to write "
736  "data: you may be trying to write to a file to which file "
737  "or directory permissions do not allow you to write. A "
738  "typical example is where you specify an output file in "
739  "a directory that does not exist.");
740 
748  std::string,
749  << "Could not open file " << arg1 << ".");
750 
760  "You are trying to use functionality in deal.II that is "
761  "currently not implemented. In many cases, this indicates "
762  "that there simply didn't appear much of a need for it, or "
763  "that the author of the original code did not have the "
764  "time to implement a particular case. If you hit this "
765  "exception, it is therefore worth the time to look into "
766  "the code to find out whether you may be able to "
767  "implement the missing functionality. If you do, please "
768  "consider providing a patch to the deal.II development "
769  "sources (see the deal.II website on how to contribute).");
770 
792  "This exception -- which is used in many places in the "
793  "library -- usually indicates that some condition which "
794  "the author of the code thought must be satisfied at a "
795  "certain point in an algorithm, is not fulfilled. An "
796  "example would be that the first part of an algorithm "
797  "sorts elements of an array in ascending order, and "
798  "a second part of the algorithm later encounters an "
799  "element that is not larger than the previous one."
800  "\n\n"
801  "There is usually not very much you can do if you "
802  "encounter such an exception since it indicates an error "
803  "in deal.II, not in your own program. Try to come up with "
804  "the smallest possible program that still demonstrates "
805  "the error and contact the deal.II mailing lists with it "
806  "to obtain help.");
807 
816  "You (or a place in the library) are trying to call a "
817  "function that is declared as a virtual function in a "
818  "base class but that has not been overridden in your "
819  "derived class."
820  "\n\n"
821  "This exception happens in cases where the base class "
822  "cannot provide a useful default implementation for "
823  "the virtual function, but where we also do not want "
824  "to mark the function as abstract (i.e., with '=0' at the end) "
825  "because the function is not essential to the class in many "
826  "contexts. In cases like this, the base class provides "
827  "a dummy implementation that makes the compiler happy, but "
828  "that then throws the current exception."
829  "\n\n"
830  "A concrete example would be the 'Function' class. It declares "
831  "the existence of 'value()' and 'gradient()' member functions, "
832  "and both are marked as 'virtual'. Derived classes have to "
833  "override these functions for the values and gradients of a "
834  "particular function. On the other hand, not every function "
835  "has a gradient, and even for those that do, not every program "
836  "actually needs to evaluate it. Consequently, there is no "
837  "*requirement* that a derived class actually override the "
838  "'gradient()' function (as there would be had it been marked "
839  "as abstract). But, since the base class cannot know how to "
840  "compute the gradient, if a derived class does not override "
841  "the 'gradient()' function and it is called anyway, then the "
842  "default implementation in the base class will simply throw "
843  "an exception."
844  "\n\n"
845  "The exception you see is what happens in cases such as the "
846  "one just illustrated. To fix the problem, you need to "
847  "investigate whether the function being called should indeed have "
848  "been called; if the answer is 'yes', then you need to "
849  "implement the missing override in your class.");
850 
855 
860 
868  int,
869  << "You are trying to execute functionality that is "
870  << "impossible in " << arg1
871  << "d or simply does not make any sense.");
872 
881  int,
882  int,
883  << "You are trying to execute functionality that is "
884  << "impossible in dimensions <" << arg1 << "," << arg2
885  << "> or simply does not make any sense.");
886 
887 
892  "In a check in the code, deal.II encountered a zero in "
893  "a place where this does not make sense. See the condition "
894  "that was being checked and that is printed further up "
895  "in the error message to get more information on what "
896  "the erroneous zero corresponds to.");
897 
903  "The object you are trying to access is empty but it makes "
904  "no sense to attempt the operation you are trying on an "
905  "empty object.");
906 
915  std::size_t,
916  std::size_t,
917  << "Dimension " << arg1 << " not equal to " << arg2 << ".");
918 
924  int,
925  int,
926  int,
927  << "Dimension " << arg1 << " neither equal to " << arg2
928  << " nor to " << arg3 << ".");
929 
944  int,
945  int,
946  int,
947  << "Index " << arg1 << " is not in the half-open range [" << arg2 << ","
948  << arg3 << ")."
949  << (arg2 == arg3 ?
950  " In the current case, this half-open range is in fact empty, "
951  "suggesting that you are accessing an element of an empty "
952  "collection such as a vector that has not been set to the "
953  "correct size." :
954  ""));
955 
971  template <typename T>
974  T,
975  T,
976  T,
977  << "Index " << arg1 << " is not in the half-open range [" << arg2 << ","
978  << arg3 << ")."
979  << (arg2 == arg3 ?
980  " In the current case, this half-open range is in fact empty, "
981  "suggesting that you are accessing an element of an empty "
982  "collection such as a vector that has not been set to the "
983  "correct size." :
984  ""));
985 
990  int,
991  int,
992  << "Number " << arg1 << " must be larger than or equal "
993  << arg2 << ".");
994 
998  template <typename T>
1000  T,
1001  T,
1002  << "Number " << arg1 << " must be larger than or equal "
1003  << arg2 << ".");
1004 
1010  int,
1011  int,
1012  << "Division " << arg1 << " by " << arg2
1013  << " has remainder different from zero.");
1014 
1024  "You are trying to use an iterator, but the iterator is "
1025  "in an invalid state. This may indicate that the iterator "
1026  "object has not been initialized, or that it has been "
1027  "moved beyond the end of the range of valid elements.");
1028 
1034  "You are trying to use an iterator, but the iterator is "
1035  "pointing past the end of the range of valid elements. "
1036  "It is not valid to dereference the iterator in this "
1037  "case.");
1038 
1052  DeclException1(ExcMessage, std::string, << arg1);
1053 
1058  "You are trying an operation on a vector that is only "
1059  "allowed if the vector has no ghost elements, but the "
1060  "vector you are operating on does have ghost elements. "
1061  "Specifically, vectors with ghost elements are read-only "
1062  "and cannot appear in operations that write into these "
1063  "vectors."
1064  "\n\n"
1065  "See the glossary entry on 'Ghosted vectors' for more "
1066  "information.");
1067 
1076  "You are trying an operation of the form 'vector=s' with "
1077  "a nonzero scalar value 's'. However, such assignments "
1078  "are only allowed if the right hand side is zero.");
1079 
1085  "You are attempting to use functionality that is only available "
1086  "if deal.II was configured to use LAPACK, but cmake did not "
1087  "find a valid LAPACK library.");
1088 
1093  ExcNeedsMPI,
1094  "You are attempting to use functionality that is only available "
1095  "if deal.II was configured to use MPI.");
1096 
1104  "You are attempting to use functionality that is only available "
1105  "if deal.II was configured to use NetCDF, but cmake did not "
1106  "find a valid NetCDF library.");
1107 
1113  "You are attempting to use functionality that is only available "
1114  "if deal.II was configured to use the function parser which "
1115  "relies on the muparser library, but cmake did not "
1116  "find a valid muparser library on your system and also did "
1117  "not choose the one that comes bundled with deal.II.");
1118 
1124  "You are attempting to use functionality that is only available "
1125  "if deal.II was configured to use Assimp, but cmake did not "
1126  "find a valid Assimp library.");
1127 
1128 #ifdef DEAL_II_WITH_CUDA
1129 
1135  DeclException1(ExcCudaError, const char *, << arg1);
1140  std::string,
1141  << "There was an error in a cuSPARSE function: " << arg1);
1142 #endif
1143 
1144 
1145 #ifdef DEAL_II_WITH_MPI
1146 
1168  class ExcMPI : public ::ExceptionBase
1169  {
1170  public:
1171  ExcMPI(const int error_code);
1172 
1173  virtual void
1174  print_info(std::ostream &out) const override;
1175 
1176  const int error_code;
1177  };
1178 #endif // DEAL_II_WITH_MPI
1179 } /*namespace StandardExceptions*/
1180 
1181 
1182 
1190 {
1191  namespace internals
1192  {
1200  extern bool allow_abort_on_exception;
1201  } // namespace internals
1202 
1221  void
1222  set_additional_assert_output(const char *const p);
1223 
1234  void
1236 
1250  void
1252 
1260  namespace internals
1261  {
1266  [[noreturn]] void
1267  abort(const ExceptionBase &exc) noexcept;
1268 
1273  {
1284  };
1285 
1303  template <class ExceptionType>
1304  [[noreturn]] void
1306  const char * file,
1307  int line,
1308  const char * function,
1309  const char * cond,
1310  const char * exc_name,
1311  ExceptionType e) {
1312  // Fill the fields of the exception object
1313  e.set_fields(file, line, function, cond, exc_name);
1314 
1315  switch (handling)
1316  {
1318  {
1322  else
1323  {
1324  // We are not allowed to abort, so just throw the error:
1325  throw e;
1326  }
1327  }
1328  case throw_on_exception:
1329  throw e;
1330  // this function should never return (and AssertNothrow can);
1331  // something must have gone wrong in the error handling code for us
1332  // to get this far, so throw an exception.
1333  default:
1335  }
1336  }
1337 
1341  void do_issue_error_nothrow(const ExceptionBase &e) noexcept;
1342 
1351  template <class ExceptionType>
1352  void
1353  issue_error_nothrow(const char * file,
1354  int line,
1355  const char * function,
1356  const char * cond,
1357  const char * exc_name,
1358  ExceptionType e) noexcept
1359  {
1361  "The provided exception must inherit from ExceptionBase.");
1362  // Fill the fields of the exception object
1363  e.set_fields(file, line, function, cond, exc_name);
1364  // avoid moving a bunch of code into the header by dispatching to
1365  // another function:
1367  }
1368 #ifdef DEAL_II_WITH_CUDA
1369 
1374  std::string
1375  get_cusparse_error_string(const cusparseStatus_t error_code);
1376 
1382  std::string
1383  get_cusolver_error_string(const cusolverStatus_t error_code);
1384 #endif
1385  } /*namespace internals*/
1386 
1387 } /*namespace deal_II_exceptions*/
1388 
1389 
1390 
1417 #ifdef DEBUG
1418 # ifdef DEAL_II_HAVE_BUILTIN_EXPECT
1419 # define Assert(cond, exc) \
1420  { \
1421  if (__builtin_expect(!(cond), false)) \
1422  ::deal_II_exceptions::internals::issue_error_noreturn( \
1423  ::deal_II_exceptions::internals:: \
1424  abort_or_throw_on_exception, \
1425  __FILE__, \
1426  __LINE__, \
1427  __PRETTY_FUNCTION__, \
1428  #cond, \
1429  #exc, \
1430  exc); \
1431  }
1432 # else /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
1433 # define Assert(cond, exc) \
1434  { \
1435  if (!(cond)) \
1436  ::deal_II_exceptions::internals::issue_error_noreturn( \
1437  ::deal_II_exceptions::internals:: \
1438  abort_or_throw_on_exception, \
1439  __FILE__, \
1440  __LINE__, \
1441  __PRETTY_FUNCTION__, \
1442  #cond, \
1443  #exc, \
1444  exc); \
1445  }
1446 # endif /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
1447 #else
1448 # define Assert(cond, exc) \
1449  {}
1450 #endif
1451 
1452 
1453 
1481 #ifdef DEBUG
1482 # ifdef DEAL_II_HAVE_BUILTIN_EXPECT
1483 # define AssertNothrow(cond, exc) \
1484  { \
1485  if (__builtin_expect(!(cond), false)) \
1486  ::deal_II_exceptions::internals::issue_error_nothrow( \
1487  __FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #exc, exc); \
1488  }
1489 # else /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
1490 # define AssertNothrow(cond, exc) \
1491  { \
1492  if (!(cond)) \
1493  ::deal_II_exceptions::internals::issue_error_nothrow( \
1494  __FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #exc, exc); \
1495  }
1496 # endif /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
1497 #else
1498 # define AssertNothrow(cond, exc) \
1499  {}
1500 #endif
1501 
1530 #ifdef DEAL_II_HAVE_BUILTIN_EXPECT
1531 # define AssertThrow(cond, exc) \
1532  { \
1533  if (__builtin_expect(!(cond), false)) \
1534  ::deal_II_exceptions::internals::issue_error_noreturn( \
1535  ::deal_II_exceptions::internals::throw_on_exception, \
1536  __FILE__, \
1537  __LINE__, \
1538  __PRETTY_FUNCTION__, \
1539  #cond, \
1540  #exc, \
1541  exc); \
1542  }
1543 #else /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
1544 # define AssertThrow(cond, exc) \
1545  { \
1546  if (!(cond)) \
1547  ::deal_II_exceptions::internals::issue_error_noreturn( \
1548  ::deal_II_exceptions::internals::throw_on_exception, \
1549  __FILE__, \
1550  __LINE__, \
1551  __PRETTY_FUNCTION__, \
1552  #cond, \
1553  #exc, \
1554  exc); \
1555  }
1556 #endif /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
1557 
1579 #define AssertDimension(dim1, dim2) \
1580  Assert(static_cast<typename ::internal::argument_type<void( \
1581  typename std::common_type<decltype(dim1), \
1582  decltype(dim2)>::type)>::type>(dim1) == \
1583  static_cast<typename ::internal::argument_type<void( \
1584  typename std::common_type<decltype(dim1), \
1585  decltype(dim2)>::type)>::type>(dim2), \
1586  ::ExcDimensionMismatch((dim1), (dim2)))
1587 
1588 
1607 #define AssertVectorVectorDimension(VEC, DIM1, DIM2) \
1608  AssertDimension(VEC.size(), DIM1); \
1609  for (const auto &subvector : VEC) \
1610  { \
1611  (void)subvector; \
1612  AssertDimension(subvector.size(), DIM2); \
1613  }
1614 
1615 namespace internal
1616 {
1617  // Workaround to allow for commas in template parameter lists
1618  // in preprocessor macros as found in
1619  // https://stackoverflow.com/questions/13842468/comma-in-c-c-macro
1620  template <typename T>
1622  template <typename T, typename U>
1623  struct argument_type<T(U)>
1624  {
1625  using type = U;
1626  };
1627 } // namespace internal
1628 
1649 #define AssertIndexRange(index, range) \
1650  Assert( \
1651  static_cast<typename ::internal::argument_type<void( \
1652  typename std::common_type<decltype(index), decltype(range)>::type)>:: \
1653  type>(index) < \
1654  static_cast<typename ::internal::argument_type<void( \
1655  typename std::common_type<decltype(index), decltype(range)>::type)>:: \
1656  type>(range), \
1657  ExcIndexRangeType<typename ::internal::argument_type<void( \
1658  typename std::common_type<decltype(index), decltype(range)>::type)>:: \
1659  type>((index), 0, (range)))
1660 
1681 #define AssertIsFinite(number) \
1682  Assert(::numbers::is_finite(number), \
1683  ::ExcNumberNotFinite(std::complex<double>(number)))
1684 
1685 #ifdef DEAL_II_WITH_MPI
1686 
1707 # define AssertThrowMPI(error_code) \
1708  AssertThrow(error_code == MPI_SUCCESS, ::ExcMPI(error_code))
1709 #else
1710 # define AssertThrowMPI(error_code) \
1711  {}
1712 #endif // DEAL_II_WITH_MPI
1713 
1714 #ifdef DEAL_II_WITH_CUDA
1715 
1733 # ifdef DEBUG
1734 # define AssertCuda(error_code) \
1735  Assert(error_code == cudaSuccess, \
1736  ::ExcCudaError(cudaGetErrorString(error_code)))
1737 # else
1738 # define AssertCuda(error_code) \
1739  { \
1740  (void)(error_code); \
1741  }
1742 # endif
1743 
1761 # ifdef DEBUG
1762 # define AssertNothrowCuda(error_code) \
1763  AssertNothrow(error_code == cudaSuccess, \
1764  ::ExcCudaError(cudaGetErrorString(error_code)))
1765 # else
1766 # define AssertNothrowCuda(error_code) \
1767  { \
1768  (void)(error_code); \
1769  }
1770 # endif
1771 
1790 # ifdef DEBUG
1791 # define AssertCudaKernel() \
1792  { \
1793  cudaError_t local_error_code = cudaPeekAtLastError(); \
1794  AssertCuda(local_error_code); \
1795  local_error_code = cudaDeviceSynchronize(); \
1796  AssertCuda(local_error_code) \
1797  }
1798 # else
1799 # define AssertCudaKernel() \
1800  {}
1801 # endif
1802 
1821 # ifdef DEBUG
1822 # define AssertCusparse(error_code) \
1823  Assert( \
1824  error_code == CUSPARSE_STATUS_SUCCESS, \
1825  ExcCusparseError( \
1826  deal_II_exceptions::internals::get_cusparse_error_string( \
1827  error_code)))
1828 # else
1829 # define AssertCusparse(error_code) \
1830  { \
1831  (void)(error_code); \
1832  }
1833 # endif
1834 
1852 # ifdef DEBUG
1853 # define AssertNothrowCusparse(error_code) \
1854  AssertNothrow( \
1855  error_code == CUSPARSE_STATUS_SUCCESS, \
1856  ExcCusparseError( \
1857  deal_II_exceptions::internals::get_cusparse_error_string( \
1858  error_code)))
1859 # else
1860 # define AssertNothrowCusparse(error_code) \
1861  { \
1862  (void)(error_code); \
1863  }
1864 # endif
1865 
1884 # ifdef DEBUG
1885 # define AssertCusolver(error_code) \
1886  Assert( \
1887  error_code == CUSOLVER_STATUS_SUCCESS, \
1888  ExcCusparseError( \
1889  deal_II_exceptions::internals::get_cusolver_error_string( \
1890  error_code)))
1891 # else
1892 # define AssertCusolver(error_code) \
1893  { \
1894  (void)(error_code); \
1895  }
1896 # endif
1897 
1898 #endif
1899 
1900 using namespace StandardExceptions;
1901 
1903 
1904 #endif
DeclExceptionMsg
#define DeclExceptionMsg(Exception, defaulttext)
Definition: exceptions.h:496
deal_II_exceptions::internals::issue_error_noreturn
void issue_error_noreturn(ExceptionHandling handling, const char *file, int line, const char *function, const char *cond, const char *exc_name, ExceptionType e)
Definition: exceptions.h:1305
StandardExceptions::ExcNeedsAssimp
static ::ExceptionBase & ExcNeedsAssimp()
StandardExceptions::ExcIO
static ::ExceptionBase & ExcIO()
deal_II_exceptions::internals::allow_abort_on_exception
bool allow_abort_on_exception
Definition: exceptions.cc:55
StandardExceptions::ExcNeedsNetCDF
static ::ExceptionBase & ExcNeedsNetCDF()
ExceptionBase
Definition: exceptions.h:49
StandardExceptions::ExcNotImplemented
static ::ExceptionBase & ExcNotImplemented()
deal_II_exceptions::internals
Definition: exceptions.h:1191
StandardExceptions::ExcOutOfMemory
static ::ExceptionBase & ExcOutOfMemory(std::size_t arg1)
StandardExceptions::ExcInvalidState
static ::ExceptionBase & ExcInvalidState()
ExceptionBase::what
virtual const char * what() const noexcept override
Definition: exceptions.cc:147
ExceptionBase::generate_message
void generate_message() const
Definition: exceptions.cc:307
ExceptionBase::ExceptionBase
ExceptionBase()
Definition: exceptions.cc:79
LAPACKSupport::U
static const char U
Definition: lapack_support.h:167
StandardExceptions::ExcMPI::error_code
const int error_code
Definition: exceptions.h:1176
Physics::Elasticity::Kinematics::e
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
StandardExceptions::ExcDivideByZero
static ::ExceptionBase & ExcDivideByZero()
ExceptionBase::n_stacktrace_frames
int n_stacktrace_frames
Definition: exceptions.h:155
deal_II_exceptions
Definition: exceptions.h:1189
StandardExceptions::ExcFileNotOpen
static ::ExceptionBase & ExcFileNotOpen(std::string arg1)
StandardExceptions::ExcLowerRange
static ::ExceptionBase & ExcLowerRange(int arg1, int arg2)
deal_II_exceptions::internals::abort_or_throw_on_exception
@ abort_or_throw_on_exception
Definition: exceptions.h:1279
deal_II_exceptions::internals::get_cusparse_error_string
std::string get_cusparse_error_string(const cusparseStatus_t error_code)
Definition: exceptions.cc:471
StandardExceptions::ExcDimensionMismatch2
static ::ExceptionBase & ExcDimensionMismatch2(int arg1, int arg2, int arg3)
StandardExceptions::ExcInvalidIterator
static ::ExceptionBase & ExcInvalidIterator()
ExceptionBase::get_exc_name
const char * get_exc_name() const
Definition: exceptions.cc:170
StandardExceptions::ExcPureFunctionCalled
static ::ExceptionBase & ExcPureFunctionCalled()
ExceptionBase::cond
const char * cond
Definition: exceptions.h:138
StandardExceptions::ExcMPI::print_info
virtual void print_info(std::ostream &out) const override
Definition: exceptions.cc:358
StandardExceptions::ExcNeedsMPI
static ::ExceptionBase & ExcNeedsMPI()
deal_II_exceptions::internals::throw_on_exception
@ throw_on_exception
Definition: exceptions.h:1283
internals
Definition: sparsity_pattern.h:69
LAPACKSupport::T
static const char T
Definition: lapack_support.h:163
deal_II_exceptions::internals::abort
void abort(const ExceptionBase &exc) noexcept
Definition: exceptions.cc:408
StandardExceptions::ExcIndexRange
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
StandardExceptions::ExcMessage
static ::ExceptionBase & ExcMessage(std::string arg1)
StandardExceptions::ExcEmptyObject
static ::ExceptionBase & ExcEmptyObject()
StandardExceptions::ExcMPI::ExcMPI
ExcMPI(const int error_code)
Definition: exceptions.cc:353
deal_II_exceptions::internals::ExceptionHandling
ExceptionHandling
Definition: exceptions.h:1272
StandardExceptions::ExcMemoryLeak
static ::ExceptionBase & ExcMemoryLeak(int arg1)
StandardExceptions::ExcLowerRangeType
static ::ExceptionBase & ExcLowerRangeType(T arg1, T arg2)
internal::argument_type
Definition: exceptions.h:1621
ExceptionBase::raw_stacktrace
void * raw_stacktrace[25]
Definition: exceptions.h:161
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
deal_II_exceptions::disable_abort_on_exception
void disable_abort_on_exception()
Definition: exceptions.cc:71
StandardExceptions::ExcIndexRangeType
static ::ExceptionBase & ExcIndexRangeType(T arg1, T arg2, T arg3)
DeclException3
#define DeclException3(Exception3, type1, type2, type3, outsequence)
Definition: exceptions.h:564
DeclException1
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:518
StandardExceptions::ExcNotInitialized
static ::ExceptionBase & ExcNotInitialized()
internal::argument_type< T(U)>::type
U type
Definition: exceptions.h:1625
deal_II_exceptions::suppress_stacktrace_in_exceptions
void suppress_stacktrace_in_exceptions()
Definition: exceptions.cc:65
deal_II_exceptions::internals::do_issue_error_nothrow
void do_issue_error_nothrow(const ExceptionBase &e) noexcept
Definition: exceptions.cc:454
value
static const bool value
Definition: dof_tools_constraints.cc:433
StandardExceptions::ExcCudaError
static ::ExceptionBase & ExcCudaError(const char *arg1)
StandardExceptions::ExcInternalError
static ::ExceptionBase & ExcInternalError()
StandardExceptions
Definition: exceptions.h:634
StandardExceptions::ExcNotMultiple
static ::ExceptionBase & ExcNotMultiple(int arg1, int arg2)
deal_II_exceptions::internals::issue_error_nothrow
void issue_error_nothrow(const char *file, int line, const char *function, const char *cond, const char *exc_name, ExceptionType e) noexcept
Definition: exceptions.h:1353
StandardExceptions::ExcImpossibleInDim
static ::ExceptionBase & ExcImpossibleInDim(int arg1)
DeclException0
#define DeclException0(Exception0)
Definition: exceptions.h:473
StandardExceptions::ExcImpossibleInDimSpacedim
static ::ExceptionBase & ExcImpossibleInDimSpacedim(int arg1, int arg2)
ExceptionBase::print_info
virtual void print_info(std::ostream &out) const
Definition: exceptions.cc:210
StandardExceptions::ExcMPI
Definition: exceptions.h:1168
StandardExceptions::ExcGhostsPresent
static ::ExceptionBase & ExcGhostsPresent()
ExceptionBase::set_fields
void set_fields(const char *file, const int line, const char *function, const char *cond, const char *exc_name)
Definition: exceptions.cc:124
StandardExceptions::ExcZero
static ::ExceptionBase & ExcZero()
ExceptionBase::print_exc_data
void print_exc_data(std::ostream &out) const
Definition: exceptions.cc:178
StandardExceptions::ExcDimensionMismatch
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
ExceptionBase::what_str
std::string what_str
Definition: exceptions.h:175
config.h
ExceptionBase::operator=
ExceptionBase operator=(const ExceptionBase &)=delete
StandardExceptions::ExcScalarAssignmentOnlyForZeroValue
static ::ExceptionBase & ExcScalarAssignmentOnlyForZeroValue()
StandardExceptions::ExcCusparseError
static ::ExceptionBase & ExcCusparseError(std::string arg1)
deal_II_exceptions::internals::get_cusolver_error_string
std::string get_cusolver_error_string(const cusolverStatus_t error_code)
Definition: exceptions.cc:517
StandardExceptions::ExcNumberNotFinite
static ::ExceptionBase & ExcNumberNotFinite(std::complex< double > arg1)
internal
Definition: aligned_vector.h:369
ExceptionBase::stacktrace
char ** stacktrace
Definition: exceptions.h:149
ExceptionBase::line
unsigned int line
Definition: exceptions.h:128
deal_II_exceptions::set_additional_assert_output
void set_additional_assert_output(const char *const p)
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
StandardExceptions::ExcNeedsLAPACK
static ::ExceptionBase & ExcNeedsLAPACK()
DeclException2
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:541
ExceptionBase::~ExceptionBase
virtual ~ExceptionBase() noexcept override
Definition: exceptions.cc:115
ExceptionBase::print_stack_trace
void print_stack_trace(std::ostream &out) const
Definition: exceptions.cc:218
ExceptionBase::file
const char * file
Definition: exceptions.h:123
StandardExceptions::ExcIteratorPastEnd
static ::ExceptionBase & ExcIteratorPastEnd()
ExceptionBase::exc
const char * exc
Definition: exceptions.h:143
StandardExceptions::ExcNeedsFunctionparser
static ::ExceptionBase & ExcNeedsFunctionparser()