Reference documentation for deal.II version 8.4.2
petsc_full_matrix.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2004 - 2014 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 at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #include <deal.II/lac/petsc_full_matrix.h>
17 
18 #ifdef DEAL_II_WITH_PETSC
19 
20 # include <deal.II/lac/petsc_vector.h>
21 
22 DEAL_II_NAMESPACE_OPEN
23 
24 namespace PETScWrappers
25 {
26 
28  {
29  // empty constructor generate an empty matrix
30  do_reinit (0, 0);
31  }
32 
34  const size_type n)
35  {
36  do_reinit (m, n);
37  }
38 
39  void
41  const size_type n)
42  {
43  // get rid of old matrix and generate a
44  // new one
45 #if DEAL_II_PETSC_VERSION_LT(3,2,0)
46  const int ierr = MatDestroy (matrix);
47 #else
48  const int ierr = MatDestroy (&matrix);
49 #endif
50  AssertThrow (ierr == 0, ExcPETScError(ierr));
51 
52  do_reinit (m, n);
53  }
54 
55  void
57  const size_type n)
58  {
59  // use the call sequence indicating only a maximal number of
60  // elements per row for all rows globally
61  const int ierr
62  = MatCreateSeqDense (PETSC_COMM_SELF, m, n, PETSC_NULL,
63  &matrix);
64 
65  AssertThrow (ierr == 0, ExcPETScError(ierr));
66  }
67 
68 
69  const MPI_Comm &
71  {
72  static const MPI_Comm communicator = MPI_COMM_SELF;
73  return communicator;
74  }
75 }
76 
77 
78 DEAL_II_NAMESPACE_CLOSE
79 
80 #endif // DEAL_II_WITH_PETSC
types::global_dof_index size_type
virtual const MPI_Comm & get_mpi_communicator() const
#define AssertThrow(cond, exc)
Definition: exceptions.h:358
void do_reinit(const size_type m, const size_type n)
void reinit(const size_type m, const size_type n)