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

src/expde/abbrevi.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 
00019 //                  abbbreviations
00021 
00022 
00023 #ifndef ABBREVI_H_
00024 #define ABBREVI_H_
00025       
00026 // update types for variables
00027 enum type_of_update { no_update,  partial_update, full_update };
00028 
00029 // types of diffrenetial opeartors
00030 enum diff_type { Dx_type, Dy_type, Dz_type, Helm_type, Poisson_type };
00031 
00032 // 1D
00033 //-------------
00034 enum dir1D { Ld,  Rd };
00035 enum Ort1D { LOrt, MOrt, ROrt };
00036 
00037 enum f_type { an,  spitz };        // face type
00038 
00039 // 2D
00040 //-------------
00041 // direction of sons in 2D
00042 enum dir2D_sons { SWdir, SEdir, NWdir, NEdir };
00043 
00044 // directions in 2D
00045 enum dir_2D { Wdir2D, Edir2D, Sdir2D, Ndir2D };
00046 
00047 // Stern in 2D
00048 //enum stencil_2D { SWsten, Ssten, SEsten, 
00049 //                  Wsten, Msten,  Esten, 
00050 //                  NWsten, Nsten, NEsten  };
00051 
00052 // 3D
00053 //-------------
00054 // directions fuer Soehne, oder Ecken einer Zellen
00055 enum dir_sons { WSDd, ESDd, WNDd, ENDd, WSTd, ESTd, WNTd, ENTd }; 
00056 
00057 // directions in 3D
00058 enum dir_3D { Wdir, Edir, Sdir, Ndir, Ddir, Tdir };
00059 
00060 // main_directions in 3D
00061 enum main_dir_3D { WE_dir, SN_dir, DT_dir };
00062 
00063 // edges of a cell
00064 enum Edges_cell { SDed, NDed, STed, NTed, WDed, EDed, WTed, ETed,
00065                   SWed, SEed, NWed, NEed }; 
00066 
00067 
00068 // for domain
00069 //-------------
00070 
00071 // is it possible to calculate the distance to the boundary?
00072 //----------------------------------------------------------
00073 enum calc_dis { no, yes, more_than };
00074 
00075 
00076 // type of a point given by domain
00077 //---------------------------------------------
00078 enum PointtypeD { exteriorD, interiorD };
00079 
00080 // type of a corner given by a cell
00081 //--------------------------------------------------
00082 enum Cornertype { exCorner, intCorner, boCorner  };
00083 
00084 // type of point
00085 //--------------------
00086 enum Pointtype { parallel_p, exterior, multigrid,    interior, slave, nearb, 
00087                  boundary,   uniform,  hierarchical, ausnahme  };
00088 
00089 // type of cell
00090 //--------------------
00091 enum Celltype { noinfo, ex_cell, int_cell, bo_cell, fine_bo_cell, 
00092                 no_cell_exists };
00093 
00094 // type of edge
00095 //--------------------
00096 enum Edgetype { edge_not_interior, edge_interior, noeinfo};
00097 
00098 
00100 // class: edge point of corner point of a boundary cell
00102 
00103 enum Cell_type_points { corner_poi_typ,  edge_poi_typ, cell_poi_typ };
00104 
00105 enum types_of_label_send { dont_send, Dirichlet_send, Neumann_send };
00106 
00107 class Edge_Corner_point {
00108   public:
00109    Cell_type_points edge_point; // edge point, corner point, or point in cell
00110    dir_sons corner; // corner of boundary cell
00111    dir_3D   d;      // direction of edge in case of edgepoint
00112 };
00113 
00115 // indices: 
00117 
00118 enum typ_of_general_points { type_P_Bo2p , type_P_interior,
00119                              type_P_cellpoi, type_P_nearb };
00120 
00122 //  funktionen for transformation
00124 
00125 
00126 // main direction of 3D-direction
00127 //-----------------------------
00128 inline main_dir_3D Main_direction(dir_3D d) {
00129   if(d>Ndir) return DT_dir;
00130   if(d<Sdir) return WE_dir;
00131   return SN_dir;
00132 }
00133 
00134 
00135 // 1D-part of 3D-direction
00136 //-----------------------------
00137 inline dir1D OneDpart(dir_3D d) {
00138   if(d>Ndir) return (dir1D)(d-4);
00139   if(d<Sdir) return (dir1D)d;
00140   return (dir1D)(d-2);
00141 }
00142 
00143 // 3D-direction by 1D-part and main direction
00144 //--------------------------------------------
00145 inline dir_3D Add(dir1D lr, main_dir_3D md) {
00146   if(md==WE_dir) return (dir_3D)(lr);
00147   if(md==SN_dir) return (dir_3D)(2+lr);
00148   return (dir_3D)(4+lr);
00149 }
00150 
00151 
00152 // corners of the face of a cell
00153 //------------------------------
00154 inline dir_sons corner_sur(dir_3D f, dir2D_sons cor) {
00155   if(f < Sdir)
00156     return (dir_sons)(f + 2*(cor&1) + 4*(cor>>1));
00157   if(f > Ndir)
00158     return (dir_sons)(4*(f-4) + (cor&1) + 2*(cor>>1));
00159   return (dir_sons)(2*(f-2) + (cor&1) + 4*(cor>>1));
00160 };
00161 
00162 // direction from one corner to another
00163 //-------------------------------------
00164 inline dir_3D direction_from_to(dir_sons from, dir_sons to) {
00165   if((from&1) != (to&1)) {
00166     if((from&1) < (to&1)) return Edir;
00167     else return Wdir;
00168   }
00169   if((from&2) != (to&2)) {
00170     if((from&2) < (to&2)) return Ndir;
00171     else return Sdir;
00172   }
00173   if((from&4) < (to&4)) return Tdir;
00174   else return Ddir;
00175 }
00176 
00177 // corners of an edge of a cell 
00178 //------------------------------
00179 inline dir_sons Transform(Edges_cell ec, dir1D d) {
00180   enum dir_3D dir;
00181   dir = (dir_3D) ((ec >> 2) << 1);
00182   if(dir<Sdir) return (dir_sons)(d+4*((ec>>1)&1)+2*(ec&1));
00183   if(dir>Ndir) return (dir_sons)(2*((ec>>1)&1)+(ec&1)+4*d);
00184   return (dir_sons)(4*((ec>>1)&1)+2*d+(ec&1));
00185 }
00186 
00187 // direction of the edge of a cell
00188 //---------------------------------
00189 inline dir_3D Trans_dir(Edges_cell ec, dir1D d) {
00190   return (dir_3D) (((ec >> 2) << 1) + d);
00191 }
00192 
00193 // next corner of a cell in a certain direction
00194 //--------------------------------------------------
00195 inline dir_sons Next_corner(dir_sons co, dir_3D dir) {
00196   if(dir<Sdir) {
00197     return (dir_sons)((co&(~1)) + ((~co)&1));
00198   }
00199   if(dir>Ndir) {
00200     return (dir_sons)((co&(~(1<<2))) + (((~(co>>2))&1)<<2));
00201   }
00202   return (dir_sons)((co&(~(1<<1))) + (((~(co>>1))&1)<<1));
00203 }
00204 
00205 inline dir_sons Next_corner_x(dir_sons co) {
00206   return (dir_sons)((co&(~1)) + ((~co)&1));
00207 }
00208 inline dir_sons Next_corner_y(dir_sons co) {
00209   return (dir_sons)((co&(~(1<<1))) + (((~(co>>1))&1)<<1));
00210 }
00211 inline dir_sons Next_corner_z(dir_sons co) {
00212     return (dir_sons)((co&(~(1<<2))) + (((~(co>>2))&1)<<2));
00213 }
00214 
00215 // opposite face type
00216 //--------------------------
00217 inline f_type opposite(f_type f) {
00218   if(f==an) return spitz;
00219   else return an;
00220 }
00221 
00222 // dir_3D coordinate of the direction of "dir_sons"
00223 //-------------------------------------------------
00224 inline dir_3D xCoord(dir_sons d) {
00225   return (dir_3D)(d&1);
00226 }
00227 inline dir_3D yCoord(dir_sons d) {
00228   return (dir_3D)(((d>>1)&1)+2);
00229 }
00230 inline dir_3D zCoord(dir_sons d) {
00231   return (dir_3D)(((d>>2)&1)+4);
00232 }
00233 
00234 // D3vector unit-vector of the corners of a cell
00235 inline double Unit_vector_x(dir_sons d) {
00236   return double(d&1);
00237 };
00238 inline double Unit_vector_y(dir_sons d) {
00239   return double((d&2)>>1);
00240 };
00241 inline double Unit_vector_z(dir_sons d) {
00242   return double((d&4)>>2);
00243 };
00244 
00245 
00246 // Sign (-1 falls links, 1 falls rechts) of a dir_3D direction
00247 //-------------------------------------------------------------------
00248 inline int sign(dir_3D d) {
00249   return (2*(d&1)-1);
00250 }
00251 
00252 // Change
00253 //-------------
00254 inline void Change(Edge_Corner_point& A, Edge_Corner_point& B) {
00255   static Edge_Corner_point sp;
00256   sp = A; A = B;  B = sp;
00257 }
00258 
00259 // Calc face type
00260 //-----------------------
00261 inline f_type Calc_f_type(dir_3D dx, dir_3D dy) {
00262   return (f_type)((OneDpart(dx)+OneDpart(dy))&1);
00263 }
00264 // opposite face type
00265 //-----------------------
00266 inline f_type opposite_face_type(f_type a) {
00267   return (f_type)((~a)&1);
00268 };
00269 
00270 // dir1D coordinate of direction "dir_sons"
00271 //---------------------------------------------
00272 inline dir1D x1DCoord(dir_sons d) {
00273   return (dir1D)(d&1);
00274 }
00275 inline dir1D y1DCoord(dir_sons d) {
00276   return (dir1D)((d>>1)&1);
00277 }
00278 inline dir1D z1DCoord(dir_sons d) {
00279   return (dir1D)((d>>2)&1);
00280 }
00281 
00282 
00283 // number of equal coordinates x,y,z of two corners (dir_sons)
00284 //---------------------------------------------------------------
00285 inline int How_Equal(dir_sons da, dir_sons db) {
00286   return (int)((da&1) == (db&1)) + 
00287     (int)((da&2) == (db&2)) +
00288     (int)((da&4) == (db&4));
00289 }
00290 
00291 // opposite directions in 3D
00292 //-----------------------------------
00293 inline dir_3D opposite3D(dir_3D dir) {
00294   if(dir<Sdir) return (dir_3D)((~dir)&1);
00295   if(dir>Ndir) return (dir_3D)(((~(dir-4))&1)+4);
00296   return (dir_3D)(((~(dir-2))&1)+2);
00297 }
00298 
00299 inline dir_sons opposite3D(dir_sons dir) {
00300   return (dir_sons)((~dir)&7);
00301 }
00302 
00303 inline Edges_cell opposite3D(Edges_cell ed) {
00304   if(ed==SDed) return NTed;
00305   if(ed==NDed) return STed;
00306   if(ed==STed) return NDed;
00307   if(ed==NTed) return SDed;
00308 
00309   if(ed==EDed) return WTed;
00310   if(ed==WDed) return ETed;
00311   if(ed==ETed) return WDed;
00312   if(ed==WTed) return EDed;
00313 
00314   if(ed==NEed) return SWed;
00315   if(ed==NWed) return SEed;
00316   if(ed==SEed) return NWed;
00317   return NEed;
00318 }
00319 
00320 // edge of a cell
00321 // d direction of the edge, sons direction of the orthogonal face
00322 //--------------------------------------------------------------------
00323 inline Edges_cell CalcEdge_cells(dir_3D d, dir2D_sons sons) {
00324   return (Edges_cell)(((d >> 1) << 2) + sons);
00325 }
00326 
00327 
00328 // edge of the face of a cell
00329 //-----------------------------
00330 inline Edges_cell Edge_surface(dir_3D surf, dir_2D dir) {
00331   if(surf<Sdir) {
00332     return (Edges_cell)(surf+2*(dir>>1)+4*((dir&1)+1));
00333   }
00334   if(surf==Ddir) {
00335     if((dir>>1)==0) 
00336       return (Edges_cell)(4*((dir&1)));
00337     return (Edges_cell)(1+4*((dir&1)));
00338   }
00339   if(surf==Tdir) {
00340     if((dir>>1)==0) 
00341       return (Edges_cell)(2+4*((dir&1)));
00342     return (Edges_cell)(3+4*((dir&1)));
00343   }
00344   if((dir&1)==0) 
00345     return (Edges_cell)((surf-2)+2*(dir>>1)+4*(2*(dir&1)));
00346   return (Edges_cell)(2*(surf-2)+(dir>>1)+4*(2*(dir&1)));
00347 
00348 }
00349 
00350 //  orthogonal directions of an edge
00351 //  ----------------------------------
00352 inline dir_3D OrthoA(Edges_cell ec) {
00353   static dir_3D dir;
00354   dir = (dir_3D) ((ec >> 2) << 1);
00355   if(dir<Sdir) return (dir_3D)((ec&1)+2);
00356   if(dir>Ndir) return (dir_3D)(ec&1);
00357   return (dir_3D)(ec&1);
00358 }
00359 
00360 
00361 inline dir_3D OrthoB(Edges_cell ec) {
00362   static dir_3D dir;
00363   dir = (dir_3D) ((ec >> 2) << 1);
00364   if(dir<Sdir) return (dir_3D) (((ec>>1)&1)+4);
00365   if(dir>Ndir) return (dir_3D) (((ec>>1)&1)+2);
00366   return (dir_3D) (((ec>>1)&1)+4);
00367 }
00368 
00369 // formula for integer-value: i+3*j+9*k
00370 inline dir_sons dir_sons_from_three_LR(dir1D i, dir1D j, dir1D k) {
00371   return (dir_sons)(i+2*j+4*k);
00372 }
00373 
00374 
00376 // describtion of a 27-stencil by
00377 // - (Ort1D)i, (Ort1D)j, (Ort1D)k       or
00378 // - the integer-value i+3*j+9*k
00379 // here are some transformatiuon formulas
00381 
00382 
00383 // formula for integer-value: i+3*j+9*k
00384 inline int trans27(Ort1D i, Ort1D j,Ort1D k) {
00385   return i+3*j+9*k;
00386 }
00387 
00388 // integer-value of a point ds in a neighbour cell dz
00389 inline int trans_cellP_27(dir_sons dz, dir_sons ds) {
00390   return ((ds&1) + (dz&1)) +
00391     3*(((ds>>1)&1) + ((dz>>1)&1)) + 
00392     9*(((ds>>2)&1) + ((dz>>2)&1));
00393 }
00394 
00395 inline Ort1D trans_cellP_27_x(dir_sons dz, dir_sons ds) {
00396   return (Ort1D)((ds&1) + (dz&1));
00397 }
00398 inline Ort1D trans_cellP_27_y(dir_sons dz, dir_sons ds) {
00399   return (Ort1D)(((ds>>1)&1) + ((dz>>1)&1));
00400 }
00401 inline Ort1D trans_cellP_27_z(dir_sons dz, dir_sons ds) {
00402   return (Ort1D)(((ds>>2)&1) + ((dz>>2)&1));
00403 }
00404 
00405 
00406 
00407 
00408 
00409 // print-functions for testing
00410 // ----------------------------
00411 inline void Print(dir_sons d) {
00412   if(d==WSDd) cout << "WSDd"; 
00413   if(d==ESDd) cout << "ESDd"; 
00414   if(d==WNDd) cout << "WNDd"; 
00415   if(d==ENDd) cout << "ENDd"; 
00416   if(d==WSTd) cout << "WSTd"; 
00417   if(d==ESTd) cout << "ESTd"; 
00418   if(d==WNTd) cout << "WNTd"; 
00419   if(d==ENTd) cout << "ENTd"; 
00420 }
00421 inline void Print(dir2D_sons d) {
00422   if(d==SWdir)  cout << "SWdir"; 
00423   if(d==SEdir)  cout << "SEdir"; 
00424   if(d==NWdir)  cout << "NWdir"; 
00425   if(d==NEdir)  cout << "NEdir"; 
00426 }
00427 
00428 inline void Print(dir_3D d) {
00429   if(d==Wdir) cout << "Wdir"; 
00430   if(d==Edir) cout << "Edir"; 
00431   if(d==Sdir) cout << "Sdir"; 
00432   if(d==Ndir) cout << "Ndir"; 
00433   if(d==Ddir) cout << "Ddir"; 
00434   if(d==Tdir) cout << "Tdir"; 
00435 }
00436 
00437 inline void Print(dir_2D d) {
00438   if(d==Wdir2D) cout << "Wdir2D"; 
00439   if(d==Edir2D) cout << "Edir2D"; 
00440   if(d==Sdir2D) cout << "Sdir2D"; 
00441   if(d==Ndir2D) cout << "Ndir2D"; 
00442 }
00443 
00444 inline void Print(Edges_cell ed) {
00445   if(ed==SDed) cout << "SDed";
00446   if(ed==NDed) cout << "NDed";
00447   if(ed==STed) cout << "STed";
00448   if(ed==NTed) cout << "NTed";
00449   if(ed==WDed) cout << "WDed";
00450   if(ed==EDed) cout << "EDed";
00451   if(ed==WTed) cout << "WTed";
00452   if(ed==ETed) cout << "ETed";
00453   if(ed==SWed) cout << "SWed";
00454   if(ed==SEed) cout << "SEed";
00455   if(ed==NWed) cout << "NWed";
00456   if(ed==NEed) cout << "NEed";
00457 }
00458 
00459 inline void Print(dir1D d) {
00460   if(d==Ld) cout << "Ld";
00461   if(d==Rd) cout << "Rd";
00462 }
00463 
00464 inline void Print(Pointtype p) {
00465   if(p==exterior) cout << "exterior";
00466   if(p==multigrid) cout << "multigrid";
00467   if(p==interior) cout << "interior";
00468   if(p==slave) cout << "slave";
00469   if(p==nearb) cout << "nearb";
00470   if(p==boundary) cout << "boundary";
00471   if(p==uniform) cout << "uniform";
00472   if(p==hierarchical) cout << "hierarchical";
00473   if(p==ausnahme) cout << "ausnahme";
00474 }
00475 
00476 #endif
00477    

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