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;
97 : _A_(A), communication(com), buildcomm(true)
101 virtual void apply (
const X& x, Y& y)
const
105 communication.addOwnerCopyToOwnerCopy(y,y);
116 communication.addOwnerCopyToOwnerCopy(y,y);
121 virtual const matrix_type&
getmat ()
const
129 const PIS& pis=communication.indexSet();
130 const RI& ri = communication.remoteIndices();
135 if (buildcomm ==
true) {
138 if (mask.size()!=
static_cast<typename std::vector<double>::size_type
>(x.size())) {
139 mask.resize(x.size());
140 for (
typename std::vector<double>::size_type i=0; i<mask.size(); i++)
142 for (
typename PIS::const_iterator i=pis.begin(); i!=pis.end(); ++i)
144 mask[i->local().local()] = 0;
146 mask[i->local().local()] = 2;
149 for (MM::iterator iter = bordercontribution.begin();
150 iter != bordercontribution.end(); ++iter)
151 bordercontribution.erase(iter);
152 std::map<int,int> owner;
157 for (RowIterator i = _A_.begin(); i != _A_.end(); ++i)
158 if (mask[i.index()] == 0)
159 for (RIIterator remote = ri.begin(); remote != ri.end(); ++remote) {
160 RIL& ril = *(remote->second.first);
161 for (RILIterator rindex = ril.begin(); rindex != ril.end(); ++rindex)
163 if (rindex->localIndexPair().local().local() == i.index()) {
165 (std::make_pair(i.index(),
166 std::pair<int,RILIterator>(remote->first, rindex)));
168 owner.insert(std::make_pair(i.index(),remote->first));
173 for (RowIterator i = _A_.begin(); i != _A_.end(); ++i) {
174 if (mask[i.index()] == 0) {
175 std::map<int,int>::iterator it = owner.find(i.index());
177 std::pair<RIMapit, RIMapit> foundiit = rimap.equal_range(i.index());
178 for (ColIterator j = _A_[i.index()].begin(); j != _A_[i.index()].end(); ++j) {
179 if (mask[j.index()] == 0) {
181 for (RIMapit foundi = foundiit.first; foundi != foundiit.second; ++foundi) {
182 std::pair<RIMapit, RIMapit> foundjit = rimap.equal_range(j.index());
183 for (RIMapit foundj = foundjit.first; foundj != foundjit.second; ++foundj)
184 if (foundj->second.first == foundi->second.first)
186 || foundj->second.first == iowner
187 || foundj->second.first < communication.communicator().rank()) {
202 bordercontribution.insert(std::pair<int,int>(i.index(),j.index()));
211 for (RowIterator i = _A_.begin(); i != _A_.end(); ++i) {
212 if (mask[i.index()] == 0) {
214 for (ColIterator j = _A_[i.index()].begin(); j != _A_[i.index()].end(); ++j) {
215 if (mask[j.index()] == 1)
216 (*j).usmv(alpha,x[j.index()],y[i.index()]);
217 else if (mask[j.index()] == 0) {
218 std::pair<MM::iterator, MM::iterator> itp =
219 bordercontribution.equal_range(i.index());
220 for (MM::iterator it = itp.first; it != itp.second; ++it)
221 if ((*it).second == (
int)j.index())
222 (*j).usmv(alpha,x[j.index()],y[i.index()]);
226 else if (mask[i.index()] == 1) {
227 for (ColIterator j = _A_[i.index()].begin(); j != _A_[i.index()].end(); ++j)
228 if (mask[j.index()] != 2)
229 (*j).usmv(alpha,x[j.index()],y[i.index()]);
235 const matrix_type& _A_;
236 const communication_type& communication;
237 mutable bool buildcomm;
238 mutable std::vector<double> mask;
239 mutable std::multimap<int,int> bordercontribution;
253 template<
class X,
class C>
279 virtual field_type
dot (
const X& x,
const X& y)
282 communication.dot(x,y,result);
289 virtual double norm (
const X& x)
291 return communication.norm(x);
298 communication.copyOwnerToAll(x,x);
302 const communication_type& communication;
305 template<
class X,
class C>
318 static ScalarProduct*
construct(
const communication_type& comm)
320 return new ScalarProduct(comm);
338 template<
class C,
class P>
364 : preconditioner(prec), communication(c)
372 virtual void pre (domain_type& x, range_type& b)
374 preconditioner.pre(x,b);
382 virtual void apply (domain_type& v,
const range_type& d)
387 preconditioner.apply(v,d);
388 communication.addOwnerCopyToOwnerCopy(v,v);
396 virtual void post (domain_type& x)
398 preconditioner.post(x);
406 const communication_type& communication;
X domain_type
The type of the domain.
Definition: novlpschwarz.hh:65
C communication_type
The type of the communication object to use.
Definition: novlpschwarz.hh:311
Nonoverlapping Scalar Product with communication object.
Definition: novlpschwarz.hh:254
Definition: owneroverlapcopy.hh:60
Base class for scalar product and norm computation.
Definition: scalarproducts.hh:43
C communication_type
The type of the communication object.
Definition: novlpschwarz.hh:348
Implementation of the BCRSMatrix class.
Definition: basearray.hh:19
std::multimap< int, int > MM
Definition: novlpschwarz.hh:80
Define base class for scalar product and norm.
This file implements a vector space as a tensor product of a given vector space. The number of compon...
Y range_type
The type of the range.
Definition: novlpschwarz.hh:67
Some generic functions for pretty printing vectors and matrices.
virtual field_type dot(const X &x, const X &y)
Dot product of two vectors. It is assumed that the vectors are consistent on the interior+border part...
Definition: novlpschwarz.hh:279
A nonoverlapping operator with communication object.
Definition: novlpschwarz.hh:59
std::multimap< int, std::pair< int, RILIterator > > RIMap
Definition: novlpschwarz.hh:81
virtual void apply(domain_type &v, const range_type &d)
Apply the preconditioner.
Definition: novlpschwarz.hh:382
C communication_type
The type of the communication object.
Definition: novlpschwarz.hh:262
virtual double norm(const X &x)
Norm of a right-hand side vector. The vector must be consistent on the interior+border partition...
Definition: novlpschwarz.hh:289
NonoverlappingSchwarzScalarProduct< X, C > ScalarProduct
The type of the scalar product for the nonoverlapping case.
Definition: novlpschwarz.hh:309
Definition: owneroverlapcopy.hh:60
Categories for the solvers.
Definition: solvercategory.hh:17
Matrix & A
Definition: matrixmatrix.hh:216
RI::RemoteIndexList RIL
Definition: novlpschwarz.hh:75
NonoverlappingBlockPreconditioner(P &prec, const communication_type &c)
Constructor.
Definition: novlpschwarz.hh:363
Define general, extensible interface for operators. The available implementation wraps a matrix...
RIMap::iterator RIMapit
Definition: novlpschwarz.hh:82
C::PIS PIS
Definition: novlpschwarz.hh:73
X::field_type field_type
The field type of the range.
Definition: novlpschwarz.hh:69
virtual void post(domain_type &x)
Clean up.
Definition: novlpschwarz.hh:396
Traits class for generically constructing non default constructable types.
Definition: novlpschwarz.hh:326
The solver category.
Definition: scalarproducts.hh:82
RI::const_iterator RIIterator
Definition: novlpschwarz.hh:76
Base class for matrix free definition of preconditioners.
Definition: preconditioner.hh:26
The category the preconditioner is part of.
Definition: novlpschwarz.hh:353
P::range_type range_type
The range type of the preconditioner.
Definition: novlpschwarz.hh:346
void make_consistent(X &x) const
make additive vector consistent
Definition: novlpschwarz.hh:296
M::ConstRowIterator RowIterator
Definition: novlpschwarz.hh:79
M matrix_type
The type of the matrix we operate on.
Definition: novlpschwarz.hh:63
virtual void apply(const X &x, Y &y) const
apply operator to x:
Definition: novlpschwarz.hh:101
Definition: novlpschwarz.hh:265
Category for on overlapping solvers.
Definition: solvercategory.hh:23
C communication_type
The type of the communication object.
Definition: novlpschwarz.hh:71
NonoverlappingSchwarzScalarProduct(const communication_type &com)
Constructor.
Definition: novlpschwarz.hh:271
X domain_type
The type of the domain.
Definition: novlpschwarz.hh:258
static ScalarProduct * construct(const communication_type &comm)
Definition: novlpschwarz.hh:318
Choose the approriate scalar product for a solver category.
Definition: scalarproducts.hh:75
P::domain_type domain_type
The domain type of the preconditioner.
Definition: novlpschwarz.hh:344
virtual const matrix_type & getmat() const
get matrix via *
Definition: novlpschwarz.hh:121
RIL::const_iterator RILIterator
Definition: novlpschwarz.hh:77
virtual void pre(domain_type &x, range_type &b)
Prepare the preconditioner.
Definition: novlpschwarz.hh:372
The solver category.
Definition: novlpschwarz.hh:86
void novlp_op_apply(const X &x, Y &y, field_type alpha) const
Definition: novlpschwarz.hh:126
virtual void applyscaleadd(field_type alpha, const X &x, Y &y) const
apply operator to x, scale and add:
Definition: novlpschwarz.hh:109
NonoverlappingSchwarzOperator(const matrix_type &A, const communication_type &com)
constructor: just store a reference to a matrix.
Definition: novlpschwarz.hh:96
Classes providing communication interfaces for overlapping Schwarz methods.
X::field_type field_type
The type of the range.
Definition: novlpschwarz.hh:260
C::RI RI
Definition: novlpschwarz.hh:74
Define general preconditioner interface.
M::ConstColIterator ColIterator
Definition: novlpschwarz.hh:78
Definition: owneroverlapcopy.hh:60
Nonoverlapping parallel preconditioner.
Definition: novlpschwarz.hh:339
A linear operator exporting itself in matrix form.
Definition: operators.hh:94
Simple iterative methods like Jacobi, Gauss-Seidel, SOR, SSOR, etc. in a generic way.
Implementations of the inverse operator interface.