operators.hh

Go to the documentation of this file.
00001 #ifndef DUNE_ISTLOPERATORS_HH
00002 #define DUNE_ISTLOPERATORS_HH
00003 
00004 #include<cmath>
00005 #include<complex>
00006 #include<iostream>
00007 #include<iomanip>
00008 #include<string>
00009 
00010 #include"solvercategory.hh"
00011 
00012 
00013 namespace Dune {
00014    
00037   //=====================================================================
00038   // Abstract operator interface
00039   //=====================================================================
00040 
00041 
00059   template<class X, class Y>
00060   class LinearOperator {
00061   public:
00063         typedef X domain_type;
00065         typedef Y range_type;
00067         typedef typename X::field_type field_type;
00068 
00073         virtual void apply (const X& x, Y& y) const = 0;
00074 
00076         virtual void applyscaleadd (field_type alpha, const X& x, Y& y) const = 0;
00077 
00079         virtual ~LinearOperator () {}
00080   };
00081 
00082 
00091   template<class M, class X, class Y>
00092   class AssembledLinearOperator : public LinearOperator<X,Y> {
00093   public:
00095         typedef M matrix_type;
00096         typedef X domain_type;
00097         typedef Y range_type;
00098         typedef typename X::field_type field_type;
00099 
00101         virtual const M& getmat () const = 0;
00102 
00104         virtual ~AssembledLinearOperator () {}
00105   };
00106 
00107 
00108 
00109   //=====================================================================
00110   // Implementation for ISTL-matrix based operator
00111   //=====================================================================
00112 
00118   template<class M, class X, class Y>
00119   class MatrixAdapter : public AssembledLinearOperator<M,X,Y>
00120   {
00121   public:
00123         typedef M matrix_type;
00124         typedef X domain_type;
00125         typedef Y range_type;
00126         typedef typename X::field_type field_type;
00127 
00129         enum {category=SolverCategory::sequential};
00130 
00132         MatrixAdapter (const M& A) : _A_(A) {}
00133 
00135         virtual void apply (const X& x, Y& y) const
00136         {
00137           _A_.mv(x,y);
00138         }
00139 
00141         virtual void applyscaleadd (field_type alpha, const X& x, Y& y) const
00142         {
00143           _A_.usmv(alpha,x,y);
00144         }
00145 
00147         virtual const M& getmat () const
00148         {
00149           return _A_;
00150         }
00151 
00152   private:
00153         const M& _A_;
00154   };
00155 
00158 } // end namespace
00159 
00160 #endif

Generated on 6 Nov 2008 with Doxygen (ver 1.5.6) [logfile].