FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
sparse_layout.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
8// includes, FEAT
10#include <kernel/util/memory_arbiter.hpp>
11#include <kernel/lafem/forward.hpp>
12#include <kernel/lafem/base.hpp>
13
14#include <vector>
15
16namespace FEAT
17{
18 namespace LAFEM
19 {
21 namespace Intern
22 {
23 template <SparseLayoutId LT_>
24 struct LayoutId;
25
26 template <>
27 struct LayoutId<SparseLayoutId::lt_csr>
28 {
29 template<typename DT_, typename IT_>
30 using MatrixType = SparseMatrixCSR<DT_, IT_>;
31 };
32
33 template <>
34 struct LayoutId<SparseLayoutId::lt_cscr>
35 {
36 template<typename DT_, typename IT_>
37 using MatrixType = SparseMatrixCSCR<DT_, IT_>;
38 };
39
40 template <>
41 struct LayoutId<SparseLayoutId::lt_banded>
42 {
43 template<typename DT_, typename IT_>
44 using MatrixType = SparseMatrixBanded<DT_, IT_>;
45 };
46
47 } // namespace Intern
49
63 template <typename IT_, SparseLayoutId Layout_>
65 {
66 public:
67 std::vector<Memory::Arbiter> _indices;
68 std::vector<Index> _indices_size;
69 std::vector<Index> _scalar_index;
70
71 template<typename DT_>
72 using MatrixType = typename Intern::LayoutId<Layout_>::template MatrixType<DT_, IT_>;
73
74 SparseLayout() :
75 _indices(),
76 _indices_size(),
77 _scalar_index()
78 {
79 }
80
81 explicit SparseLayout(const std::vector<Memory::Arbiter> & indices, const std::vector<Index> & indices_size, const std::vector<Index> & scalar_index) :
82 _indices(),
83 _indices_size(indices_size),
84 _scalar_index(scalar_index)
85 {
86 for(const auto& idx : indices)
87 this->_indices.push_back(idx.attach());
88 }
89
92 _indices(std::move(other._indices)),
93 _indices_size(std::move(other._indices_size)),
94 _scalar_index(std::move(other._scalar_index))
95 {
96 }
97
99 virtual ~SparseLayout()
100 {
101 }
102
105 {
106 _indices = std::move(other._indices);
107 _indices_size = std::move(other._indices_size);
108 _scalar_index = std::move(other._scalar_index);
109
110 return *this;
111 }
112
118 const std::vector<Memory::Arbiter> & get_indices() const
119 {
120 return _indices;
121 }
122
128 const std::vector<Index> & get_indices_size() const
129 {
130 return _indices_size;
131 }
132
138 const std::vector<Index> & get_scalar_index() const
139 {
140 return _scalar_index;
141 }
142 };
143 } // namespace LAFEM
144} // namespace FEAT
FEAT Kernel base header.
Layout scheme for sparse matrix containers.
virtual ~SparseLayout()
virtual destructor
SparseLayout & operator=(SparseLayout &&other)
move operator=
SparseLayout(SparseLayout &&other)
move constructor
const std::vector< Index > & get_indices_size() const
Returns a list of all Index array sizes.
const std::vector< Index > & get_scalar_index() const
Returns a list of all scalar values with datatype index.
const std::vector< Memory::Arbiter > & get_indices() const
Returns a list of all Index arrays.
LAFEM common type definitions.
SparseLayoutId
Definition: base.hpp:63
FEAT namespace.
Definition: adjactor.hpp:12