00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef _LSSYSTEM_H_
00032 #define _LSSYSTEM_H_
00033
00034 #include <MatSparse.h>
00035 #include <GenMatrix.h>
00036 #include <UCBtypedef.h>
00037
00038 #include <map>
00039
00040 #include <boost/shared_ptr.hpp>
00041
00074 class LSsystem {
00075 friend class MGsystem;
00076
00077
00078
00079 MatSparse A_;
00080 boost::shared_ptr<GenMatrix<UCBspl_real> > x_;
00081 GenMatrix<UCBspl_real> b_;
00082
00083 int n1_, n2_;
00084 int K_, L_;
00085
00086 double lambda_;
00087 double lambdaFac_;
00088
00089
00090 boost::shared_ptr<std::vector<double> > U_;
00091 boost::shared_ptr<std::vector<double> > V_;
00092 boost::shared_ptr<std::vector<double> > Zvals_;
00093 boost::shared_ptr<std::map<int, double, std::less<int> > > weights_;
00094
00095
00096 std::vector<double> domain_;
00097
00098
00099 void calculateDomain();
00100 double umin() const {return domain_[0];}
00101 double vmin() const {return domain_[1];}
00102 double umax() const {return domain_[2];}
00103 double vmax() const {return domain_[3];}
00104 void buildSparseStructure();
00105 void addSmoothingTerm(double lambdaVal);
00106 void setLimits();
00107 void calcLambda();
00108
00109 void buildRHS();
00110
00111 void residual(GenMatrix<UCBspl_real>& r) const;
00112
00113 public:
00114
00123 LSsystem(boost::shared_ptr<std::vector<double> > U,
00124 boost::shared_ptr<std::vector<double> > V,
00125 boost::shared_ptr<std::vector<double> > Zvals,
00126 int noX, int noY,
00127 boost::shared_ptr<GenMatrix<UCBspl_real> > PHI,
00128 double smoothingFac = 1.0);
00129
00130 ~LSsystem(){}
00131
00132 void setWeights(boost::shared_ptr<std::map<int, double, std::less<int> > > weights) {weights_ = weights;}
00133
00137 void buildEqSystem(bool buildRHS = true);
00138
00140 void relaxGaussSeidel(int noIterations);
00141
00143 void relaxCG(int noIterations);
00144
00146 void relaxCGPrecond(int noIterations);
00147
00149 void relaxJacobi(int noIterations, double omega=2./3.);
00150
00163 void setDomain(double umin, double vmin, double umax, double vmax);
00164
00166 void getDomain(double& umin, double& vmin, double& umax, double& vmax);
00167
00169 int numberOfUnknowns() const {return x_->noX() * x_->noY();}
00170
00180 void setSmoothingFactor(double smoothingFac);
00181
00189 bool addPoint(double u, double v, double z, double weight=1.0, bool addToRHS=true);
00190
00192 double currentSolutionNorm() const;
00193
00195 double residual_l2(bool scaled=false) const;
00197 double residual_linf() const;
00198
00199 static double rowMatVecMult(int row_no, const MatSparse& A, const GenMatrix<UCBspl_real>& x);
00200 };
00201
00202 #endif
00203