3#ifndef DUNE_ISTL_ILUSUBDOMAINSOLVER_HH
4#define DUNE_ISTL_ILUSUBDOMAINSOLVER_HH
33 template<
class M,
class X,
class Y>
49 virtual void apply (X& v,
const Y& d) =0;
74 template<
class M,
class X,
class Y>
80 typedef typename std::remove_const<M>::type rilu_type;
93 ILU::blockILUBacksolve(this->
ILU,v,d);
107 template<
class M,
class X,
class Y>
108 class ILUNSubdomainSolver
109 :
public ILUSubdomainSolver<M,X,Y>{
112 typedef typename std::remove_const<M>::type matrix_type;
113 typedef typename std::remove_const<M>::type rilu_type;
115 typedef X domain_type;
117 typedef Y range_type;
123 void apply (X& v,
const Y& d)
125 ILU::blockILUBacksolve(RILU,v,d);
136 void setSubMatrix(
const M& A, S& rowset);
147 template<
class M,
class X,
class Y>
153 typedef typename M::size_type size_type;
154 typedef std::map<typename S::value_type,size_type> IndexMap;
155 typedef typename IndexMap::iterator IMIter;
157 IMIter guess = indexMap.begin();
158 size_type localIndex=0;
160 typedef typename S::const_iterator SIter;
161 for(SIter rowIdx = rowSet.begin(), rowEnd=rowSet.end();
162 rowIdx!= rowEnd; ++rowIdx, ++localIndex)
163 guess = indexMap.insert(guess,
164 std::make_pair(*rowIdx,localIndex));
168 ILU.setSize(rowSet.size(),rowSet.size());
169 ILU.setBuildMode(matrix_type::row_wise);
172 typedef typename matrix_type::CreateIterator CIter;
173 CIter rowCreator = ILU.createbegin();
174 std::size_t offset=0;
175 for(SIter rowIdx = rowSet.begin(), rowEnd=rowSet.end();
176 rowIdx!= rowEnd; ++rowIdx, ++rowCreator) {
179 guess = indexMap.begin();
181 for(
typename matrix_type::ConstColIterator col=A[*rowIdx].begin(),
182 endcol=A[*rowIdx].end(); col != endcol; ++col) {
184 guess = indexMap.find(col.index());
185 if(guess!=indexMap.end()) {
187 rowCreator.insert(guess->second);
188 offset=
std::max(offset,(std::size_t)std::abs((
int)(guess->second-rowCreator.index())));
195 typename matrix_type::iterator iluRow=ILU.begin();
197 for(SIter rowIdx = rowSet.begin(), rowEnd=rowSet.end();
198 rowIdx!= rowEnd; ++rowIdx, ++iluRow) {
201 typename matrix_type::ColIterator localCol=iluRow->begin();
202 for(
typename matrix_type::ConstColIterator col=A[*rowIdx].begin(),
203 endcol=A[*rowIdx].end(); col != endcol; ++col) {
205 guess = indexMap.find(col.index());
206 if(guess!=indexMap.end()) {
217 template<
class M,
class X,
class Y>
221 this->copyToLocalMatrix(A,rowSet);
222 ILU::blockILU0Decomposition(this->ILU);
225 template<
class M,
class X,
class Y>
227 void ILUNSubdomainSolver<M,X,Y>::setSubMatrix(
const M& A, S& rowSet)
229 std::size_t offset=copyToLocalMatrix(A,rowSet);
230 RILU.setSize(rowSet.size(),rowSet.size(), (1+2*offset)*rowSet.size());
231 RILU.setBuildMode(matrix_type::row_wise);
232 ILU::blockILUDecomposition(this->ILU, (offset+1)/2, RILU);
Exact subdomain solver using ILU(p) with appropriate p.
Definition: ilusubdomainsolver.hh:76
X domain_type
The domain type of the preconditioner.
Definition: ilusubdomainsolver.hh:82
Y range_type
The range type of the preconditioner.
Definition: ilusubdomainsolver.hh:84
std::remove_const< M >::type matrix_type
The matrix type the preconditioner is for.
Definition: ilusubdomainsolver.hh:79
void apply(X &v, const Y &d)
Apply the subdomain solver.
Definition: ilusubdomainsolver.hh:91
base class encapsulating common algorithms of ILU0SubdomainSolver and ILUNSubdomainSolver.
Definition: ilusubdomainsolver.hh:34
matrix_type ILU
The ILU0 decomposition of the matrix, or the local matrix.
Definition: ilusubdomainsolver.hh:65
X domain_type
The domain type of the preconditioner.
Definition: ilusubdomainsolver.hh:39
Y range_type
The range type of the preconditioner.
Definition: ilusubdomainsolver.hh:41
std::remove_const< M >::type matrix_type
The matrix type the preconditioner is for.
Definition: ilusubdomainsolver.hh:37
virtual void apply(X &v, const Y &d)=0
Apply the subdomain solver.
Traits for type conversions and type information.
std::size_t copyToLocalMatrix(const M &A, S &rowset)
Copy the local part of the global matrix to ILU.
Definition: ilusubdomainsolver.hh:149
void setSubMatrix(const M &A, S &rowset)
Set the data of the local problem.
Definition: ilusubdomainsolver.hh:219
auto max(ADLTag< 0 >, const V &v1, const V &v2)
implements binary Simd::max()
Definition: defaults.hh:79
A dynamic dense block matrix class.
Dune namespace.
Definition: alignedallocator.hh:11
Define general preconditioner interface.