AMROC Main     Blockstructured Adaptive Mesh Refinement in object-oriented C++


Main Page   Class Hierarchy   Compound List   File List  

IndexGridData3.h

Go to the documentation of this file.
00001 #ifndef _included_IndexGridData3_h
00002 #define _included_IndexGridData3_h
00003 
00010 #include <generic.h>
00011 
00012 /*
00013 *************************************************************************
00014 *                                                                       *
00015 * Define some looping constructs for GridData.  Note that these will    *
00016 * take either an array or a region as the second argument.              *
00017 *                                                                       *
00018 * Copy the region extents into a local constant integer to aid the      *
00019 * compiler in doing some loop optimizations.                            *
00020 *                                                                       *
00021 *************************************************************************
00022 */
00023 
00024 #ifndef for_3
00025 #define for_3(i, j, k, r, s) {                                          \
00026    const int name2(k,_L) = (((r).lower(2)+((r).lower(2)<0?-s(2)+1:s(2)-1))/s(2))*s(2);    \
00027    const int name2(k,_U) = (r).upper(2);                                \
00028    const int name2(j,_L) = (((r).lower(1)+((r).lower(1)<0?-s(1)+1:s(1)-1))/s(1))*s(1);    \
00029    const int name2(j,_U) = (r).upper(1);                                \
00030    const int name2(i,_L) = (((r).lower(0)+((r).lower(0)<0?-s(0)+1:s(0)-1))/s(0))*s(0);    \
00031    const int name2(i,_U) = (r).upper(0);                                \
00032    const int name2(sk,_S) = (s(2));                                     \
00033    const int name2(sj,_S) = (s(1));                                     \
00034    const int name2(si,_S) = (s(0));                                     \
00035    for (register int k = name2(k,_L); k <= name2(k,_U); k+=name2(sk,_S))                \
00036    for (register int j = name2(j,_L); j <= name2(j,_U); j+=name2(sj,_S))                \
00037    for (register int i = name2(i,_L); i <= name2(i,_U); i+=name2(si,_S)) {
00038 #endif
00039 
00040 #ifndef end_for
00041 #define end_for } }
00042 #endif
00043 
00044 /*
00045 *************************************************************************
00046 *                                                                       *
00047 * These macros provide simple access to ``fast indexing'' from C++.     *
00048 * Current C++ compilers do not do a good job of optimizing C++ loops    *
00049 * with array access.  Using these macros should speed up loops by a     *
00050 * factor of about three.  Note that we still use the Fortran indexing   *
00051 * convention.                                                           *
00052 *                                                                       *
00053 * These macros should be used as follows:                               *
00054 *                                                                       *
00055 *       BeginFastIndex2(a, double);                                     *
00056 *       for_2(i, j, a)                                                  *
00057 *          FastIndex2(a, i, j) = 0.0;                                   *
00058 *       end_for                                                         *
00059 *       EndFastIndex2(a);                                               *
00060 *                                                                       *
00061 *************************************************************************
00062 */
00063 
00064 
00065 
00066 #ifndef BeginFastIndex3
00067 #define BeginFastIndex3(a, b, d, type) {                                \
00068 const int   name2(a,_B)  = b.bottom();                                  \
00069 type *const name2(a,_D)  = d;                                           \
00070 const int   name2(a,_e0) = b.extents(0);                                \
00071 const int   name2(a,_e1) = b.extents(1);                                \
00072 const int   name2(a,_s0) = b.stepsize(0);                               \
00073 const int   name2(a,_s1) = b.stepsize(1);                               \
00074 const int   name2(a,_s2) = b.stepsize(2)
00075 #define FastIndex3(a, i, j, k)                                          \
00076 name2(a,_D)[name2(a,_B)+((i)/name2(a,_s0))+name2(a,_e0)*(((j)/name2(a,_s1))+name2(a,_e1)*((k)/name2(a,_s2)))]
00077 #define EndFastIndex3(a) }
00078 #endif
00079 
00080 #endif


Quickstart     Users Guide     Programmers Reference     Installation      Examples     Download



AMROC Main      Home      Contact
last update: 06/01/04