MatrixNnzStructure.hpp 1.53 KB
Newer Older
1
2
3
4
5
#pragma once

#include <algorithm>
#include <vector>

Praetorius, Simon's avatar
Praetorius, Simon committed
6
#include <amdis/common/Index.hpp>
7
#include <amdis/linearalgebra/SymmetryStructure.hpp>
Praetorius, Simon's avatar
Praetorius, Simon committed
8

9
#if HAVE_MPI
10
#include <amdis/common/parallel/Communicator.hpp>
11
#endif
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

namespace AMDiS
{
  /// Sparsity pattern used to create PETSc matrices
  class MatrixNnzStructure
  {
  public:
    // Return Number of nonzeros in the diagonal part (owner part)
    std::vector<PetscInt> const& d_nnz() const
    {
      return dnnz_;
    }

    /// Return Number of nonzeros in the off-diagonal part (overlap part)
    std::vector<PetscInt> const& o_nnz() const
    {
      return onnz_;
    }

31
32
33
34
35
36
    /// Symmetry of the matrix entries
    SymmetryStructure symmetry() const
    {
      return symmetry_;
    }

Praetorius, Simon's avatar
Praetorius, Simon committed
37
    // Update pattern when basis is updated
38
    template <class RowBasis, class ColBasis>
39
40
    void init(RowBasis const& rowBasis, ColBasis const& colBasis,
              SymmetryStructure symmetry = SymmetryStructure::unknown);
Praetorius, Simon's avatar
Praetorius, Simon committed
41
42

  private:
43
44
    std::vector<PetscInt> dnnz_; //< number of nonzeros in the diagonal part (owner part)
    std::vector<PetscInt> onnz_; //< number of nonzeros in the off-diagonal part (overlap part)
45
    SymmetryStructure symmetry_ = SymmetryStructure::unknown;
46
47
48
49
50

    // use a grid change index to decide whether to update the matrix pattern or not.
    unsigned long changeIndex_ = 0;
    bool initialized_ = false;

51
#if HAVE_MPI
52
    const Mpi::Tag tag_{916821}; //< Communication tag used internally
53
#endif
54
55
56
57
58
  };

} // end namespace AMDiS

#include <amdis/linearalgebra/petsc/MatrixNnzStructure.inc.hpp>