3#ifndef DUNE_ISTL_NOVLPSCHWARZ_HH
4#define DUNE_ISTL_NOVLPSCHWARZ_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;
76 typedef typename RI::const_iterator RIIterator;
77 typedef typename RIL::const_iterator RILIterator;
78 typedef typename M::ConstColIterator ColIterator;
79 typedef typename M::ConstRowIterator RowIterator;
80 typedef std::multimap<int,int> MM;
81 typedef std::multimap<int,std::pair<int,RILIterator> > RIMap;
82 typedef typename RIMap::iterator RIMapit;
92 : _A_(A), communication(com), buildcomm(true)
96 virtual void apply (
const X& x, Y& y)
const
99 novlp_op_apply(x,y,1);
100 communication.addOwnerCopyToOwnerCopy(y,y);
110 novlp_op_apply(x,y,alpha);
111 communication.addOwnerCopyToOwnerCopy(y,y);
121 void novlp_op_apply (
const X& x, Y& y,
field_type alpha)
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)
138 if (i->local().attribute()==OwnerOverlapCopyAttributeSet::copy)
139 mask[i->local().local()] = 0;
140 else if (i->local().attribute()==OwnerOverlapCopyAttributeSet::overlap)
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)
157 if (rindex->attribute() != OwnerOverlapCopyAttributeSet::overlap)
158 if (rindex->localIndexPair().local().local() == i.index()) {
160 (std::make_pair(i.index(),
161 std::pair<int,RILIterator>(remote->first, rindex)));
162 if(rindex->attribute()==OwnerOverlapCopyAttributeSet::owner)
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)
180 if (foundj->second.second->attribute() == OwnerOverlapCopyAttributeSet::owner
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()]);
238 mutable bool buildcomm;
239 mutable std::vector<double> mask;
240 mutable std::multimap<int,int> bordercontribution;
247 template<
class T>
class ConstructionTraits;
264 template<
class C,
class P>
284 : preconditioner(prec), communication(c)
294 preconditioner.pre(x,b);
307 preconditioner.apply(v,d);
308 communication.addOwnerCopyToOwnerCopy(v,v);
318 preconditioner.post(x);
Implementation of the BCRSMatrix class.
This file implements a vector space as a tensor product of a given vector space. The number of compon...
Traits class for generically constructing non default constructable types.
Definition: construction.hh:38
A linear operator exporting itself in matrix form.
Definition: operators.hh:106
Nonoverlapping parallel preconditioner.
Definition: novlpschwarz.hh:266
virtual SolverCategory::Category category() const
Category of the preconditioner (see SolverCategory::Category)
Definition: novlpschwarz.hh:322
virtual void apply(domain_type &v, const range_type &d)
Apply the preconditioner.
Definition: novlpschwarz.hh:302
P::range_type range_type
The range type of the preconditioner.
Definition: novlpschwarz.hh:272
virtual void post(domain_type &x)
Clean up.
Definition: novlpschwarz.hh:316
C communication_type
The type of the communication object.
Definition: novlpschwarz.hh:274
NonoverlappingBlockPreconditioner(P &prec, const communication_type &c)
Constructor.
Definition: novlpschwarz.hh:283
virtual void pre(domain_type &x, range_type &b)
Prepare the preconditioner.
Definition: novlpschwarz.hh:292
P::domain_type domain_type
The domain type of the preconditioner.
Definition: novlpschwarz.hh:270
A nonoverlapping operator with communication object.
Definition: novlpschwarz.hh:60
C communication_type
The type of the communication object.
Definition: novlpschwarz.hh:71
virtual void apply(const X &x, Y &y) const
apply operator to x:
Definition: novlpschwarz.hh:96
X domain_type
The type of the domain.
Definition: novlpschwarz.hh:65
virtual SolverCategory::Category category() const
Category of the linear operator (see SolverCategory::Category)
Definition: novlpschwarz.hh:230
virtual const matrix_type & getmat() const
get matrix via *
Definition: novlpschwarz.hh:116
Y range_type
The type of the range.
Definition: novlpschwarz.hh:67
M matrix_type
The type of the matrix we operate on.
Definition: novlpschwarz.hh:63
virtual void applyscaleadd(field_type alpha, const X &x, Y &y) const
apply operator to x, scale and add:
Definition: novlpschwarz.hh:104
X::field_type field_type
The field type of the range.
Definition: novlpschwarz.hh:69
NonoverlappingSchwarzOperator(const matrix_type &A, const communication_type &com)
constructor: just store a reference to a matrix.
Definition: novlpschwarz.hh:91
Base class for matrix free definition of preconditioners.
Definition: preconditioner.hh:30
Simple iterative methods like Jacobi, Gauss-Seidel, SOR, SSOR, etc. in a generic way.
Some generic functions for pretty printing vectors and matrices.
Dune namespace.
Definition: alignedallocator.hh:10
Define general, extensible interface for operators. The available implementation wraps a matrix.
Classes providing communication interfaces for overlapping Schwarz methods.
Define general preconditioner interface.
Define base class for scalar product and norm.
Implementations of the inverse operator interface.
Category
Definition: solvercategory.hh:21
@ nonoverlapping
Category for non-overlapping solvers.
Definition: solvercategory.hh:25