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

src/expde/extemp/opoth.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 // opoth.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 #include "../formulas/diffop.h"
00054 #include "../formulas/diffopc.h"
00055 #include "../formulas/diffopv.h"
00056 
00057 // Include level 5:
00058 #include "../grid/gpar.h"
00059 #include "../grid/parallel.h"
00060 #include "../grid/mgcoeff.h"
00061 #include "../grid/sto_man.h"
00062 #include "../grid/gridbase.h"
00063 #include "../grid/grid.h"
00064 #include "../grid/input.h"
00065 
00066 
00067 // Include level 5.1
00068 #include "../evpar/evpar.h"
00069 
00070 
00071 // Include level 6:
00072 #include "variable.h"
00073 #include "opera.h"
00074 #include "operav.h"
00075 #include "sim.h"
00076 #include "extra.h"
00077 #include "res_op.h"
00078 #include "array.h"
00079 
00080 
00081 
00082 
00084                // 1. functions of sim.h
00085                // 2. functions of extra.h
00086                // 3. functions of array.h
00088 
00089                
00090 // 1. functions of sim.h
00092 
00093 
00094 DWrapSim<DExprSimLit>
00095 operator== (Variable& a, double value)
00096 {
00097   typedef DWrapSim<DExprSimLit> ExprT;
00098   return ExprT(DExprSimLit(a,value)); 
00099 }
00100 
00101 
00102 
00103 DWrapSim<DExprSimlocLit>
00104 operator== (const Local_var& a, double x)
00105 {
00106   typedef DWrapSim<DExprSimlocLit > ExprT;
00107   return ExprT(DExprSimlocLit(a,x)); 
00108 }
00109 
00110 
00111 DWrapSim<DExprSimloc<DExprVAR> >
00112 operator== (const Local_var& a, Variable& b)
00113 {
00114   typedef DWrapSim<DExprSimloc<DExprVAR> > ExprT;
00115   return ExprT(DExprSimloc<DExprVAR>(a,DExprVAR(b))); 
00116 }
00117 
00118 
00119 // 2. functions of extra.h
00121 
00122 // Extrapolation at the boundary
00123 DExpr<DVar_Extra_Op>
00124 Extrapolate_near_boundary(Variable a)
00125 {
00126   return DExpr<DVar_Extra_Op>(DVar_Extra_Op(a));
00127 }
00128 
00129 
00130 
00131 double DVar_Extra_Op::Give_at_Index(const Index3D I, const Grid* grid) const {
00132   int l;
00133   Index3D In, Inn, Innn;
00134   int i;
00135   Pointtype Ptypn, Ptypnn, Ptypnnn;
00136   double un, unn, unnn;
00137 
00138   l = grid->Max_level();
00139 
00140   //  return grid->Give_variable(I,l)[v_.Number_variable()];
00141 
00142   for(i=0;i<8;++i) {
00143     In   = I.next((dir_sons)i, l);
00144     Inn  = In.next((dir_sons)i, l);
00145     Innn = Inn.next((dir_sons)i, l);
00146     if(grid->Point_in_domain(In) && grid->Point_in_domain(Inn)
00147        && grid->Point_in_domain(Innn)) {
00148       Ptypn  = grid->Give_type(In);
00149       Ptypnn = grid->Give_type(Inn);
00150       Ptypnnn = grid->Give_type(Innn);
00151       if((interior == Ptypn   || uniform <= Ptypn) &&
00152          (interior == Ptypnn  || uniform <= Ptypnn) &&
00153          (interior == Ptypnnn || uniform <= Ptypnnn)) {
00154         un   = grid->Give_variable(In,l)[v_.Number_variable()];
00155         unn  = grid->Give_variable(Inn,l)[v_.Number_variable()];
00156         unnn = grid->Give_variable(Innn,l)[v_.Number_variable()];
00157         
00158         return unnn - 3.0*unn + 3.0 * un;
00159       }
00160     }
00161   }
00162 
00163   for(i=0;i<8;++i) {
00164     In  = I.next((dir_sons)i, l);
00165     Inn = In.next((dir_sons)i, l);
00166     if(grid->Point_in_domain(In) && grid->Point_in_domain(Inn)) {
00167       Ptypn  = grid->Give_type(In);
00168       Ptypnn = grid->Give_type(Inn);
00169       if((interior == Ptypn  || uniform <= Ptypn) &&
00170          (interior == Ptypnn || uniform <= Ptypnn)) {
00171         un  = grid->Give_variable(In,l)[v_.Number_variable()];
00172         unn = grid->Give_variable(Inn,l)[v_.Number_variable()];
00173         
00174         //      h_mesh = grid->H_mesh() / Zweipotenz(grid->Max_level());
00175         
00176         return 2.0*un - unn;
00177       }
00178     }
00179   }
00180   return grid->Give_variable(I,l)[v_.Number_variable()];
00181 
00182   /*
00183 
00184   weight = 0;
00185   sum    = 0.0;
00186   for(i=0;i<3;++i) for(j=0;j<3;++j) for(k=0;k<3;++k) {
00187     In = I.next((Ort1D)i, (Ort1D)j, (Ort1D)k, l);
00188     Ptyp = grid->Give_type(In);
00189     if(interior == Ptyp || uniform <= Ptyp) {
00190       weight = weight + 1;
00191       sum = sum + grid->Give_variable(In,l)[v_.Number_variable()];
00192     }
00193   }
00194   if(weight==0) {
00195     //    cout << "Null";
00196     return grid->Give_variable(I,l)[v_.Number_variable()];
00197   }
00198   //  cout << "Eins";
00199   return sum / weight;
00200   */
00201 }
00202 
00203                
00204 // 3. functions of array.h
00206 
00207 Schleife For(Local_int& I, int begin, int end)  {
00208   return Schleife(I.Give_pointer(),begin,end);
00209 }
00210 
00211 SchleifeSum Sum(Local_int& I, int begin, int end)  {
00212   return SchleifeSum(I.Give_pointer(),begin,end);
00213 }

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