LAMA
|
00001 00034 #ifndef LAMA_METASOLVER_HPP_ 00035 #define LAMA_METASOLVER_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/creator/SolverCreator.hpp> 00045 #include <lama/solver/creator/SolverFactory.hpp> 00046 00047 // spirit 00048 #include <boost/spirit/include/qi.hpp> 00049 00050 #include <string> 00051 #include <fstream> 00052 00053 namespace lama 00054 { 00055 00056 namespace phoenix = boost::phoenix; 00057 namespace qi = boost::spirit::qi; 00058 namespace ascii = boost::spirit::ascii; 00059 00060 class LAMA_DLL_IMPORTEXPORT MetaSolver : public Solver 00061 { 00062 public: 00063 typedef std::string::const_iterator StringIterator; 00064 00070 MetaSolver( const std::string& id ); 00071 00078 MetaSolver( const std::string& id, LoggerPtr logger ); 00079 00087 MetaSolver( const std::string& id, const std::string& configuration ); 00088 00097 MetaSolver( const std::string& id, const std::string& configuration, LoggerPtr logger ); 00098 00099 MetaSolver( const MetaSolver& other ); 00100 00104 virtual ~MetaSolver(); 00105 00120 virtual void initialize( const Matrix& coefficients ); 00121 00136 virtual void initializePreconditioner( const Matrix& coefficients, LogLevel::LogLevel level ); 00137 00138 00149 virtual void solveImpl(); 00150 00151 00152 /* 00153 * @brief If arg is a file it reads the files content. If not it calls the direct interpretation 00154 * 00155 * @param[in] arg Input string which is a file name or a configuration string 00156 */ 00157 void interpreteArgument( const std::string arg ); 00158 00159 /* 00160 * @brief Parses the given configuration and constructs the MetaSolver 00161 * 00162 * Parses the given configuration in mConfiguration and constructs the MetaSolver with the 00163 * described settings. 00164 */ 00165 void parseConfiguration( const std::string& configuration ); 00166 00167 struct MetaSolverRuntime : SolverRuntime 00168 { 00169 MetaSolverRuntime(); 00170 virtual ~MetaSolverRuntime(); 00171 00172 SolverPtr mRootSolver; 00173 }; 00174 00175 virtual const MetaSolverRuntime& getConstRuntime() const; 00176 00177 private: 00178 virtual SolverPtr copy(); 00179 00180 virtual MetaSolverRuntime& getRuntime(); 00181 00182 MetaSolverRuntime mMetaSovlerRuntime; 00183 00184 LAMA_LOG_DECL_STATIC_LOGGER(logger); 00185 00186 }; 00187 00188 class SolverConfigGrammar : 00189 public qi::grammar<std::string::const_iterator, void(), ascii::space_type> 00190 { 00191 public: 00192 typedef std::string::const_iterator StringIterator; 00193 SolverConfigGrammar(); 00194 00195 void setRootSolver( SolverPtr solver ); 00196 00197 SolverPtr getRootSolver(); 00198 00199 private: 00200 typedef SolverCreator::RuleType RuleType; 00201 00202 qi::rule<StringIterator, void(), qi::locals< RuleType >, ascii::space_type> 00203 mRSolverConfiguration; 00204 00205 qi::rule<StringIterator, void(), ascii::space_type> mRCriteriaConfiguration; 00206 00207 qi::rule<StringIterator, void(), ascii::space_type> mRLoggerConfiguration; 00208 00209 qi::rule<StringIterator, void(), ascii::space_type> mRConfiguration; 00210 00211 qi::rule<StringIterator, void(), ascii::space_type> mRConfigurationSequence; 00212 00213 SolverPtr mRootSolver; 00214 00215 LAMA_LOG_DECL_STATIC_LOGGER(logger); 00216 00217 }; 00218 00219 //template <typename Iterator> 00220 //struct SkipGrammar : qi::grammar<Iterator, void()> 00221 //{ 00222 // SkipGrammar(); 00223 // 00224 // qi::rule<Iterator, void()> comment; 00225 // qi::rule<Iterator, void()> start; 00226 //}; 00227 00228 } //namespace lama 00229 00230 #endif /* METASOLVER_HPP_ */