AMDiS 2.10
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
13namespace AMDiS
14{
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 static std::size_t surrounding
61 = Math::pow<GridView::dimension>(2) * Dune::factorial(int(GridView::dimension));
62
63 estRowSize_ = std::min(cols_, colBasis.localView().maxSize() * surrounding);
64 }
65
66 private:
67 std::size_t rows_;
68 std::size_t cols_;
69 std::size_t estRowSize_;
70 SymmetryStructure symmetry_;
71 };
72
73} // end namespace AMDiS
Definition: SlotSize.hpp:16
SymmetryStructure symmetry() const
Symmetry of the matrix entries.
Definition: SlotSize.hpp:47
std::size_t rows() const
Number of rows in the matrix.
Definition: SlotSize.hpp:29
std::size_t cols() const
Number of columns in the matrix.
Definition: SlotSize.hpp:35
std::size_t rowSizeEstimate() const
Estimate of the non-zeros per row.
Definition: SlotSize.hpp:41