LAMA
/home/brandes/workspace/LAMA/src/lama/solver/IterativeSolver.hpp
Go to the documentation of this file.
00001 
00034 #ifndef LAMA_ITERATIVESOLVER_HPP_
00035 #define LAMA_ITERATIVESOLVER_HPP_
00036 
00037 // for dll_import
00038 #include <lama/config.hpp>
00039 
00040 // base classes
00041 #include <lama/solver/Solver.hpp>
00042 
00043 // others
00044 #include <lama/solver/criteria/IterationCount.hpp>
00045 
00046 // logging
00047 #include <logging/Logger.hpp>
00048 
00049 namespace lama
00050 {
00051 
00055 class LAMA_DLL_IMPORTEXPORT IterativeSolver : public Solver
00056 {
00057 public:
00063     IterativeSolver( const std::string& id );
00064 
00071     IterativeSolver( const std::string& id, LoggerPtr logger );
00072 
00076     IterativeSolver( const IterativeSolver& other );
00077 
00081     virtual ~IterativeSolver();
00082 
00097     virtual void initialize( const Matrix& coefficients );
00098 
00112     virtual void solveImpl();
00113 
00119     void setStoppingCriterion( const CriterionPtr criterion );
00120 
00129     void setPreconditioner( SolverPtr const conditioner);
00130 
00136     const SolverPtr getPreconditioner() const;
00137 
00142     int getIterationCount() const;
00143 
00150     virtual SolverPtr copy() =0;
00151 
00152     struct IterativeSolverRuntime : SolverRuntime
00153     {
00154         IterativeSolverRuntime();
00155         virtual ~IterativeSolverRuntime();
00156 
00163         IndexType mIterations;
00164     };
00165 
00169     virtual IterativeSolverRuntime& getRuntime() =0;
00170 
00174     virtual const IterativeSolverRuntime& getConstRuntime() const =0;
00175 
00176 protected:
00177 
00183     bool criteriaAreSatisfied() const;
00184 
00195     virtual void iterate() = 0;
00196 
00200     SolverPtr mPreconditioner;
00201 
00206     CriterionPtr mCriterionRootComponent;
00207 
00211     void logStartSolve();
00212     void logEndSolve();
00213     void logIterationEndAndResidual();
00214     void logIterationStart();
00215 
00216     LAMA_LOG_DECL_STATIC_LOGGER(logger);
00217 };
00218 
00219 }// namespace lama
00220 
00221 #endif // LAMA_ITERATIVESOLVER_HPP_