NGSolve
4.9
|
00001 #ifndef FILE_MGPRE 00002 #define FILE_MGPRE 00003 00004 /*********************************************************************/ 00005 /* File: mgpre.hh */ 00006 /* Author: Joachim Schoeberl */ 00007 /* Date: 20. Apr. 2000 */ 00008 /*********************************************************************/ 00009 00010 00011 namespace ngmg 00012 { 00013 00018 class Smoother; 00020 class Prolongation; 00021 00022 00024 class NGS_DLL_HEADER MultigridPreconditioner : public BaseMatrix 00025 { 00026 00027 public: 00029 enum COARSETYPE { EXACT_COARSE, CG_COARSE, SMOOTHING_COARSE, USER_COARSE }; 00030 00031 private: 00033 const MeshAccess & ma; 00035 const FESpace & fespace; 00037 const BilinearForm & biform; 00038 00040 Smoother * smoother; 00042 Prolongation * prolongation; 00044 BaseMatrix * coarsegridpre; 00046 double checksumcgpre; 00048 int ownsmoother, ownprolongation, owncoarsegridpre; 00049 00051 COARSETYPE coarsetype; 00053 int cycle, incsmooth, smoothingsteps; 00055 int coarsesmoothingsteps; 00057 int updateall; 00059 bool update_always; 00061 // Array<BaseMatrix*> prol_projection; 00062 public: 00064 MultigridPreconditioner (const MeshAccess & ama, 00065 const FESpace & afespace, 00066 const BilinearForm & abiform, 00067 Smoother * asmoother, 00068 Prolongation * aprolongation); 00070 ~MultigridPreconditioner (); 00071 00073 void FreeMem(void); 00074 00076 void SetSmoothingSteps (int sstep); 00078 void SetCycle (int c); 00080 void SetIncreaseSmoothingSteps (int incsm); 00082 void SetCoarseType (COARSETYPE ctyp); 00084 void SetCoarseGridPreconditioner (const BaseMatrix * acoarsegridpre); 00086 void SetCoarseSmoothingSteps (int cstep); 00087 00089 void SetOwnSmoother (int os = 1); 00091 void SetOwnProlongation (int op = 1); 00093 void SetOwnCoarseGridPreconditioner (int oc = 1); 00095 void SetUpdateAll (int ua = 1); 00097 void SetUpdateAlways (bool ua = 1) { update_always = ua; } 00099 virtual void Update (); 00100 00102 virtual void Mult (const BaseVector & x, BaseVector & y) const; 00103 00105 void MGM (int level, BaseVector & u, 00106 const BaseVector & f, int incsm = 1) const; 00108 virtual BaseVector * CreateVector () const 00109 { return biform.GetMatrix().CreateVector(); } 00110 00112 const Smoother & GetSmoother() const 00113 { return *smoother; } 00115 Smoother & GetSmoother() 00116 { return *smoother; } 00118 const Prolongation & GetProlongation() const 00119 { return *prolongation; } 00120 00121 00122 virtual int VHeight() const 00123 { 00124 return biform.GetMatrix().Height(); 00125 } 00126 00127 virtual int VWidth() const 00128 { 00129 return biform.GetMatrix().VWidth(); 00130 } 00131 00132 00133 virtual void MemoryUsage (Array<MemoryUsageStruct*> & mu) const; 00134 }; 00135 00136 00137 00138 00139 00140 00141 00143 class NGS_DLL_HEADER TwoLevelMatrix : public BaseMatrix 00144 { 00146 const BaseMatrix * mat; 00148 const BaseMatrix * cpre; 00150 BaseJacobiPrecond * jacsmoother; 00152 Smoother * smoother; 00154 int level; 00156 int smoothingsteps; 00158 bool own_smoother; 00159 public: 00161 TwoLevelMatrix (const BaseMatrix * amat, 00162 const BaseMatrix * acpre, 00163 Smoother * asmoother, int alevel); 00165 ~TwoLevelMatrix (); 00166 00168 void FreeMem(void); 00170 virtual void Mult (const BaseVector & x, BaseVector & y) const; 00172 virtual BaseVector * CreateVector () const; 00174 virtual ostream & Print (ostream & s) const; 00176 void SetSmoothingSteps(int ass) { smoothingsteps = ass; } 00178 void SetOwnSmoother (bool aos) { own_smoother = aos; } 00180 const Smoother & GetSmoother() const 00181 { return *smoother; } 00183 Smoother & GetSmoother() 00184 { return *smoother; } 00186 virtual void Update(); 00187 00188 virtual int VHeight() const 00189 { 00190 return mat->Height(); 00191 } 00192 00193 virtual int VWidth() const 00194 { 00195 return mat->VWidth(); 00196 } 00197 00198 virtual void MemoryUsage (Array<MemoryUsageStruct*> & mu) const; 00199 }; 00200 00201 } 00202 00203 #endif