Dune-Fufem 2.11-git
Loading...
Searching...
No Matches
lumpmatrix.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © DUNE-FUFEM Project contributors, see file AUTHORS.md
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
3
4#ifndef DUNE_LUMP_MATRIX_HH
5#define DUNE_LUMP_MATRIX_HH
6
12#include <dune/istl/bdmatrix.hh>
13
15 template <class BlockType>
18 {
19 if (inMatrix.N() != inMatrix.M())
20 DUNE_THROW(Dune::ISTLError, "Can only lump quadratic matrices!");
21
22 typedef typename Dune::BCRSMatrix<BlockType>::row_type RowType;
23 typedef typename RowType::ConstIterator ColumnIterator;
24
25 // resize out matrix
26 //outMatrix.resize(inMatrix.N());
27 outMatrix = Dune::BDMatrix<BlockType>(inMatrix.N());
28
29 for (size_t i=0; i<inMatrix.N(); i++) {
30
31 outMatrix[i] = 0;
32
33 const RowType& row = inMatrix[i];
34
35 ColumnIterator cIt = row.begin();
36 ColumnIterator cEndIt = row.end();
37
38 for (; cIt!=cEndIt; ++cIt)
39 outMatrix[i][i] += *cIt;
40
41 }
42
43 }
44
45#endif
void lumpMatrix(const Dune::BCRSMatrix< BlockType > &inMatrix, Dune::BDMatrix< BlockType > &outMatrix)
Lump a sparse matrix.
Definition lumpmatrix.hh:16
#define DUNE_THROW(E,...)
Iterator begin()
Imp::CompressedBlockVectorWindow< B, size_type > row_type
size_type M() const
size_type N() const