src/expde/grid/grid.h

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.h
00020 //
00021 // ------------------------------------------------------------
00022 
00023 #ifndef GRID_H_
00024 #define GRID_H_
00025            
00026 #define anzahl_colors 8
00027 
00028 class Nearb_Ablage;
00029 
00030 class P_interior;
00031 class P_nearb;
00032 class P_Bo2p;
00033 class P_cellpoi;
00034 class P_interior_cell;
00035 class P_boundary_tet;
00036 class P_parallel; // ^^^^^^^^ Parallel ^^^^^^^^
00037 
00038 class Evaluation_Parallelization_object;
00039 
00040 class Grid : public Grid_base {
00041  public:
00042   Grid(int n_max, All_Domains* dom, Grid_gen_parameters& gpara, MPI_Comm comm);
00043   Grid(int n_max, All_Domains* dom, MPI_Comm comm);
00044   Grid(double h_finest_level, All_Domains* dom,
00045        Grid_gen_parameters& gpara, MPI_Comm comm);
00046   Grid(double h_finest_level, All_Domains* dom, MPI_Comm comm);
00047   Grid(int n_max, All_Domains* dom, Grid_gen_parameters& gpara);
00048   Grid(double  h_finest_level, All_Domains* dom, Grid_gen_parameters& gpara);
00049   Grid(int n_max, All_Domains* dom);
00050   Grid(double  h_finest_level, All_Domains* dom);
00051 
00052 
00053   void Delete_storage();
00054 
00055   // ^^^^^^^^ Parallel ^^^^^^^^
00056   void Full_update_Variable(int level);
00057 
00058   void Update_Variable(dir_3D d, int* array_num, int anz_num, int level);
00059   void Update_Variable(int d, int* array_num, int anz_num, int level);
00060   void Sum_ghost_nodes_Variable(int* array_num, int anz_num, int level);
00061   void Sum_ghost_nodes_Variable(int d, int* array_num, int anz_num, int level);
00062 
00063   void Update_Variable_no_full(int* array_num, int anz_num, int level);
00064 
00065   void Update_Variable_for_prolongation(dir_3D d, int* array_num, 
00066                                         int anz_num, int level);
00067   void Update_Variable_for_prolongation(int d, int* array_num, 
00068                                         int anz_num, int level);
00069   void Update_Variable_for_prolongation(int* array_num, 
00070                                         int anz_num, int level);
00071   void Update_boundary_stencil(int num_stencils, int level);
00072   void Update_global_stencil(int num_stencils, int level);
00073 
00074   void Print_number_of_communication_doubles();
00075 
00076   void Do_non_bock_sending(bool yn);
00077 
00078   // Zeitmessung und MFlops
00079   void Add_operations(long_int ops, int level);
00080   void Start_calc_time();
00081   void Stop_calc_time();
00082   void Start_calc_time_interior();
00083   void Stop_calc_time_interior();
00084   void Start_calc_time_nearbb();
00085   void Stop_calc_time_nearbb();
00086   int calc_time() { return calc_yn; }
00087   void Report_calc_time( const char * what);           
00088 
00089   // Drucke Information ueber alle Punkte
00090   void Print_poi_Info(int lev);     // innere Punkte auf     Level lev
00091   void Print_poi_Info();            // innere Punkte auf    maximal level
00092   void Print_poi_Sum_Info();        // innere Punkte bis zum Level lev
00093   void Print_poi_Info_all(int lev); // bis zum Level lev
00094 
00095   // number of interior and nearb points on a level
00096   double Give_number_interior_grid_points(int lev);
00097 
00098   void Print_maximal_interior_angles(); 
00099 
00100   // Berechnung der Mehrgitterkoeffizienten
00101   void Calc_MG_Coefficients();
00102 
00103   // Setze Zeiger der Variablen auf die Randzellen
00104   void Set_pointer_on_bocell();
00105 
00106   // Zur Verwaltung der Speicher (Datenspeicher):
00107   // Um Nummern fuer Speicher zu holen siehe: grid_base.h
00108   void Initialize();                // Initialisiere Speicher
00109   void Test_init();                 // Initialisiere Speicher, falls
00110                                     // notwendig
00111 
00112   void Refine(Index3D I);
00113 
00114   // Startfunktionen bei einer Iteration ueber die Listen
00115   // Fuer eine Iteration braucht man noch zum Beispiel die Funktion
00116   // P_interior::Next() 
00117 
00118   P_parallel*  Start_P_parallel(int level);  // ^^^^^^^^ Parallel ^^^^^^^^
00119 
00120 
00121   P_interior* Start_P_interior(int level, int color);
00122   P_nearb*    Start_P_nearb(int level, int color);
00123   P_Bo2p*     Start_P_Bo2p(int level, int color);
00124   P_nearb*   Start_P_exteri(int level, int color);
00125   P_cellpoi*  Start_P_cellpoi(int level);
00126   P_interior_cell*  Start_P_interior_cell(int level);
00127   P_boundary_tet*  Start_P_boundary_tet(int level);
00128 
00129   // Zwischenspeicher
00130   // a) helping storage needed for iteration of expression templates
00131   Nearb_Ablage* Give_Nearb_Ablage() const { return nearb_ablage; };
00132   // b) helping storage needed for prolongation, restriction, ...
00133   double*  Give_vector_ablage() const { return vector_ablage; };
00134   double** Give_Stencils_fine() const { return stencils_fine; };
00135   double*  Give_weight_27() const { return weight_27; };
00136   bool*    Give_label_on_cell_ablage() const { return label_on_cell; };
00137   bool*    Give_eight_bools() const { return eight_bools; };
00138 
00139   // Gib Speicher fuer locale Sterne:
00140   double* Give_Loc_stencil(diff_type typ_u, diff_type typ_v) const { 
00141     return loc_stencils.Give_Loc_sten(typ_u,typ_v); }
00142   double* Give_Loc_stencil_Poisson() const { 
00143     return loc_stencils.Give_Loc_sten_Poisson(); }
00144 
00145   // Gib Stern fuer Restriktion
00146   Restriction_stencil_container *Give_restriction_stencil() const {
00147     return restriction_stencil;
00148   }
00149   // Gib Grob-Gitter Funktion
00150   // Format: l +  v * 27; wobei l=0,...,26 and v=0,...,7
00151   int *Give_coarse_grid_functions() const {
00152     return coarse_grid_functions;
00153   }
00154 
00155   // For evaluation - parallelization
00156   Evaluation_Parallelization_object* Give_eval_par() {
00157     return eval_par_object;
00158   };
00159   void Set_type_of_update(int number_variable, int level, type_of_update type)
00160     const;
00161 
00162   // Fuer Level_verwaltung bei MG
00163   int Min_interior_level();   // min lev of grid with at least one 
00164                               //  interior point
00165 
00166  private:
00167   // Fuer Level_verwaltung bei MG
00168   int min_interior_level;
00169 
00170   // sum up number of points parallel
00171   double Total_number_interior_points(int lev);
00172   double Total_number_nearb_points(int lev);
00173   double Total_number_exteri_points(int lev);
00174   double Total_number_bo2p_points(int lev);
00175   double Total_number_cellpoi_points(int lev);
00176 
00177   // do non_bock_sending?
00178   bool non_bock_sending;
00179 
00180   // construct storage (used by constructor)
00181   void Construct_storage();
00182 
00183   // For evaluation - parallelization
00184   Evaluation_Parallelization_object* eval_par_object;
00185 
00186   // Hilfsfunktion zur Berechnung der Mehrgitterkoeffizienten
00187   void Calc_Near_bo_MG_Coefficients(Index3D I, int l, double weight);
00188   Point_mg_coeff_nearb* list_bilding_nearb;  // Hilfspeicher 
00189   Point_mg_coeff_bo*    list_bilding_bo;     // Hilfspeicher 
00190 
00191   // Zeitmessung
00193   int calc_yn;
00194   long_int operations;      // for east
00195   // double operations;      // sonst
00196   clock_t t0_interior;    // Zeit fuer Innen
00197   clock_t t1_interior;       
00198   clock_t t_sum_interior;       
00199   clock_t t0_nearbb;      // Zeit fuer Rand und in der Naehe des Randes
00200   clock_t t1_nearbb;        
00201   clock_t t_sum_nearbb;        
00202   clock_t t0_all;         // Gesamte Zeit
00203   clock_t t1_all;        
00204 
00205   // Speicher fuer local Sterne:
00207   Loc_stencil_container loc_stencils;
00208   Restriction_stencil_container* restriction_stencil;
00209 
00210   // Speicher fuer grob Gitter Funktion
00211   int *coarse_grid_functions;
00212 
00213   // Listen:
00215   // Anzahl der Punkte
00216   long_int  number_interior_points[Max_number_levels];    // innen
00217   long_int  number_nearb_points[Max_number_levels];       // Rand-nah
00218   long_int  number_exteri_points[Max_number_levels];      // exterior
00219   long_int  number_bo2p_points[Max_number_levels];        // Rand
00220   long_int  number_cellpoi_points[Max_number_levels];     // Zellpunkt
00221   long_int  number_parallel_points[Max_number_levels];  // ^^^^^^^ Parallel ^^^^^^^
00222   long_int  number_interior_cell_points[Max_number_levels];     // innere Zell-var
00223   long_int  number_boundary_cell_tet[Max_number_levels];     // Rand Zell-var
00224 
00225   // innere Punkte mit 27-Stern
00226   void Add_list_interior(Index3D I);
00227   void Add_list_interior(Index3D I, int level);
00228 
00229   P_interior*** start_P_interior;
00230 
00231   // randnahe Punkte
00232   void Add_list_nearb(Index3D I);
00233   void Add_list_nearb(Index3D I, int level);
00234 
00235   P_nearb*** start_P_nearb;
00236 
00237   // exterior Punkte
00238   void Add_list_exteri(Index3D I);
00239   void Add_list_exteri(Index3D I, int level);
00240 
00241   P_nearb*** start_P_exteri;
00242 
00243   // Randpunkte 2.Art
00244   void Add_list_bo2p(Bo2Point* bopoint);
00245 
00246   P_Bo2p*** start_P_Bo2p;  
00247 
00248   // Randzellenpunkte
00249   void Add_list_cellpoi(BoCell* bocellf);
00250 
00251   P_cellpoi*** start_P_cellpoi;  
00252 
00253   // Points for pararallel
00254   // ^^^^^^^^ Parallel ^^^^^^^^
00255   void Add_list_parallel(Index3D I);
00256 
00257   P_parallel** start_P_parallel;  
00258 
00259   // Zell-Variablen innen
00260   void Add_list_interior_cell(Point_hashtable0 *cellp);
00261 
00262   P_interior_cell** start_P_interior_cell;  
00263 
00264   // Zell-Variablen Rand
00265   void Add_list_boundary_tet(BoCell *cellp, Tetraeder_storage* tet);
00266 
00267   P_boundary_tet** start_P_boundary_tet;  
00268 
00269 
00270   // Zwischenspeicher
00271   Nearb_Ablage* nearb_ablage;
00272   double*  vector_ablage;
00273   double** stencils_fine;
00274   double*  weight_27;
00275   bool* label_on_cell;
00276   bool* eight_bools;
00277 };
00278 
00279 
00280 
00282 // Speicher zu Listen
00284 
00285 
00286 #include "../access.h"
00287 
00288 
00290 // Implementierung einiger Memberfunktionen
00292 
00293 
00294 // Start
00295 inline P_cellpoi* Grid::Start_P_cellpoi(int level) {
00296   return start_P_cellpoi[0][level]; 
00297 };
00298 
00299 //  ^^^^^^^^ Parallel ^^^^^^^^
00300 inline P_parallel* Grid::Start_P_parallel(int level) {
00301   return start_P_parallel[level]; 
00302 };
00303 
00304 inline P_interior* Grid::Start_P_interior(int level, int color) { 
00305   return start_P_interior[color][level]; 
00306 };
00307 
00308 
00309 inline P_nearb* Grid::Start_P_nearb(int level, int color) { 
00310   return start_P_nearb[color][level]; 
00311 };
00312 
00313 inline P_nearb* Grid::Start_P_exteri(int level, int color) { 
00314   return start_P_exteri[color][level]; 
00315 };
00316 
00317 inline P_Bo2p* Grid::Start_P_Bo2p(int level, int color) { 
00318   return start_P_Bo2p[color][level]; 
00319 };
00320 
00321 
00322 inline P_interior_cell* Grid::Start_P_interior_cell(int level) { 
00323   return start_P_interior_cell[level]; 
00324 };
00325 
00326 
00327 inline P_boundary_tet* Grid::Start_P_boundary_tet(int level) { 
00328   return start_P_boundary_tet[level]; 
00329 };
00330 
00331 
00332 
00333 #endif
00334         

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