src/expde/grid/SSten.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 // SSten.h
00019 //
00020 // ------------------------------------------------------------
00021 
00022 #ifndef SSTEN_H_
00023 #define SSTEN_H_
00024 
00025 
00026 // Speicher fuer Stencil
00027 
00029 // Nearb_Ablage ist Zwischenspeicher und enthaelt
00030 // die Zeiger auf
00031 // *u bei Randzellen. Informationen fuer Formeln
00032 // auf Randzellen.
00033 // Anwendung in z.B.  operator.h
00035 
00036 class Nearb_Ablage {
00037  public:
00038   void Initialize_leer(int numvar);  // nur am Anfang aufrufen
00039   void Put_leer();  // muss am besten nach jeder Iteration aufgerufen werden,
00040                     // damit  zu_on_cell 0 wird
00041 
00042   Index3D I;
00043   inline void Initialize(Grid* gr, P_nearb* it_n, int l);
00044   void Initialize_17(Grid* gr, P_nearb* it_n, int l);
00045   void Initialize_27(const Grid* grid, Index3D I, int l);
00046   BoCeData* Give_BoData(dir_sons is)  const { return bocedatas[is]; };
00047   Celltype  Give_Celltyp(dir_sons is) const { return celltyps[is]; };
00048   double*const * Give_u_Recell(dir_sons is) const { return zu_on_cell[is]; };
00049  private:
00050   BoCeData* bocedatas[8]; 
00051   Celltype  celltyps[8];
00052   double*  zu_on_cell[8][8];
00053   int i,j,k, cor;
00054   double* ZU[27];
00055 
00056   //       L       L       L    
00057   double *UWN,   *UN;  
00058   double *UWND,  *UND;
00059 
00060   double *UWT,   *UT;
00061   double *UW,    *UM,    *UE;
00062   double         *UD,    *UED;
00063 
00064   double         *UST,   *UEST;  
00065   double         *US,    *UES;
00066   //       L       L       L
00067 
00068   // special for 17-stencils
00069   double         *UWD,    *UET;
00070 
00071   double *ULeer;
00072 };
00073 
00075 // Implementierung der Memberfunktionen
00077 
00078 inline void Nearb_Ablage::Initialize_leer(int numvar) {
00079   ULeer = new double[numvar];
00080   for(i=0;i<numvar;++i) ULeer[i] = 0.0;
00081 
00082   zu_on_cell[WNTd][WNTd] = ULeer;
00083   zu_on_cell[WNTd][ENTd] = ULeer;
00084   zu_on_cell[WNDd][WSDd] = ULeer;
00085   zu_on_cell[WSTd][WSTd] = ULeer;
00086   zu_on_cell[WSTd][WSDd] = ULeer;
00087   zu_on_cell[WSDd][WSDd] = ULeer;
00088   zu_on_cell[WSDd][WSTd] = ULeer;
00089   zu_on_cell[WSDd][WNDd] = ULeer;
00090   zu_on_cell[WSDd][ESDd] = ULeer;
00091   zu_on_cell[ENTd][ENTd] = ULeer;
00092   zu_on_cell[ENTd][ENDd] = ULeer;
00093   zu_on_cell[ENTd][ESTd] = ULeer;
00094   zu_on_cell[ENTd][WNTd] = ULeer;
00095   zu_on_cell[ENDd][ENDd] = ULeer;
00096   zu_on_cell[ENDd][ENTd] = ULeer;
00097   zu_on_cell[ESTd][ENTd] = ULeer;
00098   zu_on_cell[ESDd][ESDd] = ULeer;
00099   zu_on_cell[ESDd][WSDd] = ULeer;
00100 }
00101 
00102 // This function has to be used after 
00103 inline void Nearb_Ablage::Put_leer() {
00104   for(i=0;i<8;++i)  for(j=0;j<8;++j) {
00105     zu_on_cell[i][j] = ULeer;
00106   } 
00107 }
00108 
00109 
00110 inline void Nearb_Ablage::Initialize_17(Grid* grid, P_nearb* it_n, int l) {
00111   Initialize(grid,it_n,l);
00112 
00113   if(celltyps[WNDd]==int_cell || celltyps[WSDd]==int_cell)
00114     UWD  = it_n->varWD(grid,l);
00115 
00116   if(celltyps[ENTd]==int_cell || celltyps[ESTd]==int_cell)
00117     UET  = it_n->varET(grid,l);
00118 
00119 
00120   if(celltyps[ENTd]==int_cell)
00121     zu_on_cell[ENTd][ESTd] = UET;
00122   if(celltyps[ESTd]==int_cell)
00123     zu_on_cell[ESTd][ENTd] = UET;
00124 
00125 
00126   if(celltyps[WNDd]==int_cell)
00127     zu_on_cell[WNDd][WSDd] = UWD;
00128   if(celltyps[WSDd]==int_cell)
00129     zu_on_cell[WSDd][WNDd] = UWD;
00130 }
00131 
00132 inline void Nearb_Ablage::Initialize_27(const Grid* grid, Index3D I, int l) {
00133   // the following can be improved!!
00134   Index3D I_son;
00135   double* zeiger;
00136   for(i=0;i<8;++i) {
00137     I_son = I.next((dir_sons)i,l+1); // center of neighbour cell
00138     for(j=0;j<8;++j) {
00139       zeiger = grid->Give_variable_slow(I_son.next((dir_sons)j,l+1),l);
00140       if(zeiger!=NULL) zu_on_cell[i][j] = zeiger;
00141       else             zu_on_cell[i][j] = ULeer;
00142     }
00143   }
00144 }
00145   
00146 
00147 inline void Nearb_Ablage::Initialize(Grid* grid, P_nearb* it_n, int l) {
00148   // Zelltyp
00149   for(i=0;i<8;++i) {
00150     celltyps[i]=it_n->Give_cell_typ(grid,(dir_sons)i,l);
00151   }
00152 
00153   // Randzellen
00154   for(i=0;i<8;++i) {
00155     if(celltyps[i] >= bo_cell) {
00156       //      bocedatas[i]=grid->Give_Bo_cell(I.next((dir_sons)i,l+1));
00157       bocedatas[i]=it_n->Give_Bo_cell(grid,(dir_sons)i,l);
00158     }
00159     else bocedatas[i]=NULL;
00160   }
00161 
00162   // a) for 15-Stencil
00163   // put U-values, if no boundary cell
00164   // later we put these values in the 
00165   // storage for cells: zu_on_cell
00166   //----------------------------------
00167   if(celltyps[WNDd]==int_cell)
00168     UWND = it_n->varWND(grid,l);
00169   if(celltyps[ESTd]==int_cell)
00170     UEST = it_n->varEST(grid,l);
00171 
00172   if(celltyps[WNTd]==int_cell || celltyps[WNDd]==int_cell)
00173     UWN  = it_n->varWN(grid,l);
00174   if(celltyps[WNDd]==int_cell || celltyps[ENDd]==int_cell)
00175     UND  = it_n->varND(grid,l);
00176   if(celltyps[WNTd]==int_cell || celltyps[WSTd]==int_cell)
00177     UWT  = it_n->varWT(grid,l);
00178   if(celltyps[ENDd]==int_cell || celltyps[ESDd]==int_cell)
00179     UED  = it_n->varED(grid,l);
00180   if(celltyps[ESTd]==int_cell || celltyps[WSTd]==int_cell)
00181     UST  = it_n->varST(grid,l);
00182   if(celltyps[ESTd]==int_cell || celltyps[ESDd]==int_cell)
00183     UES  = it_n->varES(grid,l);
00184 
00185   if(celltyps[ESTd]==int_cell || celltyps[ESDd]==int_cell ||
00186      celltyps[ENTd]==int_cell || celltyps[ENDd]==int_cell)
00187     UE  = it_n->varE(grid,l);
00188   if(celltyps[WSTd]==int_cell || celltyps[WSDd]==int_cell ||
00189      celltyps[WNTd]==int_cell || celltyps[WNDd]==int_cell)
00190     UW  = it_n->varW(grid,l);
00191   if(celltyps[WSTd]==int_cell || celltyps[ESTd]==int_cell ||
00192      celltyps[WNTd]==int_cell || celltyps[ENTd]==int_cell)
00193     UT  = it_n->varT(grid,l);
00194   if(celltyps[WSDd]==int_cell || celltyps[ESDd]==int_cell ||
00195      celltyps[WNDd]==int_cell || celltyps[ENDd]==int_cell)
00196     UD  = it_n->varD(grid,l);
00197   if(celltyps[WNDd]==int_cell || celltyps[ENDd]==int_cell ||
00198      celltyps[WNTd]==int_cell || celltyps[ENTd]==int_cell)
00199     UN  = it_n->varN(grid,l);
00200   if(celltyps[WSDd]==int_cell || celltyps[ESDd]==int_cell ||
00201      celltyps[WSTd]==int_cell || celltyps[ESTd]==int_cell)
00202     US  = it_n->varS(grid,l);
00203 
00204   UM  = it_n->varM(grid,l);
00205 
00206 
00207   // the following can be improved!!
00208 
00209   // b) put values for "bo_cell's" 
00210   //    these cells appear only on coarse grids
00211   //    therefore this is slow, but it can be improved!!
00212   Index3D I_son;
00213   double* zeiger;
00214   for(i=0;i<8;++i) 
00215     if(celltyps[i]==bo_cell) {
00216     I_son = it_n->Ind().next((dir_sons)i,l+1); // center of neighbour cell
00217     for(j=0;j<8;++j) {
00218       zeiger = grid->Give_variable_slow(I_son.next((dir_sons)j,l+1),l);
00219       if(zeiger!=NULL) zu_on_cell[i][j] = zeiger;
00220       else             zu_on_cell[i][j] = ULeer;
00221     }
00222   }
00223   
00224   
00225   // c) for interior cells we set zu_on_cell
00226   if(celltyps[WNTd]==int_cell) {
00227     zu_on_cell[WNTd][WNDd] = UWN;
00228     zu_on_cell[WNTd][WSTd] = UWT;
00229 
00230     zu_on_cell[WNTd][WSDd] = UW;
00231     zu_on_cell[WNTd][ENDd] = UN;
00232     zu_on_cell[WNTd][ESTd] = UT;
00233     zu_on_cell[WNTd][ESDd] = UM;
00234   }
00235   
00236   if(celltyps[WNDd]==int_cell) {
00237     zu_on_cell[WNDd][WNDd] = UWND;
00238     zu_on_cell[WNDd][WNTd] = UWN;
00239     zu_on_cell[WNDd][ENDd] = UND;
00240 
00241     zu_on_cell[WNDd][WSTd] = UW;
00242     zu_on_cell[WNDd][ESDd] = UD;
00243     zu_on_cell[WNDd][ENTd] = UN;
00244     zu_on_cell[WNDd][ESTd] = UM;
00245   }
00246 
00247   if(celltyps[WSTd]==int_cell) {
00248     zu_on_cell[WSTd][WNTd] = UWT;
00249     zu_on_cell[WSTd][ESTd] = UST;
00250 
00251     zu_on_cell[WSTd][WNDd] = UW;
00252     zu_on_cell[WSTd][ENTd] = UT;
00253     zu_on_cell[WSTd][ESDd] = US;
00254     zu_on_cell[WSTd][ENDd] = UM;
00255   }
00256   
00257   if(celltyps[WSDd]==int_cell) {
00258     zu_on_cell[WSDd][WNTd] = UW;
00259     zu_on_cell[WSDd][ENDd] = UD;
00260     zu_on_cell[WSDd][ESTd] = US;
00261     zu_on_cell[WSDd][ENTd] = UM;
00262   }
00263 
00264   if(celltyps[ENTd]==int_cell) {
00265     zu_on_cell[ENTd][ESDd] = UE;
00266     zu_on_cell[ENTd][WSTd] = UT;
00267     zu_on_cell[ENTd][WNDd] = UN;
00268     zu_on_cell[ENTd][WSDd] = UM;
00269   }
00270 
00271   if(celltyps[ENDd]==int_cell) {
00272     zu_on_cell[ENDd][ESDd] = UED;
00273     zu_on_cell[ENDd][WNDd] = UND;
00274 
00275     zu_on_cell[ENDd][ESTd] = UE;
00276     zu_on_cell[ENDd][WSDd] = UD;
00277     zu_on_cell[ENDd][WNTd] = UN;
00278     zu_on_cell[ENDd][WSTd] = UM;
00279   }
00280 
00281   if(celltyps[ESTd]==int_cell) {
00282     zu_on_cell[ESTd][ESTd] = UEST;
00283     zu_on_cell[ESTd][ESDd] = UES;
00284     zu_on_cell[ESTd][WSTd] = UST;
00285 
00286     zu_on_cell[ESTd][ENDd] = UE;
00287     zu_on_cell[ESTd][WNTd] = UT;
00288     zu_on_cell[ESTd][WSDd] = US;
00289     zu_on_cell[ESTd][WNDd] = UM;
00290   }
00291 
00292   if(celltyps[ESDd]==int_cell) {
00293     zu_on_cell[ESDd][ESTd] = UES;
00294     zu_on_cell[ESDd][ENDd] = UED;
00295 
00296     zu_on_cell[ESDd][ENTd] = UE;
00297     zu_on_cell[ESDd][WNDd] = UD;
00298     zu_on_cell[ESDd][WSTd] = US;
00299     zu_on_cell[ESDd][WNTd] = UM;
00300   }
00301 };
00302 
00303 
00304 #endif
00305     

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