AMDiS  0.3
The Adaptive Multi-Dimensional Simulation Toolbox
SlotSize.hpp
1 #pragma once
2 
3 #include <algorithm>
4 #include <cassert>
5 
6 #include <dune/common/math.hh>
7 
8 #include <amdis/Observer.hpp>
9 #include <amdis/common/Index.hpp>
10 #include <amdis/common/Math.hpp>
11 #include <amdis/linearalgebra/SymmetryStructure.hpp>
12 
13 namespace AMDiS
14 {
15  class SlotSize
16  {
17  public:
18  template <class RowBasis, class ColBasis>
19  SlotSize(RowBasis const& rowBasis, ColBasis const& colBasis,
20  SymmetryStructure symmetry = SymmetryStructure::unknown)
21  : rows_(rowBasis.dimension())
22  , cols_(colBasis.dimension())
23  , symmetry_(symmetry)
24  {
25  init(rowBasis, colBasis);
26  }
27 
29  std::size_t rows() const
30  {
31  return rows_;
32  }
33 
35  std::size_t cols() const
36  {
37  return cols_;
38  }
39 
41  std::size_t rowSizeEstimate() const
42  {
43  return estRowSize_;
44  }
45 
47  SymmetryStructure symmetry() const
48  {
49  return symmetry_;
50  }
51 
52  protected:
53  // estimate the number of columns by multiplying the maximal node size with the
54  // number of element surrounding a vertex. This number is approximated by the
55  // number of simplices surrounding a vertex in a kuhn triangulation
56  template <class RowBasis, class ColBasis>
57  void init(RowBasis const& rowBasis, ColBasis const& colBasis)
58  {
59  using GridView = typename RowBasis::GridView;
60  // TODO(FM): Simplify using Dune::factorial with 2.7
61  static std::size_t surrounding
62  = Math::pow<GridView::dimension>(2) * Dune::Factorial<int(GridView::dimension)>::factorial;
63 
64  estRowSize_ = std::min(cols_, colBasis.localView().maxSize() * surrounding);
65  }
66 
67  private:
68  std::size_t rows_;
69  std::size_t cols_;
70  std::size_t estRowSize_;
71  SymmetryStructure symmetry_;
72  };
73 
74 } // end namespace AMDiS
std::size_t rowSizeEstimate() const
Estimate of the non-zeros per row.
Definition: SlotSize.hpp:41
Contains all classes needed for solving linear and non linear equation systems.
Definition: AdaptBase.hpp:6
std::size_t cols() const
Number of columns in the matrix.
Definition: SlotSize.hpp:35
std::size_t rows() const
Number of rows in the matrix.
Definition: SlotSize.hpp:29
SymmetryStructure symmetry() const
Symmetry of the matrix entries.
Definition: SlotSize.hpp:47
Definition: SlotSize.hpp:15