Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

src/expde/evpar/evpar.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 // evpar.h
00020 //
00021 // ------------------------------------------------------------
00022 
00023 #ifndef EVPAR_H_
00024 #define EVPAR_H_
00025                   
00026 
00027 /*
00028  
00029          
00030           X~~~~~~~~~~~~~~~ X
00031         /                / |
00032       /                /   |
00033     /                /     |
00034    X~~~~~~~~~~~~~~~X       |
00035    |               |       |
00036    |  WNT --- ENT  |       |
00037    |/  |     / |   |       |
00038   WST --- EST  |   |       X
00039    |   |   |   |   |     /
00040    |  WND --- END  |   /
00041    | /     |  /    | /
00042   WSD --- ESD ~~~~ X
00043  
00044       
00045 
00046 
00047 // ENTd -> interior      // first 
00048 // WNTd -> W-face        // second
00049 // WSTd -> WS-edge       // third
00050 // WSDd -> WSD corner    // forth
00051 // WNDd -> WD-edge       // fifth
00052 // ENDd -> D-face        // sixth
00053 // ESDd -> SD-edge       // seventh
00054 // ESTd -> S-face        // eighth
00055 
00056 */
00057 
00058 
00059 inline dir_sons reordering_formula(dir_sons d) {
00060   if(d==ENTd) return (dir_sons)0;  // first
00061   if(d==WNTd) return (dir_sons)1;  // second
00062   if(d==WSTd) return (dir_sons)2;  // ...
00063   if(d==WSDd) return (dir_sons)3;
00064 
00065   if(d==WNDd) return (dir_sons)4;
00066   if(d==ENDd) return (dir_sons)5;
00067   if(d==ESDd) return (dir_sons)6;
00068   //  if(d==ESTd)
00069               return (dir_sons)7;  // eighth  
00070 }
00071 
00072 inline dir_sons reordering_boundary_formula(Index3D I, dir_3D d, Index3D my_index) {
00073   bool fine_x, fine_y, fine_z;
00074   fine_x = my_index.I_x() <= I.I_x();
00075   fine_y = my_index.I_y() <= I.I_y();
00076   fine_z = my_index.I_z() <= I.I_z();
00077 
00078   if(fine_x && fine_y && fine_z) return (dir_sons)0; // (first  is interior)
00079 
00080   if(fine_y && fine_z) {       
00081     if(d!=Wdir && d!=Edir) 
00082       return (dir_sons)1;     // (second is W-face)
00083     else return (dir_sons)0;
00084   }
00085   if(fine_x && fine_y) {
00086     if(d!=Ddir && d!=Tdir) 
00087       return (dir_sons)5;     // (sixth  is D-face)
00088     else return (dir_sons)0;
00089   }
00090 
00091   if(fine_x && fine_z) {
00092     if(d!=Sdir && d!=Ndir)
00093       return (dir_sons)7;     // (eighth is S-face)
00094     else return (dir_sons)0;
00095   }
00096 
00097   if(fine_x) {
00098     if(d==Wdir || d==Edir)
00099       return (dir_sons)6; // (seventh is SD-edge)
00100     else return (dir_sons)0;
00101   }
00102   if(fine_y) {
00103     if(d==Ndir || d==Sdir)
00104       return (dir_sons)4; // (fifth   is WD-edge)
00105     else return (dir_sons)0;
00106   }
00107   if(fine_z) {
00108     if(d==Ddir || d==Tdir)
00109       return (dir_sons)2; // (third   is WS-edge)
00110     else return (dir_sons)0;
00111   }
00112   
00113   return (dir_sons)3; // ( forth is WSD-corner)
00114 }
00115 
00116 enum evaluation_typ { 
00117   stop_evaluation,
00118   interior_1_evaluation_fine,
00119   interior_15_evaluation_fine,
00120   interior_17_evaluation_fine,
00121   interior_25_evaluation_fine,
00122   interior_1_evaluation_coarse,
00123   interior_15_evaluation_coarse,
00124   interior_17_evaluation_coarse,
00125   interior_25_evaluation_coarse,
00126   nearb_1_evaluation,
00127   nearb_15_evaluation,
00128   nearb_17_evaluation,
00129   cellf_1_evaluation,
00130   cellf_large_evaluation,
00131   boundary_evaluation_all,
00132   boundary_evaluation_subset,
00133   exteri_1_evaluation_subset,
00134   exteri_15_evaluation_subset,
00135   exteri_17_evaluation_subset
00136 };
00137 // Bemerkung:
00138 //   exteri_1_evaluation_subset,
00139 //   exteri_15_evaluation_subset,
00140 //   exteri_17_evaluation_subset
00141 // werden unter nearb subsummiert.
00142 
00143 class Run_type_object {
00144  public:
00145   int  r_boundary;   // run boundary point? or on Subgrid?
00146   bool  r_interior;   // run interior point? or some of them?
00147   bool r_nearb;      // run nearb point?
00148 };
00149 
00150 // remark with respect to r_boundary:
00151 /*
00152   r_boundary == 1:              run all boundary points
00153   r_boundary == 0:              run no  boundary points
00154   r_boundary == i = -1,-2, ...: run     boundary points of label -i
00155 */  
00156 
00157 class Evaluation_Parallelization_object {
00158  private:
00159   Grid *grid;
00160   Run_type_object run_object;
00161   int level;
00162   int max_level;
00163   int size_stencil;
00164   int number_ops;
00165 
00166   P_interior* interior_pointer;
00167   P_nearb*    nearb_pointer;
00168   P_Bo2p*     Bo2p_pointer;
00169   P_cellpoi*  cellpoi_pointer;
00170 
00171   int status;
00172 
00173   // which vars are in expression
00174   int max_var;            // maximal number of variables
00175   bool *array_vars;       // array of size max_var; var is in Expr. of level
00176   bool *array_vars_other; // array of size max_var; var is in Expr. of 
00177                           // level: level+1 or level-1
00178   bool other_is_fine;
00179   bool other_is_coarse;
00180 
00181   bool update_ENT;
00182   bool update_WSD;
00183   bool update_other_bla;
00184 
00185   // how to update left hand side for systems
00186   type_of_update left_update;
00187   int left_level;
00188 
00189   // transformed in the following; needed by communication:
00190   int  *array_num;
00191   int anz_num;
00192   int  *array_num_other;
00193   int anz_num_other;
00194 
00195   // GS expression (or Jacobi)
00196   bool GS_expression;
00197   dir_3D Parallel_GS_formula[8];
00198 
00199   // storage for update type of variables
00200   // code: max_level*number_variable+level-1
00201   type_of_update *storage_of_update_type;
00202  public:
00203   // constructor used only in grid.cc
00204   Evaluation_Parallelization_object(Grid *g, int max_v);
00205 
00206   // functions for type_of_update
00207   type_of_update Give_type_of_update(int number_variable, int level);
00208   void Set_type_of_update(int number_variable, int level, type_of_update type);
00209 
00210   // how to update left hand side for systems
00211   type_of_update Give_left_update() { return left_update; }
00212   int            Give_left_level()  { return left_level;  }
00213 
00214   // needed by communication:
00215   int  Give_anz_num()   { return anz_num; };
00216   int *Give_array_num() { return array_num; };
00217 
00218   void Start_evaluation_seriel(const Run_type_object rob, const int l,
00219                                const int ss, const int num_ops);
00220   void StartA_evaluation(const Run_type_object rob, const int l,
00221                         const int ss, const int num_ops);
00222   //  void StartB_evaluation(const int number_variable);
00223   void StartB_evaluation(const int number_variable, const bool GS_expr);
00224 
00225   void StartA_varcon_evaluation(const int l); // used in varcon.h
00226   void StartB_varcon_evaluation();            // used in varcon.h
00227   evaluation_typ Give_next_evaluation_typ();
00228   // functions used by part of expression
00229   void Variable_contained_in_expression(int num_variable);
00230   void Variable_contained_in_expression_other(int num_variable);
00231   void Other_is_coarse() { other_is_coarse =true; }
00232   void Other_is_fine() { other_is_fine =true; }
00233 
00234   P_interior* Start_interior_pointer() { return interior_pointer;   };
00235   P_nearb*    Start_nearb_pointer()    { return nearb_pointer; };
00236   P_Bo2p*     Start_Bo2p_pointer()     { return Bo2p_pointer; };
00237   P_cellpoi*  Start_cellpoi_pointer()  { return cellpoi_pointer; };
00238 };
00239 
00240 inline void 
00241 Evaluation_Parallelization_object::Variable_contained_in_expression(
00242                                    int num_variable) { 
00243   if(developer_version) {
00244     if(num_variable<0) 
00245       cout << " error 1 in ev_par::Variable_contained_in_expression! " << endl;
00246     if(num_variable>=max_var) 
00247       cout << " error 1 in ev_par::Variable_contained_in_expression! " << endl;
00248   }
00249   array_vars[num_variable] = true;
00250 }
00251 
00252 inline void 
00253 Evaluation_Parallelization_object::Variable_contained_in_expression_other(
00254                                    int num_variable) { 
00255   if(developer_version) {
00256     if(num_variable<0) 
00257       cout << " error 1 in ev_par::Variable_contained_in_expression_other! " 
00258            << endl;
00259     if(num_variable>=max_var) 
00260       cout << " error 1 in ev_par::Variable_contained_in_expression_other! " 
00261            << endl;
00262   }
00263   array_vars_other[num_variable] = true;
00264 }
00265 
00266 
00267 inline type_of_update Evaluation_Parallelization_object::Give_type_of_update(
00268                                                   int number_variable,
00269                                                   int level) {
00270   if(developer_version) {
00271      if(max_level*number_variable+level>max_level*(max_var+1))
00272        cout << 
00273          "error in Evaluation_Parallelization_object::Give_type_of_update!! " 
00274             << endl;
00275   }
00276   return storage_of_update_type[max_level*number_variable+level-1];
00277 };
00278 
00279 inline void Evaluation_Parallelization_object::Set_type_of_update(
00280                                                       int number_variable,
00281                                                       int level,
00282                                                       type_of_update type) {
00283   if(developer_version) {
00284      if(max_level*number_variable+level>max_level*(max_var+1))
00285        cout << 
00286          "error in Evaluation_Parallelization_object::Set_type_of_update!! " 
00287             << endl;
00288   }
00289   storage_of_update_type[max_level*number_variable+level-1] = type;
00290 }
00291 
00292 #endif
00293         

Generated on Fri Nov 2 01:25:56 2007 for IPPL by doxygen 1.3.5