AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
MatrixNnzStructure.hpp
1#pragma once
2
3#include <algorithm>
4#include <vector>
5
6#include <amdis/common/Index.hpp>
7#include <amdis/linearalgebra/SymmetryStructure.hpp>
8#include <amdis/linearalgebra/petsc/IndexDistribution.hpp>
9
10#if HAVE_MPI
11#include <amdis/common/parallel/Communicator.hpp>
12#endif
13
14namespace AMDiS
15{
18 {
19 public:
20 template <class RowBasis, class ColBasis>
21 MatrixNnzStructure(RowBasis const& rowBasis, ColBasis const& colBasis,
22 SymmetryStructure symmetry = SymmetryStructure::unknown)
23 : symmetry_(symmetry)
24 {
25 init(rowBasis, rowBasis.indexDistribution(), colBasis, colBasis.indexDistribution());
26 }
27
28 // Return Number of nonzeros in the diagonal part (owner part)
29 std::vector<PetscInt> const& d_nnz() const
30 {
31 return dnnz_;
32 }
33
35 std::vector<PetscInt> const& o_nnz() const
36 {
37 return onnz_;
38 }
39
41 SymmetryStructure symmetry() const
42 {
43 return symmetry_;
44 }
45
46 protected:
47 // Create local pattern from bases
48 template <class RowBasis, class ColBasis, class LI>
49 void init(RowBasis const& rowBasis, PetscSequentialIndexDistribution<LI> const& rowDofMap,
50 ColBasis const& colBasis, PetscSequentialIndexDistribution<LI> const& colDofMap);
51
52 // Create distributed pattern from bases
53 template <class RowBasis, class ColBasis, class GID, class LI>
54 void init(RowBasis const& rowBasis, PetscParallelIndexDistribution<GID,LI> const& rowDofMap,
55 ColBasis const& colBasis, PetscParallelIndexDistribution<GID,LI> const& colDofMap);
56 private:
57 std::vector<PetscInt> dnnz_; //< number of nonzeros in the diagonal part (owner part)
58 std::vector<PetscInt> onnz_; //< number of nonzeros in the off-diagonal part (overlap part)
59 SymmetryStructure symmetry_;
60
61#if HAVE_MPI
62 const Mpi::Tag tag_{916821}; //< Communication tag used internally
63#endif
64 };
65
66} // end namespace AMDiS
67
68#include <amdis/linearalgebra/petsc/MatrixNnzStructure.inc.hpp>
Sparsity pattern used to create PETSc matrices.
Definition: MatrixNnzStructure.hpp:18
SymmetryStructure symmetry() const
Symmetry of the matrix entries.
Definition: MatrixNnzStructure.hpp:41
std::vector< PetscInt > const & o_nnz() const
Return Number of nonzeros in the off-diagonal part (overlap part)
Definition: MatrixNnzStructure.hpp:35
Fallback for PetscParallelIndexDistribution in case there is only one mpi core.
Definition: IndexDistribution.hpp:33