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

src/expde/extemp/variable.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 #ifndef VARIABLE_H_
00018 #define VARIABLE_H_
00019              
00020 // ------------------------------------------------------------
00021 //
00022 //     variable.h 
00023 //     includes later sim2.h
00024 //
00025 // ------------------------------------------------------------
00026 
00027 // Abbreviation for dominant
00028 enum Dominace_label { anti_dominant = -1, not_dominant = 0, yes_dominant = 1 };
00029 
00030 // Abbreviation for differential operator
00031 enum Differential_op_typ { not_abstract, abstract_with_var, abstract_diag ,
00032                            abstract_both, not_both };   // ada: add not_both was missing and detected by gcc 3.4.4
00033 
00034 // Example: Abbreviation for dominant with respect to level:
00035 /*
00036   anti_dominant :  expression contains no information about level
00037   not_dominant  :  expression contains information about level, 
00038                    but expression is not dominant
00039   yes_dominant  :  expression contains information about level, 
00040                    and expression is dominant with respect to level
00041 */
00042 
00043 // remark with respect to r_boundary:
00044 /*
00045   r_boundary == 1:              run all boundary points
00046   r_boundary == 0:              run no  boundary points
00047   r_boundary == i = -1,-2, ...: run     boundary points of label -i
00048 */  
00049 
00050 
00051 // abbreviation for list of stencils
00052 #define double_stencils_in double *LuN, double *LuW, double *LuM, \
00053   double *LuE, double *LuS, double *LuT, double *LuD, double *LuND, \
00054   double *LuWN, double *LuWT, double *LuED, double *LuST, double *LuES, \
00055   double *LuWD, double *LuET, double *LuEST, double *LuWND, \
00056   double *LuCell_WSD, double *LuCell_WST, \
00057   double *LuCell_WND, double *LuCell_WNT, \
00058   double *LuCell_ESD, double *LuCell_EST, \
00059   double *LuCell_END, double *LuCell_ENT
00060 #define double_stencils_out LuN, LuW, LuM, LuE, LuS, LuT, LuD, LuND, \
00061 LuWN, LuWT, LuED, LuST, LuES, LuWD, LuET, LuEST, LuWND, \
00062 LuCell_WSD, LuCell_WST, LuCell_WND, LuCell_WNT, \
00063 LuCell_ESD, LuCell_EST, LuCell_END, LuCell_ENT
00064 
00065 //  for later:
00066 template<class B>
00067 class DExprSim;
00068 
00069 template<class A, class B> 
00070 class DExprAnd;
00071 
00072 class Variable;
00073 class Array_Variable;
00074 class Array_Local_var;
00075 
00076 template<class R> 
00077 class DExprResVarP;
00078 
00079 class ExpdeIndex;
00080 class assignable_vector;
00081 
00082 /* FunctionClass for Representing a Restriction operator for a function */
00083 // used in elementary.h
00084 class FunctionClass {
00085     int  r_boundary;
00086     bool r_interior;
00087     bool r_nearb;
00088  public:
00089     double (*Formula)(double x,double y,double z);
00090     template<class R>
00091   FunctionClass( double (*formula)(double x,double y,double z), const R& r)
00092     {
00093       Formula = formula;
00094       r_boundary = r.run_boundary();
00095       r_nearb    = r.run_nearb();
00096       r_interior = r.run_interior();
00097     }
00098   bool run_interior() const { return r_interior;  }
00099   bool run_nearb()    const { return r_nearb; }
00100   int run_boundary() const { return r_boundary; }
00101 
00102   // Put pointer to grid and activity of boundary points of test space  
00103   void Put_grid_rbo(Grid* gr, int r_bo) const { };
00104   // Is the expression an abstract differential operator?
00105   Differential_op_typ Abstract_differential_operator() const
00106     { return not_abstract; }
00107 };
00108 
00110 //  2 types of local variables 
00112 
00113 /*  local variable for double */
00114 class Local_var {
00115   friend class Array_Local_var;
00116  private:
00117   double* value_;
00118   Local_var() {
00119     value_ = NULL;
00120   }
00121   void Initialize(double* v) {
00122     value_ = v;
00123   }
00124   void Initialize() {
00125     value_ = new double;
00126     *value_ = 0.0;
00127   }
00128  public:
00129   Local_var(double* v) {
00130     value_ = v;
00131   }
00132   /*
00133   Local_var() {
00134     value_ = new double;
00135     *value_ = 0.0; 
00136   }
00137   ~Local_var() { delete value_; }
00138   */
00139   double Give_interior(const P_interior* it_i,const Grid* gr, double h_mesh,
00140                        int l, double_stencils_in) const {
00141     return *value_;
00142   }
00143   double Give_interior_coarse(const P_interior* it_i,const Grid* gr,
00144                               double h_mesh,
00145                               int l, double_stencils_in) const {
00146     return *value_;
00147   }
00148   double Give_nearb(const P_nearb* it_n,const Grid* gr, double h_mesh, int l,
00149                     const Nearb_Ablage* nearb_ablage)
00150     const {
00151     return *value_;
00152   };
00153   double Give_Bo2p(const P_Bo2p* it_b,const Grid* gr, int l) const {
00154     return *value_;
00155   };
00156   double Give_cellpoi(const P_cellpoi* it_cf,const Grid* gr,
00157                       const BoCeData* bocedata) const {
00158     return *value_;
00159   };
00160 
00161   // for procedure
00162   double* Give_regular_pointer(const P_interior* it_i,const Grid* gr, int l) 
00163     const {
00164     return value_;
00165   };
00166   double* Give_regular_pointer(const P_nearb* it_n,const Grid* gr, int l) 
00167     const {
00168     return value_;
00169   };
00170   double* Give_Bo2p_pointer(const P_Bo2p* it_b,const Grid* gr, int l) const {
00171     return value_;
00172   };
00173   double* Give_cellpoi_pointer(const P_cellpoi* it_cf,const Grid* gr) const {
00174     return value_;
00175   };
00176 
00177 
00178   // Size of necessary stencil
00179   int Sice_stencil() const { return 1; }
00180 
00181   // activity of points
00182   int Level() const { return 0; }
00183   Dominace_label Dominant_lev() const { return anti_dominant;  }
00184   Dominace_label Dominant_poi() const { return anti_dominant;  }
00185   bool run_interior() const { return true; }
00186   bool run_nearb()    const { return true; }
00187   int run_boundary()  const { return 1; }
00188   
00189   // number of operations
00190   int ops_interior() const { return 0; }
00191   // For operator ==
00192   void Active_Sim_Level( int lev) const {  };
00193   void Active_Sim_interior(bool run) const {  };
00194   void Active_Sim_nearb(bool run) const {  };
00195   void Active_Sim_boundary( int run) const {  };
00196   void Active_Sim_update(Evaluation_Parallelization_object* evpar,
00197                          int level, type_of_update typ) const {  };
00198 
00199   // Put pointer to grid and activity of boundary points of test space  
00200   void Put_grid_rbo(Grid* gr, int r_bo) const { };
00201   // Is the expression an abstract differential operator?
00202   Differential_op_typ Abstract_differential_operator()  const { 
00203     return abstract_both; 
00204   }
00205   int Give_number_var_of_abstract_op() const { return -1; }
00206   bool Give_array_variable_inserted() const {
00207     return false;
00208   }
00209   int Give_length_of_array_variable_inserted() const {
00210     return 0;
00211   }
00212   // For restriction of stencils
00213   // --------------------------------------
00214   double Give_interior_sten_element(Index3D I, double meshsize,
00215                                     int stelle,
00216                                     const Grid* grid, int l) const {
00217     return *value_;
00218   }
00219   double Give_boundary_sten_element(const Grid* grid, BoCeData* b_cell,
00220                                     double* u_ablage, int num_v) const {
00221     return *value_;
00222   }
00223   // Get and Put:
00224   // Set value
00225   void Put_interior(const P_interior* it_i, int lev, double x) { Put(x); };
00226   void Put_nearb(const P_nearb* it_n, int lev, double x) { Put(x); };
00227   void Put_Bo2p(const P_Bo2p* it_b, double x) { Put(x); };
00228   void Put_cellpoi(const P_cellpoi* it_cf, double x) { Put(x); };
00229 
00230   void Put(double x) {
00231     *value_=x;
00232   };
00233   double Get() const {
00234     return *value_;
00235   };          
00236   double* Give_pointer() const {
00237     return value_;
00238   };
00239   // for Parallelization
00240   void Add_variables_for_parallel(Evaluation_Parallelization_object *evpar) 
00241     const {};
00242   bool GS_type(int var_number_left, int dim) const {
00243   return false; }; 
00244 
00245   // at the and of an iteration of an expression
00246   void clean() const {};
00247 };
00248 
00249 
00250 /*  local variable for double */
00251 class Local_int {
00252  private:
00253   int* value_;
00254  public:
00255   Local_int(int* v) {
00256     value_ = v;
00257     *value_ = 0; 
00258   }
00259   Local_int() {
00260     value_ = new int;
00261     *value_ = 0; 
00262   }
00263   // ~Local_var() { delete value_; }
00264   double Give_interior(const P_interior* it_i,const Grid* gr, double h_mesh,
00265                        int l, double_stencils_in) const {
00266     return (double)(*value_);
00267   }
00268   double Give_interior_coarse(const P_interior* it_i,const Grid* gr,
00269                               double h_mesh,
00270                               int l, double_stencils_in) const {
00271     return (double)(*value_);
00272   }
00273   double Give_nearb(const P_nearb* it_n,const Grid* gr, double h_mesh, int l,
00274                     const Nearb_Ablage* nearb_ablage)
00275     const {
00276     return (double)(*value_);
00277   };
00278   double Give_Bo2p(const P_Bo2p* it_b,const Grid* gr, int l) const {
00279     return (double)(*value_);
00280   };
00281   double Give_cellpoi(const P_cellpoi* it_cf,const Grid* gr,
00282                       const BoCeData* bocedata) const {
00283     return (double)(*value_);
00284   };
00285   // Size of necessary stencil
00286   int Sice_stencil() const { return 1; }
00287 
00288   // activity of points
00289   int Level() const { return 0; }
00290   Dominace_label Dominant_lev() const { return anti_dominant;  }
00291   Dominace_label Dominant_poi() const { return anti_dominant;  }
00292   bool run_interior() const { return true; }
00293   bool run_nearb()    const { return true; }
00294   int run_boundary()  const { return 1; }
00295   
00296   // number of operations
00297   int ops_interior() const { return 0; }
00298   // For operator ==
00299   void Active_Sim_Level( int lev) const {  };
00300   void Active_Sim_interior(bool run) const {  };
00301   void Active_Sim_nearb(bool run) const {  };
00302   void Active_Sim_boundary( int run) const {  };
00303   void Active_Sim_update(Evaluation_Parallelization_object* evpar,
00304                          int level, type_of_update typ) const {  };
00305 
00306   // Put pointer to grid and activity of boundary points of test space  
00307   void Put_grid_rbo(Grid* gr, int r_bo) const { };
00308   // Is the expression an abstract differential operator?
00309   bool Abstract_differential_operator()  const { return false; }
00310   bool Give_array_variable_inserted() const {
00311     return false;
00312   }
00313   int Give_length_of_array_variable_inserted() const {
00314     return 0;
00315   }
00316   // Get and Put:
00317   // Set value
00318   void Put_interior(const P_interior* it_i, int lev, double x) { Put(x); };
00319   void Put_nearb(const P_nearb* it_n, int lev, double x) { Put(x); };
00320   void Put_Bo2p(const P_Bo2p* it_b, double x) { Put(x); };
00321   void Put_cellpoi(const P_cellpoi* it_cf, double x) { Put(x); };
00322 
00323   void Put(double x) {
00324     cout << " \n type conversion in Local_int! " << endl;
00325     *value_=(int)x;
00326   };
00327   int Get() const {
00328     return *value_;
00329   };
00330   int* Give_pointer() const {
00331     return value_;
00332   };
00333   // for Parallelization
00334   void Add_variables_for_parallel(Evaluation_Parallelization_object *evpar) 
00335     const {};
00336   bool GS_type(int var_number_left, int dim) const {
00337   return false; }; 
00338 
00339   // at the and of an iteration of an expression
00340   void clean() const {};
00341 };
00342 
00343 
00344 
00345 /* wrapper class wich contains  ...contains the expression types 
00346                - DExprVAR
00347                - DExprLIT 
00348                - DExprBinOp 
00349                - DExprDiffOp 
00350                - ...           */
00351 
00352 #include "sim2.h"
00353 
00354 template<class A>
00355 class DExpr {
00356  private:
00357   A a_;
00358 
00359  public:
00360   DExpr(const A& x)
00361     : a_(x)
00362     {}
00363   // special for array
00364   Grid* Give_grid() const {
00365     return a_.Give_grid();
00366   }
00367   int Number_variable() const {
00368     return a_.Number_variable();
00369   }
00370   int Number_variable_start() const {
00371     return a_.Number_variable_start();
00372   }
00373   int* Give_value() const {
00374     return a_.Give_value();
00375   }
00376   int Give_dim() const {
00377     return a_.Give_dim();
00378   }
00379   template<class B>
00380   DWrapSim<DExprVecSim<B> >
00381   operator== (const  B& b_)
00382   {
00383     typedef DWrapSim<DExprVecSim<B> > ExprT;
00384     return ExprT(DExprVecSim<B>(Number_variable_start(),Give_value(),
00385                                 Give_dim(),b_)); 
00386   }
00387   // end special
00388   // for evaluate
00389   double Give_interior(const P_interior* it_i,const Grid* gr, double h_mesh,
00390                        int l, double_stencils_in) const {
00391     return a_.Give_interior(it_i,gr,h_mesh,l, double_stencils_out);
00392   };
00393   double Give_interior_coarse(const P_interior* it_i,const Grid* gr, 
00394                               double h_mesh, int l, double_stencils_in) const {
00395     return a_.Give_interior_coarse(it_i,gr,h_mesh,l, double_stencils_out);
00396   };
00397   double Give_nearb(const P_nearb* it_n,const Grid* gr, double h_mesh, int l,
00398                     const Nearb_Ablage* nearb_ablage)
00399     const {
00400     return a_.Give_nearb(it_n,gr,h_mesh,l,nearb_ablage);
00401   };
00402   double Give_Bo2p(const P_Bo2p* it_b,const Grid* gr, int l) const {
00403     return a_.Give_Bo2p(it_b,gr,l);
00404   };
00405   double Give_cellpoi(const P_cellpoi* it_cf,const Grid* gr,
00406                       const BoCeData* bocedata) const {
00407     return a_.Give_cellpoi(it_cf,gr,bocedata);
00408   };
00409   // for evaluate on cell
00410   double Give_interior_cell(const P_interior_cell* it_icell ,
00411                             const Grid* gr, int l) const {
00412     return a_.Give_interior_cell(it_icell,gr,l);
00413   };
00414   double Give_bo_tet(const P_boundary_tet* it_bcell, 
00415                       const Grid* gr) const {
00416     return a_.Give_bo_tet(it_bcell,gr);
00417   };
00418 
00419   // Size of necessary stencil
00420   int Sice_stencil() const { return a_.Sice_stencil(); }
00421 
00422   // activity of points
00423   int Level() const { return a_.Level(); }
00424   Dominace_label Dominant_lev() const { return a_.Dominant_lev(); }
00425   Dominace_label Dominant_poi() const { return a_.Dominant_poi(); }
00426   bool run_interior() const { return a_.run_interior(); }
00427   bool run_nearb()    const { return a_.run_nearb(); }
00428   int run_boundary() const { return a_.run_boundary(); }
00429 
00430   // number of operations
00431   int ops_interior() const { return a_.ops_interior(); }   
00432 
00433   // For operator ==
00434   void Active_Sim_Level( int lev) const { a_.Active_Sim_Level(lev); }
00435   void Active_Sim_interior( bool run) const { a_.Active_Sim_interior(run); }
00436   void Active_Sim_nearb( bool run)    const { a_.Active_Sim_nearb(run); }
00437   void Active_Sim_boundary(int run) const { a_.Active_Sim_boundary(run); }
00438   void Active_Sim_update(Evaluation_Parallelization_object* evpar,
00439                          int level, type_of_update typ) const 
00440     {  a_.Active_Sim_update(evpar,level,typ); };
00441 
00442   // Put pointer to grid and activity of boundary points of test space
00443   void Put_grid_rbo(Grid* gr, int r_bo)  const { a_.Put_grid_rbo(gr,r_bo); }
00444   // For abstract differential operators:
00445   // --------------------------------------
00446   // Is the expression an abstract differential operator?
00447   Differential_op_typ Abstract_differential_operator() const  {
00448     return a_.Abstract_differential_operator(); }
00449   int Give_number_var_of_abstract_op() const { 
00450     return a_.Give_number_var_of_abstract_op(); };
00451   bool Give_array_variable_inserted() const {
00452     return  a_.Give_array_variable_inserted();
00453   }
00454   int Give_length_of_array_variable_inserted() const {
00455     return a_.Give_length_of_array_variable_inserted();
00456   }
00457   // For restriction of stencils
00458   // --------------------------------------
00459   double Give_interior_sten_element(Index3D I, double meshsize,
00460                                     int stelle,
00461                                     const Grid* grid, int level) const {
00462     return a_.Give_interior_sten_element(I,meshsize,stelle,grid,level); 
00463   }
00464   double Give_boundary_sten_element(const Grid* grid, BoCeData* b_cell,
00465                                     double* u_ablage, int num_v) const {
00466     return a_.Give_boundary_sten_element(grid, b_cell,u_ablage,num_v);
00467   }
00468   // for Parallelization
00469   void Add_variables_for_parallel(Evaluation_Parallelization_object *evpar) 
00470     const {
00471     a_.Add_variables_for_parallel(evpar);
00472   };
00473   bool GS_type(int var_number_left, int dim) const {
00474     return a_.GS_type(var_number_left, dim);
00475   }; 
00476 
00477   // for indices -> implemented in variable2.h
00478   double operator[] (ExpdeIndex& i);
00479 
00480   // at the and of an iteration of an expression
00481   void clean() const { a_.clean(); };
00482 };
00483 
00484 
00485 // Wrapper for: Restriction operator with respect to points -- slow by a domain
00486 /* DExprResDomain for Representing a Restriction operator with 
00487    respect to points */
00488 template<class A>
00489 class DExprResDomain {
00490   A a_;
00491   Domain* domain_R;
00492  public:
00493   DExprResDomain(const A& a, const Domain& dom)
00494     : a_(a) {
00495     // domain_R = &dom; 
00496     domain_R = new Domain(dom);
00497   }
00498   double Give_interior(const P_interior* it_i,const Grid* gr, double h_mesh,
00499                        int l, double_stencils_in) const {
00500     return a_.Give_interior(it_i,gr,h_mesh,l, double_stencils_out);
00501   };
00502   double Give_interior_coarse(const P_interior* it_i,const Grid* gr,
00503                               double h_mesh,
00504                               int l, double_stencils_in) const {
00505     return a_.Give_interior_coarse(it_i,gr,h_mesh,l, double_stencils_out);
00506   };
00507   double Give_nearb(const P_nearb* it_n, const Grid* gr, double h_mesh, int l,
00508                     const Nearb_Ablage* nearb_ablage)
00509     const {
00510     return a_.Give_nearb(it_n,gr,h_mesh,l,nearb_ablage);
00511   };
00512   double Give_Bo2p(const P_Bo2p* it_b, const Grid* gr, int l) const {
00513     return a_.Give_Bo2p(it_b,gr,l);
00514   };
00515   double Give_cellpoi(const P_cellpoi* it_cf, const Grid* gr,
00516                       const BoCeData* bocedata)
00517     const {
00518     return a_.Give_cellpoi(it_cf,gr,bocedata);
00519   };
00520 
00521   // Size of necessary stencil
00522   int Sice_stencil() const { return a_.Sice_stencil(); }
00523 
00524   // activity of points
00525   int Level() const { return a_.Level(); }
00526   Dominace_label Dominant_lev() const { return a_.Dominant_lev(); }
00527   Dominace_label Dominant_poi() const { return yes_dominant; }
00528   bool run_domain() const { return true; }
00529 
00530   // number of operations
00531   int ops_interior() const { return a_.ops_interior(); }
00532   int ops_nearb()    const { return a_.ops_nearb(); }
00533   int ops_Bo2p()     const { return a_.ops_Bo2p(); }
00534 
00535   // For operator ==
00536   void Active_Sim_Level( int lev) const { a_.Active_Sim_Level(lev);  };
00537   void Active_Sim_update(Evaluation_Parallelization_object* evpar,
00538                          int level, type_of_update typ) const 
00539     {  a_.Active_Sim_update(evpar,level,typ); };
00540 
00541   // In domain?
00542   bool point_in_domain(double x, double y, double z) const {
00543     return domain_R->point_in_domain(D3vector(x,y,z));
00544   }
00545 
00546   // Put pointer to grid and activity of boundary points of test space
00547   void Put_grid_rbo(Grid* gr, int r_bo) const { a_.Put_grid_rbo(gr,r_bo); }
00548   // Is the expression an abstract differential operator?
00549   Differential_op_typ Abstract_differential_operator()  const {
00550     return a_.Abstract_differential_operator();
00551   }
00552   // for Parallelization
00553   void Add_variables_for_parallel(Evaluation_Parallelization_object *evpar) 
00554     const {
00555     a_.Add_variables_for_parallel(evpar);
00556   };
00557   bool GS_type(int var_number_left, int dim) const {
00558     return a_.GS_type(var_number_left,dim);
00559   }; 
00560 
00561   // at the and of an iteration of an expression
00562   void clean() const { 
00563     a_.clean();
00564     delete(domain_R);
00565   };
00566 };
00567 
00568 
00569 /* class Variable */
00570 class Variable {
00571   friend class Array_Variable;
00572  private:
00573   Variable();
00574   void Initialize(Grid* gridp);
00575 
00576   //  public:
00577   // Aktive Punkte:
00578   int  r_boundary;   // run boundary point? or on Subgrid?
00579   bool r_interior;   // run interior point?
00580   bool r_nearb;      // run nearb point?
00581   int  level;        // level:
00582 
00583   // Iterator
00584   P_interior *iter_i;
00585   P_nearb    *iter_n;
00586   P_Bo2p     *iter_b;
00587   P_cellpoi  *iter_cf;
00588 
00589   // Zwischenspeicher
00590   Nearb_Ablage* nearb_ablage;
00591 
00592   // Gitter
00593   Grid *grid;
00594 
00595   // Nummer der Variablen
00596   int number_variable;
00597 
00598   // evaluation of general = operator
00599   template<class A>
00600   void evaluate_interior_dom(const DExprResDomain<A>& a_,
00601                              int lev,double h_mesh);
00602   template<class A>
00603   void evaluate_nearb_dom(const DExprResDomain<A>& a_, int lev, double h_mesh);
00604   template<class A>
00605   void evaluate_boundary_dom(const DExprResDomain<A>& a_, int lev);
00606  public:
00607   Variable(Grid* gridp);
00608 
00609   int my_rank() { return grid->Give_my_rank(); };
00610   class Variable* Give_my_pointer() { return this; }
00611 
00613 
00614   void Print_AVS(ofstream *Datei) {
00615     grid->Print_Variable_AVS(Datei,number_variable);
00616   }
00617   int Number_variable() const { return number_variable; }
00618   int Number_variable_start() const { // abstract differential operator
00619     return number_variable; 
00620   }
00621 
00622   // Size of necessary stencil
00623   int Sice_stencil() const { return 1; }
00624 
00625   // for array
00626   bool Give_array_variable_inserted() const {
00627     return false;
00628   }
00629   int Give_length_of_array_variable_inserted() const {
00630     return 0;
00631   }
00632   // Zur Speicherverwaltung:
00633   inline void Test_init() { grid->Test_init(); }
00634 
00635   // activity of level
00636   inline int  Level() const { return level; }
00637   inline int  Ebene() const { return level; }
00638   inline void Level_up();
00639   inline void Level_down();
00640   inline void Active_Level(int Level);
00641 
00642   // number of operations
00643   int ops_interior() const { return 0; }   
00644 
00645   // activity of points
00646   inline void Active_interior(bool run);
00647   inline void Active_nearb(bool run);
00648   inline void Active_boundary(int run_bo);
00649 
00650   inline void Active_update(Evaluation_Parallelization_object* evpar, 
00651                             int level, type_of_update typ);
00652 
00653   inline void Active_only_boundary(bool run);
00654 
00655   inline bool run_interior()  const { return r_interior; }
00656   inline bool run_nearb()     const { return r_nearb; }
00657   inline int  run_boundary()  const { return r_boundary; }
00658 
00659   Dominace_label Dominant_lev() const { return not_dominant; }
00660   Dominace_label Dominant_poi() const { return not_dominant; }
00661 
00662   inline int Max_Level() const { return grid->Max_level(); }
00663 
00664   // For operator ==
00665   void Active_Sim_Level(    int lev) const {  };
00666   void Active_Sim_interior(bool run) const {  };
00667   void Active_Sim_nearb(bool run) const {  };
00668   void Active_Sim_boundary( int run) const {  };
00669   void Active_Sim_update(Evaluation_Parallelization_object* evpar,
00670                          int level, type_of_update typ) const {  };
00671 
00672   inline Grid* Give_grid() const {
00673     if(developer_version) {
00674       if(grid==NULL) cout << "\n Variable is not initialized! Error!" << endl;
00675     }
00676     return grid;
00677   }
00678 
00679   // for evaluation of simple  expressions
00680   double Give_interior_simple(const P_interior* it_i,const Grid* gr,
00681                               int l) const;
00682   double Give_nearb(const P_nearb* it_n,const  Grid* gr,
00683                     double h_mesh, int l) const;
00684   double Give_cellpoi(const P_cellpoi* it_cf, const Grid* gr) const;
00685 
00686   // for evaluation of expression
00687   double Give_interior(const P_interior* it_i,const Grid* gr,
00688                        double h_mesh, int l, double_stencils_in) const;
00689   double Give_interior_coarse(const P_interior* it_i,const Grid* gr,
00690                        double h_mesh, int l, double_stencils_in) const;
00691   double Give_nearb(const P_nearb* it_n,const  Grid* gr, double h_mesh, int l,
00692                     const Nearb_Ablage* nearb_ablage) const;
00693   double Give_Bo2p(const P_Bo2p* it_b, const Grid* gr, int l) const;
00694   double Give_cellpoi(const P_cellpoi* it_cf, const Grid* gr,
00695                       const BoCeData* bocedata) const;
00696 
00697 
00698   // Set value
00699   void Put_interior(const P_interior* it_i, int lev, double x);
00700   void Put_nearb(const P_nearb* it_n, int lev, double x);
00701   void Put_Bo2p(const P_Bo2p* it_b, double x);
00702   void Put_cellpoi(const P_cellpoi* it_cf, double x);
00703 
00704 
00705   // for assign
00706   template<class A>
00707   inline void operator=(const DExpr<A>& a_);
00708   // ruft auf:
00709 
00710   template<class A>
00711   void evaluate_interior_15_evaluation_fine(const DExpr<A>& a_,
00712                 Evaluation_Parallelization_object* ev_par_obj,
00713                 double h_mesh, int lev);
00714   template<class A>
00715   void evaluate_interior_17_evaluation_fine(const DExpr<A>& a_,
00716                 Evaluation_Parallelization_object* ev_par_obj,
00717                 double h_mesh, int lev);
00718   template<class A>
00719   void evaluate_interior_25_evaluation_fine(const DExpr<A>& a_,
00720                 Evaluation_Parallelization_object* ev_par_obj,
00721                 double h_mesh, int lev);
00722   template<class A>
00723   void evaluate_interior_1_evaluation_fine(const DExpr<A>& a_,
00724                 Evaluation_Parallelization_object* ev_par_obj,
00725                 double h_mesh, int lev);
00726 
00727   template<class A>
00728   void operator=(const DExprResDomain<A>& a_);
00729   void operator=(const Variable &v);
00730   template<class R>
00731   void operator=(const DExprResVarP<R> &r_);
00732   void operator=(double (*Formula)(double x,double y,double z));
00733   void operator=(const FunctionClass& function);
00734   void operator= (double x);
00735   void operator= (Input_data_object& input_object);
00736   // for Parallelization
00737   void Add_variables_for_parallel(Evaluation_Parallelization_object *evpar) 
00738     const {
00739   };
00740   bool GS_type(int var_number_left, int dim) const {
00741   return false; }; 
00742 
00743   // for indices -> implemented in index.cc
00744   assignable_vector operator[] (ExpdeIndex& i);
00745 
00746   // at the and of an iteration of an expression
00747   void clean() const { };
00748 
00749 
00750 
00751 
00752 
00753 
00754 
00755  
00756 
00757 
00758   // Put pointer to grid and activity of boundary points of test space  
00759   void Put_grid_rbo(Grid* gr, int r_bo)  const { };
00760 
00761   /*
00762   // For abstract differential operators:
00763   // --------------------------------------
00764   // Is the expression an abstract differential operator?
00765   Differential_op_typ Abstract_differential_operator()
00766     const { return abstract_both; }
00767   int Give_number_var_of_abstract_op() const { return -1; }
00768   bool Give_array_variable_inserted() const {
00769     return  false;
00770   }
00771   int Give_length_of_array_variable_inserted() const {
00772     return 0;
00773   }
00774 
00775   */
00776 
00777 
00778 
00779 
00780 };
00781 
00782 
00783 
00784 
00785 /* DExprVAR for Variable */
00786 
00787 class DExprVAR {
00788  private:
00789   // Aktive Punkte:
00790   int  r_boundary;   // type boundary point:
00791   bool r_interior;   // type interior point:
00792   bool r_nearb;      // type nearb point:
00793   int  level;        // level:
00794 
00795   // Nummer der Variablen
00796   int number_variable;
00797  public:
00798   DExprVAR(const Variable& vec) {
00799     r_boundary = vec.run_boundary();
00800     r_interior = vec.run_interior();
00801     r_nearb    = vec.run_nearb();
00802     level      = vec.Level();
00803     number_variable =  vec.Number_variable();
00804   }
00805   double Give_interior(const P_interior* it_i,const Grid* gr, double h_mesh,
00806                        int l, double_stencils_in) const {
00807     return it_i->varM(gr,l)[number_variable];
00808   };
00809   double Give_interior_coarse(const P_interior* it_i,const Grid* gr,
00810                               double h_mesh, int l, double_stencils_in) const {
00811     return it_i->varM(gr,l)[number_variable];
00812   };
00813   double Give_nearb(const P_nearb* it_n,const Grid* gr, double h_mesh, int l,
00814                     const Nearb_Ablage* nearb_ablage) 
00815     const {
00816     return it_n->varM(gr,l)[number_variable];
00817   };
00818   double Give_Bo2p(const P_Bo2p* it_b,const Grid* gr, int l) const {
00819     return it_b->varM(gr)[number_variable];
00820   };  
00821   double Give_cellpoi(const P_cellpoi* it_cf,const Grid* gr,
00822                       const BoCeData* bocedata) const {
00823     return it_cf->varM(gr)[number_variable];
00824   };
00825 
00826   // for procedure
00827   double* Give_regular_pointer(const P_interior* it_i,const Grid* gr, int l) 
00828     const {
00829     return &(it_i->varM(gr,l)[number_variable]);
00830   };
00831   double* Give_regular_pointer(const P_nearb* it_n,const Grid* gr, int l) 
00832     const {
00833     return &(it_n->varM(gr,l)[number_variable]);
00834   };
00835   double* Give_Bo2p_pointer(const P_Bo2p* it_b,const Grid* gr, int l) const {
00836     return &(it_b->varM(gr)[number_variable]);
00837   };
00838   double* Give_cellpoi_pointer(const P_cellpoi* it_cf,const Grid* gr) const {
00839     return &(it_cf->varM(gr)[number_variable]);
00840   };
00841 
00842   // Size of necessary stencil
00843   int Sice_stencil() const { return 1; }
00844 
00845   // activity of points
00846   int Level() const { return level; }
00847   Dominace_label Dominant_lev() const { return not_dominant; }
00848   Dominace_label Dominant_poi() const { return not_dominant; }
00849   bool run_interior()  const { return r_interior; }
00850   bool run_nearb()     const { return r_nearb; }
00851   int run_boundary()  const { return r_boundary; }
00852 
00853   // number of operations
00854   int ops_interior() const { return 0; }
00855 
00856   // For operator ==
00857   void Active_Sim_Level(    int lev) const {  };
00858   void Active_Sim_interior(bool run) const {  };
00859   void Active_Sim_nearb(bool run) const {  };
00860   void Active_Sim_boundary( int run) const {  };
00861   void Active_Sim_update(Evaluation_Parallelization_object* evpar,
00862                          int level, type_of_update typ) const {  };
00863 
00864   // Put pointer to grid and activity of boundary points of test space  
00865   void Put_grid_rbo(Grid* gr, int r_bo)  const { };
00866   // For abstract differential operators:
00867   // --------------------------------------
00868   // Is the expression an abstract differential operator?
00869   Differential_op_typ Abstract_differential_operator()
00870     const { return abstract_both; }
00871   int Give_number_var_of_abstract_op() const { return -1; }
00872   bool Give_array_variable_inserted() const {
00873     return  false;
00874   }
00875   int Give_length_of_array_variable_inserted() const {
00876     return 0;
00877   }
00878   // For restriction of stencils
00879   // --------------------------------------
00880   double Give_interior_sten_element(Index3D I, double meshsize,
00881                                     int stelle,
00882                                     const Grid* grid, int l) const {
00883    return (grid->Give_variable(I.neighbour(ESTd),l)[number_variable] +
00884            grid->Give_variable(I.neighbour(WNDd),l)[number_variable])
00885       * 0.5;
00886   }
00887   double Give_boundary_sten_element(const Grid* grid, BoCeData* b_cell,
00888                                     double* u_ablage, int num_v) const {
00889     return b_cell->vars[num_v][number_variable];
00890     //    return 1.0;
00891   }
00892   // for Parallelization
00893   void Add_variables_for_parallel(Evaluation_Parallelization_object *evpar)
00894     const {
00895   };
00896   bool GS_type(int var_number_left, int dim) const {
00897   return false; }; 
00898 
00899   // at the and of an iteration of an expression
00900   void clean() const { };
00901 };
00902 
00903 
00904 
00905 
00906 /* DExprLIT for double */
00907 class DExprLIT {
00908  private:
00909   double value_;
00910  public:
00911   DExprLIT(double value)
00912     { value_ = value; }
00913   double Give_interior(const P_interior* it_i,const Grid* gr,double h_mesh,
00914                        int l, double_stencils_in) const {
00915     return value_;
00916   };
00917   double Give_interior_coarse(const P_interior* it_i,const Grid* gr,
00918                               double h_mesh, int l, double_stencils_in) const {
00919     return value_;
00920   };
00921   double Give_nearb(const P_nearb* it_n,const Grid* gr,double h_mesh, int l,
00922                     const Nearb_Ablage* nearb_ablage)
00923     const {
00924     return value_;
00925   };
00926   double Give_Bo2p(const P_Bo2p* it_b,const  Grid* gr, int l) const {
00927     return value_;
00928   };
00929   double Give_cellpoi(const P_cellpoi* it_cf,const  Grid* gr,
00930                       const BoCeData* bocedata) const {
00931     return value_;
00932   };
00933 
00934   // for evaluate on cell
00935   double Give_interior_cell(const P_interior_cell* it_icell ,
00936                             const Grid* gr, int l) const {
00937     return value_;
00938   };
00939   double Give_bo_tet(const P_boundary_tet* it_bcell, 
00940                       const Grid* gr) const {
00941     return value_;
00942   };
00943 
00944   // Size of necessary stencil
00945   int Sice_stencil() const { return 0; }
00946 
00947   // activity of points
00948   int Level() const { return 0; }
00949   Dominace_label Dominant_lev() const { return anti_dominant; }
00950   Dominace_label Dominant_poi() const { return anti_dominant; }
00951   bool run_interior()   const { return true; }
00952   bool run_nearb()   const { return true; }
00953   int run_boundary()   const { return true; }
00954 
00955   // number of operations
00956   int ops_interior() const { return 0; }
00957 
00958   // For operator ==
00959   void Active_Sim_Level( int lev) const {  };
00960   void Active_Sim_interior(bool run) const {  };
00961   void Active_Sim_nearb(bool run) const {  };
00962   void Active_Sim_boundary( int run) const {  };
00963   void Active_Sim_update(Evaluation_Parallelization_object* evpar,
00964                          int level, type_of_update typ) const {  };
00965 
00966   // Put pointer to grid and activity of boundary points of test space  
00967   void Put_grid_rbo(Grid* gr, int r_bo) const  { };
00968   // For abstract differential operators:
00969   // --------------------------------------
00970   // Is the expression an abstract differential operator?
00971   Differential_op_typ Abstract_differential_operator() const
00972     { return abstract_both; }
00973   int Give_number_var_of_abstract_op() const { return -1; }
00974   bool Give_array_variable_inserted() const {
00975     return  false;
00976   }
00977   int Give_length_of_array_variable_inserted() const {
00978     return 0;
00979   }   
00980   // For restriction of stencils
00981   // --------------------------------------
00982   double Give_interior_sten_element(Index3D I, double meshsize,
00983                                     int stelle,
00984                                     const Grid* grid, int l) const {
00985     return value_;
00986   }
00987   double Give_boundary_sten_element(const Grid* grid, BoCeData* b_cell,
00988                                     double* u_ablage, int num_v) const {
00989     return value_;
00990   }
00991   // for Parallelization
00992   void Add_variables_for_parallel(Evaluation_Parallelization_object *evpar)
00993     const {};
00994   bool GS_type(int var_number_left, int dim) const {
00995   return false; }; 
00996 
00997   // at the and of an iteration of an expression
00998   void clean() const { };
00999 };
01000 
01001 
01003         //         Declarations 
01005 
01006 // 1. Declaration of Scalarproduct
01007 double Maximum(Variable& a);
01008 double Minimum(Variable& a);
01009 double L_infty(Variable& a);
01010 
01011 // 2. Declaration of Scalarproduct
01012 double product(Variable& b, Variable& a);
01013 double product(Variable& a1, Variable& a2, Variable& a3,
01014                Variable& b1, Variable& b2, Variable& b3);
01015 
01016 
01017 // 3. Print functions
01018 // For AVS:
01019 void Print_UCD(Variable& a,ofstream *Datei);
01020 void Print_UCD_parallel(Variable& a,ofstream *Datei);
01021 void Print_UCD_parallel(Variable& a,ofstream *Datei, int level);
01022 void Print_UCD_surface_parallel(Variable& a,ofstream *Datei);
01023 void Print_UCD(Variable& a, Variable& b, Variable& c, ofstream *Datei);
01024 void Print_UCD_parallel(Variable& a, Variable& b, Variable& c, 
01025                         ofstream *Datei);
01026 void Print_UCD_moved(Variable& v,
01027                      Variable& a, Variable& b, Variable& c, ofstream *Datei);
01028 void Print_UCD_moved_parallel(Variable& v,
01029                      Variable& a, Variable& b, Variable& c, ofstream *Datei);
01030 // For Gnuplot:
01031 void Print_Gnuplot_moved(Variable& a, Variable& b, Variable& c,
01032                              ofstream *Datei);
01033 // For OpenDx:
01034 void Print_Dx(Variable& a,ofstream *Datei);
01035 void Print_Dx_parallel(Variable& a,ofstream *Datei);
01036 void Print_Dx_moved(Variable& v,
01037                     Variable& a, Variable& b, Variable& c, ofstream *Datei);
01038 // direct:
01039 void Print(Variable& a);
01040 
01041 
01042 // 4.: calculate normal vector
01043 void Normal_vector(Variable& vx, Variable& vy, Variable& vz);
01044 
01045 // 5.: Parallel update
01046 void Sum_ghost_nodes(Variable& vx);
01047 void Update_ghost_nodes(Variable& vx);
01048 
01049 
01050 // ------------------------------------------------------------
01051 //  implementierung of the inline member functions of variable
01052 //  other member functions are contained in variable2.h
01053 // ------------------------------------------------------------
01054 
01055 
01056 
01057 inline void Variable::Active_boundary(int run_bo) {
01058   r_boundary = run_bo; 
01059   if(run_bo==false && r_interior==false && r_nearb==false)
01060     Active_interior(true);
01061 }
01062 
01063 
01064 inline void Variable::Active_update(Evaluation_Parallelization_object* evpar, 
01065                                     int level, type_of_update typ) {
01066   evpar->Set_type_of_update(number_variable,level,no_update);
01067 }
01068 
01069 
01070 inline double Variable::Give_interior_simple(const P_interior* it_i,
01071                                              const  Grid* gr, int l) const {
01072   return it_i->varM(gr,l)[number_variable];
01073 };
01074 
01075 inline double Variable::Give_interior(const P_interior* it_i,const  Grid* gr,
01076                        double h_mesh, int l, double_stencils_in) const {
01077   return it_i->varM(gr,l)[number_variable];
01078 };
01079 
01080 inline double Variable::Give_interior_coarse(const P_interior* it_i,
01081                        const  Grid* gr,
01082                        double h_mesh, int l, double_stencils_in) const {
01083   return it_i->varM(gr,l)[number_variable];
01084 };
01085 
01086 inline double Variable::Give_nearb(const P_nearb* it_n,const  Grid* gr,
01087                             double h_mesh, int l) const {
01088   return it_n->varM(gr,l)[number_variable];
01089 };
01090 
01091 inline double Variable::Give_nearb(const P_nearb* it_n,const  Grid* gr,
01092                                    double h_mesh, int l, 
01093                                    const Nearb_Ablage* nearb_ablage) const {
01094   return it_n->varM(gr,l)[number_variable];
01095 };
01096 
01097 inline double Variable::Give_Bo2p(const P_Bo2p* it_b, const Grid* gr, int l)
01098      const {
01099   return it_b->varM(gr)[number_variable];
01100 };
01101 
01102 inline double Variable::Give_cellpoi(const P_cellpoi* it_cf, const Grid* gr,
01103                                      const BoCeData* bocedata) const {
01104   return it_cf->varM(gr)[number_variable];
01105 };
01106 inline double Variable::Give_cellpoi(const P_cellpoi* it_cf,
01107                                      const Grid* gr) const {
01108   return it_cf->varM(gr)[number_variable];
01109 };
01110 
01111 inline void Variable::Put_interior(const P_interior* it_i, int lev, double x) {
01112   it_i->varM(grid,lev)[number_variable] = x;
01113 };
01114 inline void Variable::Put_nearb(const P_nearb* it_n, int lev, double x) {
01115   it_n->varM(grid,lev)[number_variable] = x;
01116 };
01117 inline void Variable::Put_Bo2p(const P_Bo2p* it_b, double x) {
01118   it_b->varM(grid)[number_variable] = x;
01119 };
01120 inline void Variable::Put_cellpoi(const P_cellpoi* it_cf, double x) {
01121   it_cf->varM(grid)[number_variable] = x;
01122 };
01123 
01124 
01125 inline void Variable::Level_up()   { 
01126   level++; 
01127 }
01128 inline void Variable::Level_down() { 
01129   level--; 
01130 }
01131 inline void Variable::Active_Level(int Level) { 
01132   level = Level; 
01133 }
01134 
01135 
01136 inline void Variable::Active_interior(bool run)  { 
01137   r_interior = run; 
01138 }
01139 inline void Variable::Active_nearb(bool run)     { 
01140   r_nearb    = run;
01141 }
01142 
01143 inline void Variable::Active_only_boundary(bool run) { 
01144   r_boundary = run; 
01145 }
01146 
01147 
01148 #endif
01149            

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