Skip to content
Snippets Groups Projects
Commit 5e948d3c authored by Max Kahnt's avatar Max Kahnt
Browse files

Improve readability (use C++11).

parent 9938b2c6
No related branches found
No related tags found
No related merge requests found
...@@ -16,19 +16,15 @@ void BlockGSStep<MatrixType, DiscFuncType, BitVectorType>:: ...@@ -16,19 +16,15 @@ void BlockGSStep<MatrixType, DiscFuncType, BitVectorType>::
residual(int index, VectorBlock& r) const residual(int index, VectorBlock& r) const
{ {
const MatrixType& mat = *this->mat_; const MatrixType& mat = *this->mat_;
const auto& row = mat[index];
typedef typename MatrixType::row_type RowType;
const RowType& row = mat[index];
typedef typename RowType::ConstIterator ColumnIterator;
r = (*this->rhs_)[index]; r = (*this->rhs_)[index];
/* The following loop subtracts /* The following loop subtracts
* \f[ sum_i = \sum_j A_{ij}w_j \f] * \f[ sum_i = \sum_j A_{ij}w_j \f]
*/ */
ColumnIterator cIt = row.begin(); auto cIt = row.begin();
ColumnIterator cEndIt = row.end(); auto cEndIt = row.end();
for (; cIt!=cEndIt; ++cIt) { for (; cIt!=cEndIt; ++cIt) {
// r_i -= A_ij x_j // r_i -= A_ij x_j
...@@ -64,14 +60,14 @@ void BlockGSStep<MatrixType, DiscFuncType, BitVectorType>::iterate_step(int i) ...@@ -64,14 +60,14 @@ void BlockGSStep<MatrixType, DiscFuncType, BitVectorType>::iterate_step(int i)
VectorBlock r; VectorBlock r;
residual(i, r); residual(i, r);
const auto& mat_ii = mat[i][i];
// Compute x_i += A_{i,i}^{-1} r[i] // Compute correction v = A_{i,i}^{-1} r[i]
VectorBlock v; VectorBlock v;
VectorBlock& x = (*this->x_)[i];
if (count == 0) { if (count == 0) {
// No degree of freedom shall be ignored --> solve linear problem // No degree of freedom shall be ignored --> solve linear problem
mat[i][i].solve(v, r); mat_ii.solve(v, r);
} else { } else {
// Copy the matrix and adjust rhs and matrix so that dofs given in ignoreNodes[i] // Copy the matrix and adjust rhs and matrix so that dofs given in ignoreNodes[i]
// are not touched // are not touched
...@@ -83,11 +79,12 @@ void BlockGSStep<MatrixType, DiscFuncType, BitVectorType>::iterate_step(int i) ...@@ -83,11 +79,12 @@ void BlockGSStep<MatrixType, DiscFuncType, BitVectorType>::iterate_step(int i)
for (int k = 0; k < BlockSize; ++k) for (int k = 0; k < BlockSize; ++k)
matRes[j][k] = (k == j); matRes[j][k] = (k == j);
} else } else
matRes[j] = mat[i][i][j]; matRes[j] = mat_ii[j];
} }
matRes.solve(v, r); matRes.solve(v, r);
} }
// Add correction; // Add correction
VectorBlock& x = (*this->x_)[i];
x += v; x += v;
} }
...@@ -20,7 +20,7 @@ template<class MatrixType, ...@@ -20,7 +20,7 @@ template<class MatrixType,
class BlockGSStep : public LinearIterationStep<MatrixType, DiscFuncType, BitVectorType> class BlockGSStep : public LinearIterationStep<MatrixType, DiscFuncType, BitVectorType>
{ {
typedef typename DiscFuncType::block_type VectorBlock; using VectorBlock = typename DiscFuncType::block_type;
enum {BlockSize = VectorBlock::dimension}; enum {BlockSize = VectorBlock::dimension};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment