Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

BaseFabMacros.H

Go to the documentation of this file.
00001 /*   _______              __
00002     / ___/ /  ___  __ _  / /  ___
00003    / /__/ _ \/ _ \/  V \/ _ \/ _ \
00004    \___/_//_/\___/_/_/_/_.__/\___/
00005 */
00006 // CHOMBO Copyright (c) 2000-2004, The Regents of the University of
00007 // California, through Lawrence Berkeley National Laboratory (subject to
00008 // receipt of any required approvals from U.S. Dept. of Energy).  All
00009 // rights reserved.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are met:
00013 //
00014 // (1) Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 // (2) Redistributions in binary form must reproduce the above copyright
00017 // notice, this list of conditions and the following disclaimer in the
00018 // documentation and/or other materials provided with the distribution.
00019 // (3) Neither the name of Lawrence Berkeley National Laboratory, U.S.
00020 // Dept. of Energy nor the names of its contributors may be used to endorse
00021 // or promote products derived from this software without specific prior
00022 // written permission.
00023 //
00024 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00025 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
00026 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
00027 // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
00028 // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00029 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00030 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00031 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00032 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00033 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00034 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00035 //
00036 // You are under no obligation whatsoever to provide any bug fixes,
00037 // patches, or upgrades to the features, functionality or performance of
00038 // the source code ("Enhancements") to anyone; however, if you choose to
00039 // make your Enhancements available either publicly, or directly to
00040 // Lawrence Berkeley National Laboratory, without imposing a separate
00041 // written license agreement for such Enhancements, then you hereby grant
00042 // the following license: a non-exclusive, royalty-free perpetual license
00043 // to install, use, modify, prepare derivative works, incorporate into
00044 // other computer software, distribute, and sublicense such Enhancements or
00045 // derivative works thereof, in binary and source code form.
00046 //
00047 // TRADEMARKS. Product and company names mentioned herein may be the
00048 // trademarks of their respective owners.  Any rights not expressly granted
00049 // herein are reserved.
00050 //
00051 
00052 #ifndef _BASEFABMACROS_H_
00053 #define _BASEFABMACROS_H_
00054 
00055 #include "SPACE.H"
00056 
00057 #ifdef DOXYGEN
00058 #define CH_SPACEDIM  1
00059 #endif
00060 
00061 #if (CH_SPACEDIM == 1)
00062 
00109 #define ForAllThisPencil(T,b,ns,nc)                                     \
00110 {                                                                       \
00111     assert(contains(b));                                                \
00112     assert((ns) >= 0 && (ns) + (nc) <= this->nComp());                  \
00113     const int *_th_plo = this->loVect();                                \
00114     const int *_th_plen = this->size();                                 \
00115     const int *_b_lo = (b).loVect();                                    \
00116     const int *_b_len = (b).size();                                     \
00117     T* _th_p = this->m_dptr;                                            \
00118     for (int _n = (ns); _n < (ns)+(nc); ++_n) {                         \
00119         const int nR = _n;                                              \
00120         T *_th_pp = _th_p                                               \
00121             + ((_b_lo[0] - _th_plo[0])                                  \
00122                + _n * _th_plen[0]);                                     \
00123         T &thisR = * _th_pp;                                            \
00124         const int thisLen = _b_len[0];                                  \
00125 
00126 
00130 #define ForAllXBPencil(T,x,b,ns,nc)                                     \
00131 {                                                                       \
00132     assert(x.contains(b));                                              \
00133     assert((ns) >= 0 && (ns) + (nc) <= x.nComp());                      \
00134     const int *_th_plo = x.loVect();                                    \
00135     const int *_th_plen = x.size();                                     \
00136     const int *_b_lo = (b).loVect();                                    \
00137     const int *_b_len = (b).size();                                     \
00138     T* _th_p = x.dataPtr();                                             \
00139     for (int nR = (ns); nR < (ns)+(nc); ++nR) {                         \
00140         T * xR = _th_p                                                  \
00141             + ((_b_lo[0] - _th_plo[0])                                  \
00142                + nR * _th_plen[0]);                                     \
00143     const int thisLen = _b_len[0];
00144 
00166 #define ForAllThisCPencil(T,b,ns,nc)                                    \
00167 {                                                                       \
00168     assert(this->contains(b));                                          \
00169     assert((ns) >= 0 && (ns) + (nc) <= this->nComp());                  \
00170     const int *_th_plo = this->loVect();                                \
00171     const int *_th_plen = this->size();                                 \
00172     const int *_b_lo = (b).loVect();                                    \
00173     const int *_b_len = (b).size();                                     \
00174     const T* _th_p = this->m_dptr;                                      \
00175     for (int _n = (ns); _n < (ns)+(nc); ++_n) {                         \
00176         int nR = _n; nR += 0;                                           \
00177         const T *_th_pp = _th_p                                         \
00178             + ((_b_lo[0] - _th_plo[0])                                  \
00179                + _n * _th_plen[0]);                                     \
00180         const T &thisR = * _th_pp;                                      \
00181         const int thisLen = _b_len[0];
00182 
00208 #define ForAllXBNN(T,x,b,ns,nc)                                         \
00209 {                                                                       \
00210     assert(x.contains(b));                                              \
00211     assert((ns) >= 0 && (ns) + (nc) <= (x).nComp());                    \
00212     const int *_x_plo = (x).loVect();                                   \
00213     const int *_x_plen = (x).size();                                    \
00214     const int *_b_lo = (b).loVect();                                    \
00215     const int *_b_len = (b).size();                                     \
00216     T* _x_p = (x) .dataPtr();                                           \
00217     for (int _n = (ns); _n < (ns)+(nc); ++_n) {                         \
00218         const int nR = _n;                                              \
00219         T *_x_pp = _x_p                                                 \
00220             + ((_b_lo[0] - _x_plo[0])                                   \
00221                + _n * _x_plen[0]);                                      \
00222         for (int _i = 0; _i < _b_len[0]; ++_i, ++_x_pp) {               \
00223             const int iR = _i + _b_lo[0];                               \
00224             T &x##R = * _x_pp;
00225 
00226 // undocumented interface
00227 // Same as ForALLXBNN() except the index variables are not declared.
00228 // Of course, this assumes they aren't used in the loop.
00229 // This exists only for LevelFluxRegister.cpp, to eliminate the annoying
00230 // 'unused variable' compiler warning msgs.
00231 // dbs  Apr2004
00232 #define ForAllXBNNnoindx(T,x,b,ns,nc)                                   \
00233 {                                                                       \
00234     assert(x.contains(b));                                              \
00235     assert((ns) >= 0 && (ns) + (nc) <= (x).nComp());                    \
00236     const int *_x_plo = (x).loVect();                                   \
00237     const int *_x_plen = (x).size();                                    \
00238     const int *_b_lo = (b).loVect();                                    \
00239     const int *_b_len = (b).size();                                     \
00240     T* _x_p = (x) .dataPtr();                                           \
00241     for (int _n = (ns); _n < (ns)+(nc); ++_n) {                         \
00242         T *_x_pp = _x_p                                                 \
00243             + ((_b_lo[0] - _x_plo[0])                                   \
00244                + _n * _x_plen[0]);                                      \
00245         for (int _i = 0; _i < _b_len[0]; ++_i, ++_x_pp) {               \
00246             T &x##R = * _x_pp;
00247 
00269 #define ForAllXCBNN(T,x,b,ns,nc)                                        \
00270 {                                                                       \
00271     assert(x.contains(b));                                              \
00272     assert((ns) >= 0 && (ns) + (nc) <= (x).nComp());                    \
00273     const int *_x_plo = (x).loVect();                                   \
00274     const int *_x_plen = (x).size();                                    \
00275     const int *_b_lo = (b).loVect();                                    \
00276     const int *_b_len = (b).size().getVect();                           \
00277     const T* _x_p = (x).dataPtr();                                      \
00278     for (int _n = (ns); _n < (ns)+(nc); ++_n) {                         \
00279         const int nR = _n;                                              \
00280         const T *_x_pp = _x_p                                           \
00281             + ((_b_lo[0] - _x_plo[0])                                   \
00282                + _n * _x_plen[0]);                                      \
00283         for (int _i = 0; _i < _b_len[0]; ++_i) {                        \
00284             const int iR = _i + _b_lo[0];                               \
00285             const T & x##R = _x_pp[_i];
00286 
00325 #define ForAllThisBNN(T,b,ns,nc)                                        \
00326 {                                                                       \
00327     assert(this->contains(b));                                          \
00328     assert((ns) >= 0 && (ns) + (nc) <= this->nComp());                  \
00329     const int *_th_plo = this->loVect();                                \
00330     const int *_th_plen = this->size();                                 \
00331     const int *_b_lo = (b).loVect();                                    \
00332     const int *_b_len = (b).size().getVect();                           \
00333     T* _th_p = this->m_dptr;                                            \
00334     for (int _n = (ns); _n < (ns)+(nc); ++_n) {                         \
00335         int nR = _n; nR += 0;                                           \
00336         T *_th_pp = _th_p                                               \
00337             + ((_b_lo[0] - _th_plo[0])                                  \
00338                + _n * _th_plen[0]);                                     \
00339         for (int _i = 0; _i < _b_len[0]; ++_i, ++_th_pp) {              \
00340             int iR = _i + _b_lo[0]; iR += 0;                            \
00341             T &thisR = * _th_pp;
00342 
00364 #define ForAllThisCBNN(T,b,ns,nc)                                       \
00365 {                                                                       \
00366     assert(this->contains(b));                                          \
00367     assert((ns) >= 0 && (ns) + (nc) <= this->nComp());                  \
00368     const int *_th_plo = this->loVect();                                \
00369     const int *_th_plen = this->size();                                 \
00370     const int *_b_lo = (b).loVect();                                    \
00371     const int *_b_len = (b).size().getVect();                           \
00372     const T* _th_p = this->m_dptr;                                      \
00373     for (int _n = (ns); _n < (ns)+(nc); ++_n) {                         \
00374         const int nR = _n;                                              \
00375         const T *_th_pp = _th_p                                         \
00376             + ((_b_lo[0] - _th_plo[0])                                  \
00377                + _n * _th_plen[0]);                                     \
00378         for (int _i = 0; _i < _b_len[0]; ++_i) {                        \
00379             const int iR = _i + _b_lo[0];                               \
00380             const T &thisR = _th_pp[_i];
00381 
00407 #define ForAllThisBNNXC(T,b,ns,nc,x,nss)                                \
00408 {                                                                       \
00409     assert((ns) >= 0 && (ns) + (nc) <= this->nComp());                  \
00410     assert((nss) >= 0 && (nss) + (nc) <= (x).nComp());                  \
00411     Box _subbox_((x).box());                                            \
00412     _subbox_ &= this->box();                                            \
00413     _subbox_ &= b;                                                      \
00414     if (!_subbox_.isEmpty()) {                                          \
00415         const int *_th_plo = this->loVect();                            \
00416         const int *_th_plen = this->size();                             \
00417         const int *_x_plo = (x).loVect();                               \
00418         const int *_x_plen = (x).size();                                \
00419         const int *_subbox_lo = _subbox_.loVect();                      \
00420         const int *_subbox_len = _subbox_.size().getVect();             \
00421         T* _th_p = dataPtr(ns);                                         \
00422         const T* _x_p  = (x).dataPtr(nss);                              \
00423         for (int _n = 0; _n < (nc); ++_n) {                             \
00424             int nR = _n; nR += 0;                                       \
00425             T *_th_pp = _th_p                                           \
00426                 + ((_subbox_lo[0] - _th_plo[0])                         \
00427                    + _n * _th_plen[0]);                                 \
00428             const T *_x_pp = _x_p                                       \
00429                 + ((_subbox_lo[0] - _x_plo[0])                          \
00430                    + _n * _x_plen[0]);                                  \
00431             for (int _i = 0; _i < _subbox_len[0]; ++_i, ++_th_pp) {     \
00432                 int iR = _i + _subbox_lo[0]; iR += 0;                   \
00433                 T &thisR = * _th_pp; const T & x##R = _x_pp[_i];
00434 
00435 #define ForAllThisCBNNXC(T,b,ns,nc,x,nss)                               \
00436 {                                                                       \
00437     assert((ns) >= 0 && (ns) + (nc) <= this->nComp());                  \
00438     assert((nss) >= 0 && (nss) + (nc) <= (x).nComp());                  \
00439     Box _subbox_((x).box());                                            \
00440     _subbox_ &= this->box();                                            \
00441     _subbox_ &= b;                                                      \
00442     if (!_subbox_.isEmpty()) {                                          \
00443         const int *_th_plo = this->loVect();                            \
00444         const int *_th_plen = this->size();                             \
00445         const int *_x_plo = (x).loVect();                               \
00446         const int *_x_plen = (x).size();                                \
00447         const int *_subbox_lo = _subbox_.loVect();                      \
00448         const int *_subbox_len = _subbox_.size().getVect();             \
00449         const T* _th_p = this->dataPtr(ns);                             \
00450         const T* _x_p  = (x).dataPtr(nss);                              \
00451         for (int _n = 0; _n < (nc); ++_n) {                             \
00452             int nR = _n; nR += 0;                                       \
00453             const T *_th_pp = _th_p                                     \
00454                 + ((_subbox_lo[0] - _th_plo[0])                         \
00455                    + _n * _th_plen[0]);                                 \
00456             const T *_x_pp = _x_p                                       \
00457                 + ((_subbox_lo[0] - _x_plo[0])                          \
00458                    + _n * _x_plen[0]);                                  \
00459             for (int _i = 0; _i < _subbox_len[0]; ++_i, ++_th_pp) {     \
00460                 int iR = _i + _subbox_lo[0]; iR += 0;                   \
00461                 const T &thisR = * _th_pp; const T & x##R = _x_pp[_i];
00462 
00489 #define ForAllThisBNNXCBN(T,b,ns,nc,x,bx,nss)                           \
00490 {                                                                       \
00491     assert((ns) >= 0 && (ns) + (nc) <= this->nComp());                  \
00492     assert((nss) >= 0 && (nss) + (nc) <= (x).nComp());                  \
00493     assert(bx.sameSize((b)));                                           \
00494     if (!((b).isEmpty())) {                                             \
00495         const int *_th_plo = this->loVect();                            \
00496         const int *_th_plen = this->size();                             \
00497         const int *_x_plo = (x).loVect();                               \
00498         const int *_x_plen = (x).size();                                \
00499         const int *_subbox_lo = (b).loVect();                           \
00500         const int *_subbox_len = (b).size().getVect();                  \
00501         const int *_bx_lo = (bx).loVect();                              \
00502         T* _th_p = this->dataPtr(ns);                                   \
00503         const T* _x_p  = (x).dataPtr(nss);                              \
00504         for (int _n = 0; _n < (nc); ++_n) {                             \
00505             int nR = _n + ns; nR += 0;                                  \
00506             int n##x##R = _n + nss; n##x##R += 0;                       \
00507             T *_th_pp = _th_p                                           \
00508                 + ((_subbox_lo[0] - _th_plo[0])                         \
00509                    + _n * _th_plen[0]);                                 \
00510             const T *_x_pp = _x_p                                       \
00511                 + ((_bx_lo[0] - _x_plo[0])                              \
00512                    + _n * _x_plen[0]);                                  \
00513             for (int _i = 0; _i < _subbox_len[0]; ++_i, ++_th_pp) {     \
00514                 int iR = _i + _subbox_lo[0]; iR += 0;                   \
00515                 int i##x##R = _i + _bx_lo[0]; i##x##R += 0;             \
00516                 T &thisR = * _th_pp; const T & x##R = _x_pp[_i];
00517 
00547 #define ForAllThisBNNXCBNYCBN(T,b,ns,nc,x,bx,nsx,y,by,nsy)              \
00548 {                                                                       \
00549     assert((ns) >= 0 && (ns) + (nc) <= this->nComp());                  \
00550     assert((nsx) >= 0 && (nsx) + (nc) <= (x).nComp());                  \
00551     assert((nsy) >= 0 && (nsy) + (nc) <= (y).nComp());                  \
00552     Box _subbox_ = this->box();                                         \
00553     _subbox_ &= b;                                                      \
00554     assert((bx).sameSize(_subbox_));                                    \
00555     assert((by).sameSize(_subbox_));                                    \
00556     if (!_subbox_.isEmpty()) {                                          \
00557         const int *_th_plo = this->loVect();                            \
00558         const int *_th_plen = this->size();                             \
00559         const int *_x_plo = (x).loVect();                               \
00560         const int *_x_plen = (x).size();                                \
00561         const int *_y_plo = (y).loVect();                               \
00562         const int *_y_plen = (y).size();                                \
00563         const int *_subbox_lo = _subbox_.loVect();                      \
00564         const int *_subbox_len = _subbox_.size().getVect();             \
00565         const int *_bx_lo = (bx).loVect();                              \
00566         const int *_by_lo = (by).loVect();                              \
00567         T* _th_p = this->dataPtr(ns);                                   \
00568         const T* _x_p  = (x).dataPtr(nsx);                              \
00569         const T* _y_p  = (y).dataPtr(nsy);                              \
00570         for (int _n = 0; _n < (nc); ++_n) {                             \
00571             int nR      = _n + ns;  nR      += 0;                       \
00572             int n##x##R = _n + nsx; n##x##R += 0;                       \
00573             int n##y##R = _n + nsy; n##y##R += 0;                       \
00574             T *_th_pp = _th_p                                           \
00575                 + ((_subbox_lo[0] - _th_plo[0])                         \
00576                    + _n * _th_plen[0]);                                 \
00577             const T *_x_pp = _x_p                                       \
00578                 + ((_bx_lo[0] - _x_plo[0])                              \
00579                    + _n * _x_plen[0]);                                  \
00580             const T *_y_pp = _y_p                                       \
00581                 + ((_by_lo[0] - _y_plo[0])                              \
00582                    + _n * _y_plen[0]);                                  \
00583             for (int _i = 0; _i < _subbox_len[0]; ++_i, ++_th_pp) {     \
00584                 int iR = _i + _subbox_lo[0];  iR += 0;                  \
00585                 int i##x##R = _i + _bx_lo[0]; i##x##R += 0;             \
00586                 int i##y##R = _i + _by_lo[0]; i##y##R += 0;             \
00587                 T &thisR = * _th_pp;                                    \
00588                 const T & x##R = _x_pp[_i];                             \
00589                 const T & y##R = _y_pp[_i];
00590 
00591 #define ForAllRevXBNYCBNNN(T,x,bx,nsx,y,by,nsy,nc,ri)                   \
00592 {                                                                       \
00593     assert((nsx) >= 0 && (nsx) + (nc) <= (x).nComp());                  \
00594     assert((nsy) >= 0 && (nsy) + (nc) <= (y).nComp());                  \
00595     assert((x).contains(bx));                                           \
00596     assert((y).contains(by));                                           \
00597     assert((bx).sameSize(by));                                          \
00598     const int *_x_plo = (x).loVect();                                   \
00599     const int *_x_plen = (x).size();                                    \
00600     const int *_y_plo = (y).loVect();                                   \
00601     const int *_y_plen = (y).size();                                    \
00602     const int *_len = (bx).size().getVect();                            \
00603     const int *_bx_lo = (bx).loVect();                                  \
00604     const int *_by_lo = (by).loVect();                                  \
00605     T* _x_p  = (x).dataPtr(nsx);                                        \
00606     const T* _y_p  = (y).dataPtr(nsy);                                  \
00607     for (int _n = 0; _n < (nc); ++_n) {                                 \
00608         int n##x##R = _n + nsx; n##x##R += 0;                           \
00609         int n##y##R = _n + nsy; n##y##R += 0;                           \
00610         int _ix = 0;                                                    \
00611         T *_x_pp = _x_p                                                 \
00612             + ((_bx_lo[0] - _x_plo[0]) + _len[0] - 1                    \
00613                 + _n * _x_plen[0]);                                     \
00614         const T *_y_pp = _y_p                                           \
00615             + ((_by_lo[0] - _y_plo[0])                                  \
00616                 + _n * _y_plen[0]);                                     \
00617         for (int _i = 0; _i < _len[0]; ++_i, --_ix) {                   \
00618             T & x##R = _x_pp[_ix];                                      \
00619             const T & y##R = _y_pp[_i];
00620 
00625 #define EndForTX }}}}
00626 
00631 #define EndFor }}}
00632 
00636 #define EndForPencil }}
00637 
00638 #elif (CH_SPACEDIM == 2)
00639 
00640 #define ForAllThisCPencil(T,b,ns,nc)                                    \
00641 {                                                                       \
00642     assert(contains(b));                                                \
00643     assert((ns) >= 0 && (ns) + (nc) <= this->nComp());                  \
00644     const int *_th_plo = this->loVect();                                \
00645     const int *_th_plen = this->size();                                 \
00646     const int *_b_lo = (b).loVect();                                    \
00647     const int *_b_len = (b).size().getVect();                           \
00648     const T* _th_p = this->m_dptr;                                      \
00649     for (int _n = (ns); _n < (ns)+(nc); ++_n) {                         \
00650         int nR = _n; nR += 0;                                           \
00651         for (int _j = 0; _j < _b_len[1]; ++_j) {                        \
00652             const int jR = _j + _b_lo[1];                               \
00653             const T *_th_pp = _th_p                                     \
00654                 + ((_b_lo[0] - _th_plo[0])                              \
00655                    + _th_plen[0]*(                                      \
00656                        (jR - _th_plo[1])                                \
00657                        + _n * _th_plen[1]));                            \
00658             const T &thisR = * _th_pp;                                  \
00659             const int thisLen = _b_len[0];
00660 
00661 #define ForAllThisPencil(T,b,ns,nc)                                     \
00662 {                                                                       \
00663     assert(this->contains(b));                                          \
00664     assert((ns) >= 0 && (ns) + (nc) <= this->nComp());                  \
00665     const int *_th_plo = this->loVect();                                \
00666     const int *_th_plen = this->size();                                 \
00667     const int *_b_lo = (b).loVect();                                    \
00668     const int *_b_len = (b).size().getVect();                           \
00669     T* _th_p = this->m_dptr;                                            \
00670     for (int _n = (ns); _n < (ns)+(nc); ++_n) {                         \
00671         const int nR = _n;                                              \
00672         for (int _j = 0; _j < _b_len[1]; ++_j) {                        \
00673             const int jR = _j + _b_lo[1];                               \
00674             T *_th_pp = _th_p                                           \
00675                 + ((_b_lo[0] - _th_plo[0])                              \
00676                    + _th_plen[0]*(                                      \
00677                        (jR - _th_plo[1])                                \
00678                        + _n * _th_plen[1]));                            \
00679             T &thisR = * _th_pp;                                        \
00680             const int thisLen = _b_len[0];                              \
00681 
00682 #define ForAllXBPencil(T,x,b,ns,nc)                                     \
00683 {                                                                       \
00684     assert((x).contains(b));                                            \
00685     assert((ns) >= 0 && (ns) + (nc) <= (x).nComp());                    \
00686     const int *_th_plo = (x).loVect();                                  \
00687     const int *_th_plen =(x).size();                                    \
00688     const int *_b_lo = (b).loVect();                                    \
00689     const int *_b_len = (b).size().getVect();                           \
00690     T* _th_p = (x) .dataPtr();                                          \
00691     for (int nR = (ns); nR < (ns)+(nc); ++nR) {                         \
00692         for (int _j = 0; _j < _b_len[1]; ++_j) {                        \
00693             const int jR = _j + _b_lo[1];                               \
00694             T *xR = _th_p                                               \
00695                 + ((_b_lo[0] - _th_plo[0])                              \
00696                    + _th_plen[0]*(                                      \
00697                        (jR - _th_plo[1])                                \
00698                        + nR * _th_plen[1]));                            \
00699             const int thisLen = _b_len[0];                              \
00700 
00701 #define ForAllXBNN(T,x,b,ns,nc)                                         \
00702 {                                                                       \
00703     assert((x).contains(b));                                            \
00704     assert((ns) >= 0 && (ns) + (nc) <= (x).nComp());                    \
00705     const int *_x_plo = (x).loVect();                                   \
00706     const int *_x_plen = (x).size();                                    \
00707     const int *_b_lo = (b).loVect();                                    \
00708     const int *_b_len = (b).size().getVect();                           \
00709     T* _x_p = (x) .dataPtr();                                           \
00710     for (int _n = (ns); _n < (ns)+(nc); ++_n) {                         \
00711         const int nR = _n;                                              \
00712         for (int _j = 0; _j < _b_len[1]; ++_j) {                        \
00713             const int jR = _j + _b_lo[1];                               \
00714             T *_x_pp = _x_p                                             \
00715                 + ((_b_lo[0] - _x_plo[0])                               \
00716                        + _x_plen[0]*(                                   \
00717                            (jR - _x_plo[1])                             \
00718                            + _n * _x_plen[1]));                         \
00719             for (int _i = 0; _i < _b_len[0]; ++_i, ++_x_pp) {           \
00720                 const int iR = _i + _b_lo[0];                           \
00721                 T &x##R = * _x_pp;
00722 
00723 #define ForAllXBNNnoindx(T,x,b,ns,nc)                                   \
00724 {                                                                       \
00725     assert((x).contains(b));                                            \
00726     assert((ns) >= 0 && (ns) + (nc) <= (x).nComp());                    \
00727     const int *_x_plo = (x).loVect();                                   \
00728     const int *_x_plen = (x).size();                                    \
00729     const int *_b_lo = (b).loVect();                                    \
00730     const int *_b_len = (b).size().getVect();                           \
00731     T* _x_p = (x) .dataPtr();                                           \
00732     for (int _n = (ns); _n < (ns)+(nc); ++_n) {                         \
00733         for (int _j = 0; _j < _b_len[1]; ++_j) {                        \
00734             const int jR = _j + _b_lo[1];                               \
00735             T *_x_pp = _x_p                                             \
00736                 + ((_b_lo[0] - _x_plo[0])                               \
00737                        + _x_plen[0]*(                                   \
00738                            (jR - _x_plo[1])                             \
00739                            + _n * _x_plen[1]));                         \
00740             for (int _i = 0; _i < _b_len[0]; ++_i, ++_x_pp) {           \
00741                 T &x##R = * _x_pp;
00742 
00743 #define ForAllXCBNN(T,x,b,ns,nc)                                        \
00744 {                                                                       \
00745     assert(x.contains(b));                                              \
00746     assert((ns) >= 0 && (ns) + (nc) <= (x).nComp());                    \
00747     const int *_x_plo = (x).loVect();                                   \
00748     const int *_x_plen = (x).size();                                    \
00749     const int *_b_lo = (b).loVect();                                    \
00750     const int *_b_len = (b).size().getVect();                           \
00751     const T* _x_p = (x).dataPtr();                                      \
00752     for (int _n = (ns); _n < (ns)+(nc); ++_n) {                         \
00753         const int nR = _n;                                              \
00754         for (int _j = 0; _j < _b_len[1]; ++_j) {                        \
00755             const int jR = _j + _b_lo[1];                               \
00756             const T *_x_pp = _x_p                                       \
00757                 + ((_b_lo[0] - _x_plo[0])                               \
00758                        + _x_plen[0]*(                                   \
00759                            (jR  - _x_plo[1])                            \
00760                            + _n * _x_plen[1]));                         \
00761             for (int _i = 0; _i < _b_len[0]; ++_i) {                    \
00762                 const int iR = _i + _b_lo[0];                           \
00763                 const T & x##R = _x_pp[_i];
00764 
00765 #define ForAllThisBNN(T,b,ns,nc)                                        \
00766 {                                                                       \
00767     assert(this->contains(b));                                          \
00768     assert((ns) >= 0 && (ns) + (nc) <= this->nComp());                  \
00769     const int *_th_plo = this->loVect();                                \
00770     const int *_th_plen = this->size();                                 \
00771     const int *_b_lo = (b).loVect();                                    \
00772     const int *_b_len = (b).size().getVect();                           \
00773     T* _th_p = this->m_dptr;                                            \
00774     for (int _n = (ns); _n < (ns)+(nc); ++_n) {                         \
00775         int nR = _n; nR += 0;                                           \
00776         for (int _j = 0; _j < _b_len[1]; ++_j) {                        \
00777             const int jR = _j + _b_lo[1];                               \
00778             T *_th_pp = _th_p                                           \
00779                 + ((_b_lo[0] - _th_plo[0])                              \
00780                    + _th_plen[0]*(                                      \
00781                        (jR - _th_plo[1])                                \
00782                        + _n * _th_plen[1]));                            \
00783             for (int _i = 0; _i < _b_len[0]; ++_i, ++_th_pp) {          \
00784                 int iR = _i + _b_lo[0]; iR += 0;                        \
00785                 T &thisR = * _th_pp;
00786 
00787 #define ForAllThisCBNN(T,b,ns,nc)                                       \
00788 {                                                                       \
00789     assert(this->contains(b));                                          \
00790     assert((ns) >= 0 && (ns) + (nc) <= this->nComp());                  \
00791     const int *_th_plo = this->loVect();                                \
00792     const int *_th_plen = this->size();                                 \
00793     const int *_b_lo = (b).loVect();                                    \
00794     const int *_b_len = (b).size().getVect();                           \
00795     const T* _th_p = this->m_dptr;                                      \
00796     for (int _n = (ns); _n < (ns)+(nc); ++_n) {                         \
00797         const int nR = _n;                                              \
00798         for (int _j = 0; _j < _b_len[1]; ++_j) {                        \
00799             const int jR = _j + _b_lo[1];                               \
00800             const T *_th_pp = _th_p                                     \
00801                 + ((_b_lo[0] - _th_plo[0])                              \
00802                    + _th_plen[0]*(                                      \
00803                        (_j + _b_lo[1] - _th_plo[1])                     \
00804                        + _n * _th_plen[1]));                            \
00805             for (int _i = 0; _i < _b_len[0]; ++_i) {                    \
00806                 const int iR = _i + _b_lo[0];                           \
00807                 const T &thisR = _th_pp[_i];
00808 
00809 #define ForAllThisBNNXC(T,b,ns,nc,x,nss)                                \
00810 {                                                                       \
00811     assert((ns) >= 0 && (ns) + (nc) <= this->nComp());                  \
00812     assert((nss) >= 0 && (nss) + (nc) <= (x).nComp());                  \
00813     Box _subbox_((x).box());                                            \
00814     _subbox_ &= this->box();                                            \
00815     _subbox_ &= b;                                                      \
00816     if (!_subbox_.isEmpty()) {                                          \
00817         const int *_th_plo = this->loVect();                            \
00818         const int *_th_plen = this->size();                             \
00819         const int *_x_plo = (x).loVect();                               \
00820         const int *_x_plen = (x).size();                                \
00821         const int *_subbox_lo = _subbox_.loVect();                      \
00822         const int *_subbox_len = _subbox_.size().getVect();             \
00823         T* _th_p = this->dataPtr(ns);                                   \
00824         const T* _x_p  = (x).dataPtr(nss);                              \
00825         for (int _n = 0; _n < (nc); ++_n) {                             \
00826             int nR = _n; nR += 0;                                       \
00827             for (int _j = 0; _j < _subbox_len[1]; ++_j) {               \
00828                 const int jR = _j + _subbox_lo[1];                      \
00829                 T *_th_pp = _th_p                                       \
00830                     + ((_subbox_lo[0] - _th_plo[0])                     \
00831                        + _th_plen[0]*(                                  \
00832                            (jR - _th_plo[1])                            \
00833                            + _n * _th_plen[1]));                        \
00834                 const T *_x_pp = _x_p                                   \
00835                     + ((_subbox_lo[0] - _x_plo[0])                      \
00836                        + _x_plen[0]*(                                   \
00837                            (jR - _x_plo[1])                             \
00838                            + _n * _x_plen[1]));                         \
00839                 for (int _i = 0; _i < _subbox_len[0]; ++_i, ++_th_pp) { \
00840                     int iR = _i + _subbox_lo[0]; iR += 0;               \
00841                     T &thisR = * _th_pp; const T & x##R = _x_pp[_i];
00842 
00843 #define ForAllThisCBNNXC(T,b,ns,nc,x,nss)                               \
00844 {                                                                       \
00845     assert((ns) >= 0 && (ns) + (nc) <= this->nComp());                  \
00846     assert((nss) >= 0 && (nss) + (nc) <= (x).nComp());                  \
00847     Box _subbox_((x).box());                                            \
00848     _subbox_ &= this->box();                                            \
00849     _subbox_ &= b;                                                      \
00850     if (!_subbox_.isEmpty()) {                                          \
00851         const int *_th_plo = this->loVect();                            \
00852         const int *_th_plen = this->size();                             \
00853         const int *_x_plo = (x).loVect();                               \
00854         const int *_x_plen = (x).size();                                \
00855         const int *_subbox_lo = _subbox_.loVect();                      \
00856         const int *_subbox_len = _subbox_.size().getVect();             \
00857         const T* _th_p = this->dataPtr(ns);                             \
00858         const T* _x_p  = (x).dataPtr(nss);                              \
00859         for (int _n = 0; _n < (nc); ++_n) {                             \
00860             int nR = _n; nR += 0;                                       \
00861             for (int _j = 0; _j < _subbox_len[1]; ++_j) {               \
00862                 const int jR = _j + _subbox_lo[1];                      \
00863                 const T *_th_pp = _th_p                                 \
00864                     + ((_subbox_lo[0] - _th_plo[0])                     \
00865                        + _th_plen[0]*(                                  \
00866                            (jR - _th_plo[1])                            \
00867                            + _n * _th_plen[1]));                        \
00868                 const T *_x_pp = _x_p                                   \
00869                     + ((_subbox_lo[0] - _x_plo[0])                      \
00870                        + _x_plen[0]*(                                   \
00871                            (jR - _x_plo[1])                             \
00872                            + _n * _x_plen[1]));                         \
00873                 for (int _i = 0; _i < _subbox_len[0]; ++_i, ++_th_pp) { \
00874                     int iR = _i + _subbox_lo[0]; iR += 0;               \
00875                     const T &thisR = * _th_pp; const T & x##R = _x_pp[_i];
00876 
00877 #define ForAllThisBNNXCBN(T,b,ns,nc,x,bx,nss)                           \
00878 {                                                                       \
00879     assert((ns) >= 0 && (ns) + (nc) <= this->nComp());                  \
00880     assert((nss) >= 0 && (nss) + (nc) <= (x).nComp());                  \
00881     assert(bx.sameSize((b)));                                           \
00882     if (!((b).isEmpty())) {                                             \
00883         const int *_th_plo = this->loVect();                            \
00884         const int *_th_plen = this->size();                             \
00885         const int *_x_plo = (x).loVect();                               \
00886         const int *_x_plen = (x).size();                                \
00887         const int *_subbox_lo = (b).loVect();                           \
00888         const int *_subbox_len = (b).size().getVect();                  \
00889         const int *_bx_lo = (bx).loVect();                              \
00890         T* _th_p = this->dataPtr(ns);                                   \
00891         int nR = ns; int n##x##R = nss;                                 \
00892         const T* _x_p  = (x).dataPtr(nss);                              \
00893         for (int _n = 0; _n < (nc); ++_n, ++nR, ++n##x##R ) {           \
00894             for (int _j = 0; _j < _subbox_len[1]; ++_j) {               \
00895                 const int jR = _j + _subbox_lo[1];                      \
00896                 const int j##x##R = _j + _bx_lo[1];                     \
00897                 T *_th_pp = _th_p                                       \
00898                     + ((_subbox_lo[0] - _th_plo[0])                     \
00899                        + _th_plen[0]*(                                  \
00900                            (jR - _th_plo[1])                            \
00901                            + _n * _th_plen[1]));                        \
00902                 const T *_x_pp = _x_p                                   \
00903                     + ((_bx_lo[0] - _x_plo[0])                          \
00904                        + _x_plen[0]*(                                   \
00905                            (j##x##R - _x_plo[1])                        \
00906                            + _n * _x_plen[1]));                         \
00907                 int iR = _subbox_lo[0]; int i##x##R = _bx_lo[0];        \
00908                 for (int _i = 0; _i < _subbox_len[0];                   \
00909                      ++_i, ++_th_pp, ++_x_pp, ++iR, ++i##x##R) {        \
00910                     T &thisR = * _th_pp; const T & x##R = * _x_pp;
00911 
00912 #define ForAllThisBNNXCBNYCBN(T,b,ns,nc,x,bx,nsx,y,by,nsy)              \
00913 {                                                                       \
00914     assert((ns) >= 0 && (ns) + (nc) <= this->nComp());                  \
00915     assert((nsx) >= 0 && (nsx) + (nc) <= (x).nComp());                  \
00916     assert((nsy) >= 0 && (nsy) + (nc) <= (y).nComp());                  \
00917     Box _subbox_ = this->box();                                         \
00918     _subbox_ &= b;                                                      \
00919     assert((bx).sameSize(_subbox_));                                    \
00920     assert((by).sameSize(_subbox_));                                    \
00921     if (!_subbox_.isEmpty()) {                                          \
00922         const int *_th_plo = this->loVect();                            \
00923         const int *_th_plen = this->size();                             \
00924         const int *_x_plo = (x).loVect();                               \
00925         const int *_x_plen = (x).size();                                \
00926         const int *_y_plo = (y).loVect();                               \
00927         const int *_y_plen = (y).size();                                \
00928         const int *_subbox_lo = _subbox_.loVect();                      \
00929         const int *_subbox_len = _subbox_.size().getVect();             \
00930         const int *_bx_lo = (bx).loVect();                              \
00931         const int *_by_lo = (by).loVect();                              \
00932         T* _th_p = this->dataPtr(ns);                                   \
00933         const T* _x_p  = (x).dataPtr(nsx);                              \
00934         const T* _y_p  = (y).dataPtr(nsy);                              \
00935         for (int _n = 0; _n < (nc); ++_n) {                             \
00936             int nR = _n + ns; nR += 0;                                  \
00937             int n##x##R = _n + nsx; n##x##R += 0;                       \
00938             int n##y##R = _n + nsy; n##y##R += 0;                       \
00939             for (int _j = 0; _j < _subbox_len[1]; ++_j) {               \
00940                 const int jR = _j + _subbox_lo[1];                      \
00941                 const int j##x##R = _j + _bx_lo[1];                     \
00942                 const int j##y##R = _j + _by_lo[1];                     \
00943                 T *_th_pp = _th_p                                       \
00944                     + ((_subbox_lo[0] - _th_plo[0])                     \
00945                        + _th_plen[0]*(                                  \
00946                            (jR - _th_plo[1])                            \
00947                            + _n * _th_plen[1]));                        \
00948                 const T *_x_pp = _x_p                                   \
00949                     + ((_bx_lo[0] - _x_plo[0])                          \
00950                        + _x_plen[0]*(                                   \
00951                            (j##x##R - _x_plo[1])                        \
00952                            + _n * _x_plen[1]));                         \
00953                 const T *_y_pp = _y_p                                   \
00954                     + ((_by_lo[0] - _y_plo[0])                          \
00955                        + _y_plen[0]*(                                   \
00956                            (j##y##R - _y_plo[1])                        \
00957                            + _n * _y_plen[1]));                         \
00958                 for (int _i = 0; _i < _subbox_len[0]; ++_i, ++_th_pp) { \
00959                     int iR = _i + _subbox_lo[0];  iR += 0;              \
00960                     int i##x##R = _i + _bx_lo[0]; i##x##R += 0;         \
00961                     int i##y##R = _i + _by_lo[0]; i##y##R += 0;         \
00962                     T &thisR = * _th_pp;                                \
00963                     const T & x##R = _x_pp[_i];                         \
00964                     const T & y##R = _y_pp[_i];
00965 
00966 #define ForAllRevXBNYCBNNN(T,x,bx,nsx,y,by,nsy,nc,ir)                   \
00967 {                                                                       \
00968     assert((nsx) >= 0 && (nsx) + (nc) <= (x).nComp());                  \
00969     assert((nsy) >= 0 && (nsy) + (nc) <= (y).nComp());                  \
00970     assert((ir) >= 0 && (ir) < SpaceDim);                               \
00971     assert((x).contains(bx));                                           \
00972     assert((y).contains(by));                                           \
00973     assert((bx).sameSize(by));                                          \
00974     const int *_x_plo = (x).loVect();                                   \
00975     const int *_x_plen = (x).size();                                    \
00976     const int *_y_plo = (y).loVect();                                   \
00977     const int *_y_plen = (y).size();                                    \
00978     const int *_bx_lo = (bx).loVect();                                  \
00979     const int *_by_lo = (by).loVect();                                  \
00980     const int *_len = (bx).size().getVect();                            \
00981     T* _x_p  = (x).dataPtr(nsx);                                        \
00982     const T* _y_p  = (y).dataPtr(nsy);                                  \
00983     for (int _n = 0; _n < (nc); ++_n) {                                 \
00984         int n##x##R = _n + nsx; n##x##R += 0;                           \
00985         int n##y##R = _n + nsy; n##y##R += 0;                           \
00986         for (int _j = 0; _j < _len[1]; ++_j) {                          \
00987             const int j##x##R = _j + _bx_lo[1];                         \
00988             const int jrev##x##R = _len[1]-1-_j + _bx_lo[1];            \
00989             const int j##y##R = _j + _by_lo[1];                         \
00990             T *_x_pp;                                                   \
00991             int _ix = 0;                                                \
00992             int _istrd;                                                 \
00993             if (ir == 0) {                                              \
00994                 _x_pp = _x_p                                            \
00995                     + ((_bx_lo[0] - _x_plo[0]) + _len[0] - 1            \
00996                        + _x_plen[0]*(                                   \
00997                            (j##x##R - _x_plo[1])                        \
00998                            + _n * _x_plen[1]));                         \
00999                 _istrd = -1;                                            \
01000             } else {                                                    \
01001                 _x_pp = _x_p                                            \
01002                     + ((_bx_lo[0] - _x_plo[0])                          \
01003                        + _x_plen[0]*(                                   \
01004                            (jrev##x##R - _x_plo[1])                     \
01005                            + _n * _x_plen[1]));                         \
01006                 _istrd = 1;                                             \
01007             }                                                           \
01008             const T *_y_pp = _y_p                                       \
01009                     + ((_by_lo[0] - _y_plo[0])                          \
01010                        + _y_plen[0]*(                                   \
01011                            (j##y##R - _y_plo[1])                        \
01012                            + _n * _y_plen[1]));                         \
01013             int _x_rev = _len[0]-1; _x_rev += 0;                        \
01014             for (int _i = 0; _i < _len[0]; ++_i, _ix+=_istrd) {         \
01015                 T & x##R = _x_pp[_ix];                                  \
01016                 const T & y##R = _y_pp[_i];
01017 
01018 #define EndFor }}}}
01019 #define EndForTX }}}}}
01020 #define EndForPencil }}}
01021 
01022 #elif (CH_SPACEDIM == 3)
01023 
01024 #define ForAllThisCPencil(T,b,ns,nc)                                    \
01025 {                                                                       \
01026     assert(this->contains(b));                                          \
01027     assert((ns) >= 0 && (ns) + (nc) <= this->nComp());                  \
01028     const int *_th_plo = this->loVect();                                \
01029     const int *_th_plen = this->size();                                 \
01030     const int *_b_lo = (b).loVect();                                    \
01031     const int *_b_len = (b).size().getVect();                           \
01032     const T* _th_p = this->m_dptr;                                      \
01033     for (int _n = (ns); _n < (ns)+(nc); ++_n) {                         \
01034         int nR = _n; nR += 0;                                           \
01035         for (int _k = 0; _k < _b_len[2]; ++_k) {                        \
01036             const int kR = _k + _b_lo[2];                               \
01037             for (int _j = 0; _j < _b_len[1]; ++_j) {                    \
01038                 const int jR = _j + _b_lo[1];                           \
01039                 const T *_th_pp = _th_p                                 \
01040                     + ((_b_lo[0] - _th_plo[0])                          \
01041                        + _th_plen[0]*(                                  \
01042                            (jR - _th_plo[1])                            \
01043                            + _th_plen[1]*(                              \
01044                                (kR - _th_plo[2])                        \
01045                                + _n * _th_plen[2])));                   \
01046                 const T &thisR = * _th_pp;                              \
01047                 const int thisLen = _b_len[0];
01048 
01049 #define ForAllThisPencil(T,b,ns,nc)                                     \
01050 {                                                                       \
01051     assert(this->contains(b));                                          \
01052     assert((ns) >= 0 && (ns) + (nc) <= this->nComp());                  \
01053     const int *_th_plo = this->loVect();                                \
01054     const int *_th_plen = this->size();                                 \
01055     const int *_b_lo = (b).loVect();                                    \
01056     const int *_b_len = (b).size().getVect();                           \
01057     T* _th_p = this->m_dptr;                                            \
01058     for (int _n = (ns); _n < (ns)+(nc); ++_n) {                         \
01059         const int nR = _n;                                              \
01060         for (int _k = 0; _k < _b_len[2]; ++_k) {                        \
01061             const int kR = _k + _b_lo[2];                               \
01062             for (int _j = 0; _j < _b_len[1]; ++_j) {                    \
01063                 const int jR = _j + _b_lo[1];                           \
01064                 T *_th_pp = _th_p                                       \
01065                     + ((_b_lo[0] - _th_plo[0])                          \
01066                        + _th_plen[0]*(                                  \
01067                            (jR - _th_plo[1])                            \
01068                            + _th_plen[1]*(                              \
01069                                (kR - _th_plo[2])                        \
01070                                + _n * _th_plen[2])));                   \
01071                 T &thisR = * _th_pp;                                    \
01072                 const int thisLen = _b_len[0];                          \
01073 
01074 #define ForAllXBPencil(T,x,b,ns,nc)                                     \
01075 {                                                                       \
01076     assert((x).contains(b));                                            \
01077     assert((ns) >= 0 && (ns) + (nc) <= (x).nComp());                    \
01078     const int *_th_plo = (x).loVect();                                  \
01079     const int *_th_plen = (x).size();                                   \
01080     const int *_b_lo = (b).loVect();                                    \
01081     const int *_b_len = (b).size().getVect();                           \
01082     T* _th_p = (x) .dataPtr();                                          \
01083     for (int nR = (ns); nR < (ns)+(nc); ++nR) {                         \
01084         for (int _k = 0; _k < _b_len[2]; ++_k) {                        \
01085             const int kR = _k + _b_lo[2];                               \
01086             for (int _j = 0; _j < _b_len[1]; ++_j) {                    \
01087                 const int jR = _j + _b_lo[1];                           \
01088                 T *xR = _th_p                                           \
01089                     + ((_b_lo[0] - _th_plo[0])                          \
01090                        + _th_plen[0]*(                                  \
01091                            (jR - _th_plo[1])                            \
01092                            + _th_plen[1]*(                              \
01093                                (kR - _th_plo[2])                        \
01094                                + nR * _th_plen[2])));                   \
01095                 const int thisLen = _b_len[0];
01096 
01097 #define ForAllXBNN(T,x,b,ns,nc)                                         \
01098 {                                                                       \
01099     assert(x.contains(b));                                              \
01100     assert((ns) >= 0 && (ns) + (nc) <= (x).nComp());                    \
01101     const int *_x_plo = (x).loVect();                                   \
01102     const int *_x_plen = (x).size();                                    \
01103     const int *_b_lo = (b).loVect();                                    \
01104     const int *_b_len = (b).size().getVect();                           \
01105     T* _x_p = (x) .dataPtr();                                           \
01106     for (int _n = (ns); _n < (ns)+(nc); ++_n) {                         \
01107         const int nR = _n;                                              \
01108         for (int _k = 0; _k < _b_len[2]; ++_k) {                        \
01109             const int kR = _k + _b_lo[2];                               \
01110             for (int _j = 0; _j < _b_len[1]; ++_j) {                    \
01111                 const int jR = _j + _b_lo[1];                           \
01112                 T *_x_pp = _x_p                                         \
01113                     + ((_b_lo[0] - _x_plo[0])                           \
01114                        + _x_plen[0]*(                                   \
01115                            (jR - _x_plo[1])                             \
01116                            + _x_plen[1]*(                               \
01117                                (kR - _x_plo[2])                         \
01118                                + _n * _x_plen[2])));                    \
01119                 for (int _i = 0; _i < _b_len[0]; ++_i, ++_x_pp) {       \
01120                     const int iR = _i + _b_lo[0];                       \
01121                     T &x##R = * _x_pp;
01122 
01123 #define ForAllXBNNnoindx(T,x,b,ns,nc)                                   \
01124 {                                                                       \
01125     assert(x.contains(b));                                              \
01126     assert((ns) >= 0 && (ns) + (nc) <= (x).nComp());                    \
01127     const int *_x_plo = (x).loVect();                                   \
01128     const int *_x_plen = (x).size();                                    \
01129     const int *_b_lo = (b).loVect();                                    \
01130     const int *_b_len = (b).size().getVect();                           \
01131     T* _x_p = (x) .dataPtr();                                           \
01132     for (int _n = (ns); _n < (ns)+(nc); ++_n) {                         \
01133         for (int _k = 0; _k < _b_len[2]; ++_k) {                        \
01134             const int kR = _k + _b_lo[2];                               \
01135             for (int _j = 0; _j < _b_len[1]; ++_j) {                    \
01136                 const int jR = _j + _b_lo[1];                           \
01137                 T *_x_pp = _x_p                                         \
01138                     + ((_b_lo[0] - _x_plo[0])                           \
01139                        + _x_plen[0]*(                                   \
01140                            (jR - _x_plo[1])                             \
01141                            + _x_plen[1]*(                               \
01142                                (kR - _x_plo[2])                         \
01143                                + _n * _x_plen[2])));                    \
01144                 for (int _i = 0; _i < _b_len[0]; ++_i, ++_x_pp) {       \
01145                     T &x##R = * _x_pp;
01146 
01147 #define ForAllXCBNN(T,x,b,ns,nc)                                        \
01148 {                                                                       \
01149     assert(x.contains(b));                                              \
01150     assert((ns) >= 0 && (ns) + (nc) <= (x).nComp());                    \
01151     const int *_x_plo = (x).loVect();                                   \
01152     const int *_x_plen = (x).size();                                    \
01153     const int *_b_lo = (b).loVect();                                    \
01154     const int *_b_len = (b).size().getVect();                           \
01155     const T* _x_p = (x).dataPtr();                                      \
01156     for (int _n = (ns); _n < (ns)+(nc); ++_n) {                         \
01157         const int nR = _n;                                              \
01158         for (int _k = 0; _k < _b_len[2]; ++_k) {                        \
01159             const int kR = _k + _b_lo[2];                               \
01160             for (int _j = 0; _j < _b_len[1]; ++_j) {                    \
01161                 const int jR = _j + _b_lo[1];                           \
01162                 const T *_x_pp = _x_p                                   \
01163                     + ((_b_lo[0] - _x_plo[0])                           \
01164                        + _x_plen[0]*(                                   \
01165                            (jR  - _x_plo[1])                            \
01166                            + _x_plen[1]*(                               \
01167                                (kR - _x_plo[2])                         \
01168                                + _n * _x_plen[2])));                    \
01169                 for (int _i = 0; _i < _b_len[0]; ++_i) {                \
01170                     const int iR = _i + _b_lo[0];                       \
01171                     const T & x##R = _x_pp[_i];
01172 
01173 #define ForAllThisBNN(T,b,ns,nc)                                        \
01174 {                                                                       \
01175     assert(this->contains(b));                                          \
01176     assert((ns) >= 0 && (ns) + (nc) <= this->nComp());                  \
01177     const int *_th_plo = this->loVect();                                \
01178     const int *_th_plen = this->size();                                 \
01179     const int *_b_lo = (b).loVect();                                    \
01180     const int *_b_len = (b).size().getVect();                           \
01181     T* _th_p = this->m_dptr;                                            \
01182     for (int _n = (ns); _n < (ns)+(nc); ++_n) {                         \
01183         int nR = _n; nR += 0;                                           \
01184         for (int _k = 0; _k < _b_len[2]; ++_k) {                        \
01185             const int kR = _k + _b_lo[2];                               \
01186             for (int _j = 0; _j < _b_len[1]; ++_j) {                    \
01187                 const int jR = _j + _b_lo[1];                           \
01188                 T *_th_pp = _th_p                                       \
01189                     + ((_b_lo[0] - _th_plo[0])                          \
01190                        + _th_plen[0]*(                                  \
01191                            (jR - _th_plo[1])                            \
01192                            + _th_plen[1]*(                              \
01193                                (kR - _th_plo[2])                        \
01194                                + _n * _th_plen[2])));                   \
01195                 for (int _i = 0; _i < _b_len[0]; ++_i, ++_th_pp) {      \
01196                     int iR = _i + _b_lo[0]; iR += 0;                    \
01197                     T &thisR = * _th_pp;
01198 
01199 #define ForAllThisCBNN(T,b,ns,nc)                                       \
01200 {                                                                       \
01201     assert(this->contains(b));                                          \
01202     assert((ns) >= 0 && (ns) + (nc) <= this->nComp());                  \
01203     const int *_th_plo = this->loVect();                                \
01204     const int *_th_plen = this->size();                                 \
01205     const int *_b_lo = (b).loVect();                                    \
01206     const int *_b_len = (b).size().getVect();                           \
01207     const T* _th_p = this->m_dptr;                                      \
01208     for (int _n = (ns); _n < (ns)+(nc); ++_n) {                         \
01209         const int nR = _n;                                              \
01210         for (int _k = 0; _k < _b_len[2]; ++_k) {                        \
01211             const int kR = _k + _b_lo[2];                               \
01212             for (int _j = 0; _j < _b_len[1]; ++_j) {                    \
01213                 const int jR = _j + _b_lo[1];                           \
01214                 const T *_th_pp = _th_p                                 \
01215                     + ((_b_lo[0] - _th_plo[0])                          \
01216                        + _th_plen[0]*(                                  \
01217                            (jR - _th_plo[1])                            \
01218                            + _th_plen[1]*(                              \
01219                                (kR - _th_plo[2])                        \
01220                                + _n * _th_plen[2])));                   \
01221                 for (int _i = 0; _i < _b_len[0]; ++_i) {                \
01222                     const int iR = _i + _b_lo[0];                       \
01223                     const T &thisR = _th_pp[_i];
01224 
01225 #define ForAllThisBNNXC(T,b,ns,nc,x,nss)                                \
01226 {                                                                       \
01227     assert((ns) >= 0 && (ns) + (nc) <= this->nComp());                  \
01228     assert((nss) >= 0 && (nss) + (nc) <= (x).nComp());                  \
01229     Box _subbox_((x).box());                                            \
01230     _subbox_ &= this->box();                                            \
01231     _subbox_ &= b;                                                      \
01232     if (!_subbox_.isEmpty()) {                                          \
01233         const int *_th_plo = this->loVect();                            \
01234         const int *_th_plen = this->size();                             \
01235         const int *_x_plo = (x).loVect();                               \
01236         const int *_x_plen = (x).size();                                \
01237         const int *_subbox_lo = _subbox_.loVect();                      \
01238         const int *_subbox_len = _subbox_.size().getVect();             \
01239         T* _th_p = this->dataPtr(ns);                                   \
01240         const T* _x_p  = (x).dataPtr(nss);                              \
01241         for (int _n = 0; _n < (nc); ++_n) {                             \
01242             int nR = _n; nR += 0;                                       \
01243             for (int _k = 0; _k < _subbox_len[2]; ++_k) {               \
01244                 const int kR = _k + _subbox_lo[2];                      \
01245                 for (int _j = 0; _j < _subbox_len[1]; ++_j) {           \
01246                     const int jR = _j + _subbox_lo[1];                  \
01247                     T *_th_pp = _th_p                                   \
01248                         + ((_subbox_lo[0] - _th_plo[0])                 \
01249                            + _th_plen[0]*(                              \
01250                                (jR - _th_plo[1])                        \
01251                                + _th_plen[1]*(                          \
01252                                    (kR - _th_plo[2])                    \
01253                                    + _n * _th_plen[2])));               \
01254                     const T *_x_pp = _x_p                               \
01255                         + ((_subbox_lo[0] - _x_plo[0])                  \
01256                            + _x_plen[0]*(                               \
01257                                (jR - _x_plo[1])                         \
01258                                + _x_plen[1]*(                           \
01259                                    (kR - _x_plo[2])                     \
01260                                    + _n * _x_plen[2])));                \
01261                     for (int _i = 0; _i < _subbox_len[0];               \
01262                          ++_i, ++_th_pp) {                              \
01263                         int iR = _i + _subbox_lo[0]; iR += 0;           \
01264                         T &thisR = * _th_pp; const T & x##R = _x_pp[_i];
01265 
01266 #define ForAllThisCBNNXC(T,b,ns,nc,x,nss)                               \
01267 {                                                                       \
01268     assert((ns) >= 0 && (ns) + (nc) <= this->nComp());                  \
01269     assert((nss) >= 0 && (nss) + (nc) <= (x).nComp());                  \
01270     Box _subbox_((x).box());                                            \
01271     _subbox_ &= this->box();                                            \
01272     _subbox_ &= b;                                                      \
01273     if (!_subbox_.isEmpty()) {                                          \
01274         const int *_th_plo = this->loVect();                            \
01275         const int *_th_plen = this->size();                             \
01276         const int *_x_plo = (x).loVect();                               \
01277         const int *_x_plen = (x).size();                                \
01278         const int *_subbox_lo = _subbox_.loVect();                      \
01279         const int *_subbox_len = _subbox_.size().getVect();             \
01280         const T* _th_p = this->dataPtr(ns);                             \
01281         const T* _x_p  = (x).dataPtr(nss);                              \
01282         for (int _n = 0; _n < (nc); ++_n) {                             \
01283             int nR = _n; nR += 0;                                       \
01284             for (int _k = 0; _k < _subbox_len[2]; ++_k) {               \
01285                 const int kR = _k + _subbox_lo[2];                      \
01286                 for (int _j = 0; _j < _subbox_len[1]; ++_j) {           \
01287                     const int jR = _j + _subbox_lo[1];                  \
01288                     const T *_th_pp = _th_p                             \
01289                         + ((_subbox_lo[0] - _th_plo[0])                 \
01290                            + _th_plen[0]*(                              \
01291                                (jR - _th_plo[1])                        \
01292                                + _th_plen[1]*(                          \
01293                                    (kR - _th_plo[2])                    \
01294                                    + _n * _th_plen[2])));               \
01295                     const T *_x_pp = _x_p                               \
01296                         + ((_subbox_lo[0] - _x_plo[0])                  \
01297                            + _x_plen[0]*(                               \
01298                                (jR - _x_plo[1])                         \
01299                                + _x_plen[1]*(                           \
01300                                    (kR - _x_plo[2])                     \
01301                                    + _n * _x_plen[2])));                \
01302                     for (int _i = 0; _i < _subbox_len[0];               \
01303                          ++_i, ++_th_pp) {                              \
01304                         int iR = _i + _subbox_lo[0]; iR += 0;           \
01305                         const T &thisR = * _th_pp; const T & x##R = _x_pp[_i];
01306 
01307 #define ForAllThisBNNXCBN(T,b,ns,nc,x,bx,nss)                           \
01308 {                                                                       \
01309     assert((ns) >= 0 && (ns) + (nc) <= this->nComp());                  \
01310     assert((nss) >= 0 && (nss) + (nc) <= (x).nComp());                  \
01311     assert((bx).sameSize((b)));                                         \
01312     if (!((b).isEmpty())) {                                             \
01313         const int *_th_plo = this->loVect();                            \
01314         const int *_th_plen = this->size();                             \
01315         const int *_x_plo = (x).loVect();                               \
01316         const int *_x_plen = (x).size();                                \
01317         const int *_subbox_lo = (b).loVect();                           \
01318         const int *_subbox_len = (b).size().getVect();                  \
01319         const int *_bx_lo = (bx).loVect();                              \
01320         T* _th_p = this->dataPtr(ns);                                   \
01321         const T* _x_p  = (x).dataPtr(nss);                              \
01322         for (int _n = 0; _n < (nc); ++_n) {                             \
01323             int nR = _n + ns; nR += 0;                                  \
01324             int n##x##R = _n + nss; n##x##R += 0;                       \
01325             for (int _k = 0; _k < _subbox_len[2]; ++_k) {               \
01326                 const int kR = _k + _subbox_lo[2];                      \
01327                 const int k##x##R = _k + _bx_lo[2];                     \
01328                 for (int _j = 0; _j < _subbox_len[1]; ++_j) {           \
01329                     const int jR = _j + _subbox_lo[1];                  \
01330                     const int j##x##R = _j + _bx_lo[1];                 \
01331                     T *_th_pp = _th_p                                   \
01332                         + ((_subbox_lo[0] - _th_plo[0])                 \
01333                            + _th_plen[0]*(                              \
01334                                (jR - _th_plo[1])                        \
01335                                + _th_plen[1]*(                          \
01336                                    (kR - _th_plo[2])                    \
01337                                    + _n * _th_plen[2])));               \
01338                     const T *_x_pp = _x_p                               \
01339                         + ((_bx_lo[0] - _x_plo[0])                      \
01340                            + _x_plen[0]*(                               \
01341                                (j##x##R - _x_plo[1])                    \
01342                                + _x_plen[1]*(                           \
01343                                    (k##x##R - _x_plo[2])                \
01344                                    + _n * _x_plen[2])));                \
01345                     for (int _i = 0; _i < _subbox_len[0];               \
01346                          ++_i, ++_th_pp) {                              \
01347                         int iR = _i + _subbox_lo[0]; iR += 0;           \
01348                         int i##x##R = _i + _bx_lo[0]; i##x##R += 0;     \
01349                         T &thisR = * _th_pp; const T & x##R = _x_pp[_i];
01350 
01351 #define ForAllThisBNNXCBNYCBN(T,b,ns,nc,x,bx,nsx,y,by,nsy)              \
01352 {                                                                       \
01353     assert((ns) >= 0 && (ns) + (nc) <= this->nComp());                  \
01354     assert((nsx) >= 0 && (nsx) + (nc) <= (x).nComp());                  \
01355     assert((nsy) >= 0 && (nsy) + (nc) <= (y).nComp());                  \
01356     Box _subbox_(this->box());                                          \
01357     _subbox_ &= b;                                                      \
01358     assert((bx).sameSize(_subbox_));                                    \
01359     assert((by).sameSize(_subbox_));                                    \
01360     if (!_subbox_.isEmpty()) {                                          \
01361         const int *_th_plo = this->loVect();                            \
01362         const int *_th_plen = this->size();                             \
01363         const int *_x_plo = (x).loVect();                               \
01364         const int *_x_plen = (x).size();                                \
01365         const int *_y_plo = (y).loVect();                               \
01366         const int *_y_plen = (y).size();                                \
01367         const int *_subbox_lo = _subbox_.loVect();                      \
01368         const int *_subbox_len = _subbox_.size().getVect();             \
01369         const int *_bx_lo = (bx).loVect();                              \
01370         const int *_by_lo = (by).loVect();                              \
01371         T* _th_p = this->dataPtr(ns);                                   \
01372         const T* _x_p  = (x).dataPtr(nsx);                              \
01373         const T* _y_p  = (y).dataPtr(nsy);                              \
01374         for (int _n = 0; _n < (nc); ++_n) {                             \
01375             int nR = _n + ns; nR += 0;                                  \
01376             int n##x##R = _n + nsx; n##x##R += 0;                       \
01377             int n##y##R = _n + nsy; n##y##R += 0;                       \
01378             for (int _k = 0; _k < _subbox_len[2]; ++_k) {               \
01379                 const int kR = _k + _subbox_lo[2];                      \
01380                 const int k##x##R = _k + _bx_lo[2];                     \
01381                 const int k##y##R = _k + _by_lo[2];                     \
01382                 for (int _j = 0; _j < _subbox_len[1]; ++_j) {           \
01383                     const int jR = _j + _subbox_lo[1];                  \
01384                     const int j##x##R = _j + _bx_lo[1];                 \
01385                     const int j##y##R = _j + _by_lo[1];                 \
01386                     T *_th_pp = _th_p                                   \
01387                         + ((_subbox_lo[0] - _th_plo[0])                 \
01388                            + _th_plen[0]*(                              \
01389                                (jR - _th_plo[1])                        \
01390                                + _th_plen[1]*(                          \
01391                                    (kR - _th_plo[2])                    \
01392                                    + _n * _th_plen[2])));               \
01393                     const T *_x_pp = _x_p                               \
01394                         + ((_bx_lo[0] - _x_plo[0])                      \
01395                            + _x_plen[0]*(                               \
01396                                (j##x##R - _x_plo[1])                    \
01397                                + _x_plen[1]*(                           \
01398                                    (k##x##R - _x_plo[2])                \
01399                                    + _n * _x_plen[2])));                \
01400                     const T *_y_pp = _y_p                               \
01401                         + ((_by_lo[0] - _y_plo[0])                      \
01402                            + _y_plen[0]*(                               \
01403                                (j##y##R - _y_plo[1])                    \
01404                                + _y_plen[1]*(                           \
01405                                    (k##y##R - _y_plo[2])                \
01406                                    + _n * _y_plen[2])));                \
01407                     for (int _i = 0; _i < _subbox_len[0];               \
01408                          ++_i, ++_th_pp) {                              \
01409                         int iR = _i + _subbox_lo[0];  iR += 0;          \
01410                         int i##x##R = _i + _bx_lo[0]; i##x##R += 0;     \
01411                         int i##y##R = _i + _by_lo[0]; i##y##R += 0;     \
01412                         T &thisR = * _th_pp;                            \
01413                         const T & x##R = _x_pp[_i];                     \
01414                         const T & y##R = _y_pp[_i];
01415 
01416 #define ForAllRevXBNYCBNNN(T,x,bx,nsx,y,by,nsy,nc,ir)                   \
01417 {                                                                       \
01418     assert((ir) >= 0 && (ir) < SpaceDim);                               \
01419     assert((nsx) >= 0 && (nsx) + (nc) <= (x).nComp());                  \
01420     assert((nsy) >= 0 && (nsy) + (nc) <= (y).nComp());                  \
01421     assert((x).contains(bx));                                           \
01422     assert((y).contains(by));                                           \
01423     assert((bx).sameSize(by));                                          \
01424     const int *_x_plo = (x).loVect();                                   \
01425     const int *_x_plen = (x).size();                                    \
01426     const int *_y_plo = (y).loVect();                                   \
01427     const int *_y_plen = (y).size();                                    \
01428     const int *_bx_lo = (bx).loVect();                                  \
01429     const int *_by_lo = (by).loVect();                                  \
01430     const int *_len = (bx).size().getVect();                            \
01431     T* _x_p  = (x).dataPtr(nsx);                                        \
01432     const T* _y_p  = (y).dataPtr(nsy);                                  \
01433     for (int _n = 0; _n < (nc); ++_n) {                                 \
01434         int n##x##R = _n + nsx; n##x##R += 0;                           \
01435         int n##y##R = _n + nsy; n##y##R += 0;                           \
01436         for (int _k = 0; _k < _len[2]; ++_k) {                          \
01437             const int k##x##R = _k + _bx_lo[2];                         \
01438             const int krev##x##R = _len[2]-1-_k + _bx_lo[2];            \
01439             const int k##y##R = _k + _by_lo[2];                         \
01440             for (int _j = 0; _j < _len[1]; ++_j) {                      \
01441                 const int j##x##R = _j + _bx_lo[1];                     \
01442                 const int jrev##x##R = _len[1]-1-_j + _bx_lo[1];        \
01443                 const int j##y##R = _j + _by_lo[1];                     \
01444                 T *_x_pp;                                               \
01445                 int _ix = 0;                                            \
01446                 int _istrd = 1;                                         \
01447                 if (ir == 0) {                                          \
01448                     _x_pp = _x_p                                        \
01449                         + ((_bx_lo[0] - _x_plo[0]) + _len[0]-1          \
01450                            + _x_plen[0]*(                               \
01451                                (j##x##R - _x_plo[1])                    \
01452                                + _x_plen[1]*(                           \
01453                                    (k##x##R - _x_plo[2])                \
01454                                    + _n * _x_plen[2])));                \
01455                     _istrd = -1;                                        \
01456                 } else if (ir == 1) {                                   \
01457                     _x_pp = _x_p                                        \
01458                         + ((_bx_lo[0] - _x_plo[0])                      \
01459                            + _x_plen[0]*(                               \
01460                                (jrev##x##R - _x_plo[1])                 \
01461                                + _x_plen[1]*(                           \
01462                                    (k##x##R - _x_plo[2])                \
01463                                    + _n * _x_plen[2])));                \
01464                 } else {                                                \
01465                     _x_pp = _x_p                                        \
01466                         + ((_bx_lo[0] - _x_plo[0])                      \
01467                            + _x_plen[0]*(                               \
01468                                (j##x##R - _x_plo[1])                    \
01469                                + _x_plen[1]*(                           \
01470                                    (krev##x##R - _x_plo[2])             \
01471                                    + _n * _x_plen[2])));                \
01472                 }                                                       \
01473                 const T *_y_pp = _y_p                                   \
01474                     + ((_by_lo[0] - _y_plo[0])                          \
01475                        + _y_plen[0]*(                                   \
01476                            (j##y##R - _y_plo[1])                        \
01477                            + _y_plen[1]*(                               \
01478                                (k##y##R - _y_plo[2])                    \
01479                                + _n * _y_plen[2])));                    \
01480                 for (int _i = 0; _i < _len[0]; ++_i, _ix += _istrd) {   \
01481                     T & x##R = _x_pp[_ix];                              \
01482                     const T & y##R = _y_pp[_i];
01483 
01484 #define EndFor }}}}}
01485 #define EndForTX }}}}}}
01486 #define EndForPencil }}}}
01487 
01488 #endif
01489 
01494 #define ForAllXPencil(T,x)  ForAllXBPencil(T,x,((x).box()),0,((x).nComp()))
01495 
01501 #define ForAllX(T,x)            ForAllXBNN(T,x,((x).box()),0,((x).nComp()))
01502 
01506 #define ForAllXC(T,x)           ForAllXCBNN(T,x,((x).box()),0,((x).nComp()))
01507 
01512 #define ForAllXB(T,x,b)         ForAllXBNN(T,x,(b),0,(x).nComp())
01513 
01517 #define ForAllXBC(T,x,b)        ForAllXCBNN(T,x,(b),0,(x).nComp())
01518 
01524 #define ForAllThis(T)           ForAllThisBNN(T,this->m_domain,0,this->nComp())
01525 
01529 #define ForAllThisC(T)          ForAllThisCBNN(T,this->m_domain,0,this->nComp())
01530 
01535 #define ForAllThisB(T,b)        ForAllThisBNN(T,(b),0,this->nComp())
01536 
01540 #define ForAllThisCB(T,b)       ForAllThisCBNN(T,(b),0,this->nComp())
01541 
01546 #define ForAllThisNN(T,ns,nc)     ForAllThisBNN(T,this->m_domain,ns,nc)
01547 
01553 #define ForAllThisXC(T,x)       ForAllThisBNNXC(T,this->m_domain,0,this->nComp(),x,0)
01554 
01555 #ifdef DOXYGEN
01556 #undef CH_SPACEDIM
01557 #endif /* Doxygen */
01558 
01559 #endif

Generated on Wed Jan 19 17:51:22 2005 for Chombo&INSwithParticles by doxygen1.2.16