00001 00005 class LinEqSolver : public virtual HandleId 00006 00007 { 00008 protected: 00009 00010 Handle(LinEqSolver_prm) slvprm; 00011 Handle(LinEqSystem) msys; 00012 00013 int alg_work; 00014 real alg_storage; 00015 00016 real start_time; 00017 real stop_time; 00018 CPUclock cl; 00019 00020 00021 00022 bool building_framework; 00023 00024 void startTime (); 00025 void stopTime (); 00026 00027 LinEqSolver (); 00028 LinEqSolver (const LinEqSolver_prm& p); 00029 00030 virtual bool redim (LinEqSystem& system); 00031 00032 00033 public: 00034 00035 virtual ~LinEqSolver (); 00036 00037 virtual bool ok () const =0; 00038 00039 virtual String prm2name () const; 00040 virtual void name2prm (LinEqSolver_prm& prm, const String& name); 00041 00042 00043 virtual String description () const; 00044 00045 real getCPUtime () const; 00046 00047 virtual int getWork 00048 (const LinEqSysWork work_tp = TOTAL_WORK) const =0; 00049 00050 virtual real getStorage 00051 (const LinEqSysStorage storage_tp = TOTAL_STORAGE) const =0; 00052 00053 virtual void performance (LinEqStatBlk& performance_status); 00054 00055 virtual bool solve (LinEqSystem& system) =0; 00056 00057 virtual void debugPrint (Os os, int amount_of_output = 1) const =0; 00058 00059 virtual String getCategory () const =0; 00060 virtual bool inCategory (const String& baseclass_name) const; 00061 00062 CLASS_INFO 00063 00064 DEF_VIRTUAL_CAST(DirectSolver) 00065 DEF_VIRTUAL_CAST(IterativeSolver) 00066 DEF_VIRTUAL_CAST(BasicItSolver) 00067 DEF_VIRTUAL_CAST(KrylovItSolver) 00068 DEF_VIRTUAL_CAST(MLIter) 00069 }; 00070 00071 00171 class DirectSolver : public LinEqSolver 00172 00173 { 00174 00175 protected: 00176 00177 DirectSolver () 00178 : LinEqSolver () {} 00179 00180 DirectSolver (const LinEqSolver_prm& pm) 00181 : LinEqSolver (pm) {} 00182 00183 virtual bool redim (LinEqSystem& system); 00184 00185 virtual void init (); 00186 virtual void exit (); 00187 00188 public: 00189 00190 virtual void performance (LinEqStatBlk& performance_status); 00191 00192 virtual void debugPrint (Os os, int amount_of_output = 1) const; 00193 00194 virtual String getCategory () const; 00195 virtual bool inCategory (const String& baseclass_name) const; 00196 00197 CLASS_INFO 00198 00199 VIRTUAL_CAST(DirectSolver) 00200 }; 00201 00202 00225 class IterativeSolver : public LinEqSolver 00226 00227 { 00228 protected: 00229 00230 00231 Handle(ConvMonitorList) monitors; 00232 00233 00234 Handle(EigenEstimator) eigest; 00235 String eigest_id; 00236 00237 bool convflag; 00238 00239 int max_iterations; 00240 int niterations; 00241 int restartCount; 00242 00243 00244 00245 00246 00247 00248 00249 00250 00251 00252 Handle(LinEqCommBlk) communication; 00253 String communication_id; 00254 00255 00256 00257 00258 00259 00260 Handle(LinEqVector) prev_x; 00261 00262 00263 00264 Handle(SubdCommAdm) comm_adm; 00265 00266 00267 00268 00269 00270 IterativeSolver (); 00271 IterativeSolver (const LinEqSolver_prm& pm); 00272 00273 void initGuess (const StartVectorMode startmode); 00274 00275 virtual void init (const LinEqPrecMode algprec_mode) =0; 00276 00277 virtual void exit (); 00278 00279 virtual void restart (); 00280 00281 bool satisfied (); 00282 00283 00284 00285 00286 virtual void initDefaultCriterion (); 00287 00288 virtual void initEigEst (); 00289 00290 virtual void initCommBlk () =0; 00291 00292 virtual void updateCommBlk (); 00293 00294 00295 public: 00296 00297 ~IterativeSolver (); 00298 00299 00300 virtual bool ok () const; 00301 00302 bool converged () const { return convflag; } 00303 int getItCount () const { return niterations; } 00304 int getRestartCount () const { return restartCount; } 00305 00306 void attach (ConvMonitorList_prm& mon_prm); 00307 void attach (ConvMonitorList& monitors); 00308 void attach (ConvMonitor& monitor); 00309 00310 int getConvMonitors (Handle(ConvMonitorList)& monitors_) const; 00311 00312 int getWork 00313 (const LinEqSysWork work_tp = TOTAL_WORK) const; 00314 00315 real getStorage 00316 (const LinEqSysStorage storage_tp = TOTAL_STORAGE) const; 00317 00318 void plotMonitorData (CurvePlotFile& file, const String& comment, 00319 bool logplot = true, 00320 bool genPSfiles = false, 00321 const char* psFileDir = NULL); 00322 00323 virtual void performance (LinEqStatBlk& performance_status); 00324 00325 virtual void debugPrint (Os os, int amount_of_output = 1) const; 00326 00327 virtual String getCategory () const; 00328 virtual bool inCategory (const String& baseclass_name) const; 00329 00330 void attachCommAdm (const SubdCommAdm& adm_); 00331 NUMT inner (LinEqVector& x, LinEqVector& y); 00332 00333 00334 CLASS_INFO 00335 00336 VIRTUAL_CAST(IterativeSolver) 00337 }; 00338 00339 00474 class BasicItSolver : public IterativeSolver 00475 00476 { 00477 00478 protected: 00479 00480 00481 00482 BasicItSolver (); 00483 BasicItSolver (const LinEqSolver_prm& pm); 00484 00485 virtual void init (const LinEqPrecMode algprec_mode); 00486 00487 00488 00489 00490 virtual bool redim (LinEqSystem& system); 00491 00492 virtual void initDefaultCriterion (); 00493 00494 virtual void initCommBlk (); 00495 00496 00497 public: 00498 00499 ~BasicItSolver (); 00500 00501 00502 virtual bool ok () const; 00503 00504 virtual bool solve (LinEqSystem& system); 00505 00506 virtual String getCategory () const; 00507 virtual bool inCategory (const String& baseclass_name) const; 00508 00509 CLASS_INFO 00510 00511 VIRTUAL_CAST(BasicItSolver) 00512 }; 00513 00514 00544 class KrylovItSolver : public IterativeSolver 00545 00546 { 00547 00548 protected: 00549 00550 00551 00552 00553 00554 00555 00556 00557 00558 Handle(LinEqVector) r; 00559 Handle(LinEqVector) s; 00560 Handle(LinEqVector) z; 00561 00562 bool use_svector; 00563 bool use_zvector; 00564 00565 00566 00567 00568 00569 00570 Handle(LinEqVector) prev_r; 00571 Handle(LinEqVector) prev_s; 00572 Handle(LinEqVector) prev_z; 00573 00574 00575 00576 00577 00578 KrylovItSolver (); 00579 KrylovItSolver (const LinEqSolver_prm& pm); 00580 00581 00582 00583 void prepare (Residual_type residual_tp); 00584 void grabResidualVector(Residual_type residual_tp, Handle(LinEqVector)& v); 00585 00586 void initResiduals (); 00587 00588 virtual void init (const LinEqPrecMode algprec_mode); 00589 00590 virtual void restart (); 00591 00592 00593 00594 00595 00596 virtual bool redim (LinEqSystem& system); 00597 00598 virtual void initCommBlk (); 00599 00600 00601 public: 00602 00603 ~KrylovItSolver (); 00604 00605 00606 virtual bool ok () const; 00607 00608 virtual bool solve (LinEqSystem& system); 00609 00610 virtual void debugPrint (Os os, int amount_of_output = 1) const; 00611 00612 virtual String getCategory () const; 00613 virtual bool inCategory (const String& baseclass_name) const; 00614 00615 CLASS_INFO 00616 00617 VIRTUAL_CAST(KrylovItSolver) 00618 }; 00619 00620