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

src/expde/formulas/loc_sten.cc

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 // loc_sten.cc
00020 //
00021 // ------------------------------------------------------------
00022 
00023 // Include level 0:
00024 #ifdef COMP_GNUOLD
00025  #include <iostream.h>
00026  #include <fstream.h>
00027  #include <math.h>
00028 #else
00029  #include <iostream>
00030  #include <fstream>
00031  #include <cmath>
00032 #endif 
00033 
00034 // Include level 1:
00035 #include "../paramete.h"
00036 #include "../abbrevi.h"
00037 #include "../math_lib/math_lib.h"
00038 
00039 // Include level special
00040 #include "../formulas/loc_sten.h"
00041 
00042 #define x0 V0.x
00043 #define y0 V0.y
00044 #define z0 V0.z
00045 
00046 #define x1 V1.x
00047 #define y1 V1.y
00048 #define z1 V1.z
00049 
00050 #define x2 V2.x
00051 #define y2 V2.y
00052 #define z2 V2.z
00053 
00054 #define x3 V3.x
00055 #define y3 V3.y
00056 #define z3 V3.z
00057 
00058 inline bool In_tet(dir_sons* tet, dir_sons s) {
00059   return (tet[0]==s || tet[1]==s || tet[2]==s || tet[3]==s);
00060 }
00061 
00062 inline double Tetraeder_Det_dx0(const D3vector& V0, const D3vector& V1,
00063                                 const D3vector& V2, const D3vector& V3) {
00064   return y3 * (z1 - z2) + y1 * (z2 - z3) + y2 * (-z1 + z3);
00065 }
00066 
00067 inline double Tetraeder_Det_dy0(const D3vector& V0, const D3vector& V1,
00068                                 const D3vector& V2, const D3vector& V3) {
00069   return x3 * (-z1 + z2) + x2 * (z1 - z3) + x1 * (-z2 + z3);
00070 }
00071 
00072 inline double Tetraeder_Det_dz0(const D3vector& V0, const D3vector& V1,
00073                                 const D3vector& V2, const D3vector& V3) {
00074   return x3 * (y1 - y2) + x1 * (y2 - y3) + x2 * (-y1 + y3);
00075 }
00076 
00077 inline double Tetraeder_Det_dx(int n, 
00078                                const dir_sons co0, const dir_sons co1,
00079                                const dir_sons co2, const dir_sons co3) {
00080   D3vector V0, V1, V2, V3;
00081   x0 = x1DCoord(co0);  y0 = y1DCoord(co0);  z0 = z1DCoord(co0);
00082   x1 = x1DCoord(co1);  y1 = y1DCoord(co1);  z1 = z1DCoord(co1);
00083   x2 = x1DCoord(co2);  y2 = y1DCoord(co2);  z2 = z1DCoord(co2);
00084   x3 = x1DCoord(co3);  y3 = y1DCoord(co3);  z3 = z1DCoord(co3);
00085 
00086   if(n == 0) return Tetraeder_Det_dx0(V0,V1,V2,V3);
00087   if(n == 1) return Tetraeder_Det_dx0(V1,V3,V2,V0);
00088   if(n == 2) return Tetraeder_Det_dx0(V2,V1,V3,V0);
00089   //  if(n == 3) 
00090   return Tetraeder_Det_dx0(V3,V0,V2,V1);
00091 };
00092 
00093 inline double Tetraeder_Det_dy(int n, 
00094                                const dir_sons co0, const dir_sons co1,
00095                                const dir_sons co2, const dir_sons co3) {
00096   D3vector V0, V1, V2, V3;
00097   x0 = x1DCoord(co0);  y0 = y1DCoord(co0);  z0 = z1DCoord(co0);
00098   x1 = x1DCoord(co1);  y1 = y1DCoord(co1);  z1 = z1DCoord(co1);
00099   x2 = x1DCoord(co2);  y2 = y1DCoord(co2);  z2 = z1DCoord(co2);
00100   x3 = x1DCoord(co3);  y3 = y1DCoord(co3);  z3 = z1DCoord(co3);
00101 
00102   if(n == 0) return Tetraeder_Det_dy0(V0,V1,V2,V3);
00103   if(n == 1) return Tetraeder_Det_dy0(V1,V3,V2,V0);
00104   if(n == 2) return Tetraeder_Det_dy0(V2,V1,V3,V0);
00105   //  if(n == 3) 
00106   return Tetraeder_Det_dy0(V3,V0,V2,V1);
00107 };
00108 
00109 inline double Tetraeder_Det_dz(int n, 
00110                                const dir_sons co0, const dir_sons co1,
00111                                const dir_sons co2, const dir_sons co3) {
00112   D3vector V0, V1, V2, V3;
00113   x0 = x1DCoord(co0);  y0 = y1DCoord(co0);  z0 = z1DCoord(co0);
00114   x1 = x1DCoord(co1);  y1 = y1DCoord(co1);  z1 = z1DCoord(co1);
00115   x2 = x1DCoord(co2);  y2 = y1DCoord(co2);  z2 = z1DCoord(co2);
00116   x3 = x1DCoord(co3);  y3 = y1DCoord(co3);  z3 = z1DCoord(co3);
00117 
00118   if(n == 0) return Tetraeder_Det_dz0(V0,V1,V2,V3);
00119   if(n == 1) return Tetraeder_Det_dz0(V1,V3,V2,V0);
00120   if(n == 2) return Tetraeder_Det_dz0(V2,V1,V3,V0);
00121   //  if(n == 3) 
00122   return Tetraeder_Det_dz0(V3,V0,V2,V1);
00123 };
00124 
00125 
00126 inline double Evaluate_tet(dir_sons* tet, dir_sons s, diff_type dt) {
00127   if(dt==Dx_type) {
00128     if(tet[0]==s) return Tetraeder_Det_dx(0,tet[0],tet[1],tet[2],tet[3]);
00129     if(tet[1]==s) return Tetraeder_Det_dx(1,tet[0],tet[1],tet[2],tet[3]);
00130     if(tet[2]==s) return Tetraeder_Det_dx(2,tet[0],tet[1],tet[2],tet[3]);
00131     // if(tet[3]==s) 
00132     return Tetraeder_Det_dx(3,tet[0],tet[1],tet[2],tet[3]);
00133   }
00134   if(dt==Dy_type) {
00135     if(tet[0]==s) return Tetraeder_Det_dy(0,tet[0],tet[1],tet[2],tet[3]);
00136     if(tet[1]==s) return Tetraeder_Det_dy(1,tet[0],tet[1],tet[2],tet[3]);
00137     if(tet[2]==s) return Tetraeder_Det_dy(2,tet[0],tet[1],tet[2],tet[3]);
00138     // if(tet[3]==s) 
00139     return Tetraeder_Det_dy(3,tet[0],tet[1],tet[2],tet[3]);
00140   }
00141   //  if(dt==Dz_type) {
00142   if(tet[0]==s) return Tetraeder_Det_dz(0,tet[0],tet[1],tet[2],tet[3]);
00143   if(tet[1]==s) return Tetraeder_Det_dz(1,tet[0],tet[1],tet[2],tet[3]);
00144   if(tet[2]==s) return Tetraeder_Det_dz(2,tet[0],tet[1],tet[2],tet[3]);
00145   // if(tet[3]==s) 
00146   return Tetraeder_Det_dz(3,tet[0],tet[1],tet[2],tet[3]);
00147   //  }
00148 }
00149 
00150 
00151 
00152 void Calc_Loc_stencil(double* sten, diff_type typ_u, diff_type typ_v) {
00153   int u,v, k;
00154   dir_sons Tets[6][4];
00155   
00156   /* Alternative Konstruktion:
00157   // 0. Tet: WNT, END, WST, EST - schraeg
00158   Tets[0][0] = WNTd;
00159   Tets[0][1] = ENDd;
00160   Tets[0][2] = WSTd; 
00161   Tets[0][3] = ESTd;     
00162 
00163   // 1. Tet: EST, END, WST, ESD - Seite    
00164   Tets[1][0] = ESTd;
00165   Tets[1][1] = ENDd;
00166   Tets[1][2] = WSTd; 
00167   Tets[1][3] = ESDd;     
00168 
00169   // 2. Tet: WND, WSD, WST, ESD - Ecke  
00170   Tets[2][0] = WNDd;
00171   Tets[2][1] = WSDd;
00172   Tets[2][2] = WSTd; 
00173   Tets[2][3] = ESDd;     
00174 
00175   // 3. Tet: WST, WND, ESD, END -
00176   Tets[3][0] = WSTd;
00177   Tets[3][1] = WNDd;
00178   Tets[3][2] = ESDd; 
00179   Tets[3][3] = ENDd;     
00180 
00181   // 4. Tet: ENT, WNT, EST, END - Ecke
00182   Tets[4][0] = ENTd;
00183   Tets[4][1] = WNTd;
00184   Tets[4][2] = ESTd; 
00185   Tets[4][3] = ENDd;     
00186 
00187   // 5. Tet: WNT, WND, WST, END - Seite
00188   Tets[5][0] = WNTd;
00189   Tets[5][1] = WNDd;
00190   Tets[5][2] = WSTd; 
00191   Tets[5][3] = ENDd;     
00192   */
00193   
00194   // 0. Tet: WNT, WND, WST, EST 
00195   Tets[0][0] = WNTd;
00196   Tets[0][1] = WNDd;
00197   Tets[0][2] = WSTd; 
00198   Tets[0][3] = ESTd;     
00199 
00200   // 1. Tet: EST, WND, WST, ESD     
00201   Tets[1][0] = ESTd;
00202   Tets[1][1] = WNDd;
00203   Tets[1][2] = WSTd; 
00204   Tets[1][3] = ESDd;     
00205 
00206   // 2. Tet: WND, WSD, WST, ESD        
00207   Tets[2][0] = WNDd;
00208   Tets[2][1] = WSDd;
00209   Tets[2][2] = WSTd; 
00210   Tets[2][3] = ESDd;     
00211 
00212   // 3. Tet: EST, WND, ESD, END
00213   Tets[3][0] = ESTd;
00214   Tets[3][1] = WNDd;
00215   Tets[3][2] = ESDd; 
00216   Tets[3][3] = ENDd;     
00217 
00218   // 4. Tet: ENT, WNT, EST, END
00219   Tets[4][0] = ENTd;
00220   Tets[4][1] = WNTd;
00221   Tets[4][2] = ESTd; 
00222   Tets[4][3] = ENDd;     
00223 
00224   // 5. Tet: WNT, WND, EST, END
00225   Tets[5][0] = WNTd;
00226   Tets[5][1] = WNDd;
00227   Tets[5][2] = ESTd; 
00228   Tets[5][3] = ENDd;     
00229   
00230 
00231   for(u=0;u<8;++u)
00232     for(v=0;v<8;++v) sten[v+8*u] = 0.0;
00233 
00234   if(typ_u < Helm_type && typ_v < Helm_type)
00235     for(v=0;v<8;++v)
00236       for(u=0;u<8;++u) {
00237         for(k=0;k<6;++k) {
00238           if(In_tet(Tets[k],(dir_sons)u) && In_tet(Tets[k],(dir_sons)v)) {
00239             sten[v+8*u] = sten[v+8*u] +
00240               Evaluate_tet(Tets[k],(dir_sons)u,typ_u) *
00241               Evaluate_tet(Tets[k],(dir_sons)v,typ_v);
00242           }
00243         }
00244       }
00245 
00246   if(typ_u == Helm_type && typ_v == Helm_type)
00247     for(v=0;v<8;++v)
00248       for(u=0;u<8;++u) {
00249         for(k=0;k<6;++k) {
00250           if(In_tet(Tets[k],(dir_sons)u) && In_tet(Tets[k],(dir_sons)v)) {
00251             if(v==u) sten[v+8*u] = sten[v+8*u] + 2;
00252             else     sten[v+8*u] = sten[v+8*u] + 1;
00253           }
00254         }
00255       }
00256 
00257   if(typ_u < Helm_type && typ_v == Helm_type)
00258     for(v=0;v<8;++v)
00259       for(u=0;u<8;++u) {
00260         for(k=0;k<6;++k) {
00261           if(In_tet(Tets[k],(dir_sons)u) && In_tet(Tets[k],(dir_sons)v)) {
00262             sten[v+8*u] = sten[v+8*u] +
00263               Evaluate_tet(Tets[k],(dir_sons)u,typ_u);
00264           }
00265         }
00266       }
00267   if(typ_u == Helm_type && typ_v < Helm_type)
00268     for(v=0;v<8;++v)
00269       for(u=0;u<8;++u) {
00270         for(k=0;k<6;++k) {
00271           if(In_tet(Tets[k],(dir_sons)u) && In_tet(Tets[k],(dir_sons)v)) {
00272             sten[v+8*u] = sten[v+8*u] +
00273               Evaluate_tet(Tets[k],(dir_sons)v,typ_v);
00274           }
00275         }
00276       }
00277 }
00278 
00279 void Print_u_Recell(double*const * u_Recell, int num) {
00280   cout << "\n  North: " << endl;
00281   cout << "    " << u_Recell[WNTd][num] << ", " << u_Recell[ENTd][num] << endl;
00282   cout << "    " << u_Recell[WNDd][num] << ", " << u_Recell[ENDd][num] << endl;
00283   cout << "  South: " << endl;
00284   cout << "    " << u_Recell[WSTd][num] << ", " << u_Recell[ESTd][num] << endl;
00285   cout << "    " << u_Recell[WSDd][num] << ", " << u_Recell[ESDd][num] << endl;
00286 }
00287 
00288 void Print_part_loc_stencil(double* sten) {
00289   cout << "\n   North: " << endl;
00290   cout << "     " << sten[WNTd] << ", " << sten[ENTd] << endl;
00291   cout << "     " << sten[WNDd] << ", " << sten[ENDd] << endl;
00292   cout << "   South: " << endl;
00293   cout << "     " << sten[WSTd] << ", " << sten[ESTd] << endl;
00294   cout << "     " << sten[WSDd] << ", " << sten[ESDd] << endl;
00295 }
00296 
00297 void Print_Loc_stencil(double* sten) {
00298   int i;
00299   for(i=0;i<8;++i) {
00300     cout << "\n Sten bei: ";  Print((dir_sons)i);
00301     Print_part_loc_stencil(&(sten[8*i]));
00302   }
00303 }
00304 
00305 Loc_stencil_container::Loc_stencil_container() {
00306   int i, j;
00307   sten = new double**[4];
00308   for(i=0;i<4;++i) sten[i] = new double*[4];  
00309   for(i=0;i<4;++i) for(j=0;j<4;++j) sten[i][j] = NULL;
00310   sten_Poisson = new double[64];
00311 
00312   // Poisson berechnen
00313   sten_sp = Give_Loc_sten(Dx_type,Dx_type);
00314   for(i=0;i<8;++i) for(j=0;j<8;++j)
00315     sten_Poisson[i+8*j] = sten_sp[i+8*j];
00316   sten_sp = Give_Loc_sten(Dy_type,Dy_type);
00317   for(i=0;i<8;++i) for(j=0;j<8;++j)
00318     sten_Poisson[i+8*j] = sten_Poisson[i+8*j] + sten_sp[i+8*j];
00319   sten_sp = Give_Loc_sten(Dz_type,Dz_type);
00320   for(i=0;i<8;++i) for(j=0;j<8;++j)
00321     sten_Poisson[i+8*j] = sten_Poisson[i+8*j] + sten_sp[i+8*j];
00322 };
00323 
00324 double* Loc_stencil_container::Give_Loc_sten(diff_type typ_u,
00325                                               diff_type typ_v) const {
00326   if(sten[typ_u][typ_v] == NULL) {
00327     sten[typ_u][typ_v] = new double[64];
00328     Calc_Loc_stencil(sten[typ_u][typ_v],typ_u,typ_v);
00329   }
00330   return sten[typ_u][typ_v];
00331 };
00332 
00333 void Print_27_stencil(diff_type typ_u, diff_type typ_v) {
00334   int i,j,k, u,v;
00335   double Sten27[27];
00336   double* sten;
00337   sten = new double[64];
00338   for(i=0;i<27;++i) Sten27[i] = 0;
00339 
00340   Calc_Loc_stencil(sten, typ_u, typ_v);
00341   
00342   Print_Factor(typ_u,typ_v);
00343 
00344   // Nachbarzelle: j
00345   for(i=0;i<8;++i) for(j=0;j<8;++j) {
00346     v = opposite3D((dir_sons)j);
00347     u = i;
00348     Sten27[trans_cellP_27((dir_sons)i,(dir_sons)j)] = 
00349       Sten27[trans_cellP_27((dir_sons)i,(dir_sons)j)] + sten[v+8*u];
00350   }
00351   j=2;
00352   cout << "\n Nord: \n";
00353   for(k=2;k>=0;--k) {
00354     for(i=0;i<3;++i) {
00355       cout << ",   " << Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)];
00356     }
00357     cout << "\n";
00358   }
00359   j=1;
00360   cout << "\n Mitte: \n";
00361   for(k=2;k>=0;--k) {
00362     for(i=0;i<3;++i) {
00363       cout << ",   " << Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)];
00364     }
00365     cout << "\n";
00366   }
00367   j=0;
00368   cout << "\n Sued: \n";
00369   for(k=2;k>=0;--k) {
00370     for(i=0;i<3;++i) {
00371       cout << ",   " << Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)];
00372     }
00373     cout << "\n";
00374   }
00375 }
00376 
00377 void Print_27_stencil_var(diff_type typ_u, diff_type typ_v) {
00378   int i,j,k, u,v, s;
00379   double Sten27[27];
00380   double* sten;
00381   sten = new double[64];
00382   for(i=0;i<27;++i) Sten27[i] = 0;
00383 
00384   Calc_Loc_stencil(sten, typ_u, typ_v);
00385   
00386   Print_Factor(typ_u,typ_v);
00387 
00388   // Nachbarzelle: s
00389   for(s=0;s<8;++s) {
00390     cout << " cell: "; Print((dir_sons)s);  cout << endl;
00391     for(i=0;i<27;++i) Sten27[i] = 0;
00392     for(i=0;i<8;++i) {
00393       v = opposite3D((dir_sons)s);
00394       u = i;
00395       Sten27[trans_cellP_27((dir_sons)i,(dir_sons)s)] = 
00396         Sten27[trans_cellP_27((dir_sons)i,(dir_sons)s)] + sten[v+8*u];
00397     }
00398     j=2;
00399     cout << "\n Nord: \n";
00400     for(k=2;k>=0;--k) {
00401       for(i=0;i<3;++i) {
00402         cout << ",   " << Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)];
00403       }
00404       cout << "\n";
00405     }
00406     j=1;
00407     cout << "\n Mitte: \n";
00408     for(k=2;k>=0;--k) {
00409       for(i=0;i<3;++i) {
00410         cout << ",   " << Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)];
00411       }
00412       cout << "\n";
00413     }
00414     j=0;
00415     cout << "\n Sued: \n";
00416     for(k=2;k>=0;--k) {
00417       for(i=0;i<3;++i) {
00418         cout << ",   " << Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)];
00419       }
00420       cout << "\n";
00421     }
00422   }
00423 }
00424 
00425 
00426 
00427 void Print_with_Vorzeichen(double x) {
00428   if(ABS(x-1) < 0.001) {
00429     cout << " + ";
00430   }
00431   else if(ABS(x+1) < 0.001) {
00432     cout << " - ";
00433   }
00434   else if(x>0.1) cout << " + " << x << "*";
00435   else cout << " - " << -x << "*";
00436 }
00437 
00438 
00439 
00440 void Print_27_stencil_formula_var(diff_type typ_u, diff_type typ_v) {
00441   int i,j,k, u,v, s;
00442   double Sten27[27];
00443   double* sten;
00444   
00445   cout.precision(1);
00446 
00447   sten = new double[64];
00448   for(i=0;i<27;++i) Sten27[i] = 0;
00449 
00450   Calc_Loc_stencil(sten, typ_u, typ_v);
00451   
00452   Print_Factor(typ_u,typ_v);
00453 
00454   // Nachbarzelle: s
00455   for(s=0;s<8;++s) {
00456     //    cout << " cell: "; Print((dir_sons)s);
00457     //    cout << " ------------------------------------ ";
00458     cout << " \n var_interpo_"; Print((dir_sons)s); cout << " * (";
00459 
00460     for(i=0;i<27;++i) Sten27[i] = 0;
00461     for(i=0;i<8;++i) {
00462       v = opposite3D((dir_sons)s);
00463       u = i;
00464       Sten27[trans_cellP_27((dir_sons)i,(dir_sons)s)] = 
00465         Sten27[trans_cellP_27((dir_sons)i,(dir_sons)s)] + sten[v+8*u];
00466     }
00467     // Nord
00468     // ----
00469     j=2;
00470 
00471     i=0;  // West
00472     k=2; 
00473     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00474       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00475       cout << "uWNT";
00476     }
00477     k=1;
00478     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00479       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00480       cout << "uWN";
00481     }
00482     k=0;
00483     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00484       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00485       cout << "uWND";
00486     }
00487 
00488     i=1;  // Middle
00489     k=2; 
00490     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00491       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00492       cout << "uNT";
00493     }
00494     k=1;
00495     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00496       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00497       cout << "uN";
00498     }
00499     k=0;
00500     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00501       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00502       cout << "uND";
00503     }
00504 
00505     i=2;  // East
00506     k=2; 
00507     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00508       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00509       cout << "uENT";
00510     }
00511     k=1;
00512     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00513       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00514       cout << "uEN";
00515     }
00516     k=0;
00517     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00518       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00519       cout << "uEND";
00520     }
00521 
00522     // Middle
00523     // ------
00524     j=1;
00525 
00526     i=0;  // West
00527     k=2; 
00528     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00529       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00530       cout << "uWT";
00531     }
00532     k=1;
00533     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00534       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00535       cout << "uW";
00536     }
00537     k=0;
00538     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00539       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00540       cout << "uWD";
00541     }
00542 
00543     i=1;  // Middle
00544     k=2; 
00545     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00546       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00547       cout << "uT";
00548     }
00549     k=1;
00550     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00551       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00552       cout << "uM";
00553     }
00554     k=0;
00555     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00556       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00557       cout << "uD";
00558     }
00559 
00560     i=2;  // East
00561     k=2; 
00562     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00563       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00564       cout << "uET";
00565     }
00566     k=1;
00567     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00568       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00569       cout << "uE";
00570     }
00571     k=0;
00572     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00573       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00574       cout << "uED";
00575     }
00576 
00577     //Sued
00578     // ----
00579     j=0;
00580 
00581     i=0;  // West
00582     k=2; 
00583     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00584       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00585       cout << "uWST";
00586     }
00587     k=1;
00588     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00589       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00590       cout << "uWS";
00591     }
00592     k=0;
00593     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00594       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00595       cout << "uWSD";
00596     }
00597 
00598     i=1;  // Middle
00599     k=2; 
00600     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00601       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00602       cout << "uST";
00603     }
00604     k=1;
00605     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00606       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00607       cout << "uS";
00608     }
00609     k=0;
00610     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00611       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00612       cout << "uSD";
00613     }
00614 
00615     i=2;  // East
00616     k=2; 
00617     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00618       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00619       cout << "uEST";
00620     }
00621     k=1;
00622     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00623       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00624       cout << "uES";
00625     }
00626     k=0;
00627     if(ABS(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]) > 0.01) {
00628       Print_with_Vorzeichen(Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)]);;
00629       cout << "uESD";
00630     }
00631     cout << ") + ";
00632   }
00633   cout << "\n Formula of stencil!" << endl;
00634 }
00635 
00636 
00637 
00638 
00639 void Print_27_stencil_of_local_matrix(double* sten) {
00640   int i,j,k, u,v;
00641   double Sten27[27];
00642 
00643   for(i=0;i<27;++i) Sten27[i] = 0;
00644 
00645   // Nachbarzelle: j
00646   for(i=0;i<8;++i) for(j=0;j<8;++j) {
00647     v = opposite3D((dir_sons)j);
00648     u = i;
00649     Sten27[trans_cellP_27((dir_sons)i,(dir_sons)j)] = 
00650       Sten27[trans_cellP_27((dir_sons)i,(dir_sons)j)] + sten[v+8*u];
00651   }
00652   j=2;
00653   cout << "\n Nord: \n";
00654   for(k=2;k>=0;--k) {
00655     for(i=0;i<3;++i) {
00656       cout << ",   " << Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)];
00657     }
00658     cout << "\n";
00659   }
00660   j=1;
00661   cout << "\n Mitte: \n";
00662   for(k=2;k>=0;--k) {
00663     for(i=0;i<3;++i) {
00664       cout << ",   " << Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)];
00665     }
00666     cout << "\n";
00667   }
00668   j=0;
00669   cout << "\n Sued: \n";
00670   for(k=2;k>=0;--k) {
00671     for(i=0;i<3;++i) {
00672       cout << ",   " << Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)];
00673     }
00674     cout << "\n";
00675   }
00676 }
00677 
00678 void Print_27_stencil(double Sten27[27]) {
00679   int i,j,k;
00680 
00681   j=2;
00682   cout << "\n Nord: \n";
00683   for(k=2;k>=0;--k) {
00684     for(i=0;i<3;++i) {
00685       cout << ",   " << Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)];
00686     }
00687     cout << "\n";
00688   }
00689   j=1;
00690   cout << "\n Mitte: \n";
00691   for(k=2;k>=0;--k) {
00692     for(i=0;i<3;++i) {
00693       cout << ",   " << Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)];
00694     }
00695     cout << "\n";
00696   }
00697   j=0;
00698   cout << "\n Sued: \n";
00699   for(k=2;k>=0;--k) {
00700     for(i=0;i<3;++i) {
00701       cout << ",   " << Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)];
00702     }
00703     cout << "\n";
00704   }
00705 }
00706 
00707 
00708 void Print_27_stencil_Poisson() {
00709   int i,j,k, u,v;
00710   double Sten27[27];
00711   double sten[64];
00712   double sten_sp[64];
00713   /*
00714   sten = new double*[8];
00715   for(i=0;i<8;++i) sten[i] = new double[8];
00716   for(i=0;i<27;++i) Sten27[i] = 0;
00717   sten_sp = new double*[8];
00718   for(i=0;i<8;++i) sten_sp[i] = new double[8];
00719   */
00720   for(i=0;i<27;++i) Sten27[i] = 0;
00721 
00722   Calc_Loc_stencil(sten, Dx_type, Dx_type);
00723   for(i=0;i<8;++i) for(j=0;j<8;++j)
00724   Calc_Loc_stencil(sten_sp, Dy_type, Dy_type);
00725   for(i=0;i<8;++i) for(j=0;j<8;++j)
00726     sten[i+8*j] = sten[i+8*j] + sten_sp[i+8*j];
00727   Calc_Loc_stencil(sten_sp, Dz_type, Dz_type);
00728   for(i=0;i<8;++i) for(j=0;j<8;++j)
00729     sten[i+8*j] = sten[i+8*j] + sten_sp[i+8*j];
00730 
00731   Print_Factor_Poisson();
00732 
00733   // Nachbarzelle: j
00734   for(i=0;i<8;++i) for(j=0;j<8;++j) {
00735     v = opposite3D((dir_sons)j);
00736     u = i;
00737     Sten27[trans_cellP_27((dir_sons)i,(dir_sons)j)] = 
00738       Sten27[trans_cellP_27((dir_sons)i,(dir_sons)j)] + sten[v+8*u];
00739   }
00740   j=2;
00741   cout << "\n Nord: \n";
00742   for(k=2;k>=0;--k) {
00743     for(i=0;i<3;++i) {
00744       cout << ",   " << Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)];
00745     }
00746     cout << "\n";
00747   }
00748   j=1;
00749   cout << "\n Mitte: \n";
00750   for(k=2;k>=0;--k) {
00751     for(i=0;i<3;++i) {
00752       cout << ",   " << Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)];
00753     }
00754     cout << "\n";
00755   }
00756   j=0;
00757   cout << "\n Sued: \n";
00758   for(k=2;k>=0;--k) {
00759     for(i=0;i<3;++i) {
00760       cout << ",   " << Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)];
00761     }
00762     cout << "\n";
00763   }
00764 }
00765 
00766 
00767 void Print_27_stencil_Poisson_var() {
00768   int i,j,k, u,v,s;
00769   double Sten27[27];
00770   double sten[64];
00771   double sten_sp[64];
00772 
00773   for(i=0;i<27;++i) Sten27[i] = 0;
00774 
00775   Calc_Loc_stencil(sten, Dx_type, Dx_type);
00776   for(i=0;i<8;++i) for(j=0;j<8;++j)
00777   Calc_Loc_stencil(sten_sp, Dy_type, Dy_type);
00778   for(i=0;i<8;++i) for(j=0;j<8;++j)
00779     sten[i+8*j] = sten[i+8*j] + sten_sp[i+8*j];
00780   Calc_Loc_stencil(sten_sp, Dz_type, Dz_type);
00781   for(i=0;i<8;++i) for(j=0;j<8;++j)
00782     sten[i+8*j] = sten[i+8*j] + sten_sp[i+8*j];
00783 
00784   Print_Factor_Poisson();
00785 
00786   // Nachbarzelle: s
00787   for(s=0;s<8;++s) {
00788     cout << " cell: "; Print((dir_sons)s);  cout << endl;
00789     for(i=0;i<27;++i) Sten27[i] = 0;
00790     for(i=0;i<8;++i) {
00791       v = opposite3D((dir_sons)s);
00792       u = i;
00793       Sten27[trans_cellP_27((dir_sons)i,(dir_sons)s)] = 
00794         Sten27[trans_cellP_27((dir_sons)i,(dir_sons)s)] + sten[v+8*u];
00795     }
00796 
00797     j=2;
00798     cout << "\n Nord: \n";
00799     for(k=2;k>=0;--k) {
00800       for(i=0;i<3;++i) {
00801         cout << ",   " << Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)];
00802       }
00803       cout << "\n";
00804     }
00805     j=1;
00806     cout << "\n Mitte: \n";
00807     for(k=2;k>=0;--k) {
00808       for(i=0;i<3;++i) {
00809         cout << ",   " << Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)];
00810       }
00811       cout << "\n";
00812     }
00813     j=0;
00814     cout << "\n Sued: \n";
00815     for(k=2;k>=0;--k) {
00816       for(i=0;i<3;++i) {
00817         cout << ",   " << Sten27[trans27((Ort1D)i,(Ort1D)j,(Ort1D)k)];
00818       }
00819       cout << "\n";
00820     }
00821   }
00822 }
00823 
00824 
00825 
00826 void Print_Factor(diff_type typ_u, diff_type typ_v) {
00827   if(typ_u < Helm_type && typ_v < Helm_type) {
00828     cout << "\n Faktor ist: h_mesh / 6.0; " << endl;
00829     return;
00830   }
00831   if(typ_u == Helm_type && typ_v == Helm_type) {
00832     cout << "\n Faktor ist: h_mesh^3 / 120.0; " << endl;
00833     return;
00834   }
00835   cout << "\n Faktor ist: h_mesh^2 / 24.0; " << endl;
00836 }
00837 
00838 void Print_Factor_Poisson() {
00839   cout << "\n Faktor ist: h_mesh / 6.0; " << endl;
00840 }
00841 
00842 double Test_evaluation_of_lsm(double* sten, dir_sons dir_v,
00843                               bool* corner_in_domain) {
00844   static int i;
00845   static double sum;
00846   sum = 0.0;
00847   for(i=0;i<8;++i) {
00848     if(corner_in_domain[i])
00849       sum = sum + sten[dir_v+8*i] * 1.0;
00850   }
00851   return sum;
00852 }
00853 
00854 double Test_evaluation_of_lsm(double* sten, dir_sons dir_v,
00855                               double* UU) {
00856   static int i;
00857   static double sum;
00858   sum = 0.0;
00859   for(i=0;i<8;++i) {
00860     sum = sum + sten[dir_v+8*i] * UU[i];
00861   }
00862   return sum;
00863 }
00864 
00865 double Test_evaluation_of_lsm(double* sten, dir_sons dir_v) {
00866   static int i;
00867   static double sum;
00868   sum = 0.0;
00869   for(i=0;i<8;++i) {
00870     sum = sum + sten[dir_v+8*i] * 1.0;
00871   }
00872   return sum;
00873 }
00874 
00875 
00877 // for restriction operator
00878 
00879 Restriction_stencil_container::Restriction_stencil_container() {
00880   int i,j,k;
00881 
00882   for(i=0;i<5;i++) for(j=0;j<5;j++) for(k=0;k<5;k++) 
00883     reg_formula[i][j][k] = 0;
00884   
00885   reg_formula[2][2][2] = 2;
00886   reg_formula[2][3][2] = 1;
00887   reg_formula[2][1][2] = 1;
00888   reg_formula[3][2][2] = 1;
00889   reg_formula[1][2][2] = 1;
00890   reg_formula[2][2][3] = 1;
00891   reg_formula[2][2][1] = 1;
00892 
00893   reg_formula[2][3][1] = 1;
00894   reg_formula[1][3][2] = 1;
00895   reg_formula[1][2][3] = 1;
00896   reg_formula[3][2][1] = 1;
00897   reg_formula[2][1][3] = 1;
00898   reg_formula[3][1][2] = 1;
00899 
00900   reg_formula[3][1][3] = 1;
00901   reg_formula[1][3][1] = 1;
00902 }
00903 
00904 // #define vom_feinsten_Gitter false
00905 #define vom_feinsten_Gitter true
00906 #define Drucke_code true
00907 
00908 void Print_ijk_name(int i, int j, int k) {
00909   if(Drucke_code==false) {
00910     cout << " ";
00911     if(i==2 && j==2 && k==2) 
00912       cout << "M";
00913     else {
00914       if(i==0) cout << "WW";
00915       if(i==1) cout << "W";
00916       if(i==3) cout << "E";
00917       if(i==4) cout << "EE";
00918       
00919       if(j==0) cout << "SS";
00920       if(j==1) cout << "S";
00921       if(j==3) cout << "N";
00922       if(j==4) cout << "NN";
00923       
00924       if(k==0) cout << "DD";
00925       if(k==1) cout << "D";
00926       if(k==3) cout << "T";
00927       if(k==4) cout << "TT";
00928     }
00929     cout << " ";
00930   }
00931   else {
00932     if(i==2 && j==2 && k==2) {}
00933     else {
00934       if(i==0) cout << ".next_W(lpo).next_W(lpo)";
00935       if(i==1) cout << ".next_W(lpo)";
00936       if(i==3) cout << ".next_E(lpo)";
00937       if(i==4) cout << ".next_E(lpo).next_E(lpo)";
00938       
00939       if(j==0) cout << ".next_S(lpo).next_S(lpo)";
00940       if(j==1) cout << ".next_S(lpo)";
00941       if(j==3) cout << ".next_N(lpo)";
00942       if(j==4) cout << ".next_N(lpo).next_N(lpo)";
00943       
00944       if(k==0) cout << ".next_D(lpo).next_D(lpo)";
00945       if(k==1) cout << ".next_D(lpo)";
00946       if(k==3) cout << ".next_T(lpo)";
00947       if(k==4) cout << ".next_T(lpo).next_T(lpo)";
00948     }
00949   }
00950 }
00951 
00952 void Print_d_name(dir_3D d) {
00953   if(d==Wdir) cout << "Wdir";
00954   if(d==Edir) cout << "Edir";
00955   if(d==Ndir) cout << "Ndir";
00956   if(d==Sdir) cout << "Sdir";
00957   if(d==Tdir) cout << "Tdir";
00958   if(d==Ddir) cout << "Ddir";
00959 }
00960 
00961 
00962 void Print_bos_for_restriction(bool idem,
00963                                dir_3D d,
00964                                int i_from, int j_from, int k_from,
00965                                int i_to,   int j_to,   int k_to,
00966                                int reg_formula[5][5][5]) {
00967   int value_from, value_to;
00968   if(i_from >= 0 && i_from < 5 &&
00969      j_from >= 0 && j_from < 5 &&
00970      k_from >= 0 && k_from < 5 &&
00971      
00972      i_to >= 0 && i_to < 5 &&
00973      j_to >= 0 && j_to < 5 &&
00974      k_to >= 0 && k_to < 5) {
00975     value_from = reg_formula[i_from][j_from][k_from];
00976     value_to   = reg_formula[i_to][j_to][k_to];
00977     if(value_to!=0 || value_from!=0) {
00978       if(idem) {
00979         if(Drucke_code) {
00980           if(vom_feinsten_Gitter) {
00981             cout << "   near_bo_restriction_fine(next);" << endl;
00982           }
00983           else {
00984             cout << " near_bo_restriction_coarse(I";
00985             Print_ijk_name(i_from,j_from,k_from);
00986             cout << ");" << endl;
00987           }
00988         }
00989         else {
00990           cout << " Idem: "; 
00991           Print_ijk_name(i_from,j_from,k_from);
00992           cout << endl;
00993         }
00994       }
00995       else {
00996         if(Drucke_code) {
00997           cout << "   near_bo_restriction_fine_bo(next,";
00998             Print_d_name(d);
00999             cout << ","  << value_from
01000                  << ","  << value_to
01001                  << ");" << endl;
01002         }
01003         else {
01004           cout << " bo poi, direction: "; Print(d);
01005           cout << " from: "; 
01006           Print_ijk_name(i_from,j_from,k_from);
01007           cout << " value: " << value_from;
01008           
01009           cout << " to: "; 
01010           Print_ijk_name(i_to,j_to,k_to);
01011           cout << " value: " << value_to << endl;
01012         }
01013       }
01014     }
01015   }
01016 }
01017 
01018 void Print_restriction_formula() {
01019   int reg_formula[5][5][5];
01020   int i,j,k;
01021 
01022   for(i=0;i<5;i++) for(j=0;j<5;j++) for(k=0;k<5;k++) 
01023     reg_formula[i][j][k] = 0;
01024 
01025   reg_formula[2][2][2] = 2;
01026   reg_formula[2][3][2] = 1;
01027   reg_formula[2][1][2] = 1;
01028   reg_formula[3][2][2] = 1;
01029   reg_formula[1][2][2] = 1;
01030   reg_formula[2][2][3] = 1;
01031   reg_formula[2][2][1] = 1;
01032 
01033   reg_formula[2][3][1] = 1;
01034   reg_formula[1][3][2] = 1;
01035   reg_formula[1][2][3] = 1;
01036   reg_formula[3][2][1] = 1;
01037   reg_formula[2][1][3] = 1;
01038   reg_formula[3][1][2] = 1;
01039 
01040   reg_formula[3][1][3] = 1;
01041   reg_formula[1][3][1] = 1;
01042   
01043   for(i=0;i<5;i++) for(j=0;j<5;j++) for(k=0;k<5;k++) {
01044     if(Drucke_code) {
01045       cout << " next = I";
01046       Print_ijk_name(i,j,k);
01047       cout << ";" << endl;
01048       cout << " if(gr->Give_type(next) >= interior) {" << endl;
01049     }
01050     Print_bos_for_restriction(true,Wdir,
01051                               i,j,k,
01052                               i,j,k,
01053                               reg_formula);
01054     if(vom_feinsten_Gitter) {
01055       Print_bos_for_restriction(false,Wdir,
01056                                 i,j,k,
01057                                 i-1,j,k,
01058                                 reg_formula);
01059       Print_bos_for_restriction(false,Edir,
01060                                 i,j,k,
01061                                 i+1,j,k,
01062                               reg_formula);
01063       Print_bos_for_restriction(false,Ndir,
01064                                 i,j,k,
01065                                 i,j+1,k,
01066                                 reg_formula);
01067       Print_bos_for_restriction(false,Sdir,
01068                                 i,j,k,
01069                                 i,j-1,k,
01070                                 reg_formula);
01071       Print_bos_for_restriction(false,Tdir,
01072                                 i,j,k,
01073                                 i,j,k+1,
01074                                 reg_formula);
01075       Print_bos_for_restriction(false,Ddir,
01076                                 i,j,k,
01077                                 i,j,k-1,
01078                                 reg_formula);
01079     }
01080     if(Drucke_code) {
01081       cout << " };" << endl;
01082     }
01083 
01084     /*
01085     if(reg_formula[i][j][k]!=0) 
01086       Print_ijk_name(i,j,k);
01087     */
01088   }
01089 }

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