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_pool.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<IT_*> _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 SparseLayout(const std::vector<IT_ *> & indices, const std::vector<Index> & indices_size, const std::vector<Index> & scalar_index) :
82 _indices(indices),
83 _indices_size(indices_size),
84 _scalar_index(scalar_index)
85 {
86 for(auto i : this->_indices)
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 for(auto i : this->_indices)
103 }
104
107 {
108 _indices = std::move(other._indices);
109 _indices_size = std::move(other._indices_size);
110 _scalar_index = std::move(other._scalar_index);
111
112 return *this;
113 }
114
120 const std::vector<IT_*> & get_indices() const
121 {
122 return _indices;
123 }
124
130 const std::vector<Index> & get_indices_size() const
131 {
132 return _indices_size;
133 }
134
140 const std::vector<Index> & get_scalar_index() const
141 {
142 return _scalar_index;
143 }
144 };
145 } // namespace LAFEM
146} // 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< IT_ * > & get_indices() const
Returns a list of all Index arrays.
static void release_memory(void *address)
release memory or decrease reference counter
static void increase_memory(void *address)
increase memory counter
LAFEM common type definitions.
SparseLayoutId
Definition: base.hpp:63
FEAT namespace.
Definition: adjactor.hpp:12