stdsolver.h

Go to the documentation of this file.
00001 #ifndef  __StdSolver_h
00002 #define  __StdSolver_h
00003 
00004 #include  "gascoigne.h"
00005 #include  "solverinterface.h"
00006 #include  "gascoignemesh.h"
00007 #include  "solverdata.h"
00008 #include  "ghostvectoragent.h"
00009 #include  "multigridmeshinterface.h"
00010 #include  "pointfunctional.h"
00011 #include  "residualfunctional.h"
00012 #include  "stopwatch.h"
00013 #include  "hierarchicalmesh.h"
00014 #include  "pressurefilter.h"
00015 #include  "domainfunction.h"
00016 
00017 /*-----------------------------------------*/
00018 
00019 namespace Gascoigne
00020 {
00021 
00026 
00030 
00031 class StdSolver : public virtual SolverInterface
00032 {
00033   private:
00034 
00035   //
00036   //   Daten 
00037   //
00038 
00039   // 1. Gitter
00040 
00041   const MeshInterface*    _MP;
00042   const HierarchicalMesh* _HM;
00043 
00044   // 2. Matrizen
00045 
00046   MatrixInterface*  _MAP;
00047   IluInterface*     _MIP;
00048   
00049  protected:
00050 
00051 
00052   // 3. Discretization
00053 
00054   DiscretizationInterface*    _ZP;
00055 
00056   // 4. Vektoren
00057 
00058   mutable GhostVectorAgent _NGVA;
00059 
00060   // 5. Anwendungsklassen
00061 
00062   const ProblemDescriptorInterface*      _PDX;
00063 
00064   // 6. Steuerparameter
00065 
00066   bool                _distribute;
00067   int                 _mylevel;
00068 
00069   mutable int         _ndirect;
00070   mutable bool        _directsolver;
00071   mutable std::string _discname;
00072   mutable std::string _matrixtype;
00073 
00074   SolverData          _Dat;
00075   mutable int         _PrimalSolve;
00076   const ParamFile*    _paramfile;
00077 
00078   bool _useUMFPACK;
00079 
00080   // 5. sonstiges
00081   
00082   PressureFilter       _PF;
00083 /*   double               omega_domain; */
00084 
00085   mutable StopWatch    _vm, _il, _so, _ca, _ci, _cs, _re;
00086 
00087   //
00088   //        Funktionen
00089   //
00090 
00091   // 0. Zugriff
00092 
00093   const MeshInterface*& GetMeshPointer() {return _MP;}
00094   
00095   // 0.3 Matrizen
00096 
00097   MatrixInterface* GetMatrix() const { return _MAP;}
00098   MatrixInterface*& GetMatrixPointer() {return _MAP;}
00099 
00100   IluInterface* GetIlu() const {assert(_MIP); return _MIP;}
00101   IluInterface*& GetIluPointer() { return _MIP;}
00102   
00103   virtual DiscretizationInterface*& GetDiscretizationPointer() {return _ZP;}
00104 
00105   // 1. Initialisierung 
00106         
00107         void SetDefaultValues(std::string discname, std::string matrixtype, int ndirect);
00108 
00109   virtual DiscretizationInterface* NewDiscretization(int dimension, const std::string& discname);
00110 
00111   virtual MatrixInterface* NewMatrix(int ncomp, const std::string& matrixtype); 
00112   virtual IluInterface* NewIlu(int ncomp, const std::string& matrixtype); 
00113 
00114   //
00116   //
00117 
00118   virtual void smooth(int niter, VectorInterface& x, const VectorInterface& y, VectorInterface& h) const;
00119   virtual void PermutateIlu(const VectorInterface& gu) const;
00120   virtual void modify_ilu(IluInterface& I,int ncomp) const;
00121 
00122   virtual DoubleVector IntegrateSolutionVector(const VectorInterface& u) const;
00123   virtual void _check_consistency(const Equation* EQ, const DiscretizationInterface* DI) const;
00124   virtual void DirichletMatrixOnlyRow() const;
00125 
00126  public:
00127 
00128   StdSolver();
00129   ~StdSolver();
00130 
00131   std::string GetName() const {return "StdSolver";}
00132 
00133   void BasicInit(int level, const ParamFile* paramfile, const int dimension);
00134   void SetProblem(const ProblemDescriptorInterface& PDX);
00135   void SetDiscretization(DiscretizationInterface& DI, bool init=false);
00136   const ProblemDescriptorInterface* GetProblemDescriptor() const {assert(_PDX); return _PDX;}
00137   const ParamFile* GetParamfile() const { return _paramfile;}
00138 
00139   void NewMesh(int l, const MeshInterface* MP);
00140 
00141   const MeshInterface* GetMesh() const {return _MP;}
00142 
00143   // 0.2 Discretization
00144 
00145   const DiscretizationInterface* GetDiscretization() const {assert(_ZP); return _ZP;}
00146   DiscretizationInterface* GetDiscretization() {assert(_ZP); return _ZP;}
00147 
00148   void ReInitMatrix();
00149 
00150   virtual double clock_vmult() const {return _vm.read();}
00151   virtual double clock_ilu  () const {return _il.read();}
00152   virtual double clock_solve() const {return _so.read();}
00153   virtual double clock_computematrix() const {return _ca.read();}
00154   virtual double clock_computeilu   () const {return _ci.read();}
00155   virtual double clock_computesolver() const {return _cs.read();}
00156   virtual double clock_residual     () const {return _re.read();}
00157 
00158   bool DirectSolver() const {return _directsolver;}
00159 
00160   void AddNodeVector(const std::string& name, const VectorInterface& q) {
00161     assert(q.GetType()=="node");
00162     GetDiscretization()->AddNodeVector(name,&GetGV(q));
00163   }
00164   void AddCellVector(const std::string& name, const VectorInterface& q) {
00165     assert(q.GetType()=="cell");
00166     GetDiscretization()->AddCellVector(name,&GetGV(q));
00167   }
00168   void AddParameterVector(const std::string& name, const GlobalParameterVector* q) {
00169     GetDiscretization()->AddParameterVector(name,q);
00170   }
00171   void DeleteNodeVector(const std::string& name)  {
00172     GetDiscretization()->DeleteNodeVector(name);
00173   }
00174   void DeleteCellVector(const std::string& name) {
00175     GetDiscretization()->DeleteCellVector(name);
00176   }
00177   void DeleteParameterVector(const std::string& name) {
00178     GetDiscretization()->DeleteParameterVector(name);
00179   }
00180 
00181   void OutputSettings() const;
00182   virtual void PointVisu(const std::string& name, const GlobalVector& u, int i) const;
00183   virtual void CellVisu(const std::string& name, const GlobalVector& u, int i) const;
00184 
00185   void ConstructInterpolator(MgInterpolatorInterface* I, const MeshTransferInterface* MT);
00186   void VisuGrid(const std::string& name, int i) const;
00187   
00188   //
00190   //
00191     
00192   void RegisterMatrix();
00193   void RegisterVector(const VectorInterface& g);
00194   void ReInitVector(VectorInterface& dst);
00195   void ReInitVector(VectorInterface& dst, int comp);
00196 
00197         GlobalVector& GetGV(      VectorInterface& u) const { return _NGVA(u);}
00198   const GlobalVector& GetGV(const VectorInterface& u) const { return _NGVA(u);}
00199 
00200   //
00202   //
00203 
00204   bool GetDistribute() const { return _distribute; }
00205   void SetDistribute(bool dist) { _distribute = dist; }
00206 
00207   void HNAverage   (const VectorInterface& x) const;
00208   void HNZero      (const VectorInterface& x) const;
00209   void HNDistribute(VectorInterface& x) const;
00210   void HNAverageData() const;
00211   void HNZeroData() const;
00212 
00213   //
00215   //
00216 
00217   void Visu(const std::string& name, const VectorInterface& u, int i) const;
00218   void Write(const VectorInterface& u, const std::string& filename) const;
00219   void Read(VectorInterface& u, const std::string& filename) const;
00220 
00221   //
00223   //
00224 
00225   void InterpolateSolution(VectorInterface& u, const GlobalVector& uold) const;
00226 
00227   //
00229   //
00230 
00231   void Rhs(VectorInterface& f, double d=1.) const;
00232 
00233   //
00235   //
00236 
00237   void Form(VectorInterface& y, const VectorInterface& x, double d) const;
00238   void AdjointForm(VectorInterface& y, const VectorInterface& x, double d) const;
00239 
00240   //
00242   //
00243   void SetBoundaryVector(VectorInterface& f) const;
00244   void SetBoundaryVectorZero(VectorInterface& Gf) const;
00245   void SetBoundaryVectorStrong(VectorInterface& f, const BoundaryManager& BM, const DirichletData& DD, double d=1.) const;
00246 
00247   //
00249   //
00250 
00251   double NewtonNorm(const VectorInterface& u) const;
00252   void residualgmres(VectorInterface& y, const VectorInterface& x, const VectorInterface& b) const;
00253   void MatrixResidual(VectorInterface& y, const VectorInterface& x, const VectorInterface& b) const;
00254   void vmult  (VectorInterface& y, const VectorInterface& x, double d) const;
00255   void vmulteq(VectorInterface& y, const VectorInterface& x, double d) const;
00256   void smooth_pre(VectorInterface& y, const VectorInterface& x, VectorInterface& h) const;
00257   void smooth_exact(VectorInterface& y, const VectorInterface& x, VectorInterface& h) const;
00258   void smooth_post(VectorInterface& y, const VectorInterface& x, VectorInterface& h) const;
00259   void Zero(VectorInterface& dst) const;
00260 
00261   //
00263   //
00264 
00265   void SubtractMean(VectorInterface& x) const;
00266   void SubtractMeanAlgebraic(VectorInterface& x) const;
00267 
00268   //
00270   //
00271 
00272   void AssembleMatrix(const VectorInterface& u, double d);
00273   void DirichletMatrix() const;
00274   void MatrixZero() const;
00275   void ComputeIlu(const VectorInterface& u) const;
00276   void ComputeIlu() const;
00277   void AssembleDualMatrix(const VectorInterface& gu, double d);
00278 
00279   //
00281   //
00282 
00283   void ComputeError(const VectorInterface& u, GlobalVector& err) const;
00284   void AssembleError(GlobalVector& eta, const VectorInterface& u, GlobalVector& err) const;
00285   double ComputeFunctional(VectorInterface& f, const VectorInterface& u, const Functional* FP) const;
00286 
00287   virtual double ComputeBoundaryFunctional(VectorInterface& f, const VectorInterface& u, VectorInterface& z, const BoundaryFunctional* FP) const;
00288   virtual double ComputeDomainFunctional(VectorInterface& f, const VectorInterface& u, VectorInterface& z, const DomainFunctional* FP) const;
00289   virtual double ComputePointFunctional(VectorInterface& f, const VectorInterface& u, VectorInterface& z, const PointFunctional* NFP) const;
00290   virtual double ComputeResidualFunctional(VectorInterface& f, const VectorInterface& u, VectorInterface& z, const ResidualFunctional* FP) const;
00291   virtual void EvaluateCellRightHandSide(VectorInterface& f, const DomainRightHandSide& CF, double d = 1.) const;
00292   virtual void InterpolateDomainFunction(VectorInterface& f, const DomainFunction& DF) const;
00293 
00294   //
00296   //
00297 
00298   void BoundaryInit(VectorInterface& u) const;
00299   void SolutionInit(VectorInterface& u) const;
00300 
00301   //
00303   //
00304 
00305   virtual const HierarchicalMesh*& GetHierarchicalMeshPointer() { return _HM; }
00306   virtual const HierarchicalMesh*  GetHierarchicalMesh() const  { return _HM; }
00307 
00308   //
00310   //
00311   virtual void DeleteVector(VectorInterface& p) const;
00312 
00313   double ScalarProduct(const VectorInterface& y, const VectorInterface& x) const;
00314   void   Equ(VectorInterface& dst, double s, const VectorInterface& src) const;
00315   void   Add(VectorInterface& dst, double s, const VectorInterface& src) const;
00316   void   SAdd(double s1, VectorInterface& dst, double s2, const VectorInterface& src) const;
00317   double Norm(const VectorInterface& dst) const;  
00318 };
00319 }
00320 
00321 #endif
00322 
00323 
00324 

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