3 #ifndef DUNE_ISTL_NOVLPSCHWARZ_HH 4 #define DUNE_ISTL_NOVLPSCHWARZ_HH 13 #include <dune/common/timer.hh> 58 template<
class M,
class X,
class Y,
class C>
73 typedef typename C::PIS
PIS;
74 typedef typename C::RI
RI;
75 typedef typename RI::RemoteIndexList
RIL;
80 typedef std::multimap<int,int>
MM;
81 typedef std::multimap<int,std::pair<int,RILIterator> >
RIMap;
92 : _A_(A), communication(com), buildcomm(true)
96 virtual void apply (
const X& x, Y& y)
const 100 communication.addOwnerCopyToOwnerCopy(y,y);
111 communication.addOwnerCopyToOwnerCopy(y,y);
116 virtual const matrix_type&
getmat ()
const 124 const PIS& pis=communication.indexSet();
125 const RI& ri = communication.remoteIndices();
130 if (buildcomm ==
true) {
133 if (mask.size()!=
static_cast<typename std::vector<double>::size_type
>(x.size())) {
134 mask.resize(x.size());
135 for (
typename std::vector<double>::size_type i=0; i<mask.size(); i++)
137 for (
typename PIS::const_iterator i=pis.begin(); i!=pis.end(); ++i)
139 mask[i->local().local()] = 0;
141 mask[i->local().local()] = 2;
144 for (MM::iterator iter = bordercontribution.begin();
145 iter != bordercontribution.end(); ++iter)
146 bordercontribution.erase(iter);
147 std::map<int,int> owner;
152 for (RowIterator i = _A_.begin(); i != _A_.end(); ++i)
153 if (mask[i.index()] == 0)
154 for (RIIterator remote = ri.begin(); remote != ri.end(); ++remote) {
155 RIL& ril = *(remote->second.first);
156 for (RILIterator rindex = ril.begin(); rindex != ril.end(); ++rindex)
158 if (rindex->localIndexPair().local().local() == i.index()) {
160 (std::make_pair(i.index(),
161 std::pair<int,RILIterator>(remote->first, rindex)));
163 owner.insert(std::make_pair(i.index(),remote->first));
168 for (RowIterator i = _A_.begin(); i != _A_.end(); ++i) {
169 if (mask[i.index()] == 0) {
170 std::map<int,int>::iterator it = owner.find(i.index());
172 std::pair<RIMapit, RIMapit> foundiit = rimap.equal_range(i.index());
173 for (ColIterator j = _A_[i.index()].begin(); j != _A_[i.index()].end(); ++j) {
174 if (mask[j.index()] == 0) {
176 for (RIMapit foundi = foundiit.first; foundi != foundiit.second; ++foundi) {
177 std::pair<RIMapit, RIMapit> foundjit = rimap.equal_range(j.index());
178 for (RIMapit foundj = foundjit.first; foundj != foundjit.second; ++foundj)
179 if (foundj->second.first == foundi->second.first)
181 || foundj->second.first == iowner
182 || foundj->second.first < communication.communicator().rank()) {
197 bordercontribution.insert(std::pair<int,int>(i.index(),j.index()));
206 for (RowIterator i = _A_.begin(); i != _A_.end(); ++i) {
207 if (mask[i.index()] == 0) {
209 for (ColIterator j = _A_[i.index()].begin(); j != _A_[i.index()].end(); ++j) {
210 if (mask[j.index()] == 1)
211 (*j).usmv(alpha,x[j.index()],y[i.index()]);
212 else if (mask[j.index()] == 0) {
213 std::pair<MM::iterator, MM::iterator> itp =
214 bordercontribution.equal_range(i.index());
215 for (MM::iterator it = itp.first; it != itp.second; ++it)
216 if ((*it).second == (
int)j.index())
217 (*j).usmv(alpha,x[j.index()],y[i.index()]);
221 else if (mask[i.index()] == 1) {
222 for (ColIterator j = _A_[i.index()].begin(); j != _A_[i.index()].end(); ++j)
223 if (mask[j.index()] != 2)
224 (*j).usmv(alpha,x[j.index()],y[i.index()]);
236 const matrix_type& _A_;
237 const communication_type& communication;
238 mutable bool buildcomm;
239 mutable std::vector<double> mask;
240 mutable std::multimap<int,int> bordercontribution;
264 template<
class C,
class P>
284 : preconditioner(prec), communication(c)
292 virtual void pre (domain_type& x, range_type& b)
294 preconditioner.pre(x,b);
302 virtual void apply (domain_type& v,
const range_type& d)
307 preconditioner.apply(v,d);
308 communication.addOwnerCopyToOwnerCopy(v,v);
316 virtual void post (domain_type& x)
318 preconditioner.post(x);
332 const communication_type& communication;
Definition: allocator.hh:7
RI::const_iterator RIIterator
Definition: novlpschwarz.hh:76
Y range_type
The type of the range.
Definition: novlpschwarz.hh:67
void novlp_op_apply(const X &x, Y &y, field_type alpha) const
Definition: novlpschwarz.hh:121
virtual void apply(domain_type &v, const range_type &d)
Apply the preconditioner.
Definition: novlpschwarz.hh:302
Traits class for generically constructing non default constructable types.
Definition: novlpschwarz.hh:247
Some generic functions for pretty printing vectors and matrices.
Simple iterative methods like Jacobi, Gauss-Seidel, SOR, SSOR, etc. in a generic way.
virtual void post(domain_type &x)
Clean up.
Definition: novlpschwarz.hh:316
This file implements a vector space as a tensor product of a given vector space. The number of compon...
virtual void applyscaleadd(field_type alpha, const X &x, Y &y) const
apply operator to x, scale and add:
Definition: novlpschwarz.hh:104
Define base class for scalar product and norm.
Implementations of the inverse operator interface.
C::PIS PIS
Definition: novlpschwarz.hh:73
X domain_type
The type of the domain.
Definition: novlpschwarz.hh:65
Category for non-overlapping solvers.
Definition: solvercategory.hh:25
RIMap::iterator RIMapit
Definition: novlpschwarz.hh:82
virtual void apply(const X &x, Y &y) const
apply operator to x:
Definition: novlpschwarz.hh:96
virtual void pre(domain_type &x, range_type &b)
Prepare the preconditioner.
Definition: novlpschwarz.hh:292
RIL::const_iterator RILIterator
Definition: novlpschwarz.hh:77
virtual SolverCategory::Category category() const
Category of the linear operator (see SolverCategory::Category)
Definition: novlpschwarz.hh:230
Define general preconditioner interface.
Definition: owneroverlapcopy.hh:59
A nonoverlapping operator with communication object.
Definition: novlpschwarz.hh:59
Implementation of the BCRSMatrix class.
virtual SolverCategory::Category category() const
Category of the preconditioner (see SolverCategory::Category)
Definition: novlpschwarz.hh:322
M::ConstRowIterator RowIterator
Definition: novlpschwarz.hh:79
Define general, extensible interface for operators. The available implementation wraps a matrix...
P::domain_type domain_type
The domain type of the preconditioner.
Definition: novlpschwarz.hh:270
Nonoverlapping parallel preconditioner.
Definition: novlpschwarz.hh:265
NonoverlappingSchwarzOperator(const matrix_type &A, const communication_type &com)
constructor: just store a reference to a matrix.
Definition: novlpschwarz.hh:91
std::multimap< int, std::pair< int, RILIterator > > RIMap
Definition: novlpschwarz.hh:81
NonoverlappingBlockPreconditioner(P &prec, const communication_type &c)
Constructor.
Definition: novlpschwarz.hh:283
C communication_type
The type of the communication object.
Definition: novlpschwarz.hh:71
P::range_type range_type
The range type of the preconditioner.
Definition: novlpschwarz.hh:272
Definition: owneroverlapcopy.hh:59
std::multimap< int, int > MM
Definition: novlpschwarz.hh:80
A linear operator exporting itself in matrix form.
Definition: operators.hh:106
Category
Definition: solvercategory.hh:21
X::field_type field_type
The field type of the range.
Definition: novlpschwarz.hh:69
M matrix_type
The type of the matrix we operate on.
Definition: novlpschwarz.hh:63
virtual const matrix_type & getmat() const
get matrix via *
Definition: novlpschwarz.hh:116
Classes providing communication interfaces for overlapping Schwarz methods.
Definition: owneroverlapcopy.hh:59
C communication_type
The type of the communication object.
Definition: novlpschwarz.hh:274
M::ConstColIterator ColIterator
Definition: novlpschwarz.hh:78
Base class for matrix free definition of preconditioners.
Definition: preconditioner.hh:30
RI::RemoteIndexList RIL
Definition: novlpschwarz.hh:75
C::RI RI
Definition: novlpschwarz.hh:74