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.cc
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2016 - 2018 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 <petscconf.h>
22 # include <petscsys.h>
23 #endif // DEAL_II_WITH_PETSC
24 
26 
27 namespace LACExceptions
28 {
29  ExcPETScError::ExcPETScError(const int error_code)
30  : error_code(error_code)
31  {}
32 
33  void
34  ExcPETScError::print_info(std::ostream &out) const
35  {
36  out << "deal.II encountered an error while calling a PETSc function."
37  << std::endl;
38 #ifdef DEAL_II_WITH_PETSC
39  // PetscErrorMessage changes the value in a pointer to refer to a
40  // statically allocated description of the current error message.
41  const char * petsc_message;
42  const PetscErrorCode ierr = PetscErrorMessage(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 
LACExceptions
Definition: exceptions.h:25
exceptions.h
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
LACExceptions::ExcPETScError::error_code
const int error_code
Definition: exceptions.h:64
LACExceptions::ExcPETScError::ExcPETScError
ExcPETScError(const int error_code)
Definition: exceptions.cc:29
config.h
LACExceptions::ExcPETScError::print_info
virtual void print_info(std::ostream &out) const override
Definition: exceptions.cc:34
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359