Dune Core Modules (2.6.0)

schwarz.hh
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_ISTL_SCHWARZ_HH
4 #define DUNE_ISTL_SCHWARZ_HH
5 
6 #include <iostream> // for input/output to shell
7 #include <fstream> // for input/output to files
8 #include <vector> // STL vector class
9 #include <sstream>
10 
11 #include <cmath> // Yes, we do some math here
12 
13 #include <dune/common/timer.hh>
14 
15 #include "io.hh"
16 #include "bvector.hh"
17 #include "vbvector.hh"
18 #include "bcrsmatrix.hh"
19 #include "io.hh"
20 #include "gsetc.hh"
21 #include "ilu.hh"
22 #include "operators.hh"
23 #include "solvers.hh"
24 #include "preconditioners.hh"
25 #include "scalarproducts.hh"
26 #include "owneroverlapcopy.hh"
27 
28 namespace Dune {
29 
74  template<class M, class X, class Y, class C>
76  {
77  public:
82  typedef M matrix_type;
87  typedef X domain_type;
92  typedef Y range_type;
94  typedef typename X::field_type field_type;
99  typedef C communication_type;
100 
109  : _A_(A), communication(com)
110  {}
111 
113  virtual void apply (const X& x, Y& y) const
114  {
115  y = 0;
116  _A_.umv(x,y); // result is consistent on interior+border
117  communication.project(y); // we want this here to avoid it before the preconditioner
118  // since there d is const!
119  }
120 
122  virtual void applyscaleadd (field_type alpha, const X& x, Y& y) const
123  {
124  _A_.usmv(alpha,x,y); // result is consistent on interior+border
125  communication.project(y); // we want this here to avoid it before the preconditioner
126  // since there d is const!
127  }
128 
130  virtual const matrix_type& getmat () const
131  {
132  return _A_;
133  }
134 
137  {
139  }
140 
141  private:
142  const matrix_type& _A_;
143  const communication_type& communication;
144  };
145 
148  /*
149  * @addtogroup ISTL_Prec
150  * @{
151  */
165  template<class M, class X, class Y, class C>
166  class ParSSOR : public Preconditioner<X,Y> {
167  public:
169  typedef M matrix_type;
171  typedef X domain_type;
173  typedef Y range_type;
175  typedef typename X::field_type field_type;
178 
188  ParSSOR (const matrix_type& A, int n, field_type w, const communication_type& c)
189  : _A_(A), _n(n), _w(w), communication(c)
190  { }
191 
197  virtual void pre (X& x, Y& b)
198  {
199  communication.copyOwnerToAll(x,x); // make dirichlet values consistent
200  }
201 
207  virtual void apply (X& v, const Y& d)
208  {
209  for (int i=0; i<_n; i++) {
210  bsorf(_A_,v,d,_w);
211  bsorb(_A_,v,d,_w);
212  }
213  communication.copyOwnerToAll(v,v);
214  }
215 
221  virtual void post (X& x) {}
222 
225  {
227  }
228 
229  private:
231  const matrix_type& _A_;
233  int _n;
235  field_type _w;
237  const communication_type& communication;
238  };
239 
240  namespace Amg
241  {
242  template<class T> class ConstructionTraits;
243  }
244 
268  template<class X, class Y, class C, class T=Preconditioner<X,Y> >
269  class BlockPreconditioner : public Preconditioner<X,Y> {
270  friend class Amg::ConstructionTraits<BlockPreconditioner<X,Y,C,T> >;
271  public:
276  typedef X domain_type;
281  typedef Y range_type;
283  typedef typename X::field_type field_type;
289 
298  : preconditioner(p), communication(c)
299  { }
300 
306  virtual void pre (X& x, Y& b)
307  {
308  communication.copyOwnerToAll(x,x); // make dirichlet values consistent
309  preconditioner.pre(x,b);
310  }
311 
317  virtual void apply (X& v, const Y& d)
318  {
319  preconditioner.apply(v,d);
320  communication.copyOwnerToAll(v,v);
321  }
322 
323  template<bool forward>
324  void apply (X& v, const Y& d)
325  {
326  preconditioner.template apply<forward>(v,d);
327  communication.copyOwnerToAll(v,v);
328  }
329 
335  virtual void post (X& x)
336  {
337  preconditioner.post(x);
338  }
339 
342  {
344  }
345 
346  private:
348  T& preconditioner;
349 
351  const communication_type& communication;
352  };
353 
356 } // end namespace
357 
358 #endif
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
Block parallel preconditioner.
Definition: schwarz.hh:269
X domain_type
The domain type of the preconditioner.
Definition: schwarz.hh:276
virtual SolverCategory::Category category() const
Category of the preconditioner (see SolverCategory::Category)
Definition: schwarz.hh:341
Y range_type
The range type of the preconditioner.
Definition: schwarz.hh:281
BlockPreconditioner(T &p, const communication_type &c)
Constructor.
Definition: schwarz.hh:297
C communication_type
The type of the communication object..
Definition: schwarz.hh:288
virtual void post(X &x)
Clean up.
Definition: schwarz.hh:335
void apply(X &v, const Y &d)
Apply one step of the preconditioner to the system A(v)=d.
Definition: schwarz.hh:324
virtual void pre(X &x, Y &b)
Prepare the preconditioner.
Definition: schwarz.hh:306
X::field_type field_type
The field type of the preconditioner.
Definition: schwarz.hh:283
virtual void apply(X &v, const Y &d)
Apply the preconditioner.
Definition: schwarz.hh:317
X::field_type field_type
The field type of the operator.
Definition: operators.hh:71
An overlapping schwarz operator.
Definition: schwarz.hh:76
virtual const matrix_type & getmat() const
get the sequential assembled linear operator.
Definition: schwarz.hh:130
virtual void applyscaleadd(field_type alpha, const X &x, Y &y) const
apply operator to x, scale and add:
Definition: schwarz.hh:122
virtual void apply(const X &x, Y &y) const
apply operator to x:
Definition: schwarz.hh:113
C communication_type
The type of the communication object.
Definition: schwarz.hh:99
X domain_type
The type of the domain.
Definition: schwarz.hh:87
M matrix_type
The type of the matrix we operate on.
Definition: schwarz.hh:82
Y range_type
The type of the range.
Definition: schwarz.hh:92
X::field_type field_type
The field type of the range.
Definition: schwarz.hh:94
OverlappingSchwarzOperator(const matrix_type &A, const communication_type &com)
constructor: just store a reference to a matrix.
Definition: schwarz.hh:108
virtual SolverCategory::Category category() const
Category of the linear operator (see SolverCategory::Category)
Definition: schwarz.hh:136
A parallel SSOR preconditioner.
Definition: schwarz.hh:166
X::field_type field_type
The field type of the preconditioner.
Definition: schwarz.hh:175
C communication_type
The type of the communication object.
Definition: schwarz.hh:177
virtual SolverCategory::Category category() const
Category of the preconditioner (see SolverCategory::Category)
Definition: schwarz.hh:224
ParSSOR(const matrix_type &A, int n, field_type w, const communication_type &c)
Constructor.
Definition: schwarz.hh:188
virtual void post(X &x)
Clean up.
Definition: schwarz.hh:221
X domain_type
The domain type of the preconditioner.
Definition: schwarz.hh:171
Y range_type
The range type of the preconditioner.
Definition: schwarz.hh:173
M matrix_type
The matrix type the preconditioner is for.
Definition: schwarz.hh:169
virtual void apply(X &v, const Y &d)
Apply the precondtioner.
Definition: schwarz.hh:207
virtual void pre(X &x, Y &b)
Prepare the preconditioner.
Definition: schwarz.hh:197
Base class for matrix free definition of preconditioners.
Definition: preconditioner.hh:30
X::field_type field_type
The field type of the preconditioner.
Definition: preconditioner.hh:37
void bsorb(const M &A, X &x, const Y &b, const K &w)
SSOR step.
Definition: gsetc.hh:591
void bsorf(const M &A, X &x, const Y &b, const K &w)
SOR step.
Definition: gsetc.hh:579
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
@ overlapping
Category for overlapping solvers.
Definition: solvercategory.hh:27
A simple timing class.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 5, 22:29, 2024)