LAMA
/home/brandes/workspace/LAMA/src/lama/solver/SimpleAMG.hpp
Go to the documentation of this file.
00001 
00033 #ifndef LAMA_SIMPLEAMG_HPP_
00034 #define LAMA_SIMPLEAMG_HPP_
00035 
00036 // for dll_import
00037 #include <lama/config.hpp>
00038 
00039 // base classes
00040 #include <lama/solver/IterativeSolver.hpp>
00041 
00042 // others
00043 #include <lama/solver/AMGSetup.hpp>
00044 
00045 #include <vector>
00046 
00047 namespace lama
00048 {
00049 
00050 class LAMA_DLL_IMPORTEXPORT SimpleAMG: public lama::IterativeSolver
00051 {
00052 public:
00053 
00054     SimpleAMG( const std::string& id );
00055 
00056     SimpleAMG( const std::string& id, LoggerPtr logger );
00057 
00058     SimpleAMG( const SimpleAMG& other );
00059 
00060     virtual ~SimpleAMG();
00061 
00062     virtual void initialize(const Matrix&  coefficients);
00063 
00064     virtual void iterate();
00065 
00066     void setMaxLevels( unsigned int levels );
00067 
00068     void setMinVarsCoarseLevel( unsigned int vars );
00069 
00070     unsigned int getNumLevels ();
00071 
00072     const Matrix& getGalerkin( unsigned int level );
00073     const Matrix& getRestriction( unsigned int level );
00074     const Matrix& getInterpolation( unsigned int level );
00075 
00076     Vector& getSolutionVector( unsigned int level );
00077     Vector& getRhsVector( unsigned int level );
00078 
00079     Solver& getSmoother( unsigned int level );
00080     Solver& getCoarseLevelSolver();
00081 
00082     void setSmootherContext( ContextPtr smootherContext );
00083 
00084     void setHostOnlyLevel( IndexType hostOnlyLevel );
00085 
00086     void setReplicatedLevel( IndexType replicatedLevel );
00087 
00088     void setCoarseLevelSolver( SolverPtr solver );
00089 
00093     void setSmoother( SolverPtr solver );
00094 
00095     struct SimpleAMGRuntime : IterativeSolverRuntime
00096     {
00097         SimpleAMGRuntime();
00098         virtual ~SimpleAMGRuntime();
00099 
00100         std::auto_ptr<AMGSetup> mSetup;
00101         unsigned int mCurrentLevel;
00102         void* mLibHandle;
00103         IndexType mHostOnlyLevel;
00104         IndexType mReplicatedLevel;
00105 
00106         LAMA_LOG_DECL_STATIC_LOGGER(logger);
00107     };
00108 
00112     virtual SimpleAMGRuntime& getRuntime();
00113 
00117     virtual const SimpleAMGRuntime& getConstRuntime() const;
00118 
00125     virtual SolverPtr copy();
00126 
00127 protected:
00128 
00129     SimpleAMGRuntime mSimpleAMGRuntime;
00130 
00131     unsigned int mMaxLevels;
00132     unsigned int mMinVarsCoarseLevel;
00133     SolverPtr mCoarseLevelSolver;
00134     SolverPtr mSmoother;
00135     ContextPtr mSmootherContext;
00136 
00137 private:
00138 
00139     void logSetupSettings();
00140     void logSetupInfo();
00141     void logSolverInfo();
00142     void logSetupDetails();
00143 
00144     LAMA_LOG_DECL_STATIC_LOGGER(logger);
00145 
00146     void cycle();
00147 };
00148 
00149 }
00150 
00151 #endif /* LAMA_SIMPLEAMG_HPP_ */