00001
00010 #ifndef BS_FI_OPERATOR_SAVE_DEBUG_DATA_H_
00011 #define BS_FI_OPERATOR_SAVE_DEBUG_DATA_H_
00012
00013 #include "save_connection_data.h"
00014 #include "string_formater.h"
00015 #include "calc_well.h"
00016 #include "rr_rw_wr_saver.h"
00017 #include "well_type_helper.h"
00018 #include "member_accessor.h"
00019
00020 #define SAVE_BOOST_ARRAY(name, size_j) \
00021 tools::save_seq_vector (tools::string_formater (std::string (BOOST_PP_STRINGIZE(name)) + std::string (".bs.%d.txt"), iter_counter).str) \
00022 .save_via_fn (debug::BOOST_PP_CAT (save_, name) <data_array_t, item_t> (calc_model_->data, size_j));
00023
00024 #define SAVE_ITEM(name) \
00025 tools::save_seq_vector (tools::string_formater (std::string (BOOST_PP_STRINGIZE(name)) + std::string (".bs.%d.txt"), iter_counter).str) \
00026 .save_via_fn (debug::BOOST_PP_CAT (save_, name) <data_array_t, item_t> (calc_model_->data));
00027
00028 namespace blue_sky {
00029
00030 namespace debug {
00031
00032 template <typename well_t>
00033 struct ww_diveder
00034 {
00035 typedef typename well_t::item_t item_t;
00036 item_t operator () (const well_t *well) const
00037 {
00038 return 1.0 / well->get_ww_value ();
00039 }
00040 };
00041 template <typename well_t>
00042 struct ww_accessor
00043 {
00044 typedef typename well_t::item_t item_t;
00045 item_t operator () (const well_t *well) const
00046 {
00047 return well->get_ww_value ();
00048 }
00049 };
00050 template <typename well_t>
00051 struct bw_accessor
00052 {
00053 typedef typename well_t::item_t item_t;
00054 item_t operator () (const well_t *well) const
00055 {
00056 return well->get_bw_value ();
00057 }
00058 };
00059
00060 template <typename connection_t>
00061 struct rr
00062 {
00063 typedef typename connection_t::item_t item_t;
00064 item_t operator () (const connection_t *c, size_t i) const
00065 {
00066 return c->get_rr_value () [i];
00067 };
00068 };
00069 template <typename connection_t>
00070 struct rw
00071 {
00072 typedef typename connection_t::item_t item_t;
00073 item_t operator () (const connection_t *c, size_t i) const
00074 {
00075 return c->get_rw_value () [i];
00076 };
00077 };
00078 template <typename connection_t>
00079 struct wr
00080 {
00081 typedef typename connection_t::item_t item_t;
00082 item_t operator () (const connection_t *c, size_t i) const
00083 {
00084 return c->get_wr_value () [i];
00085 };
00086 };
00087 template <typename connection_t>
00088 struct rate
00089 {
00090 typedef typename connection_t::item_t item_t;
00091 item_t operator () (const connection_t *c, size_t i) const
00092 {
00093 return c->get_rate_value () [i];
00094 }
00095 };
00096
00097 template <typename connection_t>
00098 struct cur_bhp
00099 {
00100 typedef typename connection_t::item_t item_t;
00101 item_t operator () (const connection_t *c) const
00102 {
00103 return c->get_cur_bhp ();
00104 };
00105 };
00106 template <typename connection_t>
00107 struct density
00108 {
00109 typedef typename connection_t::item_t item_t;
00110 item_t operator () (const connection_t *c) const
00111 {
00112 return c->density;
00113 };
00114 };
00115 template <typename connection_t>
00116 struct bulkp
00117 {
00118 typedef typename connection_t::item_t item_t;
00119 item_t operator () (const connection_t *c) const
00120 {
00121 return c->bulkp;
00122 };
00123 };
00124
00125 #define MEMBER_SAVER(name) \
00126 template <typename data_array_t, typename item_t> \
00127 struct BOOST_PP_CAT (save_, name) \
00128 { \
00129 typedef item_t value_type; \
00130 \
00131 BOOST_PP_CAT (save_, name) (const data_array_t &data_, size_t size_j_) \
00132 : data_ (data_) \
00133 , size_j_ (size_j_) \
00134 { \
00135 } \
00136 \
00137 size_t \
00138 size_i () const \
00139 { \
00140 return data_.size (); \
00141 } \
00142 \
00143 size_t \
00144 size_j () const \
00145 { \
00146 return size_j_; \
00147 } \
00148 \
00149 item_t \
00150 get (size_t i, size_t j) const \
00151 { \
00152 return data_[i].name[j]; \
00153 } \
00154 \
00155 const data_array_t &data_; \
00156 size_t size_j_; \
00157 };
00158
00159 #define MEMBER_SAVER_2(name) \
00160 template <typename data_array_t, typename item_t> \
00161 struct BOOST_PP_CAT (save_, name) \
00162 { \
00163 typedef item_t value_type; \
00164 \
00165 BOOST_PP_CAT (save_, name) (const data_array_t &data_) \
00166 : data_ (data_) \
00167 { \
00168 } \
00169 \
00170 size_t \
00171 size_i () const \
00172 { \
00173 return data_.size (); \
00174 } \
00175 \
00176 size_t \
00177 size_j () const \
00178 { \
00179 return 1; \
00180 } \
00181 \
00182 item_t \
00183 get (size_t i, size_t j) const \
00184 { \
00185 return data_[i].name; \
00186 } \
00187 \
00188 const data_array_t &data_; \
00189 };
00190
00191 MEMBER_SAVER (mobility);
00192 MEMBER_SAVER (p_deriv_mobility);
00193 MEMBER_SAVER (s_deriv_mobility);
00194 MEMBER_SAVER (density);
00195 MEMBER_SAVER (p_deriv_density);
00196 MEMBER_SAVER (relative_perm);
00197 MEMBER_SAVER (s_deriv_relative_perm);
00198 MEMBER_SAVER (invers_visc_fvf);
00199 MEMBER_SAVER (p_deriv_invers_visc_fvf);
00200 MEMBER_SAVER (cap_pressure);
00201 MEMBER_SAVER (s_deriv_cap_pressure);
00202
00203 MEMBER_SAVER_2 (gor_deriv_invers_fvf);
00204 MEMBER_SAVER_2 (gor_deriv_invers_viscosity);
00205 MEMBER_SAVER_2 (gor_deriv_invers_visc_fvf);
00206
00207 }
00212 template <typename strategy_t, bool is_w, bool is_g, bool is_o>
00213 void
00214 fi_operator_impl <strategy_t, is_w, is_g, is_o>::debug_save_data (item_t dt)
00215 {
00216 static int iter_counter = 0;
00217 iter_counter++;
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270 typedef typename calc_model_t::reservoir_t::facility_manager_t::well_const_iterator_t well_iterator_t;
00271 well_iterator_t wb = reservoir_->get_facility_list ()->wells_begin ();
00272 well_iterator_t we = reservoir_->get_facility_list ()->wells_end ();
00273
00274 typedef wells::type_helper <strategy_t> type_helper_t;
00275 typedef typename type_helper_t::item_rr_block_t item_rr_block_t;
00276 typedef typename type_helper_t::item_rw_block_t item_rw_block_t;
00277 typedef typename type_helper_t::item_wr_block_t item_wr_block_t;
00278
00279 using namespace debug;
00280 typedef rr <wells::connection <strategy_t> > rr_t;
00281 typedef rw <wells::connection <strategy_t> > rw_t;
00282 typedef wr <wells::connection <strategy_t> > wr_t;
00283 typedef rate <wells::connection <strategy_t> > rate_t;
00284 typedef cur_bhp <wells::connection <strategy_t> > cur_bhp_t;
00285 typedef density <wells::connection <strategy_t> > density_t;
00286 typedef bulkp <wells::connection <strategy_t> > bulkp_t;
00287 typedef ww_diveder <well <strategy_t> > ww_diveder_t;
00288 typedef bw_accessor <well <strategy_t> > bw_accessor_t;
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314 BOSOUT (section::iters, level::debug) << "iter_counter: " << iter_counter << bs_end;
00315 }
00316
00317 }
00318
00319
00320 #endif // #ifndef BS_FI_OPERATOR_SAVE_DEBUG_DATA_H_
00321