Blockstructured Adaptive Mesh Refinement in object-oriented C++
00001 #ifndef _included_IndexGridData1_h 00002 #define _included_IndexGridData1_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_1 00025 #define for_1(i, r, s) { \ 00026 const int name2(i,_L) = (((r).lower(0)+((r).lower(0)<0?-s(0)+1:s(0)-1))/s(0))*s(0); \ 00027 const int name2(i,_U) = (r).upper(0); \ 00028 const int name2(si,_S) = (s(0)); \ 00029 for (register int i = name2(i,_L); i <= name2(i,_U); i+=name2(si,_S)) { 00030 #endif 00031 #ifndef end_for 00032 #define end_for } } 00033 #endif 00034 00035 /* 00036 ************************************************************************* 00037 * * 00038 * These macros provide simple access to ``fast indexing'' from C++. * 00039 * Current C++ compilers do not do a good job of optimizing C++ loops * 00040 * with array access. Using these macros should speed up loops by a * 00041 * factor of about three. Note that we still use the Fortran indexing * 00042 * convention. * 00043 * * 00044 * These macros should be used as follows: * 00045 * * 00046 * BeginFastIndex1(a, double); * 00047 * for_1(i, a) * 00048 * FastIndex1(a, i) = 0.0; * 00049 * end_for * 00050 * EndFastIndex1(a); * 00051 * * 00052 ************************************************************************* 00053 */ 00054 00055 #ifndef BeginFastIndex1 00056 #define BeginFastIndex1(a, b, d, type) { \ 00057 const int name2(a,_B) = b.bottom(); \ 00058 type *const name2(a,_D) = d; \ 00059 const int name2(a,_s0) = b.stepsize(0) 00060 #define FastIndex1(a, i) \ 00061 name2(a,_D)[name2(a,_B)+((i)/name2(a,_s0))] 00062 #define EndFastIndex1(a) } 00063 #endif 00064 00065 #endif
Quickstart Users Guide Programmers Reference Installation Examples Download
AMROC Main Home Contactlast update: 06/01/04