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

src/expde/extemp/array.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 //     array.h 
00020 //
00021 // ------------------------------------------------------------
00022 
00023 #ifndef ARRAY_H_
00024 #define ARRAY_H_
00025 
00026 
00028 //    1. arrays of Variables
00029 //    2. arrays of Local Variables
00030 //    3. arrays of Restriction operators for stencils
00031 //    4. sums and for iteration
00032 //    5. procedure
00034 
00035 
00036 //    1. arrays of Variables
00038 
00039 class DExprVAR_ARR {
00040  private:
00041   // Nummer der Variablen
00042   int number_variable;
00043   int *value_;
00044   Grid* grid;
00045   Variable* start;
00046   int dim;
00047  public:
00048   DExprVAR_ARR(Variable* vec, int number_var, int* v, int dimension) {
00049     dim = dimension;
00050     start = vec;
00051     number_variable = number_var;
00052     value_ = v;
00053     grid = vec[0].Give_grid();
00054   }
00055   // special for array
00056   Grid* Give_grid() const {
00057     return grid;
00058   }
00059   int Number_variable_start() const {
00060     return number_variable;
00061   } 
00062   int* Give_value() const {
00063     return value_;
00064   }
00065   int Give_dim() const {
00066     return dim;
00067   }
00068   // end special
00069   int Number_variable() const {
00070     return number_variable + (*value_);
00071   }
00072   double Give_interior(const P_interior* it_i,const Grid* gr, double h_mesh,
00073                        int l, double_stencils_in) const {
00074     return it_i->varM(gr,l)[number_variable+*value_];
00075   };
00076   double Give_interior_coarse(const P_interior* it_i,const Grid* gr,
00077                               double h_mesh, int l, double_stencils_in) const {
00078     return it_i->varM(gr,l)[number_variable+*value_];
00079   };
00080   double Give_nearb(const P_nearb* it_n,const Grid* gr, double h_mesh, int l,
00081                     const Nearb_Ablage* nearb_ablage) 
00082     const {
00083     return it_n->varM(gr,l)[number_variable+*value_];
00084   };
00085   double Give_Bo2p(const P_Bo2p* it_b,const Grid* gr, int l) const {
00086     return it_b->varM(gr)[number_variable+*value_];
00087   };  
00088   double Give_cellpoi(const P_cellpoi* it_cf,const Grid* gr,
00089                       const BoCeData* bocedata) const {
00090     return it_cf->varM(gr)[number_variable+*value_];
00091   };
00092 
00093   // Size of necessary stencil
00094   int Sice_stencil() const { return 1; }
00095 
00096   // activity of points
00097   int Level() const {
00098     if(*value_>=dim) *value_=0;
00099     return start[*value_].Level(); 
00100   }
00101   Dominace_label Dominant_lev() const { return not_dominant; }
00102   Dominace_label Dominant_poi() const { return not_dominant; }
00103   bool run_interior()  const { 
00104     if(*value_>=dim) *value_=0;
00105     return start[*value_].run_interior(); 
00106   }
00107   bool run_nearb()     const { 
00108     if(*value_>=dim) *value_=0;
00109     return start[*value_].run_nearb(); 
00110   }
00111   int run_boundary()  const {
00112     if(*value_>=dim) *value_=0;
00113     return start[*value_].run_boundary(); 
00114   }
00115 
00116   // number of operations
00117   int ops_interior() const { return 0; }
00118 
00119   // For operator ==
00120   void Active_Sim_Level(    int lev) const {  };
00121   void Active_Sim_interior(bool run) const {  };
00122   void Active_Sim_nearb(bool run) const {  };
00123   void Active_Sim_boundary( int run) const {  };
00124   void Active_Sim_update(Evaluation_Parallelization_object* evpar,
00125                          int level, type_of_update typ) const {  };
00126 
00127   // Put pointer to grid and activity of boundary points of test space  
00128   void Put_grid_rbo(Grid* gr, int r_bo)  const { };
00129   // For abstract differential operators:
00130   // --------------------------------------
00131   // Is the expression an abstract differential operator?
00132   Differential_op_typ Abstract_differential_operator()
00133     const { return abstract_both; }
00134   int Give_number_var_of_abstract_op() 
00135     const { return number_variable; }
00136   bool Give_array_variable_inserted() const {
00137     return true;
00138   }
00139   int Give_length_of_array_variable_inserted() const {
00140     return dim;
00141   }
00142   // For restriction of stencils
00143   // --------------------------------------
00144   double Give_interior_sten_element(Index3D I, double meshsize,
00145                                     int stelle,
00146                                     const Grid* grid, int l) const {
00147     cout << " Error in  DExprVAR_ARR! " << endl;
00148    return (grid->Give_variable(I.neighbour(ESTd),l)[number_variable+*value_] +
00149            grid->Give_variable(I.neighbour(WNDd),l)[number_variable+*value_])
00150       * 0.5;
00151   }
00152   double Give_boundary_sten_element(const Grid* grid, BoCeData* b_cell,
00153                                     double* u_ablage, int num_v) const {
00154     cout << " Error in  DExprVAR_ARR! " << endl;
00155     return b_cell->vars[num_v][number_variable+*value_];
00156     //    return 1.0;
00157   }
00158   // for Parallelization
00159   void Add_variables_for_parallel(Evaluation_Parallelization_object *evpar) 
00160     const {
00161     for(int i=0;i<dim;++i)
00162       start[i].Add_variables_for_parallel(evpar);
00163   };
00164   bool GS_type(int var_number_left, int dim) const {
00165   return false; }; 
00166 
00167   // at the and of an iteration of an expression
00168   void clean() const { };
00169 };
00170 
00171 
00172 class Array_Variable {
00173  public:
00174   Array_Variable(int dimension, Grid* gridp) {
00175     dim  = dimension;
00176     start = new Variable[dim];
00177     for(int i=0;i<dim;++i) {
00178       start[i].Initialize(gridp);
00179     }
00180     number_variable = start->Number_variable();
00181   }
00182   Variable& operator[](int i) {
00183     return start[i];
00184   }
00185   DExpr<DExprVAR_ARR>
00186   operator[](Local_int& I) const {
00187     return DExpr<DExprVAR_ARR>(DExprVAR_ARR(start,
00188                                             start[0].Number_variable(),
00189                                             I.Give_pointer(),
00190                                             dim));
00191   }
00192   int Give_dim() {
00193     return dim;
00194   }
00195 
00196   /*
00197   // for procedure
00198   double* Give_regular_pointer(const P_interior* it_i,const Grid* gr, int l) 
00199     const {
00200     return &(it_i->varM(gr,l)[number_variable]);
00201   };
00202   double* Give_regular_pointer(const P_nearb* it_n,const Grid* gr, int l) 
00203     const {
00204     return &(it_n->varM(gr,l)[number_variable]);
00205   };
00206   double* Give_Bo2p_pointer(const P_Bo2p* it_b,const Grid* gr, int l) const {
00207     return &(it_b->varM(gr)[number_variable]);
00208   };
00209   double* Give_cellpoi_pointer(const P_cellpoi* it_cf,const Grid* gr) const {
00210     return &(it_cf->varM(gr)[number_variable]);
00211   };
00212   */
00213 
00214  private:
00215   Variable *start;
00216   int dim;
00217   int number_variable;  // not needed
00218 };
00219 
00220 Macro_operator_definition(DExpr<DExprVAR_ARR>);
00221 Macro_operator_var_definition(DExpr<DExprVAR_ARR>,DExpr<DExprVAR_ARR>);
00222 //Macro_operator_var_definition(DExpr<DExprVAR_ARR>,Variable);
00223 
00224 
00225 //    2. arrays of local variables
00227 
00228 class DExprLoc_VAR_ARR {
00229  private:
00230   double* value_;
00231   int *Index_value_;
00232 
00233   int dim;
00234  public:
00235   DExprLoc_VAR_ARR(double* var_value_, int* v, int dimension) {
00236     value_ = var_value_;
00237     Index_value_ = v;
00238     dim = dimension;
00239   }
00240   double Give_interior(const P_interior* it_i,const Grid* gr, double h_mesh,
00241                        int l, double_stencils_in) const {
00242     return value_[*Index_value_];
00243   }
00244   double Give_interior_coarse(const P_interior* it_i,const Grid* gr,
00245                               double h_mesh,
00246                               int l, double_stencils_in) const {
00247     return value_[*Index_value_];
00248   }
00249   double Give_nearb(const P_nearb* it_n,const Grid* gr, double h_mesh, int l,
00250                     const Nearb_Ablage* nearb_ablage)
00251     const {
00252     return value_[*Index_value_];
00253   };
00254   double Give_Bo2p(const P_Bo2p* it_b,const Grid* gr, int l) const {
00255     return value_[*Index_value_];
00256   };
00257   double Give_cellpoi(const P_cellpoi* it_cf,const Grid* gr,
00258                       const BoCeData* bocedata) const {
00259     return value_[*Index_value_];
00260   };
00261   // Size of necessary stencil
00262   int Sice_stencil() const { return 1; }
00263 
00264   // activity of points
00265   int Level() const { return 0; }
00266   Dominace_label Dominant_lev() const { return anti_dominant;  }
00267   Dominace_label Dominant_poi() const { return anti_dominant;  }
00268   bool run_interior() const { return true; }
00269   bool run_nearb()    const { return true; }
00270   int run_boundary()  const { return 1; }
00271   
00272   // number of operations
00273   int ops_interior() const { return 0; }
00274   // For operator ==
00275   void Active_Sim_Level( int lev) const {  };
00276   void Active_Sim_interior(bool run) const {  };
00277   void Active_Sim_nearb(bool run) const {  };
00278   void Active_Sim_boundary( int run) const {  };
00279   void Active_Sim_update(Evaluation_Parallelization_object* evpar,
00280                          int level, type_of_update typ) const {  };
00281 
00282   // Put pointer to grid and activity of boundary points of test space  
00283   void Put_grid_rbo(Grid* gr, int r_bo) const { };
00284   // Is the expression an abstract differential operator?
00285   Differential_op_typ Abstract_differential_operator() const
00286     { return abstract_both; }
00287   int Give_number_var_of_abstract_op() const { return -1; }
00288   bool Give_array_variable_inserted() const {
00289     return false;
00290   }
00291   int Give_length_of_array_variable_inserted() const {
00292     return 0;
00293   } 
00294   // For restriction of stencils
00295   // --------------------------------------
00296   double Give_interior_sten_element(Index3D I, double meshsize,
00297                                     int stelle,
00298                                     const Grid* grid, int l) const {
00299     if(*value_>=dim) *value_=0;
00300     return value_[*Index_value_];
00301   }
00302   double Give_boundary_sten_element(const Grid* grid, BoCeData* b_cell,
00303                                     double* u_ablage, int num_v) const {
00304     if(*value_>=dim) *value_=0;
00305     return value_[*Index_value_];
00306   }
00307   // Get and Put:
00308   // Set value
00309   void Put_interior(const P_interior* it_i, int lev, double x) { Put(x); };
00310   void Put_nearb(const P_nearb* it_n, int lev, double x) { Put(x); };
00311   void Put_Bo2p(const P_Bo2p* it_b, double x) { Put(x); };
00312   void Put_cellpoi(const P_cellpoi* it_cf, double x) { Put(x); };
00313 
00314   void Put(double x) {
00315     value_[*Index_value_]=x;
00316   };
00317   double Get() const {
00318     return value_[*Index_value_];
00319   };          
00320   double* Give_pointer() const {
00321     return value_;
00322   };
00323   // for Parallelization
00324   void Add_variables_for_parallel(Evaluation_Parallelization_object *evpar) 
00325     const {};
00326   bool GS_type(int var_number_left, int dim) const {
00327   return false; }; 
00328 
00329   // at the and of an iteration of an expression
00330   void clean() const {};
00331 };
00332 
00333 class Array_Local_var {
00334  public:
00335   Array_Local_var(int dimension, double *startD) {
00336     dim = dimension;
00337     start_double = startD;
00338     start = new Local_var[dim];
00339     for(int i=0;i<dim;++i) {
00340       start[i].Initialize(&(startD[i]));
00341     }
00342   }
00343   Local_var& operator[](int i) const {
00344     return start[i];
00345   }
00346   DExpr<DExprLoc_VAR_ARR>
00347   operator[](Local_int& I) const {
00348     return DExpr<DExprLoc_VAR_ARR>(DExprLoc_VAR_ARR(start[0].Give_pointer(),
00349                                                     I.Give_pointer(),dim));
00350   }
00351   int Give_dim() {
00352     return dim;
00353   }
00354 
00355   /*
00356   // for procedure
00357   double* Give_regular_pointer(const P_interior* it_i,const Grid* gr, int l) 
00358     const {
00359     return start_double;
00360   };
00361   double* Give_regular_pointer(const P_nearb* it_n,const Grid* gr, int l) 
00362     const {
00363     return start_double;
00364   };
00365   double* Give_Bo2p_pointer(const P_Bo2p* it_b,const Grid* gr, int l) const {
00366     return start_double;
00367   };
00368   double* Give_cellpoi_pointer(const P_cellpoi* it_cf,const Grid* gr) const {
00369     return start_double;
00370   };
00371   */
00372 
00373  private:
00374    Local_var *start;
00375    int dim;
00376    double* start_double;  // not needed ?
00377 }; 
00378 
00379 
00380 
00381 //    3. arrays of Restriction operators for stencils
00383 
00384 
00385 template<class A>
00386 class DResDiff_Bo_ARR {
00387   A a_;
00388 
00389   //number of storage for boundary stencils
00390   int num_stencils;
00391   int *Index_value_;
00392   bool array_variable_inserted; // was an array inserted or
00393                                 // only one variable
00394   int dim;                      // length of array if array was inserted
00395 
00396   // information about the variable put in the abstract diff. operator
00397   int number_variable;  // number of the variable
00398   bool* label_on_cell;
00399 
00400   // Gitter
00401   Grid *grid;
00402 
00403   // needed for the calculation of local stiffness matrix
00404   double** Stencils_fine;  // eight stencils for finer cells
00405   double* u_ablage; // Ablage
00406 
00407   bool *corner_in_domain;
00408 
00409  public:
00410   // Constructor for concrete operators
00411   DResDiff_Bo_ARR(const A& a, int num_s, Grid* gr, int *Ivalue_) 
00412     : a_(a), num_stencils(num_s), grid(gr), Index_value_(Ivalue_) {
00413     number_variable = a_.Give_number_var_of_abstract_op();
00414     array_variable_inserted = a_.Give_array_variable_inserted();
00415     dim = a_.Give_length_of_array_variable_inserted();
00416   };
00417   double Give_interior(const P_interior* it_i, const Grid* gr, double h_mesh,
00418                        int l, double_stencils_in) const {
00419     return a_.Give_interior(it_i,gr,h_mesh,l, double_stencils_out);
00420   };
00421   double Give_interior_coarse(const P_interior* it_i, const Grid* gr,
00422                               double h_mesh,
00423                               int l, double_stencils_in) const {
00424     return a_.Give_interior_coarse(it_i,gr,h_mesh,l, double_stencils_out);
00425   };
00426   double Give_nearb(const P_nearb* it_n, const Grid* gr, double h_mesh, int l,
00427                     const Nearb_Ablage* nearb_ablage) const {
00428     static int i;
00429     static Celltype cetyp;
00430     static double sum;
00431     dir_sons dir_v;
00432     static int actual_number; 
00433 
00434     // Part 1: interior cells and boundary cells on the finest grid
00435     sum = a_.Give_nearb(it_n,gr,h_mesh,l,nearb_ablage);
00436 
00437     if(array_variable_inserted)
00438       actual_number = number_variable+(*Index_value_);
00439     else
00440       actual_number = number_variable;
00441     // Part 2: boundary cells on coarser grid
00442     for(i=0;i<8;++i) {    // Durchlaufen aller Nachbarzellen
00443       dir_v = opposite3D((dir_sons)i);
00444       // Hole Info ueber i-Randzelle
00445       cetyp = nearb_ablage->Give_Celltyp((dir_sons)i);
00446 //number_variable+(*Index_value_) besser machen !!!!!!!!!
00447       if(cetyp==bo_cell) {
00448         sum = sum +
00449           Evaluate_lsm(nearb_ablage->Give_u_Recell((dir_sons)i),
00450                        actual_number, dir_v,
00451                        gr->Give_bo_stencil(it_n->Ind().next((dir_sons)i,l+1),
00452                                            num_stencils+(*Index_value_)));
00453       }
00454     }    
00455     return sum;
00456   };
00457   double Give_cellpoi(const P_cellpoi* it_cf, const Grid* gr,
00458                       const BoCeData* bocedata) const {
00459     return a_.Give_cellpoi(it_cf,gr,bocedata);
00460   };
00461   double Give_Bo2p(const P_Bo2p* it_b, const Grid* gr,int l)  const {
00462     return a_.Give_Bo2p(it_b,gr,l);
00463   };
00464   // Size of necessary stencil
00465   int Sice_stencil() const { return a_.Sice_stencil(); }
00466 
00467   // activity of points
00468   int Level() const { return (a_).Level(); }
00469   Dominace_label Dominant_lev() const { return not_dominant; }
00470   Dominace_label Dominant_poi() const { return not_dominant; }
00471   bool run_interior() const { return (a_).run_interior(); }
00472   bool run_nearb()    const { return (a_).run_nearb(); }
00473   int run_boundary() const { return (a_).run_boundary(); }
00474 
00475   // number of operations
00476   int ops_interior() const { return a_.ops_interior(); }
00477 
00478   // For operator ==
00479   void Active_Sim_Level( int lev) const {  };
00480   void Active_Sim_interior(bool run) const {  };
00481   void Active_Sim_nearb(bool run) const {  };
00482   void Active_Sim_boundary( int run) const {  };
00483   void Active_Sim_update(Evaluation_Parallelization_object* evpar,
00484                          int level, type_of_update typ) const {  };
00485 
00486   // Put pointer to grid and activity of boundary points of test space  
00487   void Put_grid_rbo(Grid* gr, int r_bo) const {
00488     a_.Put_grid_rbo(gr,r_bo);
00489   }; 
00490   // For abstract differential operators:
00491   // --------------------------------------
00492   // Is the expression an abstract differential operator?
00493   Differential_op_typ Abstract_differential_operator() const
00494     { return not_abstract; }
00495   //  bool Give_array_variable_inserted() const {
00496   //    return true;
00497   //  }
00498 
00499   // for Parallelization
00500   void Add_variables_for_parallel(Evaluation_Parallelization_object *evpar) 
00501     const {
00502     if(array_variable_inserted == false)
00503       evpar->Variable_contained_in_expression(number_variable);
00504     else 
00505       for(int i=0;i<dim;++i)
00506         evpar->Variable_contained_in_expression(number_variable+i);
00507   };
00508   bool GS_type(int var_number_left, int dim_left) const {
00509     if(array_variable_inserted == false) {
00510       if(number_variable>=var_number_left &&
00511          number_variable<=(var_number_left+dim_left)) return true;
00512       else                                            return false;
00513     }
00514     else {
00515      if((number_variable+dim)>=var_number_left &&
00516         number_variable<=(var_number_left+dim_left)) return true;
00517      else                                            return false;
00518     }
00519   };
00520 
00521   // at the and of an iteration of an expression
00522   void clean() const { a_.clean(); };
00523 };
00524 
00525 class Index_Res_stencil_boundary_ARR {
00526  private:
00527   // Gitter
00528   Grid *grid;
00529 
00530   //number of storage for boundary stencils
00531   int num_stencils;
00532   int* Index_value_;
00533  public:
00534   Index_Res_stencil_boundary_ARR(int num_s, Grid* gr, int *Ivalue_) 
00535     : grid(gr), num_stencils(num_s),  Index_value_(Ivalue_) {
00536   };
00537 
00538   template<class A>
00539   DExpr<DResDiff_Bo_ARR<DExpr<A> > > 
00540   operator() (const DExpr<A>& a_) {
00541     Differential_op_typ a_abstract;
00542     a_abstract = a_.Abstract_differential_operator();
00543     if(a_abstract==not_abstract) {
00544       cout << " This is not an abstract differential operator! Error!" << endl;
00545     }
00546     if(a_abstract==abstract_diag)
00547       cout<<"\n Please use operator [] instead of operator ()! Error!" << endl;
00548 
00549     typedef DResDiff_Bo_ARR<DExpr<A> > ExprT;
00550     return DExpr<ExprT>(ExprT(a_,num_stencils,grid,Index_value_));
00551   }
00552   /*
00553   template<class A>
00554   DExpr<DResDiagDiff_Bo<DExpr<A> > > 
00555   operator[] (const DExpr<A>& a_) {
00556     Differential_op_typ a_abstract;
00557     a_abstract = a_.Abstract_differential_operator();
00558     if(a_abstract==not_abstract) {
00559       cout << " This is not an abstract differential operator! Error!" << endl;
00560     }
00561     if(a_abstract==abstract_with_var)
00562       cout<<"\n Please use operator () instead of operator []! Error!" << endl;
00563     typedef DResDiagDiff_Bo<DExpr<A> > ExprT;
00564     return DExpr<ExprT>(ExprT(a_,num_stencils,grid,this));
00565   }
00566   */
00567 };
00568 
00569 
00570 class Array_Res_stencil_boundary {
00571  public:
00572   Array_Res_stencil_boundary(int dimension, Grid* gr) {
00573     dim  = dimension;
00574     start = new Res_stencil_boundary[dim];
00575     for(int i=0;i<dim;++i) {
00576       start[i].Initialize(gr);
00577     }
00578   }
00579   Res_stencil_boundary& operator[](int i) const {
00580     return start[i];
00581   }
00582   Index_Res_stencil_boundary_ARR
00583   operator[](Local_int& I) const {
00584     for(int i=0;i<dim;++i) {
00585       if(start[i].Give_used()==false) {
00586         cout << " Error: Use Array_Res_stencil_boundary first time " 
00587              << " with operator operator[](int i) !! " << endl;
00588       }
00589     }
00590     return Index_Res_stencil_boundary_ARR(start[0].num_stencils,
00591                                           start[0].grid,
00592                                           I.Give_pointer());
00593   }
00594   int Give_dim() {
00595     return dim;
00596   }
00597  private:
00598   Res_stencil_boundary *start;
00599   int dim;
00600 };
00601 
00602 
00603 
00604 
00605 
00606 
00607 //    4. sums and for iteration
00609 
00610 
00611 
00612 template<class A>
00613 class Expr_for_iterator {
00614  private:
00615   A a_;
00616   int* value_;
00617   int begin;
00618   int end;
00619   
00620   double dummy;
00621  public:
00622   Expr_for_iterator(const A& x, int b, int e, int* v)
00623     : a_(x), value_(v), begin(b), end(e)
00624     {}
00625   // for evaluate
00626   void Run_interior(const P_interior* it_i,const Grid* gr, double h_mesh,
00627                        int l, double_stencils_in) const {
00628     for((*value_)=begin;(*value_)<=end;(*value_)++)
00629       a_.Run_interior(it_i,gr,h_mesh,l, double_stencils_out);
00630   };
00631   void Run_interior_coarse(const P_interior* it_i,const Grid* gr,
00632                            double h_mesh,
00633                            int l, double_stencils_in) const {
00634     for((*value_)=begin;(*value_)<=end;(*value_)++)
00635       a_.Run_interior_coarse(it_i,gr,h_mesh,l, double_stencils_out);
00636   };
00637   void Run_nearb(const P_nearb* it_n,const Grid* gr, double h_mesh, int l,
00638                     const Nearb_Ablage* nearb_ablage)
00639     const {
00640     for((*value_)=begin;(*value_)<=end;(*value_)++)
00641       a_.Run_nearb(it_n,gr,h_mesh,l,nearb_ablage);
00642   };
00643   void Run_Bo2p(const P_Bo2p* it_b,const Grid* gr, int l) const {
00644     for((*value_)=begin;(*value_)<=end;(*value_)++)
00645       a_.Run_Bo2p(it_b,gr,l);
00646   };
00647   void Run_cellpoi(const P_cellpoi* it_cf,const Grid* gr,
00648                       const BoCeData* bocedata) const {
00649     for((*value_)=begin;(*value_)<=end;(*value_)++)
00650       a_.Run_cellpoi(it_cf,gr,bocedata);
00651   };
00652 
00653   // Size of necessary stencil
00654   int Sice_stencil() const { return a_.Sice_stencil(); }
00655 
00656   // activity of points
00657   int Level() const { return a_.Level(); }
00658   Dominace_label Dominant_lev() const { return a_.Dominant_lev(); }
00659   Dominace_label Dominant_poi() const { return a_.Dominant_poi(); }
00660   bool run_interior() const { return a_.run_interior(); }
00661   bool run_nearb()    const { return a_.run_nearb(); }
00662   int run_boundary() const { return a_.run_boundary(); }
00663 
00664   // number of operations
00665   int ops_interior() const { return a_.ops_interior()*(end-begin+1); }   
00666 
00667   // For operator ==
00668   void Active_Sim_Level( int lev) const { a_.Active_Sim_Level(lev); }
00669   void Active_Sim_interior( bool run) const { a_.Active_Sim_interior(run); }
00670   void Active_Sim_nearb( bool run) const { a_.Active_Sim_nearb(run); }
00671   void Active_Sim_boundary(int run) const { a_.Active_Sim_boundary(run); }
00672   void Active_Sim_update(Evaluation_Parallelization_object* evpar,
00673                          int level, type_of_update typ) const 
00674     {  a_.Active_Sim_update(evpar,level,typ); };
00675 
00676   // Put pointer to grid and activity of boundary points of test space  
00677   void Put_grid_rbo(Grid* gr, int r_bo) const {
00678     a_.Put_grid_rbo(gr,r_bo); }
00679   // Is the expression an abstract differential operator?
00680    Differential_op_typ Abstract_differential_operator() const
00681     { return not_abstract; }
00682   // for Parallelization
00683   void Add_variables_for_parallel(Evaluation_Parallelization_object *evpar) 
00684     const {
00685     a_.Add_variables_for_parallel(evpar);
00686   };
00687   bool GS_type(int var_number_left, int dim_left) const {
00688     return a_.GS_type(var_number_left, dim_left);
00689   };
00690 
00691   // at the and of an iteration of an expression
00692   void clean() const { a_.clean(); };
00693 };
00694 
00695 template<class A>
00696 class Expr_for_sum {
00697  private:
00698   A a_;
00699   int* value_;
00700   int begin;
00701   int end;
00702   
00703   double* sum;
00704  public:
00705   Expr_for_sum(const A& x, int b, int e, int* v) 
00706     : a_(x), value_(v), begin(b), end(e) {
00707     if(e<b) cout << "\n Empty Sum! Error! " << endl;
00708     sum = new double;
00709   };
00710 
00711   // for evaluate
00712   double Give_interior(const P_interior* it_i,const Grid* gr, double h_mesh,
00713                        int l, double_stencils_in) const {
00714     (*value_)=begin;
00715     (*sum)=a_.Give_interior(it_i,gr,h_mesh,l, double_stencils_out);
00716     for((*value_)=begin+1;(*value_)<=end;(*value_)++)
00717       (*sum) = (*sum)+a_.Give_interior(it_i,gr,h_mesh,l, double_stencils_out);
00718     return (*sum);
00719   };
00720   double Give_interior_coarse(const P_interior* it_i,const Grid* gr, 
00721                               double h_mesh, int l, double_stencils_in) const {
00722     (*value_)=begin;
00723     (*sum) = a_.Give_interior_coarse(it_i,gr,h_mesh,l, double_stencils_out);
00724     for((*value_)=begin+1;(*value_)<=end;(*value_)++)
00725       (*sum)=(*sum)+
00726         a_.Give_interior_coarse(it_i,gr,h_mesh,l, double_stencils_out);
00727     return (*sum);
00728   };
00729   double Give_nearb(const P_nearb* it_n,const Grid* gr, double h_mesh, int l,
00730                     const Nearb_Ablage* nearb_ablage)
00731     const {
00732     (*value_)=begin;
00733     (*sum) = a_.Give_nearb(it_n,gr,h_mesh,l,nearb_ablage);
00734     for((*value_)=begin+1;(*value_)<=end;(*value_)++)
00735       (*sum) = (*sum) + a_.Give_nearb(it_n,gr,h_mesh,l,nearb_ablage);
00736     return (*sum);
00737   };
00738   double Give_Bo2p(const P_Bo2p* it_b,const Grid* gr, int l) const {
00739     (*value_)=begin;
00740     (*sum) = a_.Give_Bo2p(it_b,gr,l);
00741     for((*value_)=begin+1;(*value_)<=end;(*value_)++)
00742       (*sum) = (*sum) + a_.Give_Bo2p(it_b,gr,l);
00743     return (*sum);
00744   };
00745   double Give_cellpoi(const P_cellpoi* it_cf,const Grid* gr,
00746                       const BoCeData* bocedata) const {
00747     (*value_)=begin;
00748     (*sum) = a_.Give_cellpoi(it_cf,gr,bocedata);
00749     for((*value_)=begin+1;(*value_)<=end;(*value_)++)
00750       (*sum) = (*sum) + a_.Give_cellpoi(it_cf,gr,bocedata);
00751     return (*sum);
00752   };
00753 
00754   // Size of necessary stencil
00755   int Sice_stencil() const { return a_.Sice_stencil(); }
00756 
00757   // activity of points
00758   int Level() const { return a_.Level(); }
00759   Dominace_label Dominant_lev() const { return a_.Dominant_lev(); }
00760   Dominace_label Dominant_poi() const { return a_.Dominant_poi(); }
00761   bool run_interior() const { return a_.run_interior(); }
00762   bool run_nearb()    const { return a_.run_nearb(); }
00763   int run_boundary() const { return a_.run_boundary(); }
00764 
00765   // number of operations
00766   int ops_interior() const { return a_.ops_interior()*(end-begin+1)
00767                                +(end-begin); }   
00768 
00769   // For operator ==
00770   void Active_Sim_Level( int lev) const { a_.Active_Sim_Level(lev); }
00771   void Active_Sim_interior( bool run) const { a_.Active_Sim_interior(run); }
00772   void Active_Sim_nearb( bool run)    const { a_.Active_Sim_nearb(run); }
00773   void Active_Sim_boundary(int run) const { a_.Active_Sim_boundary(run); }
00774   void Active_Sim_update(Evaluation_Parallelization_object* evpar,
00775                          int level, type_of_update typ) const 
00776     {  a_.Active_Sim_update(evpar,level,typ); };
00777 
00778   // Put pointer to grid and activity of boundary points of test space
00779   void Put_grid_rbo(Grid* gr, int r_bo)  const { a_.Put_grid_rbo(gr,r_bo); }
00780   // For abstract differential operators:
00781   // --------------------------------------
00782   // Is the expression an abstract differential operator?
00783   Differential_op_typ Abstract_differential_operator() const  {
00784     return not_abstract; }
00785   // for Parallelization
00786   void Add_variables_for_parallel(Evaluation_Parallelization_object *evpar) 
00787     const {
00788     a_.Add_variables_for_parallel(evpar);
00789   };
00790   bool GS_type(int var_number_left, int dim_left) const {
00791     return a_.GS_type(var_number_left, dim_left);
00792   };
00793 
00794   // at the and of an iteration of an expression
00795   void clean() const { delete(sum); a_.clean(); };
00796 };
00797 
00798 
00799 
00800 class Schleife {
00801  public:
00802   int* value_;
00803   int begin;
00804   int end;
00805   Schleife(int* v, int b, int e) : value_(v), begin(b), end(e)
00806     {};
00807   template<class A>
00808     DWrapSim<Expr_for_iterator<DWrapSim<A> > >
00809     operator()(const DWrapSim<A> & a)
00810     {
00811       typedef Expr_for_iterator<DWrapSim<A> >  ExprT;
00812       return DWrapSim<ExprT>(ExprT(a,begin,end,value_));
00813     }
00814 };
00815 
00816 
00817 
00818 
00819 class SchleifeSum {
00820  public:
00821   int* value_;
00822   int begin;
00823   int end;
00824   SchleifeSum(int* v, int b, int e) : value_(v), begin(b), end(e)
00825     {};
00826   template<class A>
00827     DExpr<Expr_for_sum<DExpr<A> > >
00828     operator()(const DExpr<A> & a)
00829     {
00830       typedef Expr_for_sum<DExpr<A> >  ExprT;
00831       return DExpr<ExprT>(ExprT(a,begin,end,value_));
00832     }
00833 };
00834 
00835 
00836 
00837 
00838 
00840 //  for iterator function
00842 
00843 
00844 Schleife For(Local_int& I, int begin, int end);
00845 
00846 
00847 SchleifeSum Sum(Local_int& I, int begin, int end);
00848 
00850 // 5.:  Class for procedure
00851 
00852 // 5.1.a. procedure with 3  parameters, and per reference
00853 template<class A, class B, class C>
00854 class DExprProcedure3 {
00855  private:
00856   void (*Procedure)(double* x, double* y, double* z);
00857   int opsf; // number of operations for Formula
00858   A a_;
00859   B b_;
00860   C c_;
00861  public:
00862   DExprProcedure3(void (*procedure)(double* x, double* y, double* z),
00863              const A& a, const B& b, const C& c) : a_(a), b_(b), c_(c)
00864     {
00865       Procedure = procedure;
00866       opsf = 0;
00867     }
00868   // for evaluate
00869   void Run_interior(const P_interior* it_i,const Grid* gr, double h_mesh,
00870                        int l, double_stencils_in) const {
00871     Procedure(a_.Give_regular_pointer(it_i,gr,l),
00872               b_.Give_regular_pointer(it_i,gr,l),
00873               c_.Give_regular_pointer(it_i,gr,l));
00874   };
00875   void Run_interior_coarse(const P_interior* it_i,const Grid* gr,
00876                            double h_mesh,
00877                            int l, double_stencils_in) const {
00878     Procedure(a_.Give_regular_pointer(it_i,gr,l),
00879               b_.Give_regular_pointer(it_i,gr,l),
00880               c_.Give_regular_pointer(it_i,gr,l));
00881   };
00882   void Run_nearb(const P_nearb* it_n,const Grid* gr, double h_mesh, int l,
00883                     const Nearb_Ablage* nearb_ablage)
00884     const {
00885     Procedure(a_.Give_regular_pointer(it_n,gr,l),
00886               b_.Give_regular_pointer(it_n,gr,l),
00887               c_.Give_regular_pointer(it_n,gr,l));
00888   };
00889   void Run_Bo2p(const P_Bo2p* it_b,const Grid* gr, int l) const {
00890     Procedure(a_.Give_Bo2p_pointer(it_b,gr,l),
00891               b_.Give_Bo2p_pointer(it_b,gr,l),
00892               c_.Give_Bo2p_pointer(it_b,gr,l));
00893   };
00894   void Run_cellpoi(const P_cellpoi* it_cf, const Grid* gr,
00895                    const BoCeData* bocedata) const {
00896     Procedure(a_.Give_cellpoi_pointer(it_cf,gr),
00897               b_.Give_cellpoi_pointer(it_cf,gr),
00898               c_.Give_cellpoi_pointer(it_cf,gr));
00899   };
00900 
00901   // Size of necessary stencil
00902   int Sice_stencil() const { return 1; }
00903 
00904   // activity of points
00905   int Level() const { 
00906     if(c_.Dominant_lev() ==  yes_dominant || 
00907        (b_.Dominant_lev() == anti_dominant &&
00908         a_.Dominant_lev() == anti_dominant))
00909       return c_.Level();
00910     if(b_.Dominant_lev() ==  yes_dominant || 
00911        (c_.Dominant_lev() == anti_dominant &&
00912         a_.Dominant_lev() == anti_dominant))
00913       return b_.Level();
00914     if(a_.Dominant_lev() ==  yes_dominant || 
00915        (b_.Dominant_lev() == anti_dominant &&
00916         c_.Dominant_lev() == anti_dominant))
00917       return a_.Level();
00918    if(c_.Dominant_lev() == anti_dominant)
00919      return MAX(a_.Level(),b_.Level()); 
00920    if(b_.Dominant_lev() == anti_dominant)
00921      return MAX(a_.Level(),c_.Level()); 
00922    if(a_.Dominant_lev() == anti_dominant)
00923      return MAX(c_.Level(),b_.Level());
00924    return MAX(a_.Level(),b_.Level(),c_.Level()); 
00925   }
00926   Dominace_label Dominant_lev() const {
00927     return (Dominace_label)(MAX(a_.Dominant_lev(),
00928                                 b_.Dominant_lev(),
00929                                 c_.Dominant_lev()));
00930   }
00931   Dominace_label Dominant_poi() const {
00932     return (Dominace_label)(MAX(a_.Dominant_poi(),
00933                                 b_.Dominant_poi(),
00934                                 c_.Dominant_poi()));
00935   }
00936   bool run_interior() const { 
00937     if(c_.Dominant_poi() ==  yes_dominant || 
00938        (b_.Dominant_poi() == anti_dominant &&
00939         a_.Dominant_poi() == anti_dominant))
00940       return c_.run_interior();
00941     if(b_.Dominant_poi() ==  yes_dominant || 
00942        (c_.Dominant_poi() == anti_dominant &&
00943         a_.Dominant_poi() == anti_dominant))
00944       return b_.run_interior();
00945     if(a_.Dominant_poi() ==  yes_dominant || 
00946        (b_.Dominant_poi() == anti_dominant &&
00947         c_.Dominant_poi() == anti_dominant))
00948       return a_.run_interior();
00949     if(c_.Dominant_poi() == anti_dominant)
00950       return b_.run_interior();
00951     return c_.run_interior();
00952   }
00953   bool run_nearb() const { 
00954     if(c_.Dominant_poi() ==  yes_dominant || 
00955        (b_.Dominant_poi() == anti_dominant &&
00956         a_.Dominant_poi() == anti_dominant))
00957       return c_.run_nearb();
00958     if(b_.Dominant_poi() ==  yes_dominant || 
00959        (c_.Dominant_poi() == anti_dominant &&
00960         a_.Dominant_poi() == anti_dominant))
00961       return b_.run_nearb();
00962     if(a_.Dominant_poi() ==  yes_dominant || 
00963        (b_.Dominant_poi() == anti_dominant &&
00964         c_.Dominant_poi() == anti_dominant))
00965       return a_.run_nearb();
00966     if(c_.Dominant_poi() == anti_dominant)
00967       return b_.run_nearb();
00968     return c_.run_nearb();
00969   }
00970   bool run_boundary() const { 
00971     if(c_.Dominant_poi() ==  yes_dominant || 
00972        (b_.Dominant_poi() == anti_dominant &&
00973         a_.Dominant_poi() == anti_dominant))
00974       return c_.run_boundary();
00975     if(b_.Dominant_poi() ==  yes_dominant || 
00976        (c_.Dominant_poi() == anti_dominant &&
00977         a_.Dominant_poi() == anti_dominant))
00978       return b_.run_boundary();
00979     if(a_.Dominant_poi() ==  yes_dominant || 
00980        (b_.Dominant_poi() == anti_dominant &&
00981         c_.Dominant_poi() == anti_dominant))
00982       return a_.run_boundary();
00983     if(c_.Dominant_poi() == anti_dominant)
00984       return b_.run_boundary();
00985     return c_.run_boundary();
00986   }
00987 
00988   // number of operations
00989   int ops_interior() const { 
00990     return opsf;
00991   }
00992   // For operator ==
00993   void Active_Sim_Level( int lev) const { 
00994     a_.Active_Sim_Level(lev);
00995     b_.Active_Sim_Level(lev);
00996     c_.Active_Sim_Level(lev); 
00997   };
00998   void Active_Sim_interior(bool run) const { 
00999     a_.Active_Sim_interior(run);
01000     b_.Active_Sim_interior(run);
01001     c_.Active_Sim_interior(run); 
01002   };
01003   void Active_Sim_nearb(bool run) const { 
01004     a_.Active_Sim_nearb(run); 
01005     b_.Active_Sim_nearb(run); 
01006     c_.Active_Sim_nearb(run); 
01007   };
01008   void Active_Sim_boundary( int run) const {
01009     a_.Active_Sim_boundary(run); 
01010     b_.Active_Sim_boundary(run); 
01011     c_.Active_Sim_boundary(run); 
01012   };
01013   void Active_Sim_update(Evaluation_Parallelization_object* evpar,
01014                          int level, type_of_update typ) const {
01015     a_.Active_Sim_update(evpar,level,typ);
01016     b_.Active_Sim_update(evpar,level,typ); 
01017     b_.Active_Sim_update(evpar,level,typ); 
01018   };
01019 
01020   // Put pointer to grid and activity of boundary points of test space  
01021   void Put_grid_rbo(Grid* gr, int r_bo) const {
01022     a_.Put_grid_rbo(gr,r_bo);
01023     b_.Put_grid_rbo(gr,r_bo); 
01024     c_.Put_grid_rbo(gr,r_bo); 
01025   }
01026  // For abstract differential operators:
01027   // --------------------------------------
01028   // Is the expression an abstract differential operator?
01029   Differential_op_typ Abstract_differential_operator()  const {
01030     return not_abstract;
01031   };
01032  // for Parallelization
01033   void Add_variables_for_parallel(Evaluation_Parallelization_object *evpar)
01034     const {
01035     a_.Add_variables_for_parallel(evpar);
01036     b_.Add_variables_for_parallel(evpar);
01037     c_.Add_variables_for_parallel(evpar);
01038   };
01039   bool GS_type(int var_number_left, int dim_left) const {
01040    if(c_.GS_type(var_number_left, dim_left)==true) return true;
01041    if(b_.GS_type(var_number_left, dim_left)==true) return true;
01042     return a_.GS_type(var_number_left, dim_left);
01043   };
01044 
01045   // at the and of an iteration of an expression
01046   void clean() const  {
01047     a_.clean(); 
01048     b_.clean(); 
01049     c_.clean(); 
01050   };
01051 };
01052 
01053 /*
01054 // 5.1.b. procedure with 3  parameters, and not per reference
01055 template<class A, class B, class C>
01056 class DExprProcedure3_nr {
01057  private:
01058   void (*Procedure)(double x, double y, double z);
01059   int opsf; // number of operations for Formula
01060   A a_;
01061   B b_;
01062   C c_;
01063  public:
01064   DExprProcedure3(void (*procedure)(double x, double y, double z),
01065              const A& a, const B& b, const C& c) : a_(a), b_(b), c_(c)
01066     {
01067       Procedure = procedure;
01068       opsf = 0;
01069     }
01070   // for evaluate
01071   void Run_interior(const P_interior* it_i,const Grid* gr, double h_mesh,
01072                       int l, double_stencils_in) const { 
01073     Procedure(a_.Give_interior(it_i,gr,h_mesh,l, double_stencils_out),
01074                    b_.Give_interior(it_i,gr,h_mesh,l, double_stencils_out),
01075                    c_.Give_interior(it_i,gr,h_mesh,l, double_stencils_out)); 
01076   }
01077   void Run_interior_coarse(const P_interior* it_i,const Grid* gr,
01078                            double h_mesh,
01079                            int l, double_stencils_in) const { 
01080     Procedure(a_.Give_interior_coarse(it_i,gr,h_mesh,l,
01081                                       double_stencils_out),
01082               b_.Give_interior_coarse(it_i,gr,h_mesh,l,
01083                                       double_stencils_out),
01084               c_.Give_interior_coarse(it_i,gr,h_mesh,l,
01085                                       double_stencils_out)); 
01086   }
01087   void Run_nearb(const P_nearb* it_n,const Grid* gr, double h_mesh, int l,
01088                  const Nearb_Ablage* nearb_ablage) const { 
01089     Procedure(a_.Give_nearb(it_n,gr,h_mesh,l,nearb_ablage),
01090               b_.Give_nearb(it_n,gr,h_mesh,l,nearb_ablage),
01091               c_.Give_nearb(it_n,gr,h_mesh,l,nearb_ablage)); 
01092   }
01093   void Run_Bo2p(const P_Bo2p* it_b,const Grid* gr, int l) const {
01094     Procedure(a_.Give_Bo2p(it_b,gr,l),
01095               b_.Give_Bo2p(it_b,gr,l),
01096               c_.Give_Bo2p(it_b,gr,l)); 
01097   }
01098   void Run_cellpoi(const P_cellpoi* it_cf,const Grid* gr,
01099                    const BoCeData* bocedata) const {
01100     Procedure(a_.Give_cellpoi(it_cf,gr,bocedata),
01101               b_.Give_cellpoi(it_cf,gr,bocedata),
01102               c_.Give_cellpoi(it_cf,gr,bocedata)); 
01103   }
01104   
01105   // Size of necessary stencil
01106   int Sice_stencil() const { return 1; }
01107 
01108   // activity of points
01109   int Level() const { 
01110     if(c_.Dominant_lev() ==  yes_dominant || 
01111        (b_.Dominant_lev() == anti_dominant &&
01112         a_.Dominant_lev() == anti_dominant))
01113       return c_.Level();
01114     if(b_.Dominant_lev() ==  yes_dominant || 
01115        (c_.Dominant_lev() == anti_dominant &&
01116         a_.Dominant_lev() == anti_dominant))
01117       return b_.Level();
01118     if(a_.Dominant_lev() ==  yes_dominant || 
01119        (b_.Dominant_lev() == anti_dominant &&
01120         c_.Dominant_lev() == anti_dominant))
01121       return a_.Level();
01122    if(c_.Dominant_lev() == anti_dominant)
01123      return MAX(a_.Level(),b_.Level()); 
01124    if(b_.Dominant_lev() == anti_dominant)
01125      return MAX(a_.Level(),c_.Level()); 
01126    if(a_.Dominant_lev() == anti_dominant)
01127      return MAX(c_.Level(),b_.Level());
01128    return MAX(a_.Level(),b_.Level(),c_.Level()); 
01129   }
01130   Dominace_label Dominant_lev() const {
01131     return (Dominace_label)(MAX(a_.Dominant_lev(),
01132                                 b_.Dominant_lev(),
01133                                 c_.Dominant_lev()));
01134   }
01135   Dominace_label Dominant_poi() const {
01136     return (Dominace_label)(MAX(a_.Dominant_poi(),
01137                                 b_.Dominant_poi(),
01138                                 c_.Dominant_poi()));
01139   }
01140   bool run_interior() const { 
01141     if(c_.Dominant_poi() ==  yes_dominant || 
01142        (b_.Dominant_poi() == anti_dominant &&
01143         a_.Dominant_poi() == anti_dominant))
01144       return c_.run_interior();
01145     if(b_.Dominant_poi() ==  yes_dominant || 
01146        (c_.Dominant_poi() == anti_dominant &&
01147         a_.Dominant_poi() == anti_dominant))
01148       return b_.run_interior();
01149     if(a_.Dominant_poi() ==  yes_dominant || 
01150        (b_.Dominant_poi() == anti_dominant &&
01151         c_.Dominant_poi() == anti_dominant))
01152       return a_.run_interior();
01153     if(c_.Dominant_poi() == anti_dominant)
01154       return b_.run_interior();
01155     return c_.run_interior();
01156   }
01157   bool run_nearb() const { 
01158     if(c_.Dominant_poi() ==  yes_dominant || 
01159        (b_.Dominant_poi() == anti_dominant &&
01160         a_.Dominant_poi() == anti_dominant))
01161       return c_.run_nearb();
01162     if(b_.Dominant_poi() ==  yes_dominant || 
01163        (c_.Dominant_poi() == anti_dominant &&
01164         a_.Dominant_poi() == anti_dominant))
01165       return b_.run_nearb();
01166     if(a_.Dominant_poi() ==  yes_dominant || 
01167        (b_.Dominant_poi() == anti_dominant &&
01168         c_.Dominant_poi() == anti_dominant))
01169       return a_.run_nearb();
01170     if(c_.Dominant_poi() == anti_dominant)
01171       return b_.run_nearb();
01172     return c_.run_nearb();
01173   }
01174   bool run_boundary() const { 
01175     if(c_.Dominant_poi() ==  yes_dominant || 
01176        (b_.Dominant_poi() == anti_dominant &&
01177         a_.Dominant_poi() == anti_dominant))
01178       return c_.run_boundary();
01179     if(b_.Dominant_poi() ==  yes_dominant || 
01180        (c_.Dominant_poi() == anti_dominant &&
01181         a_.Dominant_poi() == anti_dominant))
01182       return b_.run_boundary();
01183     if(a_.Dominant_poi() ==  yes_dominant || 
01184        (b_.Dominant_poi() == anti_dominant &&
01185         c_.Dominant_poi() == anti_dominant))
01186       return a_.run_boundary();
01187     if(c_.Dominant_poi() == anti_dominant)
01188       return b_.run_boundary();
01189     return c_.run_boundary();
01190   }
01191 
01192   // number of operations
01193   int ops_interior() const { 
01194     return opsf;
01195   }
01196   // For operator ==
01197   void Active_Sim_Level( int lev) const { 
01198     a_.Active_Sim_Level(lev);
01199     b_.Active_Sim_Level(lev);
01200     c_.Active_Sim_Level(lev); 
01201   };
01202   void Active_Sim_interior(bool run) const { 
01203     a_.Active_Sim_interior(run);
01204     b_.Active_Sim_interior(run);
01205     c_.Active_Sim_interior(run); 
01206   };
01207   void Active_Sim_nearb(bool run) const { 
01208     a_.Active_Sim_nearb(run); 
01209     b_.Active_Sim_nearb(run); 
01210     c_.Active_Sim_nearb(run); 
01211   };
01212   void Active_Sim_boundary( int run) const {
01213     a_.Active_Sim_boundary(run); 
01214     b_.Active_Sim_boundary(run); 
01215     c_.Active_Sim_boundary(run); 
01216   };
01217   void Active_Sim_update(Evaluation_Parallelization_object* evpar,
01218                          int level, type_of_update typ) const {
01219     a_.Active_Sim_update(evpar,level,typ);
01220     b_.Active_Sim_update(evpar,level,typ); 
01221     b_.Active_Sim_update(evpar,level,typ); 
01222   };
01223 
01224   // Put pointer to grid and activity of boundary points of test space  
01225   void Put_grid_rbo(Grid* gr, int r_bo) const {
01226     a_.Put_grid_rbo(gr,r_bo);
01227     b_.Put_grid_rbo(gr,r_bo); 
01228     c_.Put_grid_rbo(gr,r_bo); 
01229   }
01230  // For abstract differential operators:
01231   // --------------------------------------
01232   // Is the expression an abstract differential operator?
01233   Differential_op_typ Abstract_differential_operator()  const {
01234     return not_abstract;
01235   };
01236  // for Parallelization
01237   void Add_variables_for_parallel(Evaluation_Parallelization_object *evpar)
01238     const {
01239     a_.Add_variables_for_parallel(evpar);
01240     b_.Add_variables_for_parallel(evpar);
01241     c_.Add_variables_for_parallel(evpar);
01242   };
01243   bool GS_type(int var_number_left, int dim_left) const {
01244    if(c_.GS_type(var_number_left, dim_left)==true) return true;
01245    if(b_.GS_type(var_number_left, dim_left)==true) return true;
01246     return a_.GS_type(var_number_left, dim_left);
01247   };
01248 
01249   // at the and of an iteration of an expression
01250   void clean() const  {
01251     a_.clean(); 
01252     b_.clean(); 
01253     c_.clean(); 
01254   };
01255 };
01256 */
01257 
01258 
01259 // 5.3. procedure definition
01260 class Procedure {
01261   private:
01262   void (*Procedure3)(double* x, double* y,double* z);
01263   void (*Procedure4)(double* x, double* y,double* z, double* u);
01264 
01265   int type;  // 3 or 4 
01266 
01267   int length_x, length_y, length_z; // only for array
01268  public:
01269 
01270   Procedure(void (*procedure)(double* x, double* y,double* z),
01271             int len_x, int len_y, int len_z)
01272     {
01273       Procedure3 = procedure;
01274       type = 3;
01275       length_x = len_x;
01276       length_y = len_y;
01277       length_z = len_z;
01278     }
01279   Procedure(void (*procedure)(double* x, double* y,double* z))
01280     {
01281       Procedure3 = procedure;
01282       type = 3;
01283       length_x = 0;
01284       length_y = 0;
01285       length_z = 0;
01286     }
01287   // procedure with 3 entries
01288   // a) for array
01289   DWrapSim<DExprProcedure3<DExprVAR, DExprVAR, DExprVAR> > operator() 
01290      (Array_Variable& a, Array_Variable& b, Array_Variable& c) {
01291     if(a.Give_dim()<length_x &&
01292        b.Give_dim()<length_y &&
01293        c.Give_dim()<length_z) {
01294       cout << "\n Wrong length of vectors! " << endl;
01295     }
01296     if(type != 3) cout << "\n Wrong usage of procedure 3! " << endl;
01297     typedef DExprProcedure3<DExprVAR, DExprVAR, DExprVAR>  ExprT;
01298     return DWrapSim<ExprT>(ExprT(Procedure3,
01299       DExprVAR(a[0]),DExprVAR(b[0]),DExprVAR(c[0])));
01300   }
01301 
01302   DWrapSim<DExprProcedure3<Local_var, DExprVAR, DExprVAR> > operator() 
01303      (Array_Local_var& a, Array_Variable& b, Array_Variable& c) {
01304     if(a.Give_dim()<length_x &&
01305        b.Give_dim()<length_y &&
01306        c.Give_dim()<length_z) {
01307       cout << "\n Wrong length of vectors! " << endl;
01308     }
01309     if(type != 3) cout << "\n Wrong usage of procedure 3! " << endl;
01310     typedef DExprProcedure3<Local_var, DExprVAR, DExprVAR>  ExprT;
01311     return DWrapSim<ExprT>(ExprT(Procedure3,
01312       a[0],DExprVAR(b[0]),DExprVAR(c[0])));
01313   }
01314 
01315   DWrapSim<DExprProcedure3<DExprVAR, Local_var, DExprVAR> > operator() 
01316      (Array_Variable& a, Array_Local_var& b, Array_Variable& c) {
01317     if(a.Give_dim()<length_x &&
01318        b.Give_dim()<length_y &&
01319        c.Give_dim()<length_z) {
01320       cout << "\n Wrong length of vectors! " << endl;
01321     }
01322     if(type != 3) cout << "\n Wrong usage of procedure 3! " << endl;
01323     typedef DExprProcedure3<DExprVAR, Local_var, DExprVAR>  ExprT;
01324     return DWrapSim<ExprT>(ExprT(Procedure3,
01325       DExprVAR(a[0]),b[0],DExprVAR(c[0])));
01326   }
01327 
01328   DWrapSim<DExprProcedure3<DExprVAR, DExprVAR, Local_var> > operator() 
01329      (Array_Variable& a, Array_Variable& b, Array_Local_var& c) {
01330     if(a.Give_dim()<length_x &&
01331        b.Give_dim()<length_y &&
01332        c.Give_dim()<length_z) {
01333       cout << "\n Wrong length of vectors! " << endl;
01334     }
01335     if(type != 3) cout << "\n Wrong usage of procedure 3! " << endl;
01336     typedef DExprProcedure3<DExprVAR, DExprVAR, Local_var>  ExprT;
01337     return DWrapSim<ExprT>(ExprT(Procedure3,
01338       DExprVAR(a[0]),DExprVAR(b[0]),c[0]));
01339   }
01340   /*
01341   // b) for scalars
01342   template<class A, class B, class C>
01343     DWrapSim<DExprProcedure3_nr<A,B,C> > operator() (A a, B b, C c) {
01344     if(type != 3) cout << "\n Wrong usage of procedure 3! " << endl;
01345     typedef DExprProcedure3_nr<A, B, C>  ExprT;
01346     return DWrapSim<ExprT>(ExprT(Procedure3,a,b,c));
01347   }
01348   */
01349 };
01350 
01351 
01352 #endif
01353         

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