Dune-Fufem 2.11-git
Loading...
Searching...
No Matches
matrixbuilder.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3
4// SPDX-FileCopyrightText: Copyright © DUNE-FUFEM Project contributors, see file AUTHORS.md
5// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
6
7#ifndef DUNE_FUFEM_BACKENDS_MATRIXBUILDER_HH
8#define DUNE_FUFEM_BACKENDS_MATRIXBUILDER_HH
9
10#ifndef DUNE_FUFEM_DISABLE_HEADER_DEPRECATION
11#warning This header is deprecated and will be removed after 2.11. Use the ISTLMatrixBackend::PatternBuilder from dune-assembler instead.
12#endif
13
24#include <array>
25#include <vector>
26
29
30#include <dune/istl/matrix.hh>
35
36namespace Dune::Fufem {
37
38
39
50template<class Matrix>
51class
53
54
55
66template<class T, class A>
67class
68[[deprecated("This class is deprecated and will be removed after 2.11. Use the ISTLMatrixBackend::PatternBuilder from dune-assembler instead.")]]
70{
71public:
72
74
76 matrix_(matrix)
77 {}
78
79 template<class RowSizeInfo, class ColSizeInfo>
80 void resize(const RowSizeInfo& rowSizeInfo, const ColSizeInfo& colSizeInfo)
81 {
82 indices_.resize(rowSizeInfo.size(), colSizeInfo.size());
83 }
84
85 template<class RowIndex, class ColIndex>
86 void insertEntry(const RowIndex& rowIndex, const ColIndex& colIndex)
87 {
88 indices_.add(rowIndex[0], colIndex[0]);
89 }
90
92 {
93 indices_.exportIdx(matrix_);
94 }
95
96private:
97 Dune::MatrixIndexSet indices_;
98 Matrix& matrix_;
99};
100
101
102
113template<class Row0, class... Rows>
114class
115[[deprecated("This class is deprecated and will be removed after 2.11. Use the ISTLMatrixBackend::PatternBuilder from dune-assembler instead.")]]
117{
118public:
119
120 using Matrix = MultiTypeBlockMatrix<Row0,Rows...>;
121
123 matrix_(matrix)
124 {}
125
126 template<class RowSizeInfo, class ColSizeInfo>
127 void resize(const RowSizeInfo& rowSizeInfo, const ColSizeInfo& colSizeInfo)
128 {
129 for(size_t i=0; i<rowBlocks_; i++)
130 for(size_t j=0; j<colBlocks_; j++)
131 indices_[i][j].resize(rowSizeInfo.size({i}), colSizeInfo.size({j}));
132 }
133
134 template<class RowIndex, class ColIndex>
135 void insertEntry(const RowIndex& rowIndex, const ColIndex& colIndex)
136 {
137 indices_[rowIndex[0]][colIndex[0]].add(rowIndex[1], colIndex[1]);
138 }
139
141 {
144 indices_[i][j].exportIdx(matrix_[i][j]);
145 });
146 });
147
148 }
149
150private:
152 static constexpr size_t rowBlocks_ = Matrix::N();
154 static constexpr size_t colBlocks_ = Matrix::M();
157 Matrix& matrix_;
158};
159
160
167template<class T, class A>
168class
169[[deprecated("This class is deprecated and will be removed after 2.11. Use the ISTLMatrixBackend::PatternBuilder from dune-assembler instead.")]]
171{
172public:
173
175
177 matrix_(matrix)
178 {}
179
180 template<class RowSizeInfo, class ColSizeInfo>
181 void resize(const RowSizeInfo& rowSizeInfo, const ColSizeInfo& colSizeInfo)
182 {
183 auto rowBlocks = rowSizeInfo.size();
184 auto colBlocks = colSizeInfo.size();
185 indices_.resize(rowBlocks);
186 for(size_t i=0; i<rowBlocks; i++)
187 {
188 indices_[i].resize(colBlocks);
189 for(size_t j=0; j<colBlocks; j++)
190 indices_[i][j].resize(rowSizeInfo.size({i}), colSizeInfo.size({j}));
191 }
192 }
193
194 template<class RowIndex, class ColIndex>
195 void insertEntry(const RowIndex& rowIndex, const ColIndex& colIndex)
196 {
197 indices_[rowIndex[0]][colIndex[0]].add(rowIndex[1], colIndex[1]);
198 }
199
201 {
202 auto rowBlocks = indices_.size();
203 auto colBlocks = indices_[0].size();
204 matrix_.setSize(rowBlocks, colBlocks);
205 for(size_t i=0; i<rowBlocks; i++)
206 for(size_t j=0; j<colBlocks; j++)
207 indices_[i][j].exportIdx(matrix_[i][j]);
208 }
209
210private:
212 Matrix& matrix_;
213};
214
215
216
217} // namespace Dune::Fufem
218
219
220
221#endif // DUNE_FUFEM_BACKENDS_MATRIXBUILDER_HH
constexpr void forEach(Range &&range, F &&f)
constexpr auto integralRange(const Begin &begin, const End &end)
size_type rowIndex() const
Definition dunefunctionsboundaryfunctionalassembler.hh:29
size_type M() const
size_type N() const
Helper class for building matrix pattern.
Definition matrixbuilder.hh:51
void resize(const RowSizeInfo &rowSizeInfo, const ColSizeInfo &colSizeInfo)
Definition matrixbuilder.hh:80
MatrixBuilder(Matrix &matrix)
Definition matrixbuilder.hh:75
void setupMatrix()
Definition matrixbuilder.hh:91
void insertEntry(const RowIndex &rowIndex, const ColIndex &colIndex)
Definition matrixbuilder.hh:86
void insertEntry(const RowIndex &rowIndex, const ColIndex &colIndex)
Definition matrixbuilder.hh:135
MatrixBuilder(Matrix &matrix)
Definition matrixbuilder.hh:122
void resize(const RowSizeInfo &rowSizeInfo, const ColSizeInfo &colSizeInfo)
Definition matrixbuilder.hh:127
MatrixBuilder(Matrix &matrix)
Definition matrixbuilder.hh:176
void resize(const RowSizeInfo &rowSizeInfo, const ColSizeInfo &colSizeInfo)
Definition matrixbuilder.hh:181
void insertEntry(const RowIndex &rowIndex, const ColIndex &colIndex)
Definition matrixbuilder.hh:195