00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011
00012
00013
00014
00015 #ifndef _LINEARSOLVER_H_
00016 #define _LINEARSOLVER_H_
00017
00018 #include "REAL.H"
00019 #include "Box.H"
00020 #include <cmath>
00021 #include "NamespaceHeader.H"
00022
00024
00027 template <class T>
00028 class LinearOp
00029 {
00030 public:
00032 virtual ~LinearOp(){;}
00033
00035
00039 virtual void residual( T& a_lhs, const T& a_phi, const T& a_rhs, bool a_homogeneous = false) = 0;
00040
00042
00045 virtual void preCond( T& a_cor, const T& a_residual) = 0;
00046
00048
00052 virtual void applyOp( T& a_lhs, const T& a_phi, bool a_homogeneous = false) = 0;
00053
00055
00059 virtual void create( T& a_lhs, const T& a_rhs) = 0;
00060
00061
00063
00069 virtual void clear(T& a_lhs) {;}
00070
00071
00073
00076 virtual void assign( T& a_lhs, const T& a_rhs) = 0;
00077
00078 virtual void assignLocal(T& a_lhs, const T& a_rhs)
00079 {
00080 this->assign(a_lhs, a_rhs);
00081 }
00083
00087 virtual Real dotProduct(const T& a_1, const T& a_2) = 0;
00088
00090
00093 virtual void incr ( T& a_lhs, const T& a_x, Real a_scale) = 0;
00094
00096
00099 virtual void axby( T& a_lhs, const T& a_x, const T& a_y, Real a_a, Real a_b) = 0;
00100
00102
00105 virtual void scale( T& a_lhs, const Real& a_scale) = 0;
00106
00108
00112 virtual Real norm(const T& a_rhs, int a_ord) = 0;
00113
00115
00118 virtual void setToZero(T& a_lhs) = 0;
00119
00121
00125 virtual void write(const T* a, const char* filename)
00126 {
00127 MayDay::Warning("LinearOp::write not implemented");
00128 }
00129
00130 };
00131
00133
00136 template <class T>
00137 class LinearSolver
00138 {
00139 public:
00140 virtual ~LinearSolver(){;}
00141
00143
00146 virtual void setHomogeneous(bool a_homogeneous) = 0;
00147
00149
00158 virtual void define(LinearOp<T>* a_operator, bool a_homogeneous = false) = 0;
00159
00161
00164 virtual void solve(T& a_phi, const T& a_rhs) = 0;
00165
00166
00168
00172 virtual void setConvergenceMetrics(Real a_metric, Real a_tolerance) {;};
00173 };
00174
00175 #include "NamespaceFooter.H"
00176 #endif