00001 /* _______ __
00002 / ___/ / ___ __ _ / / ___
00003 / /__/ _ \/ _ \/ ' \/ _ \/ _ \
00004 \___/_//_/\___/_/_/_/_.__/\___/
00005 */
00006 //
00007 // This software is copyright (C) by the Lawrence Berkeley
00008 // National Laboratory. Permission is granted to reproduce
00009 // this software for non-commercial purposes provided that
00010 // this notice is left intact.
00011 //
00012 // It is acknowledged that the U.S. Government has rights to
00013 // this software under Contract DE-AC03-765F00098 between
00014 // the U.S. Department of Energy and the University of
00015 // California.
00016 //
00017 // This software is provided as a professional and academic
00018 // contribution for joint exchange. Thus it is experimental,
00019 // is provided ``as is'', with no warranties of any kind
00020 // whatsoever, no support, no promise of updates, or printed
00021 // documentation. By using this software, you acknowledge
00022 // that the Lawrence Berkeley National Laboratory and
00023 // Regents of the University of California shall have no
00024 // liability with respect to the infringement of other
00025 // copyrights by any part of this software.
00026 //
00027
00028 #ifndef _CH_LAME_MACROS_H
00029 #define _CH_LAME_MACROS_H
00030
00031 #if (CH_SPACEDIM == 1)
00032
00033 /*@ManDoc:
00034 The macro ForAllThisPencil(T,b,ns,nc) is intended to facilitate efficient
00035 looping over the contents of BaseFabs and objects derived from BaseFab.
00036 Special attention has been paid to make it work efficiently on vector
00037 supercomputers.
00038
00039 This macro acts upon the BaseFab *this. Instead of iterating over the
00040 entire Box b, it iterates over components starting at component ns and
00041 ending at component ns+nc-1, in all directions except the first coordinate
00042 direction. The user must iterate over the first coordinate direction within
00043 the ForAllThisPencil loop. The macro creates two internal reference
00044 variables; thisR that references the first element in the pencil, and
00045 thisLen that gives the length of the pencil. The first argument of the
00046 macro is a type: the type contained in the BaseFab that is being iterated
00047 over.
00048
00049 We can rewrite the code illustrated in `ForAllThisBNN' in this form:
00050
00051 template <class T>
00052 void BaseFab<T>::performSetVal(const T val, const Box bx, int ns, int nc)
00053 {
00054 assert(domain.contains(bx));
00055 ForAllThisPencil(T,bx,ns,nc)
00056 {
00057 T* dog = \&thisR;
00058 for (int i = 0; i < thisLen; i++)
00059 dog[i] = val;
00060 } EndForPencil
00061 }
00062
00063 Looping macro mnemonics:
00064
00065 This stands for the current object
00066 C for a const
00067 X stands for a BaseFab
00068 B for a Box
00069 N for an int
00070 */
00071 #define ForAllThisPencil(T,b,ns,nc) \
00072 { \
00073 assert(contains(b)); \
00074 assert((ns) >= 0 && (ns) + (nc) <= nComp()); \
00075 const int *_th_plo = loVect(); \
00076 const int *_th_plen = size(); \
00077 const int *_b_lo = (b).loVect(); \
00078 const int *_b_len = (b).size(); \
00079 T* _th_p = dptr; \
00080 for(int _n = (ns); _n < (ns)+(nc); ++_n) { \
00081 const int nR = _n; \
00082 T *_th_pp = _th_p \
00083 + ((_b_lo[0] - _th_plo[0]) \
00084 + _n * _th_plen[0]); \
00085 T &thisR = * _th_pp; \
00086 const int thisLen = _b_len[0]; \
00087
00088 /*@ManDoc:
00089 Same as ForAllThisPencil, except that it operates on the
00090 the argument BaseFab passed in. added by bvs, 05/27/99
00091 */
00092 #define ForAllXBPencil(T,x,b,ns,nc) \
00093 { \
00094 assert(x.contains(b)); \
00095 assert((ns) >= 0 && (ns) + (nc) <= x.nComp()); \
00096 const int *_th_plo = x.loVect(); \
00097 const int *_th_plen = x.size(); \
00098 const int *_b_lo = (b).loVect(); \
00099 const int *_b_len = (b).size(); \
00100 T* _th_p = x.dataPtr(); \
00101 for(int nR = (ns); nR < (ns)+(nc); ++nR) { \
00102 T * xR = _th_p \
00103 + ((_b_lo[0] - _th_plo[0]) \
00104 + nR * _th_plen[0]); \
00105 const int thisLen = _b_len[0];
00106
00107 /*@ManDoc:
00108 The macro ForAllThisCPencil(T,b,ns,nc) is intended to facilitate efficient
00109 looping over the contents of BaseFabs and objects derived from BaseFab.
00110 Special attention has been paid to make it work efficiently on vector
00111 supercomputers.
00112
00113 This is the constant version of ForAllThisPencil; i.e. it works when the
00114 underlying BaseFab is constant.
00115
00116 Looping macro mnemonics:
00117
00118 This stands for the current object
00119 C for a const
00120 X stands for a BaseFab
00121 B for a Box
00122 N for an int
00123 */
00124 #define ForAllThisCPencil(T,b,ns,nc) \
00125 { \
00126 assert(contains(b)); \
00127 assert((ns) >= 0 && (ns) + (nc) <= nComp()); \
00128 const int *_th_plo = loVect(); \
00129 const int *_th_plen = size(); \
00130 const int *_b_lo = (b).loVect(); \
00131 const int *_b_len = (b).size(); \
00132 const T* _th_p = dptr; \
00133 for(int _n = (ns); _n < (ns)+(nc); ++_n) { \
00134 int nR = _n; nR += 0; \
00135 const T *_th_pp = _th_p \
00136 + ((_b_lo[0] - _th_plo[0]) \
00137 + _n * _th_plen[0]); \
00138 const T &thisR = * _th_pp; \
00139 const int thisLen = _b_len[0];
00140
00141 /*@ManDoc:
00142 The macro ForAllXBNN(T,x,b,ns,nc) is intended to facilitate efficient
00143 looping over the contents of BaseFabs and objects derived from BaseFab.
00144 Special attention has been paid to make it work efficiently on vector
00145 supercomputers.
00146
00147 This macro acts upon the BaseFab x where the loop runs over the points in
00148 the Box b and over components starting at ns and ending at ns+nc-1. The
00149 first argument of the macro is a type: the type contained in the BaseFab
00150 that is being iterated over. The reference variable is xR, where x
00151 is literally replaced by the macros second argument. Thus an expression
00152 ForAllXBNN(int,dog,...) would have a reference variable dogR of type int.
00153
00154 Looping macro mnemonics:
00155
00156 This stands for the current object
00157 C for a const
00158 X stands for a BaseFab
00159 B for a Box
00160 N for an int
00161 */
00162 #define ForAllXBNN(T,x,b,ns,nc) \
00163 { \
00164 assert(x.contains(b)); \
00165 assert((ns) >= 0 && (ns) + (nc) <= (x).nComp()); \
00166 const int *_x_plo = (x).loVect(); \
00167 const int *_x_plen = (x).size(); \
00168 const int *_b_lo = (b).loVect(); \
00169 const int *_b_len = (b).size(); \
00170 T* _x_p = (x) .dataPtr(); \
00171 for(int _n = (ns); _n < (ns)+(nc); ++_n) { \
00172 const int nR = _n; \
00173 T *_x_pp = _x_p \
00174 + ((_b_lo[0] - _x_plo[0]) \
00175 + _n * _x_plen[0]); \
00176 for(int _i = 0; _i < _b_len[0]; ++_i, ++_x_pp) { \
00177 const int iR = _i + _b_lo[0]; \
00178 T &x##R = * _x_pp;
00179
00180 /*@ManDoc:
00181 The macro ForAllXCBNN(T,x,b,ns,nc) is intended to facilitate efficient
00182 looping over the contents of BaseFabs and objects derived from BaseFab.
00183 Special attention has been paid to make it work efficiently on vector
00184 supercomputers.
00185
00186 This is the constant version of ForAllXBNN; i.e. it works when the
00187 underlying BaseFab is constant.
00188
00189 Looping macro mnemonics:
00190
00191 This stands for the current object
00192 C for a const
00193 X stands for a BaseFab
00194 B for a Box
00195 N for an int
00196 */
00197 #define ForAllXCBNN(T,x,b,ns,nc) \
00198 { \
00199 assert(x.contains(b)); \
00200 assert((ns) >= 0 && (ns) + (nc) <= (x).nComp()); \
00201 const int *_x_plo = (x).loVect(); \
00202 const int *_x_plen = (x).size(); \
00203 const int *_b_lo = (b).loVect(); \
00204 const int *_b_len = (b).size().getVect(); \
00205 const T* _x_p = (x).dataPtr(); \
00206 for(int _n = (ns); _n < (ns)+(nc); ++_n) { \
00207 const int nR = _n; \
00208 const T *_x_pp = _x_p \
00209 + ((_b_lo[0] - _x_plo[0]) \
00210 + _n * _x_plen[0]); \
00211 for(int _i = 0; _i < _b_len[0]; ++_i) { \
00212 const int iR = _i + _b_lo[0]; \
00213 const T & x##R = _x_pp[_i];
00214
00215 /*@ManDoc:
00216 The ForAllThisBNN(T,b,ns,nc) macro is intended to facilitate efficient
00217 looping over the contents of BaseFabs and objects derived from BaseFab.
00218 Special attention has been paid to make it work efficiently on vector
00219 supercomputers.
00220
00221 This macro performs the loop over the current object (*this) where the loop
00222 runs over the points in the Box b and over components starting at ns and
00223 ending at ns+nc-1. The first argument of the macro is a type: the type
00224 contained in the BaseFab that is being iterated over. The reference
00225 variable is thisR.
00226
00227 For example:
00228
00229 template<class T>
00230 void
00231 BaseFab<T>::performSetVal (const T val, const Box bx, int ns, int num)
00232 {
00233 assert(domain.contains(bx));
00234 ForAllThisBNN(T,bx,ns,num)
00235 {
00236 thisR = val;
00237 } EndFor
00238 }
00239
00240 Looping macro mnemonics:
00241
00242 This stands for the current object
00243 C for a const
00244 X stands for a BaseFab
00245 B for a Box
00246 N for an int
00247 */
00248 #define ForAllThisBNN(T,b,ns,nc) \
00249 { \
00250 assert(contains(b)); \
00251 assert((ns) >= 0 && (ns) + (nc) <= nComp()); \
00252 const int *_th_plo = loVect(); \
00253 const int *_th_plen = size(); \
00254 const int *_b_lo = (b).loVect(); \
00255 const int *_b_len = (b).size().getVect(); \
00256 T* _th_p = dptr; \
00257 for(int _n = (ns); _n < (ns)+(nc); ++_n) { \
00258 int nR = _n; nR += 0; \
00259 T *_th_pp = _th_p \
00260 + ((_b_lo[0] - _th_plo[0]) \
00261 + _n * _th_plen[0]); \
00262 for(int _i = 0; _i < _b_len[0]; ++_i, ++_th_pp) { \
00263 int iR = _i + _b_lo[0]; iR += 0; \
00264 T &thisR = * _th_pp;
00265
00266 /*@ManDoc:
00267 The macro ForAllThisCBNN(T,b,ns,nc) is intended to facilitate efficient
00268 looping over the contents of BaseFabs and objects derived from BaseFab.
00269 Special attention has been paid to make it work efficiently on vector
00270 supercomputers.
00271
00272 This is the constant version of ForAllThisBNN; i.e. it works when the
00273 underlying BaseFab is constant.
00274
00275 Looping macro mnemonics:
00276
00277 This stands for the current object
00278 C for a const
00279 X stands for a BaseFab
00280 B for a Box
00281 N for an int
00282 */
00283 #define ForAllThisCBNN(T,b,ns,nc) \
00284 { \
00285 assert(contains(b)); \
00286 assert((ns) >= 0 && (ns) + (nc) <= nComp()); \
00287 const int *_th_plo = loVect(); \
00288 const int *_th_plen = size(); \
00289 const int *_b_lo = (b).loVect(); \
00290 const int *_b_len = (b).size().getVect(); \
00291 const T* _th_p = dptr; \
00292 for(int _n = (ns); _n < (ns)+(nc); ++_n) { \
00293 const int nR = _n; \
00294 const T *_th_pp = _th_p \
00295 + ((_b_lo[0] - _th_plo[0]) \
00296 + _n * _th_plen[0]); \
00297 for(int _i = 0; _i < _b_len[0]; ++_i) { \
00298 const int iR = _i + _b_lo[0]; \
00299 const T &thisR = _th_pp[_i];
00300
00301 /*@ManDoc:
00302 The macro ForAllThisBNNXC(T,b,ns,nc,x,nss) is intended to facilitate
00303 efficient looping over the contents of BaseFabs and objects derived from
00304 BaseFab. Special attention has been paid to make it work efficiently on
00305 vector supercomputers.
00306
00307 This macro acts upon the BaseFab *this and in addition is able to utiliize
00308 values in the const BaseFab x. The loop runs over the points in the Box b
00309 and over components starting at ns and ending at ns+nc-1. The reference
00310 variables are thisR and xR, respectively. As usual the x in xR is replaced
00311 by the macro's fifth argument. The sixth argument nss is the number of the
00312 argument in x that corresponds to the ns argument in *this.
00313
00314 Looping macro mnemonics:
00315
00316 This stands for the current object
00317 C for a const
00318 X stands for a BaseFab
00319 B for a Box
00320 N for an int
00321 */
00322 #define ForAllThisBNNXC(T,b,ns,nc,x,nss) \
00323 { \
00324 assert((ns) >= 0 && (ns) + (nc) <= nComp()); \
00325 assert((nss) >= 0 && (nss) + (nc) <= (x).nComp()); \
00326 Box _subbox_((x).box()); \
00327 _subbox_ &= box(); \
00328 _subbox_ &= b; \
00329 if(!_subbox_.isEmpty()) { \
00330 const int *_th_plo = loVect(); \
00331 const int *_th_plen = size(); \
00332 const int *_x_plo = (x).loVect(); \
00333 const int *_x_plen = (x).size(); \
00334 const int *_subbox_lo = _subbox_.loVect(); \
00335 const int *_subbox_len = _subbox_.size().getVect(); \
00336 T* _th_p = dataPtr(ns); \
00337 const T* _x_p = (x).dataPtr(nss); \
00338 for(int _n = 0; _n < (nc); ++_n) { \
00339 int nR = _n; nR += 0; \
00340 T *_th_pp = _th_p \
00341 + ((_subbox_lo[0] - _th_plo[0]) \
00342 + _n * _th_plen[0]); \
00343 const T *_x_pp = _x_p \
00344 + ((_subbox_lo[0] - _x_plo[0]) \
00345 + _n * _x_plen[0]); \
00346 for(int _i = 0; _i < _subbox_len[0]; ++_i, ++_th_pp) { \
00347 int iR = _i + _subbox_lo[0]; iR += 0; \
00348 T &thisR = * _th_pp; const T & x##R = _x_pp[_i];
00349 /*@ManDoc:
00350 The macro ForAllThisBNNXCBN(T,b,ns,nc,x,bx,nss) is intended to facilitate
00351 efficient looping over the contents of BaseFabs and objects derived from
00352 BaseFab. Special attention has been paid to make it work efficiently on
00353 vector supercomputers.
00354
00355 This macro acts upon the BaseFab *this and in addition is able to utiliize
00356 values in the const BaseFab x. The loop runs over the points in the
00357 Box b with components starting at ns and ending at ns+nc-1. The reference
00358 variables are thisR and xR, respectively. As usual the x in xR is replaced
00359 by the macro's fifth argument. The sixth argument nss is the number of the
00360 argument in x that corresponds to the ns argument in *this. Box bx must
00361 be the same size as this->box() intersected with b.
00362
00363 Looping macro mnemonics:
00364
00365 This stands for the current object
00366 C for a const
00367 X stands for a BaseFab
00368 B for a Box
00369 N for an int
00370 */
00371 #define ForAllThisBNNXCBN(T,b,ns,nc,x,bx,nss) \
00372 { \
00373 assert((ns) >= 0 && (ns) + (nc) <= nComp()); \
00374 assert((nss) >= 0 && (nss) + (nc) <= (x).nComp()); \
00375 assert(bx.sameSize((b))); \
00376 if(!((b).isEmpty())) { \
00377 const int *_th_plo = loVect(); \
00378 const int *_th_plen = size(); \
00379 const int *_x_plo = (x).loVect(); \
00380 const int *_x_plen = (x).size(); \
00381 const int *_subbox_lo = (b).loVect(); \
00382 const int *_subbox_len = (b).size().getVect(); \
00383 const int *_bx_lo = (bx).loVect(); \
00384 T* _th_p = dataPtr(ns); \
00385 const T* _x_p = (x).dataPtr(nss); \
00386 for(int _n = 0; _n < (nc); ++_n) { \
00387 int nR = _n + ns; nR += 0; \
00388 int n##x##R = _n + nss; n##x##R += 0; \
00389 T *_th_pp = _th_p \
00390 + ((_subbox_lo[0] - _th_plo[0]) \
00391 + _n * _th_plen[0]); \
00392 const T *_x_pp = _x_p \
00393 + ((_bx_lo[0] - _x_plo[0]) \
00394 + _n * _x_plen[0]); \
00395 for(int _i = 0; _i < _subbox_len[0]; ++_i, ++_th_pp) { \
00396 int iR = _i + _subbox_lo[0]; iR += 0; \
00397 int i##x##R = _i + _bx_lo[0]; i##x##R += 0; \
00398 T &thisR = * _th_pp; const T & x##R = _x_pp[_i];
00399
00400 /*@ManDoc:
00401 The macro ForAllThisBNNXCBNYCBN(T,b,ns,nc,x,bx,nsx,y,by,nsy) is intended to
00402 facilitate efficient looping over the contents of BaseFabs and objects
00403 derived from BaseFab. Special attention has been paid to make it work
00404 efficiently on vector supercomputers.
00405
00406 This macro acts upon the BaseFab *this and in addition is able to utiliize
00407 values in the const BaseFab x and const BaseFab y. The loop runs over the
00408 points in the intersection of Box b with components starting at ns and
00409 ending at ns+nc-1. The reference variables are thisR, xR, and yR
00410 respectively. As usual the x in xR is replaced by the macro's fifth argument
00411 and likewise for the y in yR. The seventh argument nsx is the number of the
00412 argument in x that corresponds to the ns argument in *this, and the eighth
00413 argument nsy is the number of the argument in y that corresponds to the ns
00414 argument in *this. Boxes bx and by must be the same size as this->box()
00415 intersected with b.
00416
00417 Looping macro mnemonics:
00418
00419 This stands for the current object
00420 C for a const
00421 X stands for a BaseFab
00422 B for a Box
00423 N for an int
00424 */
00425 #define ForAllThisBNNXCBNYCBN(T,b,ns,nc,x,bx,nsx,y,by,nsy) \
00426 { \
00427 assert((ns) >= 0 && (ns) + (nc) <= nComp()); \
00428 assert((nsx) >= 0 && (nsx) + (nc) <= (x).nComp()); \
00429 assert((nsy) >= 0 && (nsy) + (nc) <= (y).nComp()); \
00430 Box _subbox_ = box(); \
00431 _subbox_ &= b; \
00432 assert((bx).sameSize(_subbox_)); \
00433 assert((by).sameSize(_subbox_)); \
00434 if(!_subbox_.isEmpty()) { \
00435 const int *_th_plo = loVect(); \
00436 const int *_th_plen = size(); \
00437 const int *_x_plo = (x).loVect(); \
00438 const int *_x_plen = (x).size(); \
00439 const int *_y_plo = (y).loVect(); \
00440 const int *_y_plen = (y).size(); \
00441 const int *_subbox_lo = _subbox_.loVect(); \
00442 const int *_subbox_len = _subbox_.size().getVect(); \
00443 const int *_bx_lo = (bx).loVect(); \
00444 const int *_by_lo = (by).loVect(); \
00445 T* _th_p = dataPtr(ns); \
00446 const T* _x_p = (x).dataPtr(nsx); \
00447 const T* _y_p = (y).dataPtr(nsy); \
00448 for(int _n = 0; _n < (nc); ++_n) { \
00449 int nR = _n + ns; nR += 0; \
00450 int n##x##R = _n + nsx; n##x##R += 0; \
00451 int n##y##R = _n + nsy; n##y##R += 0; \
00452 T *_th_pp = _th_p \
00453 + ((_subbox_lo[0] - _th_plo[0]) \
00454 + _n * _th_plen[0]); \
00455 const T *_x_pp = _x_p \
00456 + ((_bx_lo[0] - _x_plo[0]) \
00457 + _n * _x_plen[0]); \
00458 const T *_y_pp = _y_p \
00459 + ((_by_lo[0] - _y_plo[0]) \
00460 + _n * _y_plen[0]); \
00461 for(int _i = 0; _i < _subbox_len[0]; ++_i, ++_th_pp) { \
00462 int iR = _i + _subbox_lo[0]; iR += 0; \
00463 int i##x##R = _i + _bx_lo[0]; i##x##R += 0; \
00464 int i##y##R = _i + _by_lo[0]; i##y##R += 0; \
00465 T &thisR = * _th_pp; \
00466 const T & x##R = _x_pp[_i]; \
00467 const T & y##R = _y_pp[_i];
00468
00469 #define ForAllRevXBNYCBNNN(T,x,bx,nsx,y,by,nsy,nc,ri) \
00470 { \
00471 assert((nsx) >= 0 && (nsx) + (nc) <= (x).nComp()); \
00472 assert((nsy) >= 0 && (nsy) + (nc) <= (y).nComp()); \
00473 assert((x).contains(bx)); \
00474 assert((y).contains(by)); \
00475 assert((bx).sameSize(by)); \
00476 const int *_x_plo = (x).loVect(); \
00477 const int *_x_plen = (x).size(); \
00478 const int *_y_plo = (y).loVect(); \
00479 const int *_y_plen = (y).size(); \
00480 const int *_len = (bx).size().getVect(); \
00481 const int *_bx_lo = (bx).loVect(); \
00482 const int *_by_lo = (by).loVect(); \
00483 T* _x_p = (x).dataPtr(nsx); \
00484 const T* _y_p = (y).dataPtr(nsy); \
00485 for(int _n = 0; _n < (nc); ++_n) { \
00486 int n##x##R = _n + nsx; n##x##R += 0; \
00487 int n##y##R = _n + nsy; n##y##R += 0; \
00488 int _ix = 0; \
00489 T *_x_pp = _x_p \
00490 + ((_bx_lo[0] - _x_plo[0]) + _len[0] - 1 \
00491 + _n * _x_plen[0]); \
00492 const T *_y_pp = _y_p \
00493 + ((_by_lo[0] - _y_plo[0]) \
00494 + _n * _y_plen[0]); \
00495 for(int _i = 0; _i < _len[0]; ++_i, --_ix) { \
00496 T & x##R = _x_pp[_ix]; \
00497 const T & y##R = _y_pp[_i];
00498
00499 /*@ManDoc:
00500 The macro EndForTX must be used to end all ForAllThisBNNXC,
00501 ForAllThisBNNXCBN and ForAllThisBNNXCBNYCBN looping constructs.
00502 */
00503 #define EndForTX }}}}
00504
00505 /*@ManDoc:
00506 The macro EndFor must be used to end all ForAllXBNN, ForAllXCBNN,
00507 ForAllThisBNN, and ForAllThisCBNN looping constructs.
00508 */
00509 #define EndFor }}}
00510
00511 /*@ManDoc:
00512 The macro EndForPencil must be used to end ForAll*Pencil looping constructs.
00513 */
00514 #define EndForPencil }}
00515
00516 #elif (CH_SPACEDIM == 2)
00517
00518 #define ForAllThisCPencil(T,b,ns,nc) \
00519 { \
00520 assert(contains(b)); \
00521 assert((ns) >= 0 && (ns) + (nc) <= nComp()); \
00522 const int *_th_plo = loVect(); \
00523 const int *_th_plen = size(); \
00524 const int *_b_lo = (b).loVect(); \
00525 const int *_b_len = (b).size().getVect(); \
00526 const T* _th_p = dptr; \
00527 for(int _n = (ns); _n < (ns)+(nc); ++_n) { \
00528 int nR = _n; nR += 0; \
00529 for(int _j = 0; _j < _b_len[1]; ++_j) { \
00530 const int jR = _j + _b_lo[1]; \
00531 const T *_th_pp = _th_p \
00532 + ((_b_lo[0] - _th_plo[0]) \
00533 + _th_plen[0]*( \
00534 (jR - _th_plo[1]) \
00535 + _n * _th_plen[1])); \
00536 const T &thisR = * _th_pp; \
00537 const int thisLen = _b_len[0];
00538
00539 #define ForAllThisPencil(T,b,ns,nc) \
00540 { \
00541 assert(contains(b)); \
00542 assert((ns) >= 0 && (ns) + (nc) <= nComp()); \
00543 const int *_th_plo = loVect(); \
00544 const int *_th_plen = size(); \
00545 const int *_b_lo = (b).loVect(); \
00546 const int *_b_len = (b).size().getVect(); \
00547 T* _th_p = dptr; \
00548 for(int _n = (ns); _n < (ns)+(nc); ++_n) { \
00549 const int nR = _n; \
00550 for(int _j = 0; _j < _b_len[1]; ++_j) { \
00551 const int jR = _j + _b_lo[1]; \
00552 T *_th_pp = _th_p \
00553 + ((_b_lo[0] - _th_plo[0]) \
00554 + _th_plen[0]*( \
00555 (jR - _th_plo[1]) \
00556 + _n * _th_plen[1])); \
00557 T &thisR = * _th_pp; \
00558 const int thisLen = _b_len[0]; \
00559
00560 #define ForAllXBPencil(T,x,b,ns,nc) \
00561 { \
00562 assert((x).contains(b)); \
00563 assert((ns) >= 0 && (ns) + (nc) <= (x).nComp()); \
00564 const int *_th_plo = (x).loVect(); \
00565 const int *_th_plen =(x).size(); \
00566 const int *_b_lo = (b).loVect(); \
00567 const int *_b_len = (b).size().getVect(); \
00568 T* _th_p = (x) .dataPtr(); \
00569 for(int nR = (ns); nR < (ns)+(nc); ++nR) { \
00570 for(int _j = 0; _j < _b_len[1]; ++_j) { \
00571 const int jR = _j + _b_lo[1]; \
00572 T *xR = _th_p \
00573 + ((_b_lo[0] - _th_plo[0]) \
00574 + _th_plen[0]*( \
00575 (jR - _th_plo[1]) \
00576 + nR * _th_plen[1])); \
00577 const int thisLen = _b_len[0]; \
00578
00579 #define ForAllXBNN(T,x,b,ns,nc) \
00580 { \
00581 assert((x).contains(b)); \
00582 assert((ns) >= 0 && (ns) + (nc) <= (x).nComp()); \
00583 const int *_x_plo = (x).loVect(); \
00584 const int *_x_plen = (x).size(); \
00585 const int *_b_lo = (b).loVect(); \
00586 const int *_b_len = (b).size().getVect(); \
00587 T* _x_p = (x) .dataPtr(); \
00588 for(int _n = (ns); _n < (ns)+(nc); ++_n) { \
00589 const int nR = _n; \
00590 for(int _j = 0; _j < _b_len[1]; ++_j) { \
00591 const int jR = _j + _b_lo[1]; \
00592 T *_x_pp = _x_p \
00593 + ((_b_lo[0] - _x_plo[0]) \
00594 + _x_plen[0]*( \
00595 (jR - _x_plo[1]) \
00596 + _n * _x_plen[1])); \
00597 for(int _i = 0; _i < _b_len[0]; ++_i, ++_x_pp) { \
00598 const int iR = _i + _b_lo[0]; \
00599 T &x##R = * _x_pp;
00600
00601 #define ForAllXCBNN(T,x,b,ns,nc) \
00602 { \
00603 assert(x.contains(b)); \
00604 assert((ns) >= 0 && (ns) + (nc) <= (x).nComp()); \
00605 const int *_x_plo = (x).loVect(); \
00606 const int *_x_plen = (x).size(); \
00607 const int *_b_lo = (b).loVect(); \
00608 const int *_b_len = (b).size().getVect(); \
00609 const T* _x_p = (x).dataPtr(); \
00610 for(int _n = (ns); _n < (ns)+(nc); ++_n) { \
00611 const int nR = _n; \
00612 for(int _j = 0; _j < _b_len[1]; ++_j) { \
00613 const int jR = _j + _b_lo[1]; \
00614 const T *_x_pp = _x_p \
00615 + ((_b_lo[0] - _x_plo[0]) \
00616 + _x_plen[0]*( \
00617 (jR - _x_plo[1]) \
00618 + _n * _x_plen[1])); \
00619 for(int _i = 0; _i < _b_len[0]; ++_i) { \
00620 const int iR = _i + _b_lo[0]; \
00621 const T & x##R = _x_pp[_i];
00622
00623
00624 #define ForAllThisBNN(T,b,ns,nc) \
00625 { \
00626 assert(contains(b)); \
00627 assert((ns) >= 0 && (ns) + (nc) <= nComp()); \
00628 const int *_th_plo = loVect(); \
00629 const int *_th_plen = size(); \
00630 const int *_b_lo = (b).loVect(); \
00631 const int *_b_len = (b).size().getVect(); \
00632 T* _th_p = dptr; \
00633 for(int _n = (ns); _n < (ns)+(nc); ++_n) { \
00634 int nR = _n; nR += 0; \
00635 for(int _j = 0; _j < _b_len[1]; ++_j) { \
00636 const int jR = _j + _b_lo[1]; \
00637 T *_th_pp = _th_p \
00638 + ((_b_lo[0] - _th_plo[0]) \
00639 + _th_plen[0]*( \
00640 (jR - _th_plo[1]) \
00641 + _n * _th_plen[1])); \
00642 for(int _i = 0; _i < _b_len[0]; ++_i, ++_th_pp) { \
00643 int iR = _i + _b_lo[0]; iR += 0; \
00644 T &thisR = * _th_pp;
00645
00646 #define ForAllThisCBNN(T,b,ns,nc) \
00647 { \
00648 assert(contains(b)); \
00649 assert((ns) >= 0 && (ns) + (nc) <= nComp()); \
00650 const int *_th_plo = loVect(); \
00651 const int *_th_plen = size(); \
00652 const int *_b_lo = (b).loVect(); \
00653 const int *_b_len = (b).size().getVect(); \
00654 const T* _th_p = dptr; \
00655 for(int _n = (ns); _n < (ns)+(nc); ++_n) { \
00656 const int nR = _n; \
00657 for(int _j = 0; _j < _b_len[1]; ++_j) { \
00658 const int jR = _j + _b_lo[1]; \
00659 const T *_th_pp = _th_p \
00660 + ((_b_lo[0] - _th_plo[0]) \
00661 + _th_plen[0]*( \
00662 (_j + _b_lo[1] - _th_plo[1]) \
00663 + _n * _th_plen[1])); \
00664 for(int _i = 0; _i < _b_len[0]; ++_i) { \
00665 const int iR = _i + _b_lo[0]; \
00666 const T &thisR = _th_pp[_i];
00667
00668 #define ForAllThisBNNXC(T,b,ns,nc,x,nss) \
00669 { \
00670 assert((ns) >= 0 && (ns) + (nc) <= nComp()); \
00671 assert((nss) >= 0 && (nss) + (nc) <= (x).nComp()); \
00672 Box _subbox_((x).box()); \
00673 _subbox_ &= box(); \
00674 _subbox_ &= b; \
00675 if(!_subbox_.isEmpty()) { \
00676 const int *_th_plo = loVect(); \
00677 const int *_th_plen = size(); \
00678 const int *_x_plo = (x).loVect(); \
00679 const int *_x_plen = (x).size(); \
00680 const int *_subbox_lo = _subbox_.loVect(); \
00681 const int *_subbox_len = _subbox_.size().getVect(); \
00682 T* _th_p = dataPtr(ns); \
00683 const T* _x_p = (x).dataPtr(nss); \
00684 for(int _n = 0; _n < (nc); ++_n) { \
00685 int nR = _n; nR += 0; \
00686 for(int _j = 0; _j < _subbox_len[1]; ++_j) { \
00687 const int jR = _j + _subbox_lo[1]; \
00688 T *_th_pp = _th_p \
00689 + ((_subbox_lo[0] - _th_plo[0]) \
00690 + _th_plen[0]*( \
00691 (jR - _th_plo[1]) \
00692 + _n * _th_plen[1])); \
00693 const T *_x_pp = _x_p \
00694 + ((_subbox_lo[0] - _x_plo[0]) \
00695 + _x_plen[0]*( \
00696 (jR - _x_plo[1]) \
00697 + _n * _x_plen[1])); \
00698 for(int _i = 0; _i < _subbox_len[0]; ++_i, ++_th_pp) { \
00699 int iR = _i + _subbox_lo[0]; iR += 0; \
00700 T &thisR = * _th_pp; const T & x##R = _x_pp[_i];
00701
00702 #define ForAllThisBNNXCBN(T,b,ns,nc,x,bx,nss) \
00703 { \
00704 assert((ns) >= 0 && (ns) + (nc) <= nComp()); \
00705 assert((nss) >= 0 && (nss) + (nc) <= (x).nComp()); \
00706 assert(bx.sameSize((b))); \
00707 if(!((b).isEmpty())) { \
00708 const int *_th_plo = loVect(); \
00709 const int *_th_plen = size(); \
00710 const int *_x_plo = (x).loVect(); \
00711 const int *_x_plen = (x).size(); \
00712 const int *_subbox_lo = (b).loVect(); \
00713 const int *_subbox_len = (b).size().getVect(); \
00714 const int *_bx_lo = (bx).loVect(); \
00715 T* _th_p = dataPtr(ns); \
00716 int nR = ns; int n##x##R = nss; \
00717 const T* _x_p = (x).dataPtr(nss); \
00718 for(int _n = 0; _n < (nc); ++_n, ++nR, ++n##x##R ) { \
00719 for(int _j = 0; _j < _subbox_len[1]; ++_j) { \
00720 const int jR = _j + _subbox_lo[1]; \
00721 const int j##x##R = _j + _bx_lo[1]; \
00722 T *_th_pp = _th_p \
00723 + ((_subbox_lo[0] - _th_plo[0]) \
00724 + _th_plen[0]*( \
00725 (jR - _th_plo[1]) \
00726 + _n * _th_plen[1])); \
00727 const T *_x_pp = _x_p \
00728 + ((_bx_lo[0] - _x_plo[0]) \
00729 + _x_plen[0]*( \
00730 (j##x##R - _x_plo[1]) \
00731 + _n * _x_plen[1])); \
00732 int iR = _subbox_lo[0]; int i##x##R = _bx_lo[0]; \
00733 for(int _i = 0; _i < _subbox_len[0]; ++_i, ++_th_pp, ++_x_pp, ++iR, ++i##x##R) { \
00734 T &thisR = * _th_pp; const T & x##R = * _x_pp;
00735
00736 #define ForAllThisBNNXCBNYCBN(T,b,ns,nc,x,bx,nsx,y,by,nsy) \
00737 { \
00738 assert((ns) >= 0 && (ns) + (nc) <= nComp()); \
00739 assert((nsx) >= 0 && (nsx) + (nc) <= (x).nComp()); \
00740 assert((nsy) >= 0 && (nsy) + (nc) <= (y).nComp()); \
00741 Box _subbox_ = box(); \
00742 _subbox_ &= b; \
00743 assert((bx).sameSize(_subbox_)); \
00744 assert((by).sameSize(_subbox_)); \
00745 if(!_subbox_.isEmpty()) { \
00746 const int *_th_plo = loVect(); \
00747 const int *_th_plen = size(); \
00748 const int *_x_plo = (x).loVect(); \
00749 const int *_x_plen = (x).size(); \
00750 const int *_y_plo = (y).loVect(); \
00751 const int *_y_plen = (y).size(); \
00752 const int *_subbox_lo = _subbox_.loVect(); \
00753 const int *_subbox_len = _subbox_.size().getVect(); \
00754 const int *_bx_lo = (bx).loVect(); \
00755 const int *_by_lo = (by).loVect(); \
00756 T* _th_p = dataPtr(ns); \
00757 const T* _x_p = (x).dataPtr(nsx); \
00758 const T* _y_p = (y).dataPtr(nsy); \
00759 for(int _n = 0; _n < (nc); ++_n) { \
00760 int nR = _n + ns; nR += 0; \
00761 int n##x##R = _n + nsx; n##x##R += 0; \
00762 int n##y##R = _n + nsy; n##y##R += 0; \
00763 for(int _j = 0; _j < _subbox_len[1]; ++_j) { \
00764 const int jR = _j + _subbox_lo[1]; \
00765 const int j##x##R = _j + _bx_lo[1]; \
00766 const int j##y##R = _j + _by_lo[1]; \
00767 T *_th_pp = _th_p \
00768 + ((_subbox_lo[0] - _th_plo[0]) \
00769 + _th_plen[0]*( \
00770 (jR - _th_plo[1]) \
00771 + _n * _th_plen[1])); \
00772 const T *_x_pp = _x_p \
00773 + ((_bx_lo[0] - _x_plo[0]) \
00774 + _x_plen[0]*( \
00775 (j##x##R - _x_plo[1]) \
00776 + _n * _x_plen[1])); \
00777 const T *_y_pp = _y_p \
00778 + ((_by_lo[0] - _y_plo[0]) \
00779 + _y_plen[0]*( \
00780 (j##y##R - _y_plo[1]) \
00781 + _n * _y_plen[1])); \
00782 for(int _i = 0; _i < _subbox_len[0]; ++_i, ++_th_pp) { \
00783 int iR = _i + _subbox_lo[0]; iR += 0; \
00784 int i##x##R = _i + _bx_lo[0]; i##x##R += 0; \
00785 int i##y##R = _i + _by_lo[0]; i##y##R += 0; \
00786 T &thisR = * _th_pp; \
00787 const T & x##R = _x_pp[_i]; \
00788 const T & y##R = _y_pp[_i];
00789
00790 #define ForAllRevXBNYCBNNN(T,x,bx,nsx,y,by,nsy,nc,ir) \
00791 { \
00792 assert((nsx) >= 0 && (nsx) + (nc) <= (x).nComp()); \
00793 assert((nsy) >= 0 && (nsy) + (nc) <= (y).nComp()); \
00794 assert((ir) >= 0 && (ir) < SpaceDim); \
00795 assert((x).contains(bx)); \
00796 assert((y).contains(by)); \
00797 assert((bx).sameSize(by)); \
00798 const int *_x_plo = (x).loVect(); \
00799 const int *_x_plen = (x).size(); \
00800 const int *_y_plo = (y).loVect(); \
00801 const int *_y_plen = (y).size(); \
00802 const int *_bx_lo = (bx).loVect(); \
00803 const int *_by_lo = (by).loVect(); \
00804 const int *_len = (bx).size().getVect(); \
00805 T* _x_p = (x).dataPtr(nsx); \
00806 const T* _y_p = (y).dataPtr(nsy); \
00807 for(int _n = 0; _n < (nc); ++_n) { \
00808 int n##x##R = _n + nsx; n##x##R += 0; \
00809 int n##y##R = _n + nsy; n##y##R += 0; \
00810 for(int _j = 0; _j < _len[1]; ++_j) { \
00811 const int j##x##R = _j + _bx_lo[1]; \
00812 const int jrev##x##R = _len[1]-1-_j + _bx_lo[1]; \
00813 const int j##y##R = _j + _by_lo[1]; \
00814 T *_x_pp; \
00815 int _ix = 0; \
00816 int _istrd; \
00817 if (ir == 0) { \
00818 _x_pp = _x_p \
00819 + ((_bx_lo[0] - _x_plo[0]) + _len[0] - 1 \
00820 + _x_plen[0]*( \
00821 (j##x##R - _x_plo[1]) \
00822 + _n * _x_plen[1])); \
00823 _istrd = -1; \
00824 } else { \
00825 _x_pp = _x_p \
00826 + ((_bx_lo[0] - _x_plo[0]) \
00827 + _x_plen[0]*( \
00828 (jrev##x##R - _x_plo[1]) \
00829 + _n * _x_plen[1])); \
00830 _istrd = 1; \
00831 } \
00832 const T *_y_pp = _y_p \
00833 + ((_by_lo[0] - _y_plo[0]) \
00834 + _y_plen[0]*( \
00835 (j##y##R - _y_plo[1]) \
00836 + _n * _y_plen[1])); \
00837 int _x_rev = _len[0]-1; _x_rev += 0; \
00838 for(int _i = 0; _i < _len[0]; ++_i, _ix+=_istrd) { \
00839 T & x##R = _x_pp[_ix]; \
00840 const T & y##R = _y_pp[_i];
00841
00842
00843 #define EndFor }}}}
00844 #define EndForTX }}}}}
00845 #define EndForPencil }}}
00846
00847 #elif (CH_SPACEDIM == 3)
00848
00849 #define ForAllThisCPencil(T,b,ns,nc) \
00850 { \
00851 assert(contains(b)); \
00852 assert((ns) >= 0 && (ns) + (nc) <= nComp()); \
00853 const int *_th_plo = loVect(); \
00854 const int *_th_plen = size(); \
00855 const int *_b_lo = (b).loVect(); \
00856 const int *_b_len = (b).size().getVect(); \
00857 const T* _th_p = dptr; \
00858 for(int _n = (ns); _n < (ns)+(nc); ++_n) { \
00859 int nR = _n; nR += 0; \
00860 for(int _k = 0; _k < _b_len[2]; ++_k) { \
00861 const int kR = _k + _b_lo[2]; \
00862 for(int _j = 0; _j < _b_len[1]; ++_j) { \
00863 const int jR = _j + _b_lo[1]; \
00864 const T *_th_pp = _th_p \
00865 + ((_b_lo[0] - _th_plo[0]) \
00866 + _th_plen[0]*( \
00867 (jR - _th_plo[1]) \
00868 + _th_plen[1]*( \
00869 (kR - _th_plo[2]) \
00870 + _n * _th_plen[2]))); \
00871 const T &thisR = * _th_pp; \
00872 const int thisLen = _b_len[0];
00873
00874 #define ForAllThisPencil(T,b,ns,nc) \
00875 { \
00876 assert(contains(b)); \
00877 assert((ns) >= 0 && (ns) + (nc) <= nComp()); \
00878 const int *_th_plo = loVect(); \
00879 const int *_th_plen = size(); \
00880 const int *_b_lo = (b).loVect(); \
00881 const int *_b_len = (b).size().getVect(); \
00882 T* _th_p = dptr; \
00883 for(int _n = (ns); _n < (ns)+(nc); ++_n) { \
00884 const int nR = _n; \
00885 for(int _k = 0; _k < _b_len[2]; ++_k) { \
00886 const int kR = _k + _b_lo[2]; \
00887 for(int _j = 0; _j < _b_len[1]; ++_j) { \
00888 const int jR = _j + _b_lo[1]; \
00889 T *_th_pp = _th_p \
00890 + ((_b_lo[0] - _th_plo[0]) \
00891 + _th_plen[0]*( \
00892 (jR - _th_plo[1]) \
00893 + _th_plen[1]*( \
00894 (kR - _th_plo[2]) \
00895 + _n * _th_plen[2]))); \
00896 T &thisR = * _th_pp; \
00897 const int thisLen = _b_len[0]; \
00898
00899 #define ForAllXBPencil(T,x,b,ns,nc) \
00900 { \
00901 assert((x).contains(b)); \
00902 assert((ns) >= 0 && (ns) + (nc) <= (x).nComp()); \
00903 const int *_th_plo = (x).loVect(); \
00904 const int *_th_plen = (x).size(); \
00905 const int *_b_lo = (b).loVect(); \
00906 const int *_b_len = (b).size().getVect(); \
00907 T* _th_p = (x) .dataPtr(); \
00908 for(int nR = (ns); nR < (ns)+(nc); ++nR) { \
00909 for(int _k = 0; _k < _b_len[2]; ++_k) { \
00910 const int kR = _k + _b_lo[2]; \
00911 for(int _j = 0; _j < _b_len[1]; ++_j) { \
00912 const int jR = _j + _b_lo[1]; \
00913 T *xR = _th_p \
00914 + ((_b_lo[0] - _th_plo[0]) \
00915 + _th_plen[0]*( \
00916 (jR - _th_plo[1]) \
00917 + _th_plen[1]*( \
00918 (kR - _th_plo[2]) \
00919 + nR * _th_plen[2]))); \
00920 const int thisLen = _b_len[0];
00921
00922
00923 #define ForAllXBNN(T,x,b,ns,nc) \
00924 { \
00925 assert(x.contains(b)); \
00926 assert((ns) >= 0 && (ns) + (nc) <= (x).nComp()); \
00927 const int *_x_plo = (x).loVect(); \
00928 const int *_x_plen = (x).size(); \
00929 const int *_b_lo = (b).loVect(); \
00930 const int *_b_len = (b).size().getVect(); \
00931 T* _x_p = (x) .dataPtr(); \
00932 for(int _n = (ns); _n < (ns)+(nc); ++_n) { \
00933 const int nR = _n; \
00934 for(int _k = 0; _k < _b_len[2]; ++_k) { \
00935 const int kR = _k + _b_lo[2]; \
00936 for(int _j = 0; _j < _b_len[1]; ++_j) { \
00937 const int jR = _j + _b_lo[1]; \
00938 T *_x_pp = _x_p \
00939 + ((_b_lo[0] - _x_plo[0]) \
00940 + _x_plen[0]*( \
00941 (jR - _x_plo[1]) \
00942 + _x_plen[1]*( \
00943 (kR - _x_plo[2]) \
00944 + _n * _x_plen[2]))); \
00945 for(int _i = 0; _i < _b_len[0]; ++_i, ++_x_pp) { \
00946 const int iR = _i + _b_lo[0]; \
00947 T &x##R = * _x_pp;
00948
00949 #define ForAllXCBNN(T,x,b,ns,nc) \
00950 { \
00951 assert(x.contains(b)); \
00952 assert((ns) >= 0 && (ns) + (nc) <= (x).nComp()); \
00953 const int *_x_plo = (x).loVect(); \
00954 const int *_x_plen = (x).size(); \
00955 const int *_b_lo = (b).loVect(); \
00956 const int *_b_len = (b).size().getVect(); \
00957 const T* _x_p = (x).dataPtr(); \
00958 for(int _n = (ns); _n < (ns)+(nc); ++_n) { \
00959 const int nR = _n; \
00960 for(int _k = 0; _k < _b_len[2]; ++_k) { \
00961 const int kR = _k + _b_lo[2]; \
00962 for(int _j = 0; _j < _b_len[1]; ++_j) { \
00963 const int jR = _j + _b_lo[1]; \
00964 const T *_x_pp = _x_p \
00965 + ((_b_lo[0] - _x_plo[0]) \
00966 + _x_plen[0]*( \
00967 (jR - _x_plo[1]) \
00968 + _x_plen[1]*( \
00969 (kR - _x_plo[2]) \
00970 + _n * _x_plen[2]))); \
00971 for(int _i = 0; _i < _b_len[0]; ++_i) { \
00972 const int iR = _i + _b_lo[0]; \
00973 const T & x##R = _x_pp[_i];
00974
00975
00976 #define ForAllThisBNN(T,b,ns,nc) \
00977 { \
00978 assert(contains(b)); \
00979 assert((ns) >= 0 && (ns) + (nc) <= nComp()); \
00980 const int *_th_plo = loVect(); \
00981 const int *_th_plen = size(); \
00982 const int *_b_lo = (b).loVect(); \
00983 const int *_b_len = (b).size().getVect(); \
00984 T* _th_p = dptr; \
00985 for(int _n = (ns); _n < (ns)+(nc); ++_n) { \
00986 int nR = _n; nR += 0; \
00987 for(int _k = 0; _k < _b_len[2]; ++_k) { \
00988 const int kR = _k + _b_lo[2]; \
00989 for(int _j = 0; _j < _b_len[1]; ++_j) { \
00990 const int jR = _j + _b_lo[1]; \
00991 T *_th_pp = _th_p \
00992 + ((_b_lo[0] - _th_plo[0]) \
00993 + _th_plen[0]*( \
00994 (jR - _th_plo[1]) \
00995 + _th_plen[1]*( \
00996 (kR - _th_plo[2]) \
00997 + _n * _th_plen[2]))); \
00998 for(int _i = 0; _i < _b_len[0]; ++_i, ++_th_pp) { \
00999 int iR = _i + _b_lo[0]; iR += 0; \
01000 T &thisR = * _th_pp;
01001
01002 #define ForAllThisCBNN(T,b,ns,nc) \
01003 { \
01004 assert(contains(b)); \
01005 assert((ns) >= 0 && (ns) + (nc) <= nComp()); \
01006 const int *_th_plo = loVect(); \
01007 const int *_th_plen = size(); \
01008 const int *_b_lo = (b).loVect(); \
01009 const int *_b_len = (b).size().getVect(); \
01010 const T* _th_p = dptr; \
01011 for(int _n = (ns); _n < (ns)+(nc); ++_n) { \
01012 const int nR = _n; \
01013 for(int _k = 0; _k < _b_len[2]; ++_k) { \
01014 const int kR = _k + _b_lo[2]; \
01015 for(int _j = 0; _j < _b_len[1]; ++_j) { \
01016 const int jR = _j + _b_lo[1]; \
01017 const T *_th_pp = _th_p \
01018 + ((_b_lo[0] - _th_plo[0]) \
01019 + _th_plen[0]*( \
01020 (jR - _th_plo[1]) \
01021 + _th_plen[1]*( \
01022 (kR - _th_plo[2]) \
01023 + _n * _th_plen[2]))); \
01024 for(int _i = 0; _i < _b_len[0]; ++_i) { \
01025 const int iR = _i + _b_lo[0]; \
01026 const T &thisR = _th_pp[_i];
01027
01028 #define ForAllThisBNNXC(T,b,ns,nc,x,nss) \
01029 { \
01030 assert((ns) >= 0 && (ns) + (nc) <= nComp()); \
01031 assert((nss) >= 0 && (nss) + (nc) <= (x).nComp()); \
01032 Box _subbox_((x).box()); \
01033 _subbox_ &= box(); \
01034 _subbox_ &= b; \
01035 if(!_subbox_.isEmpty()) { \
01036 const int *_th_plo = loVect(); \
01037 const int *_th_plen = size(); \
01038 const int *_x_plo = (x).loVect(); \
01039 const int *_x_plen = (x).size(); \
01040 const int *_subbox_lo = _subbox_.loVect(); \
01041 const int *_subbox_len = _subbox_.size().getVect(); \
01042 T* _th_p = dataPtr(ns); \
01043 const T* _x_p = (x).dataPtr(nss); \
01044 for(int _n = 0; _n < (nc); ++_n) { \
01045 int nR = _n; nR += 0; \
01046 for(int _k = 0; _k < _subbox_len[2]; ++_k) { \
01047 const int kR = _k + _subbox_lo[2]; \
01048 for(int _j = 0; _j < _subbox_len[1]; ++_j) { \
01049 const int jR = _j + _subbox_lo[1]; \
01050 T *_th_pp = _th_p \
01051 + ((_subbox_lo[0] - _th_plo[0]) \
01052 + _th_plen[0]*( \
01053 (jR - _th_plo[1]) \
01054 + _th_plen[1]*( \
01055 (kR - _th_plo[2]) \
01056 + _n * _th_plen[2]))); \
01057 const T *_x_pp = _x_p \
01058 + ((_subbox_lo[0] - _x_plo[0]) \
01059 + _x_plen[0]*( \
01060 (jR - _x_plo[1]) \
01061 + _x_plen[1]*( \
01062 (kR - _x_plo[2]) \
01063 + _n * _x_plen[2]))); \
01064 for(int _i = 0; _i < _subbox_len[0]; ++_i, ++_th_pp) { \
01065 int iR = _i + _subbox_lo[0]; iR += 0; \
01066 T &thisR = * _th_pp; const T & x##R = _x_pp[_i];
01067
01068 #define ForAllThisBNNXCBN(T,b,ns,nc,x,bx,nss) \
01069 { \
01070 assert((ns) >= 0 && (ns) + (nc) <= nComp()); \
01071 assert((nss) >= 0 && (nss) + (nc) <= (x).nComp()); \
01072 assert((bx).sameSize((b))); \
01073 if(!((b).isEmpty())) { \
01074 const int *_th_plo = loVect(); \
01075 const int *_th_plen = size(); \
01076 const int *_x_plo = (x).loVect(); \
01077 const int *_x_plen = (x).size(); \
01078 const int *_subbox_lo = (b).loVect(); \
01079 const int *_subbox_len = (b).size().getVect(); \
01080 const int *_bx_lo = (bx).loVect(); \
01081 T* _th_p = dataPtr(ns); \
01082 const T* _x_p = (x).dataPtr(nss); \
01083 for(int _n = 0; _n < (nc); ++_n) { \
01084 int nR = _n + ns; nR += 0; \
01085 int n##x##R = _n + nss; n##x##R += 0; \
01086 for(int _k = 0; _k < _subbox_len[2]; ++_k) { \
01087 const int kR = _k + _subbox_lo[2]; \
01088 const int k##x##R = _k + _bx_lo[2]; \
01089 for(int _j = 0; _j < _subbox_len[1]; ++_j) { \
01090 const int jR = _j + _subbox_lo[1]; \
01091 const int j##x##R = _j + _bx_lo[1]; \
01092 T *_th_pp = _th_p \
01093 + ((_subbox_lo[0] - _th_plo[0]) \
01094 + _th_plen[0]*( \
01095 (jR - _th_plo[1]) \
01096 + _th_plen[1]*( \
01097 (kR - _th_plo[2]) \
01098 + _n * _th_plen[2]))); \
01099 const T *_x_pp = _x_p \
01100 + ((_bx_lo[0] - _x_plo[0]) \
01101 + _x_plen[0]*( \
01102 (j##x##R - _x_plo[1]) \
01103 + _x_plen[1]*( \
01104 (k##x##R - _x_plo[2]) \
01105 + _n * _x_plen[2]))); \
01106 for(int _i = 0; _i < _subbox_len[0]; ++_i, ++_th_pp) { \
01107 int iR = _i + _subbox_lo[0]; iR += 0; \
01108 int i##x##R = _i + _bx_lo[0]; i##x##R += 0; \
01109 T &thisR = * _th_pp; const T & x##R = _x_pp[_i];
01110
01111 #define ForAllThisBNNXCBNYCBN(T,b,ns,nc,x,bx,nsx,y,by,nsy) \
01112 { \
01113 assert((ns) >= 0 && (ns) + (nc) <= nComp()); \
01114 assert((nsx) >= 0 && (nsx) + (nc) <= (x).nComp()); \
01115 assert((nsy) >= 0 && (nsy) + (nc) <= (y).nComp()); \
01116 Box _subbox_(box()); \
01117 _subbox_ &= b; \
01118 assert((bx).sameSize(_subbox_)); \
01119 assert((by).sameSize(_subbox_)); \
01120 if(!_subbox_.isEmpty()) { \
01121 const int *_th_plo = loVect(); \
01122 const int *_th_plen = size(); \
01123 const int *_x_plo = (x).loVect(); \
01124 const int *_x_plen = (x).size(); \
01125 const int *_y_plo = (y).loVect(); \
01126 const int *_y_plen = (y).size(); \
01127 const int *_subbox_lo = _subbox_.loVect(); \
01128 const int *_subbox_len = _subbox_.size().getVect(); \
01129 const int *_bx_lo = (bx).loVect(); \
01130 const int *_by_lo = (by).loVect(); \
01131 T* _th_p = dataPtr(ns); \
01132 const T* _x_p = (x).dataPtr(nsx); \
01133 const T* _y_p = (y).dataPtr(nsy); \
01134 for(int _n = 0; _n < (nc); ++_n) { \
01135 int nR = _n + ns; nR += 0; \
01136 int n##x##R = _n + nsx; n##x##R += 0; \
01137 int n##y##R = _n + nsy; n##y##R += 0; \
01138 for(int _k = 0; _k < _subbox_len[2]; ++_k) { \
01139 const int kR = _k + _subbox_lo[2]; \
01140 const int k##x##R = _k + _bx_lo[2]; \
01141 const int k##y##R = _k + _by_lo[2]; \
01142 for(int _j = 0; _j < _subbox_len[1]; ++_j) { \
01143 const int jR = _j + _subbox_lo[1]; \
01144 const int j##x##R = _j + _bx_lo[1]; \
01145 const int j##y##R = _j + _by_lo[1]; \
01146 T *_th_pp = _th_p \
01147 + ((_subbox_lo[0] - _th_plo[0]) \
01148 + _th_plen[0]*( \
01149 (jR - _th_plo[1]) \
01150 + _th_plen[1]*( \
01151 (kR - _th_plo[2]) \
01152 + _n * _th_plen[2]))); \
01153 const T *_x_pp = _x_p \
01154 + ((_bx_lo[0] - _x_plo[0]) \
01155 + _x_plen[0]*( \
01156 (j##x##R - _x_plo[1]) \
01157 + _x_plen[1]*( \
01158 (k##x##R - _x_plo[2]) \
01159 + _n * _x_plen[2]))); \
01160 const T *_y_pp = _y_p \
01161 + ((_by_lo[0] - _y_plo[0]) \
01162 + _y_plen[0]*( \
01163 (j##y##R - _y_plo[1]) \
01164 + _y_plen[1]*( \
01165 (k##y##R - _y_plo[2]) \
01166 + _n * _y_plen[2]))); \
01167 for(int _i = 0; _i < _subbox_len[0]; ++_i, ++_th_pp) { \
01168 int iR = _i + _subbox_lo[0]; iR += 0; \
01169 int i##x##R = _i + _bx_lo[0]; i##x##R += 0; \
01170 int i##y##R = _i + _by_lo[0]; i##y##R += 0; \
01171 T &thisR = * _th_pp; \
01172 const T & x##R = _x_pp[_i]; \
01173 const T & y##R = _y_pp[_i];
01174
01175 #define ForAllRevXBNYCBNNN(T,x,bx,nsx,y,by,nsy,nc,ir) \
01176 { \
01177 assert((ir) >= 0 && (ir) < SpaceDim); \
01178 assert((nsx) >= 0 && (nsx) + (nc) <= (x).nComp()); \
01179 assert((nsy) >= 0 && (nsy) + (nc) <= (y).nComp()); \
01180 assert((x).contains(bx)); \
01181 assert((y).contains(by)); \
01182 assert((bx).sameSize(by)); \
01183 const int *_x_plo = (x).loVect(); \
01184 const int *_x_plen = (x).size(); \
01185 const int *_y_plo = (y).loVect(); \
01186 const int *_y_plen = (y).size(); \
01187 const int *_bx_lo = (bx).loVect(); \
01188 const int *_by_lo = (by).loVect(); \
01189 const int *_len = (bx).size().getVect(); \
01190 T* _x_p = (x).dataPtr(nsx); \
01191 const T* _y_p = (y).dataPtr(nsy); \
01192 for(int _n = 0; _n < (nc); ++_n) { \
01193 int n##x##R = _n + nsx; n##x##R += 0; \
01194 int n##y##R = _n + nsy; n##y##R += 0; \
01195 for(int _k = 0; _k < _len[2]; ++_k) { \
01196 const int k##x##R = _k + _bx_lo[2]; \
01197 const int krev##x##R = _len[2]-1-_k + _bx_lo[2]; \
01198 const int k##y##R = _k + _by_lo[2]; \
01199 for(int _j = 0; _j < _len[1]; ++_j) { \
01200 const int j##x##R = _j + _bx_lo[1]; \
01201 const int jrev##x##R = _len[1]-1-_j + _bx_lo[1]; \
01202 const int j##y##R = _j + _by_lo[1]; \
01203 T *_x_pp; \
01204 int _ix = 0; \
01205 int _istrd = 1; \
01206 if (ir == 0) { \
01207 _x_pp = _x_p \
01208 + ((_bx_lo[0] - _x_plo[0]) + _len[0]-1 \
01209 + _x_plen[0]*( \
01210 (j##x##R - _x_plo[1]) \
01211 + _x_plen[1]*( \
01212 (k##x##R - _x_plo[2]) \
01213 + _n * _x_plen[2]))); \
01214 _istrd = -1; \
01215 } else if (ir == 1) { \
01216 _x_pp = _x_p \
01217 + ((_bx_lo[0] - _x_plo[0]) \
01218 + _x_plen[0]*( \
01219 (jrev##x##R - _x_plo[1]) \
01220 + _x_plen[1]*( \
01221 (k##x##R - _x_plo[2]) \
01222 + _n * _x_plen[2]))); \
01223 } else { \
01224 _x_pp = _x_p \
01225 + ((_bx_lo[0] - _x_plo[0]) \
01226 + _x_plen[0]*( \
01227 (j##x##R - _x_plo[1]) \
01228 + _x_plen[1]*( \
01229 (krev##x##R - _x_plo[2]) \
01230 + _n * _x_plen[2]))); \
01231 } \
01232 const T *_y_pp = _y_p \
01233 + ((_by_lo[0] - _y_plo[0]) \
01234 + _y_plen[0]*( \
01235 (j##y##R - _y_plo[1]) \
01236 + _y_plen[1]*( \
01237 (k##y##R - _y_plo[2]) \
01238 + _n * _y_plen[2]))); \
01239 for(int _i = 0; _i < _len[0]; ++_i, _ix += _istrd) { \
01240 T & x##R = _x_pp[_ix]; \
01241 const T & y##R = _y_pp[_i];
01242
01243 #define EndFor }}}}}
01244 #define EndForTX }}}}}}
01245 #define EndForPencil }}}}
01246
01247 #endif
01248 /*@ManDoc:
01249 The Macro ForAllXPencil is a shortened version of ForAllXBPencil
01250 where the box is defaulted to the entire domain the the
01251 components run over all components of x
01252 */
01253 #define ForAllXPencil(T,x) ForAllXBPencil(T,x,((x).box()),0,((x).nComp()))
01254
01255 /*@ManDoc:
01256 The macro ForAllX(T,x) is a shortened form of `ForAllXBNN' where the Box
01257 defaults to the domain of x and the components run over all the components
01258 of x.
01259 */
01260 #define ForAllX(T,x) ForAllXBNN(T,x,((x).box()),0,((x).nComp()))
01261
01262 /*@ManDoc:
01263 The macro ForAllXC(T,x) is the constant form of ForAllX(T,x).
01264 */
01265 #define ForAllXC(T,x) ForAllXCBNN(T,x,((x).box()),0,((x).nComp()))
01266
01267 /*@ManDoc:
01268 The macro ForAllXB(T,x,b) is a shortened form of `ForAllXBNN'
01269 where the components run over all the components of x.
01270 */
01271 #define ForAllXB(T,x,b) ForAllXBNN(T,x,(b),0,(x).nComp())
01272
01273 /*@ManDoc:
01274 The macro ForAllXBC(T,x,b) is the constant form of ForAllXB(T,x,b).
01275 */
01276 #define ForAllXBC(T,x,b) ForAllXCBNN(T,x,(b),0,(x).nComp())
01277
01278 /*@ManDoc:
01279 The macro ForAllThis(T) is a shortened form of `ForAllThisBNN' where the Box
01280 defaults to the domain of x and the components run over all the components
01281 of x.
01282 */
01283 #define ForAllThis(T) ForAllThisBNN(T,domain,0,nComp())
01284
01285 /*@ManDoc:
01286 The macro ForAllThisC(T) is the constant form of ForAllThis(T).
01287 */
01288 #define ForAllThisC(T) ForAllThisCBNN(T,domain,0,nComp())
01289
01290 /*@ManDoc:
01291 The macro ForAllThisB(T,b) is a shortened form of `ForAllThisBNN'
01292 where the components run over all the components of x.
01293 */
01294 #define ForAllThisB(T,b) ForAllThisBNN(T,(b),0,nComp())
01295
01296 /*@ManDoc:
01297 The macro ForAllThisCB(T,b) is the constant form of ForAllThisB(T,b).
01298 */
01299 #define ForAllThisCB(T,b) ForAllThisCBNN(T,(b),0,nComp())
01300
01301 /*@ManDoc:
01302 The macro ForAllThisNN(T,ns,nc) is a shortened form of `ForAllThisBNN'
01303 where the Box defaults to the domain of *this.
01304 */
01305 #define ForAllThisNN(T,ns,nc) ForAllThisBNN(T,domain,ns,nc)
01306
01307 /*@ManDoc:
01308 The macro ForAllThisXC(T,x) is a shortened form of `ForAllThisBNNXC'
01309 where the Box defaults to the domain of *this and the components run over
01310 all the components of *this.
01311 */
01312 #define ForAllThisXC(T,x) ForAllThisBNNXC(T,domain,0,nComp(),x,0)
01313
01314 #endif /*CH_BASEFAB_H*/
01315
1.2.16