00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00024
00026
00027
00028 #ifdef COMP_GNUOLD
00029 #include <iostream.h>
00030 #include <fstream.h>
00031 #include <time.h>
00032 #include <math.h>
00033 #else
00034 #include <iostream>
00035 #include <fstream>
00036 #include <ctime>
00037 #include <cmath>
00038 #endif
00039
00040 #ifdef USE_PBE
00041 #include "pbedefs.h"
00042 #endif
00043
00044
00045 #include "../parser.h"
00046
00047
00048 #include "../paramete.h"
00049 #include "../abbrevi.h"
00050 #include "../math_lib/math_lib.h"
00051
00052
00053 #include "../basic/basic.h"
00054
00055
00056 #include "../domain/domain.h"
00057
00058
00059 #include "../formulas/boundy.h"
00060 #include "../formulas/loc_sten.h"
00061
00062
00063 #include "gpar.h"
00064 #include "parallel.h"
00065 #include "mgcoeff.h"
00066 #include "sto_man.h"
00067 #include "gridbase.h"
00068 #include "grid.h"
00069
00070
00072
00074
00075 Grid_base::Grid_base(int n_max, All_Domains* dom,
00076 Grid_gen_parameters& gpara, MPI_Comm comm) :
00077 Parallel_Info(dom,comm) {
00078
00079 if(dom->Is_periodic()) {
00080 cout << " please do not use this constructor! " << endl;
00081 }
00082
00083
00084 refine_level = gpara.Give_r_parallel();
00085
00086
00087 offset_square = gpara.Give_offset_square();
00088 h_offset = offset_square * dom->GiveH() / Zweipotenz(n_max);
00089
00090
00091 A_bounding = dom->GiveA() + D3vector(-h_offset, -h_offset, -h_offset);
00092 H_bounding = dom->GiveH()+2.0*h_offset;
00093 H_bounding = gpara.Give_stretch_square() * H_bounding;
00094
00095 max_level=n_max;
00096
00097
00098 if(gpara.Is_there_grid_point()) {
00099 make_grid_with_grid_point(gpara.Give_grid_point(),
00100 H_bounding / Zweipotenz(max_level));
00101 }
00102
00103
00104 if(parallel_version) {
00105 if(print_status_of_grid_generator) if(my_rank==0) {
00106 cout << " Generate_processes(); " << endl;
00107 }
00108 Generate_processes();
00109 if(print_status_of_grid_generator) if(my_rank==0) {
00110 cout << " Grid_generation(); " << endl;
00111 }
00112 if(I_am_active()) Grid_generation(n_max);
00113 else Dummy_grid_generation();
00114 }
00115
00116 else {
00117 Generate_seriel_process();
00118 Grid_generation(n_max);
00119 }
00120 }
00121
00122 Grid_base::Grid_base(double h_finest_level, All_Domains* dom,
00123 Grid_gen_parameters& gpara, MPI_Comm comm) :
00124 Parallel_Info(dom,comm) {
00125 int i;
00126
00127 if(dom->Is_periodic()) {
00128 cout << " please do not use this constructor! " << endl;
00129 }
00130
00131
00132 refine_level = gpara.Give_r_parallel();
00133
00134
00135 offset_square = gpara.Give_offset_square();
00136 h_offset = offset_square * h_finest_level;
00137
00138
00139 A_bounding = dom->GiveA() + D3vector(-h_offset, -h_offset, -h_offset);
00140 H_bounding = dom->GiveH()+2.0*h_offset;
00141 H_bounding = gpara.Give_stretch_square() * H_bounding;
00142
00143
00144 if(h_finest_level > H_bounding / 4.0)
00145 cout << " Coose large meshsize h_finest_level!! " << endl;
00146
00147
00148 if(gpara.Is_there_grid_point()) {
00149 make_grid_with_grid_point(gpara.Give_grid_point(),h_finest_level);
00150 }
00151
00152
00153 for(i=2;(i<Max_number_levels) &&
00154 (H_bounding > ((double)(Zweipotenz(i)) * h_finest_level));i++) { };
00155 max_level=i;
00156 H_bounding = Zweipotenz(max_level) * h_finest_level;
00157
00158
00159
00160 if(parallel_version) {
00161 if(print_status_of_grid_generator) if(my_rank==0) {
00162 cout << " Generate_processes(); " << endl;
00163 }
00164 Generate_processes();
00165 if(print_status_of_grid_generator) if(my_rank==0) {
00166 cout << " Grid_generation(); " << endl;
00167 }
00168 if(I_am_active()) Grid_generation(max_level);
00169 else Dummy_grid_generation();
00170 }
00171
00172 else {
00173 Generate_seriel_process();
00174 Grid_generation(max_level);
00175 }
00176 }
00177
00178 Grid_base::Grid_base(int n_max, All_Domains* dom, MPI_Comm comm) :
00179 Parallel_Info(dom,comm) {
00180 Grid_gen_parameters gpara;
00181
00182 if(dom->Is_periodic()) {
00183 gpara.Set_offset_square(0.0);
00184 gpara.Set_stretch_square(1.0);
00185 }
00186
00187
00188 refine_level = gpara.Give_r_parallel();
00189
00190
00191 offset_square = gpara.Give_offset_square();
00192 h_offset = offset_square * dom->GiveH() / Zweipotenz(n_max);
00193
00194
00195
00196 A_bounding = dom->GiveA() + D3vector(-h_offset, -h_offset, -h_offset);
00197 H_bounding = dom->GiveH()+2.0*h_offset;
00198 H_bounding = gpara.Give_stretch_square() * H_bounding;
00199
00200 max_level=n_max;
00201
00202
00203 if(parallel_version) {
00204 if(print_status_of_grid_generator) if(my_rank==0) {
00205 cout << " Generate_processes(); " << endl;
00206 }
00207 Generate_processes();
00208 if(print_status_of_grid_generator) if(my_rank==0) {
00209 cout << " Grid_generation(); " << endl;
00210 }
00211 if(I_am_active()) Grid_generation(max_level);
00212 else Dummy_grid_generation();
00213 }
00214
00215 else {
00216 Generate_seriel_process();
00217 Grid_generation(max_level);
00218 }
00219 }
00220
00221 Grid_base::Grid_base(double h_finest_level, All_Domains* dom, MPI_Comm comm) :
00222 Parallel_Info(dom,comm) {
00223 int i;
00224 Grid_gen_parameters gpara;
00225
00226 if(dom->Is_periodic()) {
00227 cout << " please do not use this constructor! " << endl;
00228 }
00229
00230
00231 refine_level = gpara.Give_r_parallel();
00232
00233
00234 offset_square = gpara.Give_offset_square();
00235 h_offset = offset_square * h_finest_level;
00236
00237
00238 A_bounding = dom->GiveA() + D3vector(-h_offset, -h_offset, -h_offset);
00239 H_bounding = dom->GiveH()+2.0*h_offset;
00240 H_bounding = gpara.Give_stretch_square() * H_bounding;
00241
00242 if(h_finest_level > H_bounding / 4.0)
00243 cout << " Coose large meshsize h_finest_level!! " << endl;
00244
00245
00246
00247 for(i=2;(i<Max_number_levels) &&
00248 (H_bounding > ((double)(Zweipotenz(i)) * h_finest_level));i++) { };
00249
00250 max_level=i;
00251 H_bounding = Zweipotenz(max_level) * h_finest_level;
00252
00253
00254 if(parallel_version) {
00255 if(print_status_of_grid_generator) if(my_rank==0) {
00256 cout << " Generate_processes(); " << endl;
00257 }
00258 Generate_processes();
00259 if(print_status_of_grid_generator) if(my_rank==0) {
00260 cout << " Grid_generation(); " << endl;
00261 }
00262 if(I_am_active()) Grid_generation(max_level);
00263 else Dummy_grid_generation();
00264 }
00265
00266 else {
00267 Generate_seriel_process();
00268 Grid_generation(max_level);
00269 }
00270 }
00271
00272
00273 double Grid_base::finest_mesh_size() const {
00274 return H_mesh() / Zweipotenz(Max_level());
00275 }
00276
00278
00280
00281
00282 void Grid_base::Initialize_variable() {
00283 if(print_status_of_grid_generator) if(my_rank==0) {
00284 cout << " Initialize_variable(); " << endl;
00285 }
00286
00287
00288
00289
00290
00291
00292 if(print_status_of_grid_generator) if(my_rank==0) {
00293 cout << " III.3.1 construct boundary points; " << endl;
00294 }
00295 #ifdef USE_PBE
00296 pbe_start(19,"III-3.1_construct_boundary_points");
00297 #endif
00298 auxiliary_P = NULL;
00299 auxiliary_number = 0;
00300 h_min_for_boundary_points =
00301 finest_mesh_size() * finest_mesh_size()
00302 / domain->GiveH() * factor_boundary_dis;
00303 Calc_boundary_2points(Give_max_num_var());
00304 #ifdef USE_PBE
00305 pbe_stop(19);
00306 #endif
00307
00308
00309 if(print_status_of_grid_generator) if(my_rank==0) {
00310 cout << " remove edges; " << endl;
00311 }
00312 #ifdef USE_PBE
00313 pbe_start(20,"III-3.2_remove_edges");
00314 #endif
00315 Remove_edges();
00316
00317
00318 Calc_multigrid_points_part2();
00319 #ifdef USE_PBE
00320 pbe_stop(20);
00321 #endif
00322
00323
00324 if(print_status_of_grid_generator) if(my_rank==0) {
00325 cout << " III.4.1 storage for boundary cells; " << endl;
00326 }
00327 #ifdef USE_PBE
00328 pbe_start(21,"III-4.1_storage_for_bo_cells");
00329 #endif
00330 iterate_hash2 {
00331 if(bocell->Exists_bocellpoint()) {
00332 if(Give_max_num_var()>0) bocell->var = newdouble(Give_max_num_var());
00333 else bocell->var = NULL;
00334 }
00335 }
00336 #ifdef USE_PBE
00337 pbe_stop(21);
00338 #endif
00339
00340
00341 if(print_status_of_grid_generator) if(my_rank==0) {
00342 cout << " III.4.2 storage for cells and stencils; " << endl;
00343 }
00344 #ifdef USE_PBE
00345 pbe_start(22,"III-4.2_storage_for_cells_and_stencils");
00346 #endif
00347 iterate_hash0 {
00348 if(point0->Give_Index().Cell_index()) {
00349 if(point0->typ==bo_cell) {
00350 if(Give_max_num_bo_cells()>0)
00351 point0->var = newdouble(Give_max_num_bo_cells());
00352 else point0->var = NULL;
00353 }
00354 if(point0->typ==int_cell) {
00355 if(point0->Give_Index().Tiefe()<=Max_level()) {
00356 if(Give_max_num_coarse_int_cells()>0)
00357 point0->var = newdouble(Give_max_num_coarse_int_cells());
00358 else point0->var = NULL;
00359 }
00360 }
00361
00362 if(point0->typ==int_cell) {
00363 if(point0->Give_Index().Tiefe()==Max_level()+1) {
00364 if(Give_max_num_fine_all_cells()>0)
00365 point0->var = newdouble(Give_max_num_fine_all_cells());
00366 else point0->var = NULL;
00367 }
00368 }
00369 }
00370 }
00371 #ifdef USE_PBE
00372 pbe_stop(22);
00373 #endif
00374
00375 if(print_status_of_grid_generator) if(my_rank==0) {
00376 cout << " III.4.3 storage for boundary matrices; " << endl;
00377 }
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392 }
00393
00394
00395
00396
00397 void Grid_base::Calc_boundary_2points(int number_var) {
00398 static int i, d;
00399 static IndexEdge edge;
00400 static Index3D I, Icorner;
00401 Bo_description Bodes;
00402 Pointtype typpoi;
00403 static dir_3D oppdir;
00404 static double h;
00405
00406
00407 Tetraeder_storage* tet;
00408 double h_[24];
00409 D3vector V;
00410
00411
00412 iterate_hash2 {
00413 I = bocell->Give_Index();
00414 Bodes.Put_zero();
00415
00416 for(i=0;i<12;++i) {
00417 edge = I.edge((Edges_cell)i);
00418 if(Give_edge_typ(edge.I()) == edge_interior) {
00419
00420 Bodes.Put_edge((Edges_cell)i);
00421 }
00422 else {
00423
00424 for(d=0;d<2;++d) {
00425 Icorner = edge.corner((dir1D)d);
00426 typpoi=Give_type(Icorner);
00427
00428 if(typpoi!=exterior && typpoi!=multigrid && typpoi!=boundary) {
00429 oppdir = edge.opposite_direction((dir1D)d);
00430 Add_bo2point(Icorner,oppdir,I.Tiefe()-1,number_var);
00431
00432 h = hashtable3_point(Icorner,oppdir)->h;
00433 Bodes.Put_edge_point(Transform((Edges_cell)i,(dir1D)d),oppdir,h);
00434 }
00435 }
00436 }
00437 }
00438
00439
00440 for(i=0;i<8;++i) {
00441 typpoi=Give_type(I.neighbour((dir_sons)i));
00442 if(typpoi!=exterior && typpoi!=multigrid)
00443 Bodes.Put_corner_point((dir_sons)i);
00444 }
00445
00446 Bodes.Put_Meshsize(H_mesh()/Zweipotenz(I.Tiefe()-1));
00447 bocell->Calc_FE_elements(Bodes);
00448
00449
00450 if(Give_max_num_fine_all_cells()>0) {
00451 bocell->Set_h(h_,Bodes);
00452
00453 for(tet=bocell->Give_tets();tet!=NULL;tet=tet->Next()) {
00454 tet->Set_var(newdouble(Give_max_num_fine_all_cells()));
00455
00456 V = (bocell->coord(tet->N0(),h_) +
00457 bocell->coord(tet->N1(),h_) +
00458 bocell->coord(tet->N2(),h_) +
00459 bocell->coord(tet->N3(),h_) ) / 4.0 +
00460 transform_coord(I.neighbour(WSDd));
00461
00462 auxiliary_P =
00463 new P_boundary_tet(V,auxiliary_P,
00464 tet->Give_variable(),tet,bocell);
00465 ++auxiliary_number;
00466 }
00467 }
00468 }
00469 }
00470
00471
00472
00473 void Grid_base::Information() {
00474 cout << "Information about the grid: " << endl;
00475 Info_hashtable0();
00476 Info_hashtable1();
00477 Info_hashtable2();
00478 Info_hashtable3();
00479 Info_hashtable4();
00480 }
00481
00482
00483 int Grid_base::Give_Nummer(Index3D I) {
00484 static Point_hashtable1* point;
00485
00486 if(developer_version) {
00487 point=hashtable1_point(I);
00488 if(point==NULL) {
00489 cout << " \n Punkt existiert nicht in Give_Nummer!" << endl;
00490 return 0;
00491 }
00492 else return point->nummer;
00493 }
00494 else return hashtable1_point(I)->nummer;
00495 }
00496
00497 int Grid_base::Give_Nummer(Index3D I, dir_3D d) {
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508 if(developer_version) {
00509 if(hashtable3_point(I,d)==NULL) {
00510 cout << " \n Grid_base::Fehler Give_Nummer!" << endl;
00511 return 0;
00512 }
00513 return hashtable3_point(I,d)->Nummer();
00514 }
00515 else return hashtable3_point(I,d)->Nummer();
00516 }
00517
00518 int Grid_base::Give_Nummer_cellpoi(Index3D I) {
00519 if(developer_version) {
00520 if(hashtable2_point(I)==NULL) {
00521 cout << " \n Fehler Give_Nummer_cellpoi!" << endl;
00522 return 0;
00523 }
00524 return hashtable2_point(I)->Number_avs();
00525 }
00526 else return hashtable2_point(I)->Number_avs();
00527 }
00528
00529
00530
00531
00532
00533 Pointtype Grid_base::Give_type(Index3D I) const {
00534 Point_hashtable1* point;
00535
00536 point=hashtable1_point(I);
00537 if(point==NULL) {
00538 return exterior;
00539 }
00540 else return point->typ;
00541 }
00542
00543 Pointtype Grid_base::Give_global_type(Index3D I) const {
00544 Point_hashtable1* point;
00545
00546 point=hashtable1_point(I);
00547 if(point==NULL) {
00548 return exterior;
00549 }
00550 else return point->global_typ;
00551
00552 }
00553
00554 bool Grid_base::Grid_point_on_finest_level(Index3D I) const {
00555 Point_hashtable1* point;
00556
00557 point=hashtable1_point(I);
00558 if(point==NULL) {
00559 return false;
00560 }
00561 if(point->typ >= interior) return true;
00562 if(point->typ == parallel_p &&
00563 point->my_finest_parallel_level == max_level)
00564 return true;
00565 return false;
00566 }
00567
00568
00569 void Grid_base::Add_double(Index3D I, int varebene, int number_var) {
00570
00571 Put_finest_level_minimal(I,varebene);
00572
00573 Point_hashtable4* point;
00574
00575 point = hashtable4_start[hashtable4_function(
00576 I.ind_x.index,I.ind_y.index,I.ind_z.index,varebene,hashtable4_leng)];
00577
00578 if(point==NULL) {
00579 hashtable4_occ++;
00580 point = new Point_hashtable4(I,varebene,number_var);
00581 hashtable4_start[hashtable4_function(
00582 I.ind_x.index,I.ind_y.index,I.ind_z.index,varebene,hashtable4_leng)] =
00583 point;
00584 }
00585 else {
00586 while(point->next!=NULL && (point->ind!=I || point->level!=varebene))
00587 point = point->next;
00588 if(point->ind!=I || point->level!=varebene) {
00589 hashtable4_occ++;
00590 point->next = new Point_hashtable4(I,varebene,number_var);
00591 }
00592 }
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621 }
00622
00623
00624 void Grid_base::Add_MG_double(int varebene, int number_var) {
00625 iterate_hash1 {
00626 if(point1->label4)
00627 Add_double(point1->ind,varebene,number_var);
00628 }
00629 }
00630
00631 void Grid_base::False_Label4() {
00632 iterate_hash1 {
00633 point1->label4 = false;
00634 }
00635 }
00636
00637
00638 void Grid_base::Add_cell(Index3D I) {
00639 static Point_hashtable0* point;
00640 if(developer_version) {
00641 if(!I.Cell_index()) cout << "\n Error in Add_cell!" << endl;
00642 }
00643 point = hashtable0_start
00644 [hashtable0_function(I.ind_x.index,I.ind_y.index,I.ind_z.index,
00645 hashtable0_leng)];
00646 if(point==NULL) {
00647 hashtable0_occ++;
00648 point = new Point_hashtable0(I);
00649 hashtable0_start[hashtable0_function(I.ind_x.index,I.ind_y.index,
00650 I.ind_z.index,
00651 hashtable0_leng)] = point;
00652 }
00653 else {
00654 while(point->next!=NULL && point->ind!=I) point = point->next;
00655 if(point->ind!=I) {
00656 hashtable0_occ++;
00657 point->next = new Point_hashtable0(I);
00658 }
00659 }
00660 }
00661
00662 void Grid_base::Add_edge(Index3D I) {
00663
00664
00665 static Point_hashtable0* point;
00666 if(developer_version) {
00667 if(!I.Edge_index()) {
00668 cout << "\n Error in Add_edge!" << endl;
00669 return;
00670 }
00671 }
00672 point = hashtable0_start
00673 [hashtable0_function(I.ind_x.index,I.ind_y.index,I.ind_z.index,
00674 hashtable0_leng)];
00675 if(point==NULL) {
00676 hashtable0_occ++;
00677 point = new Point_hashtable0(I);
00678 point->typ = edge_interior;
00679 hashtable0_start[hashtable0_function(I.ind_x.index,I.ind_y.index,
00680 I.ind_z.index,
00681 hashtable0_leng)] = point;
00682 }
00683 else {
00684 while(point->next!=NULL && point->ind!=I) point = point->next;
00685 if(point->ind!=I) {
00686 hashtable0_occ++;
00687 point->next = new Point_hashtable0(I);
00688 point->next->typ = edge_interior;
00689 }
00690 }
00691 }
00692
00693 void Grid_base::Add_edge_parallel(Index3D I) {
00694 if((my_index<=I)==false) {
00695
00696 put_for_send_edge(I);
00697 }
00698 Add_edge(I);
00699 }
00700
00701 Edgetype Grid_base::Give_edge_typ(Index3D I) {
00702 static Point_hashtable0* point;
00703 if(developer_version) {
00704 if(!I.Edge_index()) {
00705 cout << "\n Error 1 in Give_edge_typ!" << endl;
00706 cout << " Point: "; I.coordinate().Print(); cout << endl;
00707 }
00708 }
00709 point = hashtable0_point(I);
00710 if(point==NULL)
00711 return edge_not_interior;
00712 else
00713 return (Edgetype)point->typ;
00714 }
00715
00716 void Grid_base::Set_edge_typ(Index3D I, Edgetype type) {
00717 static Point_hashtable0* point;
00718 if(developer_version) {
00719 if(!I.Edge_index()) cout << "\n Error 1 in Set_edge_typ!" << endl;
00720 }
00721 if(developer_version) {
00722 if(type <0 || type>2) cout << "\n Error 3 in Set_edge_typ!" << endl;
00723 }
00724 if(type==edge_interior) {
00725 point = hashtable0_point(I);
00726 if(developer_version) {
00727 if(point==NULL) cout << "\n Error 2 in Set_edge_typ!" << endl;
00728 }
00729 point->typ = (Edgetype)type;
00730 }
00731 }
00732
00733 void Grid_base::Set_cell_typ(Index3D I, Celltype type) {
00734 static Point_hashtable0* point;
00735 if(developer_version) {
00736 if(!I.Cell_index()) cout << "\n Error 1 in Set_cell_typ!" << endl;
00737 }
00738 if(developer_version) {
00739 if(type <0 || type>4) cout << "\n Error 3 in Set_cell_typ!" << endl;
00740 }
00741 point = hashtable0_point(I);
00742 if(developer_version) {
00743 if(point==NULL) cout << "\n Error 2 in Set_cell_typ!" << endl;
00744 }
00745 point->typ = (Celltype)type;
00746 }
00747
00748
00749 void Grid_base::Set_point_typ(Index3D I, Pointtype type) {
00750 static Point_hashtable1* point;
00751 if(developer_version) {
00752 if(type <0 || type>8) cout << "\n Error 1 in Set_point_typ!" << endl;
00753 }
00754 point = hashtable1_point(I);
00755 if(developer_version) {
00756 if(point==NULL) cout << "\n Error 2 in Set_point_typ!" << endl;
00757 }
00758 point->typ = type;
00759 }
00760
00761 void Grid_base::Add_point(Index3D I, Pointtype type) {
00762 static Point_hashtable1* point;
00763 if(developer_version) {
00764 if(I<<Index3D(2,2,2) == false) {
00765 cout << " Error in Grid_base::Add_point(Index3D I, Pointtype type)"
00766 << endl;
00767 }
00768 }
00769 point = hashtable1_start
00770 [hashtable1_function(I.ind_x.index,I.ind_y.index,I.ind_z.index,
00771 hashtable1_leng)];
00772 if(point==NULL) {
00773 hashtable1_occ++;
00774
00775 point = new Point_hashtable1(I);
00776 point->typ = type;
00777 hashtable1_start[hashtable1_function(I.ind_x.index,I.ind_y.index,
00778 I.ind_z.index,
00779 hashtable1_leng)] = point;
00780 }
00781 else {
00782 while(point->next!=NULL && point->ind!=I) {
00783 point = point->next;
00784 }
00785 if(point->ind!=I) {
00786 hashtable1_occ++;
00787
00788 point->next = new Point_hashtable1(I);
00789 point->next->typ = type;
00790 }
00791 }
00792 }
00793
00794
00795
00796 void Grid_base::Add_point(Index3D I) {
00797 static Point_hashtable1* point;
00798 point = hashtable1_start
00799 [hashtable1_function(I.ind_x.index,I.ind_y.index,I.ind_z.index,
00800 hashtable1_leng)];
00801 if(point==NULL) {
00802 hashtable1_occ++;
00803 point = new Point_hashtable1(I);
00804 hashtable1_start[hashtable1_function(I.ind_x.index,I.ind_y.index,
00805 I.ind_z.index,
00806 hashtable1_leng)] = point;
00807 }
00808 else {
00809 while(point->next!=NULL && point->ind!=I) point = point->next;
00810 if(point->ind!=I) {
00811 hashtable1_occ++;
00812 point->next = new Point_hashtable1(I);
00813 }
00814 }
00815 }
00816
00817 void Grid_base::Set_point_typ(Index3D I, int finest_parallel_level,
00818 Pointtype type) {
00819 static Point_hashtable1* point;
00820 if(developer_version) {
00821 if(type <0 || type>8) cout << "\n Error 3 in Set_point_typ!" << endl;
00822 }
00823 point = hashtable1_point(I);
00824 if(developer_version) {
00825 if(point==NULL) cout << "\n Error 4 in Set_point_typ!" << endl;
00826 }
00827 point->typ = type;
00828 point->my_finest_parallel_level = finest_parallel_level;
00829 }
00830
00831 void Grid_base::Add_point_interior(Index3D I) {
00832 static Point_hashtable1* point;
00833 point = hashtable1_start
00834 [hashtable1_function(I.ind_x.index,I.ind_y.index,I.ind_z.index,
00835 hashtable1_leng)];
00836 if(point==NULL) {
00837 hashtable1_occ++;
00838 point = new Point_hashtable1(I,interior);
00839 hashtable1_start[hashtable1_function(I.ind_x.index,I.ind_y.index,
00840 I.ind_z.index,
00841 hashtable1_leng)] = point;
00842 }
00843 else {
00844 while(point->next!=NULL && point->ind!=I) point = point->next;
00845 if(point->ind!=I) {
00846 hashtable1_occ++;
00847 point->next = new Point_hashtable1(I,interior);
00848 }
00849 }
00850 }
00851
00852 void Grid_base::Add_bocell(Index3D I) {
00853 static Point_hashtable2* bocell_sp;
00854 bocell_sp = hashtable2_start
00855 [hashtable2_function(I.ind_x.index,I.ind_y.index,I.ind_z.index,
00856 hashtable2_leng)];
00857 if(bocell_sp==NULL) {
00858 hashtable2_occ++;
00859 bocell_sp = new Point_hashtable2(I,this);
00860 hashtable2_start[hashtable2_function(I.ind_x.index,I.ind_y.index,
00861 I.ind_z.index,
00862 hashtable2_leng)] = bocell_sp;
00863 }
00864 else {
00865 while(bocell_sp->next!=NULL && bocell_sp->ind!=I)
00866 bocell_sp = bocell_sp->next;
00867 if(bocell_sp->ind!=I) {
00868 hashtable2_occ++;
00869 bocell_sp->next = new Point_hashtable2(I,this);
00870 }
00871 }
00872 }
00873
00874
00875 void Grid_base::Add_bo2point(Index3D I, dir_3D d, int l, int number_var) {
00876 static Point_hashtable3* bo2point_sp;
00877 bo2point_sp = hashtable3_start
00878 [hashtable3_function(I.ind_x.index,I.ind_y.index,I.ind_z.index,d,
00879 hashtable3_leng)];
00880 if(bo2point_sp==NULL) {
00881 hashtable3_occ++;
00882 bo2point_sp = new Point_hashtable3(I,d,l,this,number_var);
00883 hashtable3_start[hashtable3_function(I.ind_x.index,I.ind_y.index,
00884 I.ind_z.index,d,
00885 hashtable3_leng)] = bo2point_sp;
00886 }
00887 else {
00888 while(bo2point_sp->next!=NULL && (bo2point_sp->ind!=I
00889 || bo2point_sp->direction!=d))
00890 bo2point_sp = bo2point_sp->next;
00891 if(bo2point_sp->ind!=I || bo2point_sp->direction!=d) {
00892 hashtable3_occ++;
00893 bo2point_sp->next = new Point_hashtable3(I,d,l,this,number_var);
00894 }
00895 }
00896 }
00897
00898
00899
00900
00901
00902 void Grid_base::Label_true(Index3D I) {
00903 hashtable1_point(I)->label4=true;
00904 }
00905
00906 bool Grid_base::Label_ask(Index3D I) {
00907 return hashtable1_point(I)->label4;;
00908 }
00909
00910
00911
00912 bool Grid_base::Is_Bo_cell(Index3D I) {
00913 return hashtable2_point(I)!=NULL;
00914 }
00915 BoCell *Grid_base::Give_Bo_cell(Index3D I) const {
00916 return hashtable2_point(I);
00917 }
00918
00919
00920 void Grid_base::Fullfill_27Stencil() {
00921 static int occ_old;
00922
00923 occ_old = 0;
00924 while(occ_old != hashtable1_occ) {
00925 occ_old = hashtable1_occ;
00926 iterate_hash1 {
00927 Add_27Stencil(point1->ind);
00928 }
00929 }
00930 }
00931
00932 void Grid_base::Add_small_27Stencil(Index3D I, int level) {
00933 static int i, j, k;
00934 static Index3D Inext;
00935
00936 for(i=0;i<3;++i)
00937 for(j=0;j<3;++j)
00938 for(k=0;k<3;++k) {
00939 Inext = I.next((Ort1D)i,(Ort1D)j,(Ort1D)k,level);
00940 if(!Exists_Point(Inext)) Add_point(Inext);
00941 }
00942 }
00943
00944
00945 void Grid_base::Add_27Stencil(Index3D I) {
00946 if(I.Tiefe()>0) Recursion_Add_27Stencil(I,I.Tiefe());
00947 }
00948
00949 void Grid_base::Recursion_Add_27Stencil(Index3D I,int l) {
00950 if(!Exists_Point(I)) Add_point(I);
00951 if(I.ind_x.Tiefe() == l) {
00952 Recursion_Add_27Stencil(I.neighbour_EW(Ld),l);
00953 Recursion_Add_27Stencil(I.neighbour_EW(Rd),l);
00954 }
00955 if(I.ind_y.Tiefe() == l) {
00956 Recursion_Add_27Stencil(I.neighbour_NS(Ld),l);
00957 Recursion_Add_27Stencil(I.neighbour_NS(Rd),l);
00958 }
00959 if(I.ind_z.Tiefe() == l) {
00960 Recursion_Add_27Stencil(I.neighbour_TD(Ld),l);
00961 Recursion_Add_27Stencil(I.neighbour_TD(Rd),l);
00962 }
00963 }
00964
00965
00966
00967 void Grid_base::Add_points_of_cell(Index3D I) {
00968 static int i;
00969 static Index3D In;
00970
00971 for(i=0;i<8;++i) {
00972 In = I.neighbour((dir_sons)i);
00973 if(!Exists_Point(In)) Add_point(In);
00974 }
00975 }
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061 bool Grid_base::Is_Slave(Index3D I) {
01062 bool slave_yn;
01063 Point_hashtable1* poi;
01064
01065 if(I.Tiefe()>0) slave_yn = Calc_Is_Slave(I);
01066 else slave_yn = false;
01067 if(slave_yn==true) {
01068
01069 poi = hashtable1_point(I);
01070 poi->typ = slave;
01071 poi->level = I.Tiefe();
01072 }
01073 return slave_yn;
01074 }
01075
01076 bool Grid_base::Decide_poi_interpolates(Index3D I) {
01077 Pointtype p_typ;
01078
01079 p_typ = Give_type(I);
01080 if((p_typ == exterior) || (p_typ == multigrid) || (p_typ == nearb))
01081
01082 return false;
01083 return true;
01084 }
01085
01086
01087 bool Grid_base::Calc_Is_Slave(Index3D I) {
01088 int t, i, j, k;
01089 Index3D Ix, Iy, Iz;
01090
01091 t = I.Tiefe();
01092 if(I.ind_x.Tiefe() == t && I.ind_x.Tiefe() > 0) {
01093 if(I.ind_y.Tiefe() < t && I.ind_z.Tiefe() < t) return true;
01094 for(i=0;i<2;++i) {
01095 Ix = I.neighbour_EW((dir1D)i);
01096 if(I.ind_y.Tiefe() == t && I.ind_y.Tiefe() > 0) {
01097 for(j=0;j<2;++j) {
01098 Iy = Ix.neighbour_NS((dir1D)j);
01099 if(I.ind_z.Tiefe() == t && I.ind_z.Tiefe() > 0) {
01100 for(k=0;k<2;++k) {
01101 Iz = Iy.neighbour_TD((dir1D)k);
01102 if(!Decide_poi_interpolates(Iz)) return false;
01103 }
01104 }
01105 else {
01106 if(!Decide_poi_interpolates(Iy)) return false;
01107 }
01108 }
01109 }
01110 else {
01111
01112 if(I.ind_z.Tiefe() == t && I.ind_z.Tiefe() > 0) {
01113 for(k=0;k<2;++k) {
01114 Iz = Ix.neighbour_TD((dir1D)k);
01115 if(!Decide_poi_interpolates(Iz)) return false;
01116 }
01117 }
01118 else {
01119 if(!Decide_poi_interpolates(Ix)) return false;
01120 }
01121 }
01122 }
01123 }
01124 else {
01125 if(I.ind_y.Tiefe() == t && I.ind_y.Tiefe() > 0) {
01126 if(I.ind_z.Tiefe() < t) return true;
01127 for(j=0;j<2;++j) {
01128 Iy = I.neighbour_NS((dir1D)j);
01129
01130 if(I.ind_z.Tiefe() == t && I.ind_z.Tiefe() > 0) {
01131 for(k=0;k<2;++k) {
01132 Iz = Iy.neighbour_TD((dir1D)k);
01133 if(!Decide_poi_interpolates(Iz)) return false;
01134 }
01135 }
01136 else {
01137 if(!Decide_poi_interpolates(Iy)) return false;
01138 }
01139 }
01140 }
01141 else {
01142 return true;
01143 }
01144 }
01145 return true;
01146 }
01147
01148
01149
01150 void Grid_base::Put_finest_level_minimal(Index3D I, int level) {
01151 Point_hashtable1* poi;
01152 poi = hashtable1_point(I);
01153 if(poi->finest_level<level) poi->finest_level = level;
01154 }
01155
01156 int Grid_base::Give_finest_level(Index3D I) {
01157 return hashtable1_point(I)->finest_level;
01158 }
01159
01160
01161
01162
01163
01164
01165
01166
01167
01168
01169
01170
01171
01172
01173
01174
01175
01176 int Grid_base::Give_my_finest_parallel_level(Index3D I) const {
01177
01178 Point_hashtable1* poi;
01179 poi = hashtable1_point(I);
01180 if(poi==NULL) return -1;
01181 return poi->my_finest_parallel_level;
01182 }
01183
01184
01185
01186 double Grid_base::distanceD(D3vector V, dir_3D d) {
01187 return domain->distance(transform_coord(V),d);
01188 };
01189
01190
01192
01193
01194
01195
01196 #ifdef WITH_BRICK
01197 #define DIMENSION 3
01198
01199
01200 void Grid_base::getBrickInfo() {
01201
01202
01203
01204
01205
01206 D3vector v_WSD;
01207 D3vector v_ENT;
01208
01209 BInfoT brick;
01210
01211
01212 brickInfo_m.clear();
01213
01214
01215 if(parallel_version) {
01216 iterate_hash_proc {
01217 if(point_proc!=NULL) {
01218 if(point_proc->Give_Index().Tiefe()==n_parallel) {
01219 v_WSD = transform_coord(
01220 point_proc->Give_Index().neighbour(WSDd).coordinate());
01221 v_ENT = transform_coord(
01222 point_proc->Give_Index().neighbour(ENTd).coordinate());
01223
01224 brick.localXMin[0] = v_WSD.x - finest_meshsize * 0.5;
01225 brick.localXMin[1] = v_WSD.y - finest_meshsize * 0.5;
01226 brick.localXMin[2] = v_WSD.z - finest_meshsize * 0.5;
01227
01228 brick.localXMax[0] = v_ENT.x - finest_meshsize * 0.5;
01229 brick.localXMax[1] = v_ENT.y - finest_meshsize * 0.5;
01230 brick.localXMax[2] = v_ENT.z - finest_meshsize * 0.5;
01231
01232 brick.eps = finest_meshsize * 0.001;
01233 brick.rank = point_proc->Give_num_proc();
01234 brickInfo_m.insert(brick);
01235
01236
01237
01238
01239
01240
01241 }
01242 }
01243 }
01244 }
01245 else {
01246
01247
01248 v_WSD = transform_coord(Index3D(2,2,2).neighbour(WSDd).coordinate());
01249 v_ENT = transform_coord(Index3D(2,2,2).neighbour(ENTd).coordinate());
01250
01251 brick.localXMin[0] = v_WSD.x - finest_meshsize * 0.5;
01252 brick.localXMin[1] = v_WSD.y - finest_meshsize * 0.5;
01253 brick.localXMin[2] = v_WSD.z - finest_meshsize * 0.5;
01254
01255 brick.localXMax[0] = v_ENT.x - finest_meshsize * 0.5;
01256 brick.localXMax[1] = v_ENT.y - finest_meshsize * 0.5;
01257 brick.localXMax[2] = v_ENT.z - finest_meshsize * 0.5;
01258
01259 brick.eps = finest_meshsize * 0.001;
01260 brick.rank = 0;
01261 brickInfo_m.insert(brick);
01262 }
01263 }
01264
01265 void Grid_base::boundbox(double localXMin[DIMENSION], double localXMax[DIMENSION]) {
01266 Set_of_Processors::const_iterator i;
01267 for(unsigned int d=0; d<DIMENSION; d++) {
01268 localXMin[d] = 100000000.0;
01269 localXMax[d] =-100000000.0;
01270 }
01271 for(i=brickInfo_m.begin();i!=brickInfo_m.end();i++) {
01272 for(unsigned int d=0; d<DIMENSION; d++) {
01273 localXMin[d] = MIN(localXMin[d],(*i).localXMin[d]);
01274 localXMax[d] = MAX(localXMax[d],(*i).localXMax[d]);
01275 }
01276 }
01277 }
01278
01279 void Grid_base::localbox(double localXMin[DIMENSION], double localXMax[DIMENSION], int node) {
01280
01281 Set_of_Processors::const_iterator i;
01282 for(i=brickInfo_m.begin();i!=brickInfo_m.end();i++) {
01283 if ((*i).rank==node) {
01284 for(unsigned int d=0; d<DIMENSION; d++) {
01285 localXMin[d] = (*i).localXMin[d];
01286 localXMax[d] = (*i).localXMax[d];
01287 }
01288 }
01289 }
01290 }
01291
01292
01293 #endif // WITH_BRICK
01294
01295
01296
01297
01298
01299
01300
01301
01302
01303
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325
01327
01328
01329
01330 void Grid_base::Test_just_this2(int bla) {
01331 D3vector v;
01332 Index3D I;
01333
01334 MPI_Barrier(MPI_COMM_WORLD);
01335
01336 for(int i=0;i<8;++i) {
01337 if(my_rank==i) {
01338 cout << " \n rank: " << i << endl;
01339 iterate_hash1 {
01340 I = point1->Give_Index();
01341 if(Give_type(I)==multigrid
01342 && I.Tiefe()<=bla
01343 && point1->finest_level>=bla
01344 && ((point1->Give_label(5)>=bla) == true)
01345 ) {
01346
01347
01348
01349
01350
01351 v = I.coordinate();
01352 cout << " point: " << point1->Give_label(5)
01353
01354 << " resp: " << (I<my_index)
01355 << " vector: x: " << v.x << " y: " << v.y << " z: " << v.z
01356 << " level: " << I.Tiefe()
01357 << " x: " << I.I_x().get()
01358 << " y: " << I.I_y().get()
01359 << " z: " << I.I_z().get()
01360 << " lab: " << point1->Give_label(5)
01361 << endl;
01362 }
01363 }
01364 }
01365 MPI_Barrier(MPI_COMM_WORLD);
01366 }
01367 }
01368
01369
01370
01371 void Grid_base::Test_just_this() {
01372
01373 Index3D I;
01374
01375 MPI_Barrier(MPI_COMM_WORLD);
01376 if(my_rank==0) cout << " Test_just_this: " << endl;
01377 MPI_Barrier(MPI_COMM_WORLD);
01378
01379
01380
01381 MPI_Barrier(MPI_COMM_WORLD);
01382 if(my_rank==0) {
01383 cout << " procs von 0: " << endl;
01384 iterate_hash_proc {
01385 cout << " processor "
01386 << " x: " << point_proc->Give_Index().I_x().coordinate()
01387 << " y: " << point_proc->Give_Index().I_y().coordinate()
01388 << " z: " << point_proc->Give_Index().I_z().coordinate()
01389 << endl;
01390 }
01391 }
01392
01393 MPI_Barrier(MPI_COMM_WORLD);
01394 cout << " my_rank: " << my_rank
01395 << " x: " << my_index.I_x().coordinate()
01396 << " y: " << my_index.I_y().coordinate()
01397 << " z: " << my_index.I_z().coordinate()
01398 << endl;
01399 MPI_Barrier(MPI_COMM_WORLD);
01400
01401
01402
01403
01404
01405
01406
01407
01408
01409
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419
01420
01421
01422
01423
01424
01425
01426
01427
01428
01429
01430
01431
01432
01433
01434
01435
01436
01437
01438
01439
01440
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461
01462
01463
01464
01465
01466
01467
01468
01469
01470
01471
01472
01473
01474
01475
01476
01477
01478
01479
01480
01481
01482
01483
01484
01485
01486
01487
01488
01489
01490
01491
01492
01493
01494
01495
01496
01497
01498
01499
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516
01517
01518
01519
01520
01521
01522
01523
01524
01525
01526
01527
01528
01529
01530
01531
01532
01533
01534
01535
01536
01537
01538
01539
01540
01541
01542
01543
01544
01545
01546
01547
01548
01549
01550
01551
01552
01553
01554
01555
01556
01557
01558
01559
01560
01561
01562
01563
01564
01565
01566
01567
01568
01569
01570
01571
01572
01573
01574
01575
01576
01577
01578
01579
01580
01581
01582
01583
01584
01585
01586
01587
01588
01589
01590
01591
01592
01593
01594
01595
01596
01597
01598
01599
01600
01601
01602
01603
01604
01605
01606
01607
01608
01609
01610
01611
01612
01613
01614
01615
01616
01617
01618
01619
01620
01621
01622
01623
01624
01625
01626
01627
01628
01629
01630
01631
01632
01633
01634
01635
01636
01637
01638
01639
01640
01641
01642
01643
01644
01645
01646
01647
01648
01649
01650
01651
01652
01653
01654
01655
01656
01657
01658
01659
01660
01661
01662
01663
01664
01665
01666
01667
01668
01669
01670
01671
01672
01673
01674
01675
01676
01677
01678
01679
01680
01681
01682
01683
01684
01685
01686
01687
01688
01689
01690
01691
01692
01693
01694
01695
01696
01697
01698
01699
01700
01701
01702
01703
01704
01705
01706
01707 }