00001
00009 #ifndef TWO_STAGE_PREC_H__
00010 #define TWO_STAGE_PREC_H__
00011
00012 #ifdef _MPI
00013 #include "mpi_csr_matrix.h"
00014 #endif //_MPI
00015 #include "memory_macroses.h"
00016
00017 #include BS_FORCE_PLUGIN_IMPORT ()
00018 #include "linear_solvers.h"
00019 #include BS_STOP_PLUGIN_IMPORT ()
00020
00021 namespace blue_sky
00022 {
00023
00028 template <class strategy_t>
00029 class BS_API_PLUGIN two_stage_preconditioner: public linear_solver_base<strategy_t>
00030 {
00031 public:
00032 typedef linear_solver_base<strategy_t> base_t;
00033 typedef two_stage_preconditioner<strategy_t> this_t;
00034 typedef typename strategy_t::matrix_t matrix_t;
00035 typedef typename strategy_t::item_array_t item_array_t;
00036 typedef typename strategy_t::item_t item_t;
00037 typedef typename strategy_t::rhs_item_t rhs_item_t;
00038 typedef typename strategy_t::rhs_item_array_t rhs_item_array_t;
00039 typedef typename strategy_t::index_t index_t;
00040 typedef item_t fp_type;
00041 typedef index_t i_type;
00042 typedef smart_ptr <base_t, true> sp_base_t;
00043 typedef smart_ptr <matrix_t, true> sp_matrix_t;
00044
00045
00046
00047 public:
00049 virtual ~two_stage_preconditioner ();
00050
00058 virtual int
00059 solve (matrix_t *matrix, rhs_item_array_t &rhs, item_array_t &sol);
00060
00068 virtual int
00069 solve_prec (matrix_t *matrix, item_array_t &rhs, item_array_t &sol);
00070
00078 template <class rhs_t>
00079 int
00080 templ_solve (matrix_t *matrix, rhs_t &rhs, item_array_t &sol);
00081
00082
00088 virtual int
00089 setup (matrix_t *matrix);
00090
00095 void
00096 set_prec_1 (const base_t *prec)
00097 {
00098 base_t::prec = prec;
00099 set_subnode_in_tree ("prec", sp_base_t (prec));
00100 }
00101
00106 void
00107 set_prec_2 (const base_t *prec)
00108 {
00109 prec_2 = prec;
00110 set_subnode_in_tree ("prec_2", sp_base_t (prec));
00111 }
00112
00118 int
00119 get_prec_1_iters ()
00120 {
00121 return base_t::prec ? base_t::prec->get_prop ()->get_iters () : 0;
00122 }
00123
00128 sp_base_t
00129 get_prec_1 () const
00130 {
00131 return base_t::prec;
00132 }
00133
00138 sp_base_t
00139 get_prec_2 () const
00140 {
00141 return prec_2;
00142 }
00143
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00163 BLUE_SKY_TYPE_DECL (two_stage_preconditioner);
00164
00165 private:
00166
00167
00168
00169
00170 private:
00171 sp_base_t prec_2;
00172
00173 item_array_t r_array;
00174 item_array_t w_array;
00175 };
00176
00182 bool
00183 two_stage_prec_register_type (const blue_sky::plugin_descriptor &pd);
00184
00185 }
00186 #endif // TWO_STAGE_PREC_H__