stdmultilevelsolver.h

Go to the documentation of this file.
00001 #ifndef  __StdMultiLevelSolver_h
00002 #define  __StdMultiLevelSolver_h
00003 
00004 #include  "multilevelsolverinterface.h"
00005 #include  "stdmultilevelsolverdata.h"
00006 #include  "problemdescriptorinterface.h"
00007 #include  "problemcontainer.h"
00008 #include  "functionalcontainer.h"
00009 #include  "monitor.h"
00010 #include  "stopwatch.h"
00011 #include  "mginterpolatorinterface.h"
00012 
00013 /*-------------------------------------------------------------*/
00014 
00015 namespace Gascoigne
00016 {
00017 
00022 
00028 
00029 class StdMultiLevelSolver : public virtual MultiLevelSolverInterface
00030 {
00031   private :
00032 
00033   std::vector<SolverInterface*>  _SP;
00034   const MeshAgentInterface* _MAP;
00035   std::vector<MgInterpolatorInterface*>   _Interpolator;
00036 
00037   protected :
00038 
00039   const MeshAgentInterface* GetMeshAgent() const {return _MAP;}
00040   std::vector<SolverInterface*>& GetSolverPointers() { return _SP; }
00041   const std::vector<SolverInterface*>& GetSolverPointers() const { return _SP; }
00042 
00043 
00044   mutable VectorInterface _cor, _res, _mg0, _mg1;
00045 
00046   mutable StopWatch   _clock_residual, _clock_solve;
00047 
00048   mutable int ComputeLevel;
00049   mutable int oldnlevels;
00050 
00051   const ParamFile*  _paramfile;
00052 
00053   Monitor*                          MON;
00054   StdMultiLevelSolverData*          DataP;
00055   const ProblemDescriptorInterface*      _PD;
00056   const ProblemContainer*                _PC;
00057   const FunctionalContainer*             _FC;
00058   
00059   virtual void NewSolvers();
00060 
00061   virtual SolverInterface* NewSolver(int solverlevel);
00062   virtual void NewMgInterpolator();
00063   virtual void SolverNewMesh();
00064 
00065   virtual const ProblemDescriptorInterface* GetProblemDescriptor() const { return _PD;}
00066 
00067   virtual void SetProblemContainer(const ProblemContainer* PC)       { _PC=PC;     }
00068   virtual const FunctionalContainer* GetFunctionalContainer()  const { return _FC; }
00069   virtual void SetFunctionalContainer(const FunctionalContainer* FC) { _FC=FC;     }
00070 
00071   const DoubleVector GetExactValues() const;
00072   const DoubleVector ComputeFunctionals(VectorInterface& f, const VectorInterface& u) const;
00073   
00074   virtual SolverInterface*& GetSolverPointer(int l) {assert(l<_SP.size()); return _SP[l];}
00075   virtual void SetComputeLevel(int level) {ComputeLevel=level;}
00076 
00077   virtual double NewtonNorm(const VectorInterface& u) const {
00078     return GetSolver(ComputeLevel)->NewtonNorm(u);
00079   }
00080   virtual void mgstep(std::vector<double>& res, std::vector<double>& rw, int l, int maxl, int minl, std::string& p0, std::string p, VectorInterface& u, VectorInterface& b, VectorInterface& v);
00081 
00082   virtual void Cg   (VectorInterface& x, const VectorInterface& f, CGInfo& info);
00083   virtual void Gmres(VectorInterface& x, const VectorInterface& f, CGInfo& info);
00084 
00085   virtual void ViewProtocoll() const;
00086 
00087   virtual void SolutionTransfer(int high, int low, VectorInterface& u) const;
00088   virtual void Transfer(int high, int low, VectorInterface& u) const;
00089 
00090  public:
00091 
00092   // Constructor
00093 
00094   StdMultiLevelSolver();
00095   ~StdMultiLevelSolver();
00096 
00097   std::string GetName() const {return "StdMultiLevelSolver";}
00098 
00099   void RegisterVectors();
00100   void RegisterMatrix();
00101   void ReInitMatrix();
00102   void ReInitVector(VectorInterface& v);
00103   void ReInitVector(VectorInterface& v, int comp);
00104 
00105   void BasicInit(const MeshAgentInterface* GMGM, const ParamFile* paramfile,
00106                  const ProblemContainer* PC,
00107                  const FunctionalContainer* FC=NULL);
00108 
00109   // Zugriff
00110 
00111 //  virtual void SetState(const std::string& s) {
00112 //    for(int l=0;l<_SP.size();l++) _SP[l]->SetState(s);
00113 //  }
00114 
00115   virtual const ProblemContainer* GetProblemContainer()        const { assert(_PC); return _PC; }
00116 
00117 
00118   int nlevels()                 const { assert(GetMeshAgent()); return GetMeshAgent()->nlevels();}
00119   virtual int FinestLevel  ()  const { return nlevels()-1;}
00120   virtual int CoarsestLevel()  const { return 0;}
00121   
00122   SolverInterface* GetSolver(int l) {assert(l<_SP.size()); return _SP[l];}
00123   const SolverInterface* GetSolver(int l) const {assert(l<_SP.size()); return _SP[l];}
00124   SolverInterface* GetSolver() {assert(_SP.size()==nlevels()); return _SP[FinestLevel()];}
00125   const SolverInterface* GetSolver() const {assert(_SP.size()==nlevels()); return _SP[FinestLevel()];}
00126 
00127   void SetMonitorPtr(Monitor* mon) { MON = mon;}
00128 
00129   void ReInit(const std::string& problemlabel);
00130   void SetProblem(const std::string& label);
00131 
00132   // neue vektoren
00133 
00134   std::string LinearSolve(int level, VectorInterface& u, const VectorInterface& b, CGInfo& info);
00135   std::string Solve(int level, VectorInterface& x, const VectorInterface& b, NLInfo& nlinfo);
00136   void InterpolateSolution(VectorInterface& u, const GlobalVector& uold) const;
00137   void InterpolateCellSolution(VectorInterface& u, const GlobalVector& uold) const;
00138 
00139   virtual void NewtonVectorZero(VectorInterface& w) const;
00140   virtual double NewtonResidual(VectorInterface& y, const VectorInterface& x, const VectorInterface& b) const;
00141   virtual double NewtonUpdate(double& rr, VectorInterface& x, VectorInterface& dx, VectorInterface& r, const VectorInterface& f, NLInfo& nlinfo);
00142   virtual void NewtonLinearSolve(VectorInterface& x, const VectorInterface& b, CGInfo& info);
00143   virtual void NewtonMatrixControl(VectorInterface& u, NLInfo& nlinfo);
00144   virtual void NewtonOutput(NLInfo& nlinfo) const;
00145   virtual void NewtonPreProcess(VectorInterface& u, const VectorInterface& f,NLInfo& info) const;
00146   virtual void NewtonPostProcess(VectorInterface& u, const VectorInterface& f,NLInfo& info) const;
00147 
00148 
00149   void AssembleMatrix(VectorInterface& u, NLInfo& nlinfo);
00150   void AssembleMatrix(VectorInterface& u);
00152   void ComputeIlu(VectorInterface& u);
00153   void ComputeIlu();
00154   
00155   void BoundaryInit(VectorInterface& u) const;
00156 
00157   virtual void SolutionTransfer(VectorInterface& u) const;
00158   virtual void Transfer(VectorInterface& u) const;
00159 
00160   
00161   void vmulteq(VectorInterface& y, const VectorInterface&  x) const;
00162   
00163   virtual void LinearMg(int minlevel, int maxlevel, VectorInterface& u, const VectorInterface& f, CGInfo&);
00164 
00165   double ComputeFunctional(VectorInterface& f, const VectorInterface& u, const std::string& label) const;
00166   
00167   void AssembleDualMatrix(VectorInterface& u);
00168 
00169   // fuer gmres
00170   
00171   virtual void precondition(VectorInterface& x, VectorInterface& y);
00172   virtual void DeleteVector(VectorInterface& p);
00173   virtual void Equ(VectorInterface& dst, double s, const VectorInterface& src)const;
00174   void Zero(VectorInterface& dst)const;
00175 
00176   void AddNodeVector(const std::string& name, VectorInterface& q);
00177   void DeleteNodeVector(const std::string& q);
00178 
00179   void newton(VectorInterface& u, const VectorInterface& f, VectorInterface& r, VectorInterface& w, NLInfo& info);
00180 };
00181 }
00182 
00183 #endif
00184 
00185 

Generated on Thu Sep 14 10:34:38 2006 for Gascoigne by  doxygen 1.4.7