00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifdef COMP_GNUOLD
00027 #include <iostream.h>
00028 #include <fstream.h>
00029 #include <math.h>
00030 #include <time.h>
00031 #else
00032 #include <iostream>
00033 #include <fstream>
00034 #include <cmath>
00035 #include <ctime>
00036 #endif
00037
00038
00039
00040 #include "../parser.h"
00041
00042
00043 #include "../paramete.h"
00044 #include "../abbrevi.h"
00045 #include "../math_lib/math_lib.h"
00046
00047
00048 #include "../basic/basic.h"
00049
00050
00051 #include "../domain/domain.h"
00052
00053
00054 #include "../formulas/boundy.h"
00055 #include "../formulas/loc_sten.h"
00056
00057
00058
00059 #include "../grid/gpar.h"
00060 #include "../grid/parallel.h"
00061 #include "../grid/mgcoeff.h"
00062 #include "../grid/sto_man.h"
00063 #include "../grid/gridbase.h"
00064 #include "../grid/grid.h"
00065
00066
00067 #include "evpar.h"
00068
00069
00070
00071 Evaluation_Parallelization_object::Evaluation_Parallelization_object(
00072 Grid *g, int max_v) :
00073 grid(g) {
00074
00075 max_var = max_v;
00076 max_level = g->Max_level();
00077 storage_of_update_type = new type_of_update[max_level*(max_var+1)];
00078 for(int i=max_level*(max_var+1)-1;i>=0;--i) {
00079 storage_of_update_type[i] = full_update;
00080 }
00081 array_vars = new bool[max_var];
00082 array_num = new int[max_var];
00083 array_vars_other = new bool[max_var];
00084 array_num_other = new int[max_var];
00085
00086
00087
00088 Parallel_GS_formula[0] = Edir;
00089 Parallel_GS_formula[1] = Ndir;
00090 Parallel_GS_formula[2] = Tdir;
00091 Parallel_GS_formula[3] = Sdir;
00092
00093 Parallel_GS_formula[4] = Wdir;
00094 Parallel_GS_formula[5] = Ndir;
00095 Parallel_GS_formula[6] = Ddir;
00096 Parallel_GS_formula[7] = Sdir;
00097 };
00098
00099 void Evaluation_Parallelization_object::Start_evaluation_seriel(
00100 const Run_type_object rob, const int l, const int ss,
00101 const int num_ops) {
00102 size_stencil = ss;
00103 run_object = rob;
00104 level=l;
00105 status=0;
00106 number_ops=num_ops;
00107 }
00108
00109 void Evaluation_Parallelization_object::StartA_varcon_evaluation(int l) {
00110 level=l;
00111 for(int i=0;i<max_var;++i) {
00112 array_vars[i]=false;
00113 }
00114 };
00115
00116
00117 void Evaluation_Parallelization_object::StartB_varcon_evaluation() {
00118 type_of_update type_upd;
00119
00120 anz_num=0;
00121
00122 for(int i=0;i<max_var;++i) {
00123 if(array_vars[i]) {
00124 type_upd = Give_type_of_update(i,level);
00125 if(type_upd!=full_update) {
00126 array_num[anz_num]=i;
00127 ++anz_num;
00128 }
00129 Set_type_of_update(i,level,full_update);
00130 }
00131 }
00132 grid->Update_Variable_no_full(array_num,anz_num,level);
00133 };
00134
00135 void Evaluation_Parallelization_object::StartA_evaluation(
00136 const Run_type_object rob, const int l, const int ss,
00137 const int num_ops) {
00138 size_stencil = ss;
00139 run_object = rob;
00140 level=l;
00141 status=0;
00142 number_ops=num_ops;
00143
00144 if(size_stencil>1) {
00145 other_is_fine=other_is_coarse=false;
00146 for(int i=0;i<max_var;++i) {
00147 array_vars[i]=array_vars_other[i]=false;
00148 }
00149
00150 }
00151 }
00152
00153
00154 void Evaluation_Parallelization_object::StartB_evaluation(
00155 const int number_variable,
00156 const bool GS_expr) {
00157 anz_num=anz_num_other=0;
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178 GS_expression = GS_expr;
00179
00180 type_of_update type_upd;
00181
00182 if(size_stencil>1) {
00183
00184 update_other_bla = false;
00185 for(int i=0;i<max_var;++i) {
00186 if(array_vars_other[i]) {
00187 if(other_is_fine) {
00188 type_upd = Give_type_of_update(i,level+1);
00189 if(type_upd!=full_update) {
00190 array_num_other[anz_num_other]=i;
00191 ++anz_num_other;
00192 if(type_upd==no_update) {
00193 update_other_bla = true;
00194 }
00195 Set_type_of_update(i,level+1,full_update);
00196 }
00197 }
00198 if(other_is_coarse) {
00199 type_upd = Give_type_of_update(i,level-1);
00200 if(type_upd!=full_update) {
00201 array_num_other[anz_num_other]=i;
00202 ++anz_num_other;
00203 if(type_upd==no_update) {
00204 update_other_bla = true;
00205 }
00206 Set_type_of_update(i,level-1,full_update);
00207 }
00208 }
00209 }
00210 }
00211 if(GS_expr==true) {
00212
00213 update_ENT = false;
00214 update_WSD = false;
00215
00216 for(int i=0;i<max_var;++i) {
00217 if(array_vars[i]) {
00218 type_upd = Give_type_of_update(i,level);
00219 array_num[anz_num]=i;
00220 ++anz_num;
00221 if(type_upd==no_update) {
00222 update_ENT = true;
00223 }
00224
00225
00226
00227 Set_type_of_update(i,level,full_update);
00228 }
00229 }
00230
00231 Set_type_of_update(number_variable,level,partial_update);
00232 left_level = level;
00233 left_update = partial_update;
00234 }
00235 else {
00236
00237 update_ENT = false;
00238 update_WSD = true;
00239
00240 for(int i=0;i<max_var;++i) {
00241 if(array_vars[i]) {
00242 type_upd = Give_type_of_update(i,level);
00243 if(type_upd!=full_update) {
00244 array_num[anz_num]=i;
00245 ++anz_num;
00246 if(type_upd==no_update) {
00247 update_ENT = true;
00248 }
00249 }
00250
00251
00252
00253 Set_type_of_update(i,level,full_update);
00254 }
00255 }
00256
00257 Set_type_of_update(number_variable,level,no_update);
00258 left_level = level;
00259 left_update = no_update;
00260 }
00261
00262 if(other_is_fine && other_is_coarse)
00263 cout << " Restriction and Prolongation in one expression "
00264 << " is not allowed!! " << endl;
00265 }
00266 else {
00267
00268 Set_type_of_update(number_variable,level,no_update);
00269 left_level = level;
00270 left_update = no_update;
00271 }
00272
00273
00274
00275
00276
00277
00278
00279
00280 }
00281
00282
00283 evaluation_typ Evaluation_Parallelization_object::Give_next_evaluation_typ() {
00284
00285 if(parallel_version) {
00286 if(status==0 && size_stencil>1) {
00287 if(other_is_fine) {
00288 if(update_other_bla==true) {
00289
00290 grid->Update_Variable_no_full(array_num_other,anz_num_other,level+1);
00291 }
00292 else {
00293
00294 grid->Update_Variable_no_full(array_num,anz_num,level);
00295
00296
00297 grid->Update_Variable(Edir,array_num_other,anz_num_other,level+1);
00298 grid->Update_Variable(Ndir,array_num_other,anz_num_other,level+1);
00299 grid->Update_Variable(Tdir,array_num_other,anz_num_other,level+1);
00300 }
00301 }
00302 if(other_is_coarse) {
00303 if((level-1)>=(grid->Give_n_parallel()-1)) {
00304 if(update_other_bla==true) {
00305
00306 grid->Update_Variable_no_full(array_num_other,anz_num_other,level-1);
00307
00308
00309
00310
00311
00312 }
00313 }
00314 else {
00315 grid->Update_Variable_for_prolongation(array_num_other,
00316 anz_num_other,level-1);
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332 }
00333 }
00334 }
00335 if(GS_expression==false) {
00336 if(status==0) {
00337 if(size_stencil>1 && anz_num>0) {
00338 if(update_ENT && update_WSD) {
00339
00340 grid->Update_Variable_no_full(array_num,anz_num,level);
00341 }
00342 else {
00343
00344
00345
00346 grid->Update_Variable_no_full(array_num,anz_num,level);
00347
00348 grid->Update_Variable(Edir,array_num,anz_num,level);
00349 grid->Update_Variable(Ndir,array_num,anz_num,level);
00350 grid->Update_Variable(Tdir,array_num,anz_num,level);
00351 }
00352 }
00353 ++status;
00354 if(run_object.r_nearb==true) {
00355 cellpoi_pointer = grid->Start_P_cellpoi(level);
00356
00357 if(size_stencil>1) return cellf_large_evaluation;
00358 else return cellf_1_evaluation;
00359 }
00360 }
00361 int color, kind;
00362
00363 while(status<33) {
00364
00365
00366
00367
00368
00369
00370 color = (status-1)/4;
00371 kind = (status-1)%4;
00372
00373 if(kind==0) {
00374 ++status;
00375 if(run_object.r_interior==true) {
00376 interior_pointer = grid->Start_P_interior(level,color);
00377 if(max_level==level) {
00378 if(size_stencil==25) return interior_25_evaluation_fine;
00379 if(size_stencil==17) return interior_17_evaluation_fine;
00380 if(size_stencil==15) return interior_15_evaluation_fine;
00381 else return interior_1_evaluation_fine;
00382 }
00383 else {
00384 if(size_stencil==25) return interior_25_evaluation_coarse;
00385 if(size_stencil==17) return interior_17_evaluation_coarse;
00386 if(size_stencil==15) return interior_15_evaluation_coarse;
00387 else return interior_1_evaluation_coarse;
00388 }
00389 }
00390 kind=1;
00391 }
00392 if(kind==1) {
00393 ++status;
00394 if(run_object.r_nearb==true) {
00395 nearb_pointer = grid->Start_P_nearb(level,color);
00396
00397 if(size_stencil>=17) return nearb_17_evaluation;
00398 if(size_stencil==15) return nearb_15_evaluation;
00399 else return nearb_1_evaluation;
00400 }
00401 kind=2;
00402 }
00403 if(kind==2) {
00404 ++status;
00405 Bo2p_pointer = grid->Start_P_Bo2p(level,color);
00406
00407 if(run_object.r_boundary==1) {
00408 return boundary_evaluation_all;
00409 }
00410 if(run_object.r_boundary<0) {
00411 return boundary_evaluation_subset;
00412 }
00413 }
00414 if(kind==3) {
00415 ++status;
00416 nearb_pointer = grid->Start_P_exteri(level,color);
00417 if(run_object.r_boundary==1) {
00418 if(size_stencil>=17) return nearb_17_evaluation;
00419 if(size_stencil==15) return nearb_15_evaluation;
00420 else return nearb_1_evaluation;
00421 }
00422 if(run_object.r_boundary<0) {
00423 if(size_stencil>=17) return exteri_17_evaluation_subset;
00424 if(size_stencil==15) return exteri_15_evaluation_subset;
00425 else return exteri_1_evaluation_subset;
00426 }
00427 }
00428 }
00429 return stop_evaluation;
00430 }
00431 else {
00432 if(status==0) {
00433 ++status;
00434 if(size_stencil>1 && anz_num>0) {
00435 if(update_ENT) {
00436
00437 grid->Update_Variable_no_full(array_num,anz_num,level);
00438
00439
00440 grid->Update_Variable(Wdir,array_num,anz_num,level);
00441 grid->Update_Variable(Sdir,array_num,anz_num,level);
00442 grid->Update_Variable(Ddir,array_num,anz_num,level);
00443 }
00444 }
00445 if(run_object.r_nearb==true) {
00446 cellpoi_pointer = grid->Start_P_cellpoi(level);
00447
00448 if(size_stencil>1) return cellf_large_evaluation;
00449 else return cellf_1_evaluation;
00450 }
00451 }
00452
00453 int color, kind;
00454
00455 while(status<33) {
00456
00457
00458
00459
00460
00461
00462 color = (status-1)/4;
00463 kind = (status-1)%4;
00464
00465 if(size_stencil>1 && color!=0 && kind==0 && anz_num>0) {
00466
00467
00468 grid->Update_Variable_no_full(array_num,anz_num,level);
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481 grid->Update_Variable(Parallel_GS_formula[color-1],array_num,
00482 anz_num,level);
00483
00484 }
00485
00486 if(kind==0) {
00487 ++status;
00488 if(run_object.r_interior==true) {
00489 interior_pointer = grid->Start_P_interior(level,color);
00490
00491 if(max_level==level) {
00492 if(size_stencil==25) return interior_25_evaluation_fine;
00493 if(size_stencil==17) return interior_17_evaluation_fine;
00494 if(size_stencil==15) return interior_15_evaluation_fine;
00495 else return interior_1_evaluation_fine;
00496 }
00497 else {
00498 if(size_stencil==25) return interior_25_evaluation_coarse;
00499 if(size_stencil==17) return interior_17_evaluation_coarse;
00500 if(size_stencil==15) return interior_15_evaluation_coarse;
00501 else return interior_1_evaluation_coarse;
00502 }
00503 }
00504 kind=1;
00505 }
00506 if(kind==1) {
00507 ++status;
00508 if(run_object.r_nearb==true) {
00509 nearb_pointer = grid->Start_P_nearb(level,color);
00510
00511 if(size_stencil>=17) return nearb_17_evaluation;
00512 if(size_stencil==15) return nearb_15_evaluation;
00513 else return nearb_1_evaluation;
00514 }
00515 kind=2;
00516 }
00517 if(kind==2) {
00518 ++status;
00519 Bo2p_pointer = grid->Start_P_Bo2p(level,color);
00520
00521 if(run_object.r_boundary==1) {
00522 return boundary_evaluation_all;
00523 }
00524 if(run_object.r_boundary<0) {
00525 return boundary_evaluation_subset;
00526 }
00527 }
00528 if(kind==3) {
00529 ++status;
00530 nearb_pointer = grid->Start_P_exteri(level,color);
00531 if(run_object.r_boundary==1) {
00532 if(size_stencil>=17) return nearb_17_evaluation;
00533 if(size_stencil==15) return nearb_15_evaluation;
00534 else return nearb_1_evaluation;
00535 }
00536 if(run_object.r_boundary<0) {
00537 if(size_stencil>=17) return exteri_17_evaluation_subset;
00538 if(size_stencil==15) return exteri_15_evaluation_subset;
00539 else return exteri_1_evaluation_subset;
00540 }
00541 }
00542 }
00543 if(size_stencil>1) {
00544 grid->Update_Variable(Parallel_GS_formula[7],array_num,anz_num,level);
00545 }
00546 return stop_evaluation;
00547 }
00548 }
00549
00550 else {
00551 if(status==0) {
00552 ++status;
00553 if(run_object.r_nearb==true) {
00554 cellpoi_pointer = grid->Start_P_cellpoi(level);
00555
00556 if(size_stencil>1) return cellf_large_evaluation;
00557 else return cellf_1_evaluation;
00558 }
00559 }
00560 int color, kind;
00561
00562 while(status<33) {
00563
00564
00565
00566
00567
00568
00569 color = (status-1)/4;
00570 kind = (status-1)%4;
00571
00572 if(kind==0) {
00573 ++status;
00574 if(run_object.r_interior==true) {
00575 interior_pointer = grid->Start_P_interior(level,color);
00576 if(max_level==level) {
00577 if(size_stencil==25) return interior_25_evaluation_fine;
00578 if(size_stencil==17) return interior_17_evaluation_fine;
00579 if(size_stencil==15) return interior_15_evaluation_fine;
00580 else return interior_1_evaluation_fine;
00581 }
00582 else {
00583 if(size_stencil==25) return interior_25_evaluation_coarse;
00584 if(size_stencil==17) return interior_17_evaluation_coarse;
00585 if(size_stencil==15) return interior_15_evaluation_coarse;
00586 else return interior_1_evaluation_coarse;
00587 }
00588 }
00589 kind=1;
00590 }
00591 if(kind==1) {
00592 ++status;
00593 if(run_object.r_nearb==true) {
00594 nearb_pointer = grid->Start_P_nearb(level,color);
00595
00596 if(size_stencil>=17) return nearb_17_evaluation;
00597 if(size_stencil==15) return nearb_15_evaluation;
00598 else return nearb_1_evaluation;
00599 }
00600 kind=2;
00601 }
00602 if(kind==2) {
00603 ++status;
00604 Bo2p_pointer = grid->Start_P_Bo2p(level,color);
00605
00606 if(run_object.r_boundary==1) {
00607 return boundary_evaluation_all;
00608 }
00609 if(run_object.r_boundary<0) {
00610 return boundary_evaluation_subset;
00611 }
00612 }
00613 if(kind==3) {
00614 ++status;
00615 nearb_pointer = grid->Start_P_exteri(level,color);
00616 if(run_object.r_boundary==1) {
00617 if(size_stencil>=17) return nearb_17_evaluation;
00618 if(size_stencil==15) return nearb_15_evaluation;
00619 else return nearb_1_evaluation;
00620 }
00621 if(run_object.r_boundary<0) {
00622 if(size_stencil>=17) return exteri_17_evaluation_subset;
00623 if(size_stencil==15) return exteri_15_evaluation_subset;
00624 else return exteri_1_evaluation_subset;
00625 }
00626 }
00627 }
00628 return stop_evaluation;
00629 }
00630 };
00631
00632