src/expde/grid/gridbase.cc

Go to the documentation of this file.
00001 //    expde: expression templates for partial differential equations.
00002 //    Copyright (C) 2001  Christoph Pflaum
00003 //    This program is free software; you can redistribute it and/or modify
00004 //    it under the terms of the GNU General Public License as published by
00005 //    the Free Software Foundation; either version 2 of the License, or
00006 //    (at your option) any later version.
00007 //
00008 //    This program is distributed in the hope that it will be useful,
00009 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 //    GNU General Public License for more details.
00012 //
00013 //                 SEE  Notice1.doc made by 
00014 //                 LAWRENCE LIVERMORE NATIONAL LABORATORY
00015 //
00016 
00017 // ------------------------------------------------------------
00018 //
00019 // grid_base.cc
00020 //
00021 // ------------------------------------------------------------
00022 
00024 //  A. Grid_base::Initialize_variable
00026 
00027 // Include level 0:
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 // Include level 0:
00045 #include "../parser.h"
00046 
00047 // Include level 1:
00048 #include "../paramete.h"
00049 #include "../abbrevi.h"
00050 #include "../math_lib/math_lib.h"
00051 
00052 // Include level 2:
00053 #include "../basic/basic.h"
00054 
00055 // Include level 3:
00056 #include "../domain/domain.h"
00057 
00058 // Include level 4:
00059 #include "../formulas/boundy.h"
00060 #include "../formulas/loc_sten.h"
00061 
00062 // Include level 5:
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 //  Z. Grid_base::Grid_base
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   // for parallel:
00084   refine_level = gpara.Give_r_parallel();
00085 
00086   // calc offset
00087   offset_square = gpara.Give_offset_square();
00088   h_offset = offset_square * dom->GiveH() / Zweipotenz(n_max);
00089 
00090   // set bounding_box parameters
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   // move A_bounding if necessary
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   // -> parallel
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   // -> seriell
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   // for parallel:
00132   refine_level = gpara.Give_r_parallel();
00133 
00134   // calc offset
00135   offset_square = gpara.Give_offset_square();
00136   h_offset = offset_square * h_finest_level;
00137 
00138   // set bounding_box parameters
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   // move A_bounding if necessary
00148   if(gpara.Is_there_grid_point()) {
00149     make_grid_with_grid_point(gpara.Give_grid_point(),h_finest_level);
00150   }
00151 
00152   // h_finest_level = H_bounding / Zweipotenz(max_level)
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   // -> parallel
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   // -> seriell
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   // for parallel:
00188   refine_level = gpara.Give_r_parallel();
00189 
00190   // calc offset
00191   offset_square = gpara.Give_offset_square();
00192   h_offset = offset_square * dom->GiveH() / Zweipotenz(n_max);
00193 
00194 
00195   // set bounding_box parameters
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   // -> parallel
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   // -> seriell
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   // for parallel:
00231   refine_level = gpara.Give_r_parallel();
00232 
00233   // calc offset
00234   offset_square = gpara.Give_offset_square();
00235   h_offset = offset_square * h_finest_level;
00236 
00237   // set bounding_box parameters
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   // es muss gelten: 
00246   // h_finest_level = H_bounding / Zweipotenz(max_level)
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   // -> parallel
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   // -> seriell
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 //  A. Grid_base::Initialize_variable
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   //  if(Is_storage_initialized() == false) {
00287   // Continue: Teil III:
00288   // III.3.1.Schritt: Randpunkte 2.Teil berechnen
00289   //                und Berechnung der FE-Zerlegung
00290   //                und Datenspeicher bereitstellen fuer Randpunkte
00291   //                and one list of P_boundary_tet
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   // III.3.2. Schritt: beseitige Kanten
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   // III.3.3. Schritt: 
00318   Calc_multigrid_points_part2();
00319 #ifdef USE_PBE
00320   pbe_stop(20);
00321 #endif
00322 
00323   // III.4.1. Schritt: Datenspeicher bereitstellen fuer Punkte in Randzellen
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   // III.4.2. Schritt: Datenspeicher bereitstellen Zellen-Variablen 
00340   //                   und Stencils
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       // new:
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   // III.4.3. Schritt: Datenspeicher bereitstellen fuer Matrizen in Randzellen 
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   // new:
00381   // -> boundary tets: see Grid_base::Calc_boundary_2points
00382   /*
00383   Tetraeder_storage* tet;
00384   iterate_hash2 {
00385     for(tet=bocell->Give_tets();tet!=NULL;tet=tet->Next()) {
00386       tet->Set_var(newdouble(Give_max_num_fine_all_cells()));
00387     }
00388   }
00389   */
00390   //  }
00391   //  Storge_initialization_done();
00392 }
00393 
00394 // Schritt III.3.1
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   // for list P_boundary_tet:
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         // Kante im Gebiet
00420         Bodes.Put_edge((Edges_cell)i);  
00421       }
00422       else {
00423         // Kante nicht im Gebiet
00424         for(d=0;d<2;++d) {
00425           Icorner = edge.corner((dir1D)d);       
00426           typpoi=Give_type(Icorner);
00427           // typpoi=exterior;
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             // Kantenpunkt im Gebiet
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     // Welche Eckpunkte sind im Gebiet?
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     // for list P_boundary_tet:
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   /* old Vis :
00499   if(developer_version) {
00500     if(hashtable3_point(I,d)==NULL) {
00501       cout << " \n Grid_base::Fehler Give_Nummer!" << endl;
00502       return 0;
00503     }
00504     return hashtable3_point(I,d)->Nummer()+hashtable1_occ;
00505   }
00506   else return hashtable3_point(I,d)->Nummer()+hashtable1_occ;
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   // else return point->typ;
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 && // point->global_typ  != multigrid && 
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   // static Point_hashtable4* point;
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   /* old_hash
00596   static Point_hashtable4* point;
00597   point = &(hashtable4_start
00598     [hashtable4_function(I.ind_x.index,I.ind_y.index,I.ind_z.index,varebene,
00599                          hashtable4_leng)]);
00600   if(point->level==-2) {
00601     hashtable4_occ++;
00602     point->ind = I;
00603     point->level = varebene;
00604     point->var = newdouble(number_var);
00605     if(developer_version) {
00606       if(point->next!=NULL) cout << "\n Fehler 1 in Add_double!" << endl;
00607     }
00608   }
00609   else {
00610     while(point->next!=NULL && (point->ind!=I || point->level!=varebene)) 
00611       point = point->next;
00612     if(point->ind!=I || point->level!=varebene) {
00613       hashtable4_occ++;
00614       point->next = new Point_hashtable4(I,varebene,number_var);
00615       if(developer_version) {
00616         if(point->next->next!=NULL) cout << "\n Fehler 2 in Add_double!" << endl;
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   // cout << "\n Kante: "; I.coordinate().Print();
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     //    cout << " \n face correction not perfect implemented! " << endl;
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 // Informationen ueber die Punkte
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 // Informationen ueber die Randzellen
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   // Schneller machen !!
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 // hier fehlt was: Es reicht nicht wenn der 27-Stern im Gebiet ist;
00980 // Man muss auch testen ob die Zellen im Gebiet sind.
00981 /*
00982 void Grid_base::Calc_interior_points_old() {
00983   static Pointtype point_typ;
00984   static Index3D I, Inext;
00985   static bool weiter, stop, no_27_S;
00986   static int t, i, j, k;
00987   iterate_hash1 {
00988     point_typ = point1->typ;
00989     if(point_typ != exterior && point_typ != multigrid &&
00990        point_typ != boundary) {
00991       // gut??
00992       point1->typ = interior;
00993       I = point1->ind;
00994       weiter = true;  // Annahme: es gibt einen Punkt in der Naehe
00995       for(t=I.Tiefe();weiter;++t) {
00996         no_27_S   = false;   // Annahme: es gibt 27-Stern
00997         weiter    = false;   // Annahme: nicht feinere Sterne untersuchen
00998         for(i=0;i<3;++i)     // fehlt: besser machen mit stop
00999           for(j=0;j<3;++j)
01000             for(k=0;k<3;++k) if(!((i==1) && (j==1) && (k==1)))  {
01001               Inext = I.next((Ort1D)i,(Ort1D)j,(Ort1D)k,t);
01002               if(Exists_Point(Inext)) {
01003                 weiter    = true;          // Untersuche feinere Sterne
01004                 point_typ = Give_type(Inext);
01005                 // hier fehlt Test der Zellen!!!!!
01006                 if(point_typ == exterior || point_typ == multigrid)
01007                   no_27_S=true;               // kein 27-Stern vorhanden
01008               }
01009               else {
01010                 no_27_S   = true;             // stop kein 27-Stern vorhanden
01011               }
01012             }
01013         if(no_27_S==false) {
01014           weiter = false;                  // 27-Stern gefunden
01015           point1->level = t;
01016           if(t==I.Tiefe()) {
01017             point1->typ = hierarchical;
01018           }
01019           else {
01020             point1->typ = ausnahme;
01021           }
01022         }
01023       }
01024       if(no_27_S==true) {          // kein 27-Stern vorhanden
01025         point1->level = t-2;
01026         //  cout << "\n no: " << t; I.coordinate().Print();
01027       }
01028     }
01029   }
01030 }
01031 */
01032 /*
01033 void Grid_base::Calc_slave_points() {
01034   iterate_hash1 {
01035     if(point1->typ == interior) {
01036       point1->typ = nearb;
01037     // vorerst sind alle Punkte hier nearb, keine slave points
01038     //  if(!Is_Slave(point1->ind)) {
01039     //  point1->typ = nearb;
01040     //      }
01041     }
01042   }
01043 }
01044 */
01045 
01046 /*
01047 void Grid_base::Calc_nearb_points() {
01048   iterate_hash1 {
01049      if(point1->typ == nearb) {
01050        // Add_small_27Stencil(point1->ind,point1->ind.Tiefe());
01051        // Add_small_27Stencil(point1->ind,point1->level);
01052        //if(test<test_max) {
01053        //                Add_small_27Stencil(point1->ind,point1->ind.Tiefe());
01054        //        ++test;
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     //    cout << " slave ";
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     // if((p_typ == exterior) || (p_typ == multigrid))
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         // Es kann nur dies eintreten:
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           // kann nur eintreten:
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 void Halte_mal() {
01162   cout << " halt mal" << endl;
01163 }
01164 
01165 Index1D Index1D::neighbour(dir1D d) const   {
01166   static int ind;
01167   if(developer_version) {
01168     if(d==Ld && index==0) cout << " error in Index1D::neighbour! "  << endl;
01169     Halte_mal();
01170   }
01171   for(ind = index;(ind&1)==d;ind = ind >> 1) {};
01172   return Index1D(ind >> 1);
01173 }
01174 */
01175 
01176 int Grid_base::Give_my_finest_parallel_level(Index3D I) const {
01177   //  return hashtable1_point(I)->my_finest_parallel_level;
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 // Abstand zum Rand in Richting d
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     /* Used in /Particle/ParticleBase.h to setup
01203        the required datastructure
01204     */
01205 
01206     D3vector v_WSD;
01207     D3vector v_ENT;
01208     
01209     BInfoT     brick;
01210 
01211     
01212     brickInfo_m.clear();
01213       
01214     // set cells in brick
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             //    Index3D d = point_proc->Give_Index().neighbour(WSDd);
01237             //for(int d=0;d<8;++d)
01238             //     int n = give_next_rank_destination((dir_sons)d);
01239             //cout << "next rank WSDd" << n << endl; 
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; /* FIXME: VERY ugly */
01269       localXMax[d] =-100000000.0; /* FIXME: VERY ugly */
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 //      if(Give_type(I)==multigrid && I==Index3D(0,4,0)) {
01348 
01349           //    if(Give_type(I)==multigrid) {
01350           //  v = transform_coord(I);
01351           v = I.coordinate();
01352           cout << " point: " << point1->Give_label(5) 
01353             //         << " my_rank: " << my_rank 
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   // I = Index3D(0,4,8);
01403   // I = Index3D(0,2,0);
01404   // I = Index3D(9,8,16);
01405   //  I = Index3D(8,35,35);
01406   I = Index3D(37,17,33);
01407   // I = Index3D(37,35,8);
01408   if(my_rank==0) {
01409     v = I.coordinate();
01410     cout << " vector: x: " 
01411          << v.x << " y: " << v.y << " z: " << v.z 
01412          << endl;
01413   }
01414 
01415   if(I_am_active()) {
01416     if(Exists_Point(I)) {
01417       cout << " Point: type: " << Give_type(I)
01418            << " my rank: " << my_rank 
01419            << " in my finest index: " 
01420            << (I << Give_my_level_index(n_parallel))
01421            << " my_coarsest_level: " 
01422            << my_coarsest_level
01423            << " finest level: " 
01424            << Give_finest_level(I)
01425            << " Tiefe: " << I.Tiefe()
01426            << endl;
01427     }
01428   }
01429   MPI_Barrier(MPI_COMM_WORLD);
01430   */
01431 
01432   /*
01433   I = Index3D(9,8,18);
01434   if(Exists_Bo_Point(I,Edir)) {
01435     cout << " Bo Point: type: " << Give_type(I)
01436          << " my rank: " << my_rank << endl;
01437   }
01438   MPI_Barrier(MPI_COMM_WORLD);
01439   */  
01440 
01441   /*
01442   MPI_Barrier(MPI_COMM_WORLD);
01443   if(my_rank==0) {
01444     I = Index3D(37,38,36);
01445     //    v = transform_coord(I);
01446     v = I.coordinate();
01447     cout        << " Punkt D: " 
01448                 << v.x << " y: " << v.y << " z: " << v.z 
01449                 << endl;
01450   }
01451   */
01452   /*
01453   MPI_Barrier(MPI_COMM_WORLD);
01454   if(my_rank==0) {
01455     cout << " procs von 0: " << endl; 
01456     iterate_hash_proc {
01457       cout << " processor "
01458            << " x: " << point_proc->Give_Index().I_x().get()
01459            << " y: " << point_proc->Give_Index().I_y().get()
01460            << " z: " << point_proc->Give_Index().I_z().get()
01461            << endl;
01462     }
01463   }
01464 
01465   MPI_Barrier(MPI_COMM_WORLD);
01466   if(my_rank==7) {
01467     cout << " procs von 7: " << endl; 
01468     iterate_hash_proc {
01469       cout << " processor "
01470            << " x: " << point_proc->Give_Index().I_x().get()
01471            << " y: " << point_proc->Give_Index().I_y().get()
01472            << " z: " << point_proc->Give_Index().I_z().get()
01473            << endl;
01474     }
01475   }
01476 
01477   */
01478   
01479   /*
01480   MPI_Barrier(MPI_COMM_WORLD);
01481   //  v = transform_coord(my_index);
01482   v = my_index.coordinate();
01483   cout  << " my_rank: " << my_rank 
01484         << " vector: x: " 
01485         << v.x << " y: " << v.y << " z: " << v.z 
01486         << " x: " << my_index.I_x().get()
01487         << " y: " << my_index.I_y().get()
01488         << " z: " << my_index.I_z().get()
01489         << "Give_my_coarsest_level(): " << Give_my_coarsest_level() 
01490         << endl;
01491   MPI_Barrier(MPI_COMM_WORLD);
01492 
01493   int lll;
01494   lll = n_parallel-1;
01495   if(my_rank==0)  cout << " Grob: cell level " << lll << endl;
01496 
01497   MPI_Barrier(MPI_COMM_WORLD);
01498   //  v = transform_coord(my_index);
01499   if(Give_my_coarsest_level() <= lll-1) {
01500     v = Give_my_level_index(lll).coordinate();
01501     cout        << " my_rank: " << my_rank 
01502                 << " vector: x: " 
01503                 << v.x << " y: " << v.y << " z: " << v.z 
01504                 << " x: " << Give_my_level_index(lll).I_x().get()
01505                 << " y: " << Give_my_level_index(lll).I_y().get()
01506                 << " z: " << Give_my_level_index(lll).I_z().get()
01507                 << endl;
01508   }
01509   MPI_Barrier(MPI_COMM_WORLD);
01510   
01511 
01512   
01513   lll = n_parallel-2;
01514   if(my_rank==0)  cout << " Grob: cell level " << lll << endl;
01515 
01516   MPI_Barrier(MPI_COMM_WORLD);
01517   //  v = transform_coord(my_index);
01518   if(Give_my_coarsest_level() <= lll-1) {
01519     v = Give_my_level_index(lll).coordinate();
01520     cout        << " my_rank: " << my_rank 
01521                 << " vector: x: " 
01522                 << v.x << " y: " << v.y << " z: " << v.z 
01523                 << " x: " << Give_my_level_index(lll).I_x().get()
01524                 << " y: " << Give_my_level_index(lll).I_y().get()
01525                 << " z: " << Give_my_level_index(lll).I_z().get()
01526                 << endl;
01527   }
01528   MPI_Barrier(MPI_COMM_WORLD);
01529   */
01530 
01531 
01532   /*
01533   MPI_Barrier(MPI_COMM_WORLD);
01534   
01535   I = Index3D(4,2,19).next(ESTd,max_level+1).next(WSTd,max_level+1);
01536   v = transform_coord(I);
01537   if(Exists_Point(I)) {
01538     cout << " point: " << Give_type(I) 
01539          << " my_rank: " << my_rank 
01540          << " resposible: " << (I<my_index)
01541          << " vector: x: " << v.x << " y: " << v.y << " z: " << v.z 
01542          << " x: " << I.I_x().get()
01543          << " y: " << I.I_y().get()
01544          << " z: " << I.I_z().get()
01545          <<  endl;
01546   }
01547   */  
01548   
01549   
01550   /*
01551   //0.995 0.995 0.995
01552   iterate_hash1 {
01553     I = point1->ind;
01554     if(point1->typ==multigrid && I.Tiefe()==3) {
01555       v = transform_coord(point1->ind);
01556       
01557       cout << " point: " << Give_type(I) 
01558            << " my_rank: " << my_rank 
01559            << " resposible: " << (I << my_index)
01560            << " vector: x: " << v.x << " y: " << v.y << " z: " << v.z 
01561            << " x: " << I.I_x().get()
01562            << " y: " << I.I_y().get()
01563            << " z: " << I.I_z().get()
01564            <<  endl;
01565     }
01566   }
01567   */
01568 
01569   /*
01570   ofstream DATEI;
01571   // Print FE-solution in file with UCD_file format
01572 
01573   if(my_rank==0) {
01574     DATEI.open("../../point0.dat",ios :: out);
01575     Print_test_AVS(&DATEI,1);
01576     DATEI.close();
01577   }
01578   if(my_rank==1) {
01579     DATEI.open("../../point1.dat",ios :: out);
01580     Print_test_AVS(&DATEI,1);
01581     DATEI.close();
01582   }
01583   if(my_rank==2) {
01584     DATEI.open("../../point2.dat",ios :: out);
01585     Print_test_AVS(&DATEI,1);
01586     DATEI.close();
01587   }
01588   if(my_rank==3) {
01589     DATEI.open("../../point3.dat",ios :: out);
01590     Print_test_AVS(&DATEI,1);
01591     DATEI.close();
01592   }
01593   */
01594 
01595   /*
01596 MPI_Barrier(MPI_COMM_WORLD);
01597  if(my_rank==0) {
01598    cout << " Problem at: " << endl;
01599    transform_coord(Index3D(17,17,17)).Print();
01600    cout << endl;
01601  }
01602 
01603 MPI_Barrier(MPI_COMM_WORLD);
01604 
01605   if(Exists_Cell(Index3D(17,17,17))) {
01606      cout << " cell typ: " 
01607            << Give_cell_typ(Index3D(17,17,17))
01608            << " my_rank: " << my_rank << endl;
01609   }
01610 
01611 
01612   for(int r=0;r<20;++r) {
01613     MPI_Barrier(MPI_COMM_WORLD);
01614 
01615     if(my_rank==r) { 
01616       cout << endl;
01617       for(int i=0;i<8;++i) {
01618         I = Index3D(17,17,17).neighbour((dir_sons)i);
01619         v = transform_coord(I);
01620         if(Exists_Point(I)) {
01621           cout << " typ: " 
01622                << Give_type(I) 
01623                << " my_rank: " << my_rank 
01624                << " resposible: " << (I<my_index)
01625                << " vector: x: " << v.x << " y: " << v.y << " z: " << v.z 
01626                << " x: " << I.I_x().get()
01627                << " y: " << I.I_y().get()
01628                << " z: " << I.I_z().get()
01629                <<  endl;
01630         }
01631       }
01632     }
01633   }
01634   */
01635 
01636   /*
01637   int number_sp;
01638   number_sp=0;
01639   if(my_rank==3) 
01640     iterate_hash1 {
01641     if(point1->typ==hierarchical) {
01642       ++number_sp;
01643       v = transform_coord(point1->ind);
01644       if(my_rank==3) {
01645         if(v.y<0.45 && v.z<0.45)
01646           cout << " EEEErrror! " << endl;
01647 
01648         cout << " hiera.: x: " << v.x << " y: " << v.y << " z: " << v.z 
01649            << " my rank: : "  << my_rank << endl; 
01650 
01651         
01652       }
01653       
01654     }
01655   }
01656   
01657   cout << " my rank:   "  << my_rank
01658        << " number_sp: "  << number_sp << endl; 
01659   */
01660 
01661 
01662   /*
01663   if(my_rank==1) {
01664     if(Exists_Cell(Index3D(34,35,35))) {
01665       cout << " \n \n typ: " << Give_cell_typ(Index3D(34,35,35)) << endl;
01666     }
01667   }
01668   */
01669 
01670   /*
01671   for(int r=0;r<12;++r) {
01672     MPI_Barrier(comm);
01673     if(my_rank==r) {
01674       v = transform_coord(my_index);
01675       cout << " my index: x: " << v.x << " y: " << v.y << " z: " << v.z 
01676            << " my rank: : "  << my_rank << endl; 
01677 
01678       v = transform_coord(Give_my_level_index(n_parallel-1));
01679       cout << " unten: x: " << v.x << " y: " << v.y << " z: " << v.z 
01680            << " my rank: : "  << my_rank << endl; 
01681 
01682 
01683     }
01684   }
01685   */
01686 
01687 
01688   /*
01689   d = Wdir;
01690 
01691   for(int r=0;r<16;++r) {
01692     MPI_Barrier(comm);
01693     if(my_rank==r) {
01694       v = transform_coord(my_index);
01695       cout << " my index: x: " << v.x << " y: " << v.y << " z: " << v.z 
01696            << " my rank: : "  << my_rank << endl; 
01697       for(int l=0;l<=max_level;++l) {
01698         cout << " \n level: " << l << endl;
01699         cout << " next rank destination: " 
01700              << give_next_rank_destination(d,l) << endl;
01701         cout << " next rank source: " 
01702              << give_next_rank_source(d,l) << endl;
01703       }
01704     }
01705   }
01706   */
01707 }

Generated on Mon Jan 16 13:23:40 2006 for IPPL by  doxygen 1.4.6