00001 /* 00002 * Copyright (c) 2001 The AUTHORS 00003 * Romeu Andre' Pieritz, Ph.D. - romeu_pieritz@hotmail.com 00004 * Rafael Mendes, Eng. – mendes_rafael@yahoo.com 00005 * Rodrigo Ferraz de Andrade, Eng. – rferraz@iname.com 00006 * All rights reserved. 00007 * 00008 * Permission to use, copy and distribute this software and its 00009 * documentation for educational and personal use, without fee is hereby granted, 00010 * provided that the above copyright notice and the following 00011 * two paragraphs appear in all copies of this software. 00012 * 00013 * IN NO EVENT SHALL THE AUTHORS BE LIABLE TO ANY PARTY FOR 00014 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT 00015 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHORS 00016 * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00017 * 00018 * THE AUTHORS SPECIFICALLY DISCLAIMS ANY WARRANTIES, 00019 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 00020 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HERE UNDER IS 00021 * ON AN "AS IS" BASIS, AND THE AUTHORS HAVE NO OBLIGATION TO 00022 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 00023 * 00024 * SINMEC Lab. - CFD Sinflow Project - http://www.sinmec.ufsc.br/cfd 00025 */ 00026 00027 00028 // File Define 00029 #ifndef __CSFL_MATH_SOLVER_MULTIGRID_H__ 00030 #define __CSFL_MATH_SOLVER_MULTIGRID_H__ 00031 00032 00033 // Include 00034 #include <csfl/math/solver/itsolver.h> 00035 #include <csfl/sys/math/linearsys9d.h> 00036 #include <csfl/math/solver/tdma.h> 00037 #include <csfl/math/solver/lu.h> 00038 00039 00040 00041 // Namespace 00042 namespace csfl { 00043 00047 typedef 00048 enum _TMGSequence { 00049 mgsV, 00050 mgsW, 00051 mgsF 00052 } 00053 TMGSequence; 00054 00055 00056 // Predefinition required 00057 class ISolverIterMultiGrid; 00058 00059 //============================================================================== 00060 // Class IMultiGridLevel 00061 // Description: retains all the information about a Multi-Grid Level, 00062 // including its Lynear System 00063 //============================================================================== 00064 00065 class IMultiGridLevel 00066 { 00072 public: 00073 IMultiGridLevel(); 00074 IMultiGridLevel( IMultiGridLevel *_mgl); 00075 IMultiGridLevel(int _ni, 00076 int _nj); 00077 ~IMultiGridLevel(); 00078 00079 00083 IPoint CoordIni( const int & i, const int & j ) 00084 { return ( Cini )? Cini->Value( i, j ) : IPoint::zero; } 00085 00086 00090 IPoint CoordEnd( const int & i, const int & j ) 00091 { return ( Cend )? Cend->Value( i, j ) : IPoint::zero; } 00092 00093 00094 00098 int NI() { return ni; } 00099 00100 00104 int NJ() { return nj; } 00105 00106 00110 IMultiGridLevel & operator =( const IMultiGridLevel & ); 00111 00112 00113 00114 protected: 00115 00119 ILinearSystem * LinearSystem() { return lsys; } 00120 00125 void SetSize( const ISize & _size ); 00126 00130 void SetCini( const int & i, const int & j, const IPoint & value ) 00131 { if( Cini ) Cini->SetValue( i, j, value ); } 00132 00133 00137 void SetCend( const int & i, const int & j, const IPoint & value ) 00138 { if( Cend ) Cend->SetValue( i, j, value ); } 00139 00140 protected: 00141 00145 ILinearSystem9D *lsys; 00146 00147 int ni, nj; //Level Size 00148 00149 MatrixPoint *Cini, *Cend; //Coordinates in the subsequent refined mesh 00150 00151 friend class ISolverIterMultiGrid; 00152 }; 00153 00154 00155 00156 00157 //============================================================================== 00158 // Class ISolverIterMultiGrid 00159 // Description: Coordinates the Multi-Grid Solver 00160 //============================================================================== 00161 00162 class ISolverIterMultiGrid : 00163 public ISolverIteract 00164 00171 { 00172 00173 public: 00180 ISolverIterMultiGrid( ISize _agglomerator, 00181 ILinearSystem *_lsys = NULL, 00182 double _tol = 0.001, 00183 int _iterMax = 100, 00184 TMGSequence _MGsequence = mgsV, 00185 IContainerParameter *_cont = NULL ); 00186 00192 ISolverIterMultiGrid( ILinearSystem *_lsys = NULL, 00193 double _tol = 0.001, 00194 int _itermax = 100, 00195 TMGSequence _MGsequence = mgsV, 00196 IContainerParameter * = NULL ); 00197 00198 ISolverIterMultiGrid( ISolverIterMultiGrid * ); 00199 00200 ~ISolverIterMultiGrid(); 00201 00205 void Solve(); 00206 00210 void Solve( ILinearSystem *_lsys ); 00211 00215 IMultiGridLevel * MultiGridLevels() { return MGL; } 00216 00221 ISize Agglomerator() { return agglomerator; } 00222 00223 00228 void SetAgglomerator( const ISize & _agglomerator ); 00229 00233 int Levels() { return levels; } 00234 00238 void SetMaximumNumberOfLevels( const int & _maxLevels ) { maxLevels = _maxLevels; } 00239 00243 int LevelMaximumIteration() { return MGiterMax; } 00244 00248 void SetLevelMaximumIteration( const int & _maxiter ) { MGiterMax = _maxiter; } 00249 00253 int LevelIteration() { return MGiter; } 00254 00258 int CoarsenSize() { return coarsensize; } 00259 00263 void SetCoarsenSize( int _size ){ coarsensize = _size; } 00264 00268 double LevelResidualReduction() { return MGreduction; } 00269 00273 void SetLevelResidualReduction( const double & _red ) { MGreduction = _red; } 00274 00278 double LevelError() { return MGerror; } 00279 00280 00284 TMGSequence MultiGridSequence() { return MGsequence; } 00285 00289 void SetFicticiousVolumes( const bool & _FictVol ) { FictVolumes = _FictVol; } 00290 00294 void SetIterToEvaluateError( int _v ); 00295 00300 void SolveWhenCoarsening( bool _swcoarsening ) { swcoarsening = _swcoarsening; } 00301 00305 IAction ActionSolveLevel; 00306 00310 IAction ActionLevelConverged; 00311 00315 void Write( ofstream &_os ); 00316 00317 protected: 00318 void SolveCoarsening(); 00319 void SolveRefining(); 00320 void CreateLevels(); 00321 void SetCoefficients(); 00322 void SetResiduals( int _level ); 00323 void MakeCorrection ( int _level ); 00324 void CheckMagnitudeReduction( ISFLObject * = NULL ); 00325 void SolveCall( ISFLObject * = NULL ); 00326 void ComputeAgglomerator(); 00327 00328 int levels; 00329 IMultiGridLevel * MGL; 00330 int ni, nj; 00331 ISize agglomerator; 00332 bool swcoarsening; 00333 00334 int MGiterMax, MGiter; 00335 int coarsensize; 00336 double MGreduction, MGinitialError, MGerror; 00337 TMGSequence MGsequence; 00338 00339 ISolverIterTdma * RefinedSolver; 00340 ISolverLU * CoarsenSolver; 00341 bool FictVolumes; 00342 00343 }; 00344 00345 00346 } // csfl namespace 00347 00348 #endif // __CSFL_MATH_SOLVER_MULTIGRID__
CFD Project
|
Documents |
Downloads |
Contact us |
Use Terms |
|
|||
© SINMEC/EMC/UFSC,
2001. |
All rights
reserved. |
Last Update: Jan. 18, 2002 |
|