3#ifndef DUNE_ISTL_ILUSUBDOMAINSOLVER_HH
4#define DUNE_ISTL_ILUSUBDOMAINSOLVER_HH
32 template<
class M,
class X,
class Y>
48 virtual void apply (X& v,
const Y& d) =0;
73 template<
class M,
class X,
class Y>
79 typedef typename std::remove_const<M>::type rilu_type;
106 template<
class M,
class X,
class Y>
107 class ILUNSubdomainSolver
108 :
public ILUSubdomainSolver<M,X,Y>{
111 typedef typename std::remove_const<M>::type matrix_type;
112 typedef typename std::remove_const<M>::type rilu_type;
114 typedef X domain_type;
116 typedef Y range_type;
122 void apply (X& v,
const Y& d)
135 void setSubMatrix(
const M& A, S& rowset);
146 template<
class M,
class X,
class Y>
152 typedef typename M::size_type size_type;
153 typedef std::map<typename S::value_type,size_type> IndexMap;
154 typedef typename IndexMap::iterator IMIter;
156 IMIter guess = indexMap.begin();
157 size_type localIndex=0;
159 typedef typename S::const_iterator SIter;
160 for(SIter rowIdx = rowSet.begin(), rowEnd=rowSet.end();
161 rowIdx!= rowEnd; ++rowIdx, ++localIndex)
162 guess = indexMap.insert(guess,
163 std::make_pair(*rowIdx,localIndex));
167 ILU.setSize(rowSet.size(),rowSet.size());
168 ILU.setBuildMode(matrix_type::row_wise);
171 typedef typename matrix_type::CreateIterator CIter;
172 CIter rowCreator = ILU.createbegin();
173 std::size_t offset=0;
174 for(SIter rowIdx = rowSet.begin(), rowEnd=rowSet.end();
175 rowIdx!= rowEnd; ++rowIdx, ++rowCreator) {
178 guess = indexMap.begin();
180 for(
typename matrix_type::ConstColIterator col=A[*rowIdx].begin(),
181 endcol=A[*rowIdx].end(); col != endcol; ++col) {
183 guess = indexMap.find(col.index());
184 if(guess!=indexMap.end()) {
186 rowCreator.insert(guess->second);
187 offset=std::max(offset,(std::size_t)std::abs((
int)(guess->second-rowCreator.index())));
194 typename matrix_type::iterator iluRow=ILU.begin();
196 for(SIter rowIdx = rowSet.begin(), rowEnd=rowSet.end();
197 rowIdx!= rowEnd; ++rowIdx, ++iluRow) {
200 typename matrix_type::ColIterator localCol=iluRow->begin();
201 for(
typename matrix_type::ConstColIterator col=A[*rowIdx].begin(),
202 endcol=A[*rowIdx].end(); col != endcol; ++col) {
204 guess = indexMap.find(col.index());
205 if(guess!=indexMap.end()) {
216 template<
class M,
class X,
class Y>
220 this->copyToLocalMatrix(A,rowSet);
224 template<
class M,
class X,
class Y>
226 void ILUNSubdomainSolver<M,X,Y>::setSubMatrix(
const M& A, S& rowSet)
228 std::size_t offset=copyToLocalMatrix(A,rowSet);
229 RILU.setSize(rowSet.size(),rowSet.size(), (1+2*offset)*rowSet.size());
230 RILU.setBuildMode(matrix_type::row_wise);
Exact subdomain solver using ILU(p) with appropriate p.
Definition: ilusubdomainsolver.hh:75
X domain_type
The domain type of the preconditioner.
Definition: ilusubdomainsolver.hh:81
Y range_type
The range type of the preconditioner.
Definition: ilusubdomainsolver.hh:83
std::remove_const< M >::type matrix_type
The matrix type the preconditioner is for.
Definition: ilusubdomainsolver.hh:78
void apply(X &v, const Y &d)
Apply the subdomain solver.
Definition: ilusubdomainsolver.hh:90
base class encapsulating common algorithms of ILU0SubdomainSolver and ILUNSubdomainSolver.
Definition: ilusubdomainsolver.hh:33
matrix_type ILU
The ILU0 decomposition of the matrix, or the local matrix.
Definition: ilusubdomainsolver.hh:64
X domain_type
The domain type of the preconditioner.
Definition: ilusubdomainsolver.hh:38
Y range_type
The range type of the preconditioner.
Definition: ilusubdomainsolver.hh:40
std::remove_const< M >::type matrix_type
The matrix type the preconditioner is for.
Definition: ilusubdomainsolver.hh:36
virtual void apply(X &v, const Y &d)=0
Apply the subdomain solver.
void bilu_backsolve(const M &A, X &v, const Y &d)
LU backsolve with stored inverse.
Definition: ilu.hh:96
void bilu_decomposition(const M &A, int n, M &ILU)
Definition: ilu.hh:156
void bilu0_decomposition(M &A)
compute ILU decomposition of A. A is overwritten by its decomposition
Definition: ilu.hh:35
std::size_t copyToLocalMatrix(const M &A, S &rowset)
Copy the local part of the global matrix to ILU.
Definition: ilusubdomainsolver.hh:148
void setSubMatrix(const M &A, S &rowset)
Set the data of the local problem.
Definition: ilusubdomainsolver.hh:218
A dynamic dense block matrix class.
Dune namespace.
Definition: alignment.hh:11
Traits for type conversions and type information.