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

src/expde/extemp/mg.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 // mg.cc
00019 //
00020 // ------------------------------------------------------------
00021 
00022 // Include level 0:
00023 #ifdef COMP_GNUOLD
00024  #include <iostream.h>
00025  #include <fstream.h>
00026  #include <time.h>
00027  #include <math.h>
00028 #else
00029  #include <iostream>
00030  #include <fstream>
00031  #include <ctime>
00032  #include <cmath>
00033 #endif 
00034 
00035 
00036 // Include level 0:
00037 #include "../parser.h"
00038 
00039 // Include level 1:
00040 #include "../paramete.h"
00041 #include "../abbrevi.h"
00042 #include "../math_lib/math_lib.h"
00043 
00044 // Include level 2:
00045 #include "../basic/basic.h"
00046 
00047 // Include level 3:
00048 #include "../domain/domain.h"
00049 
00050 // Include level 4:
00051 #include "../formulas/boundy.h"
00052 #include "../formulas/loc_sten.h"
00053 
00054 // Include level 5:
00055 #include "../grid/gpar.h"
00056 #include "../grid/parallel.h"
00057 #include "../grid/mgcoeff.h"
00058 #include "../grid/sto_man.h"
00059 #include "../grid/gridbase.h"
00060 #include "../grid/grid.h"
00061 #include "../grid/input.h"
00062 
00063 // Include level 5.1
00064 #include "../evpar/evpar.h"
00065 
00066 
00067 // Include level 6:
00068 #include "variable.h"
00069 #include "mg_op.h"
00070 
00072     // functions of mg.h
00074 
00075 /* Unary operator */
00076 
00077 DExpr<DVar_Res_Op>
00078 Restriction_FE(Variable a)
00079 {
00080   typedef DVar_Res_Op ExprT;
00081   return DExpr<ExprT>(ExprT(a));
00082 }
00083 
00084 DExpr<DVar_Prol_Op>
00085 Prolongation_FE(Variable a)
00086 {
00087   typedef DVar_Prol_Op ExprT;
00088   return DExpr<ExprT>(ExprT(a));
00089 }
00090 
00091 
00092 
00093 // Interpolation at a regular point near the boundary, l level of fine grid
00094 double DVar_Prol_Op::Give_at_Index(const Index3D I, const Grid* grid,
00095                                    int l) const {
00096 
00097 
00098   if(I.I_x().Tiefe()==l) {
00099     if(I.I_y().Tiefe()==l) {
00100       if(I.I_z().Tiefe()==l) {
00101         // middle point
00102         // edge between EST-WND
00103         return 0.5 *
00104           (grid->Give_variable(I.next_EST(l),l-1)[v_.Number_variable()] +
00105            grid->Give_variable(I.next_WND(l),l-1)[v_.Number_variable()]);
00106       }
00107       else {
00108         // TD-surface
00109         // edge between ES-WN
00110         return 0.5 *
00111           (grid->Give_variable(I.next_ES(l),l-1)[v_.Number_variable()] +
00112            grid->Give_variable(I.next_WN(l),l-1)[v_.Number_variable()]);
00113       }
00114     }
00115     else {
00116       if(I.I_z().Tiefe()==l) {
00117         // NS-surface
00118         // edge between WT-ED
00119         return 0.5 *
00120           (grid->Give_variable(I.next_WT(l),l-1)[v_.Number_variable()] +
00121            grid->Give_variable(I.next_ED(l),l-1)[v_.Number_variable()]);
00122       }
00123       else {
00124         // EW-edge
00125         return 0.5 *
00126           (grid->Give_variable(I.next_E(l),l-1)[v_.Number_variable()] +
00127            grid->Give_variable(I.next_W(l),l-1)[v_.Number_variable()]);
00128       }
00129     }
00130   }
00131   else {
00132     if(I.I_y().Tiefe()==l) {
00133       if(I.I_z().Tiefe()==l) {
00134         // EW-surface
00135         // edge between ST-ND
00136         return 0.5 *
00137           (grid->Give_variable(I.next_ST(l),l-1)[v_.Number_variable()] +
00138            grid->Give_variable(I.next_ND(l),l-1)[v_.Number_variable()]);
00139       }
00140       else {
00141         // NS-edge
00142         return 0.5 *
00143           (grid->Give_variable(I.next_N(l),l-1)[v_.Number_variable()] +
00144            grid->Give_variable(I.next_S(l),l-1)[v_.Number_variable()]);
00145       }
00146     }
00147     else {
00148       if(I.I_z().Tiefe()==l) {
00149         // TD-edge
00150         return 0.5 *
00151           (grid->Give_variable(I.next_T(l),l-1)[v_.Number_variable()] +
00152            grid->Give_variable(I.next_D(l),l-1)[v_.Number_variable()]);
00153 
00154 
00155       }
00156       else {
00157         // idem-point
00158         return grid->Give_variable(I,l-1)[v_.Number_variable()];
00159       }
00160     }
00161   }
00162   return 0.0;
00163 };
00164 

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