Reference documentation for deal.II version 8.5.1
petsc_full_matrix.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2004 - 2016 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_compatibility.h>
21 #include <deal.II/lac/exceptions.h>
22 
23 DEAL_II_NAMESPACE_OPEN
24 
25 namespace PETScWrappers
26 {
27 
29  {
30  // empty constructor generate an empty matrix
31  do_reinit (0, 0);
32  }
33 
35  const size_type n)
36  {
37  do_reinit (m, n);
38  }
39 
40  void
42  const size_type n)
43  {
44  // get rid of old matrix and generate a
45  // new one
46  const PetscErrorCode ierr = destroy_matrix(matrix);
47  AssertThrow(ierr == 0, ExcPETScError(ierr));
48 
49  do_reinit (m, n);
50  }
51 
52  void
54  const size_type n)
55  {
56  // use the call sequence indicating only a maximal number of
57  // elements per row for all rows globally
58  const PetscErrorCode ierr = MatCreateSeqDense (PETSC_COMM_SELF, m, n,
59  PETSC_NULL, &matrix);
60  AssertThrow (ierr == 0, ExcPETScError(ierr));
61  }
62 
63 
64  const MPI_Comm &
66  {
67  static const MPI_Comm communicator = MPI_COMM_SELF;
68  return communicator;
69  }
70 }
71 
72 
73 DEAL_II_NAMESPACE_CLOSE
74 
75 #endif // DEAL_II_WITH_PETSC
PetscErrorCode destroy_matrix(Mat &matrix)
types::global_dof_index size_type
virtual const MPI_Comm & get_mpi_communicator() const
#define AssertThrow(cond, exc)
Definition: exceptions.h:369
void do_reinit(const size_type m, const size_type n)
void reinit(const size_type m, const size_type n)