Skip to content
Snippets Groups Projects
Commit 432e2a6e authored by Markus Blatt's avatar Markus Blatt
Browse files

Detect matrix rows where all offdiagonal entries are zero (such as Dirichlet

values) and update the left hand side x during pre such that A_dd*x_d=b_d.

[[Imported from SVN: r1709]]
parent 30b43062
No related branches found
No related tags found
No related merge requests found
......@@ -388,6 +388,35 @@ namespace Dune
template<class M, class X, class S, class PI, class A>
void AMG<M,X,S,PI,A>::pre(Domain& x, Range& b)
{
// Detect Matrix rows where all offdiagonal entries are
// zero and set x such that A_dd*x_d=b_d
// Thus users can be more careless when setting up their linear
// systems.
typedef typename M::matrix_type Matrix;
typedef typename Matrix::ConstRowIterator RowIter;
typedef typename Matrix::ConstColIterator ColIter;
typedef typename Matrix::block_type Block;
Block zero;
Block diagonal;
zero=typename Matrix::field_type();
const Matrix& mat=matrices_->matrices().finest()->getmat();
for(RowIter row=mat.begin(); row!=mat.end(); ++row) {
bool isDirichlet = true;
bool hasDiagonal = false;
for(ColIter col=row->begin(); col!=row->end(); ++col) {
if(row.index()==col.index()) {
diagonal = *col;
hasDiagonal = false;
}else{
if(*col!=zero)
isDirichlet = false;
}
}
if(isDirichlet)
diagonal.solve(x[row.index()], b[row.index()]);
}
if(smoothers_.levels()>0)
smoothers_.finest()->pre(x,b);
else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment