src/expde/grid/input.h

Go to the documentation of this file.
00001 //    expde: expression templates for partial differential equations.
00002 //    Copyright (C) 2000  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 // ------------------------------------------------------------
00014 //
00015 // input.h
00016 //
00017 // ------------------------------------------------------------
00018 
00019    
00020 #ifndef INPUT_H_
00021 #define INPUT_H_
00022                    
00023 #define factor_eps_input 0.00000001
00024 #define search_length 3
00025 
00026 
00028 // for hashtable
00030 
00031 class Input_data_object;
00032 
00033 class Point_hashtable_input {
00034  public:
00035   int nx, ny, nz;   // inter code
00036 
00037   double wert;
00038 
00039   Point_hashtable_input* next;
00040 
00041   Point_hashtable_input(int Nx, int Ny, int Nz, 
00042                         double value) 
00043     : nx(Nx), ny(Ny), nz(Nz), wert(value) {
00044     next = NULL;
00045   };
00046   bool Is_point(int Nx, int Ny,int Nz) { return (Nx==nx && Ny==ny && Nz==nz); }
00047   double Value() { return wert; }
00048   ~Point_hashtable_input() {
00049     delete next;
00050   };
00051 };
00052 
00053 inline int hashtable_input_function(int x, int y, int z, int length) {
00054   int sp;
00055   sp = (x + 101*y + 10007*z) % length;
00056   if(sp>0) return sp;
00057   return -sp;
00058  //  return (x + 101*y + 10007*z) % length;
00059 }
00060 
00061 
00063 // Input_data_object
00065 
00066 class Input_data_object {
00067  public:
00068   Input_data_object(D3vector* coordinates, double* value, int num_points,
00069                     double mesh_x, double mesh_y, double mesh_z);
00070 
00071   double Interpolate_value(D3vector coordinates);
00072   
00073  private:
00074   D3vector* ort;
00075   double*   werte;
00076   
00077   double org_x;
00078   double org_y;
00079   double org_z;
00080 
00081   int anz_punkte;
00082 
00083   double h_x;             // Maschenweite x
00084   double h_y;             // Maschenweite y
00085   double h_z;             // Maschenweite z
00086 
00087   double epsx;
00088   double epsy;
00089   double epsz;
00090 
00091   // Punkt hinzufuegen usw.
00092   void Add_point(double x, double y, double z, double value);
00093   bool   Exists_point(D3vector coordinates);
00094   double Give_value(D3vector coordinates);
00095   D3vector Staggered_coordinate(D3vector coordinates);
00096 
00097   // Speicher des hashtables:
00098   Point_hashtable_input* point;              // fuer Iterationen
00099   int hashtable_input_leng;                  // Laenge des hashtable
00100   int hashtable_input_occ;                   // Besetzungszahl des hashtable
00101   Point_hashtable_input** hashtable_input_start;   // Zeiger auf Tabelle
00102 
00103   // gehe zu hashtable
00104   Point_hashtable_input* hashtable_input_point(int Nx, int Ny, int Nz) const;
00105 };
00106 
00107 
00108 inline Point_hashtable_input* 
00109 Input_data_object::hashtable_input_point(int Nx, int Ny, int Nz) const {
00110   Point_hashtable_input* point;
00111   point = hashtable_input_start[hashtable_input_function(Nx,Ny,Nz,
00112                                  hashtable_input_leng)];
00113   while(point!=NULL) {
00114     if(point->nx==Nx && point->ny==Ny && point->nz==Nz) return point;
00115     point = point->next;
00116   }
00117   return NULL;
00118 }
00119 
00120 
00121 #endif

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