Reference documentation for deal.II version GIT e8f57130d0 2023-09-28 07:00:03+00:00
\(\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.cc
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2016 - 2022 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 #include <deal.II/base/config.h>
17 
18 #include <deal.II/lac/exceptions.h>
19 
20 #ifdef DEAL_II_WITH_PETSC
21 # include <petscsys.h>
22 #endif // DEAL_II_WITH_PETSC
23 
25 
26 namespace LACExceptions
27 {
28  ExcPETScError::ExcPETScError(const int error_code)
29  : error_code(error_code)
30  {}
31 
32  void
33  ExcPETScError::print_info(std::ostream &out) const
34  {
35  out << "deal.II encountered an error while calling a PETSc function."
36  << std::endl;
37 #ifdef DEAL_II_WITH_PETSC
38  // PetscErrorMessage changes the value in a pointer to refer to a
39  // statically allocated description of the current error message.
40  const char *petsc_message;
41  const PetscErrorCode ierr =
42  PetscErrorMessage(static_cast<PetscErrorCode>(error_code),
43  &petsc_message,
44  /*specific=*/nullptr);
45  if (ierr == 0 && petsc_message != nullptr)
46  {
47  out << "The description of the error provided by PETSc is \""
48  << petsc_message << "\"." << std::endl;
49  }
50  else
51  {
52  out
53  << "PETSc was not able to determine a description for this particular error code."
54  << std::endl;
55  }
56 #endif // DEAL_II_WITH_PETSC
57  out << "The numerical value of the original error code is " << error_code
58  << '.' << std::endl;
59  }
60 } // namespace LACExceptions
61 
virtual void print_info(std::ostream &out) const override
Definition: exceptions.cc:33
ExcPETScError(const int error_code)
Definition: exceptions.cc:28
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:477
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:478