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


Main Page   Class Hierarchy   Compound List   File List  

GridDataOpsRel1.h

Go to the documentation of this file.
00001 #ifndef _included_GridDataOpsRel_1_h
00002 #define _included_GridDataOpsRel_1_h
00003 
00009 /****************************** == ***************************************/
00010 
00011 template <class Type>
00012 BBox GridData(1)<Type>::is_eq (Type const &val, BBox const &where)
00013   {
00014     BBox intersection = _bbox * where;
00015     if (!intersection.empty())
00016       {
00017        Coords max_step = _step.getmax(where.stepsize());
00018        BBox to(intersection); to.setstepsize(_step);
00019        BBox from(intersection); from.setstepsize(where.stepsize());
00020        BBox bb(1,max_step);
00021        gd_OperateRegion(is_eq)(val, to, from, max_step, bb);
00022        return (bb);
00023       }
00024     else 
00025      { BBox bb(1,1); return (bb); }
00026   }
00027 
00028 template <class Type>
00029 BBox GridData(1)<Type>::is_eq (GridData(1)<Type> const &gd, BBox const &to,
00030                                                 BBox const &from)
00031   {
00032    const Coords  toshift = from.lower() - to.lower();
00033    BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
00034    if (!newfrom.empty())
00035      {
00036       BBox newto = shiftabs(newfrom, -toshift);
00037       Coords max_step = _step.getmax(gd._step);
00038       newto.setstepsize(_step);
00039       newfrom.setstepsize(gd._step);
00040       BBox bb(1,max_step);
00041       gd_OperateRegion(is_eq)(gd, newto, newfrom, max_step, bb);
00042       return (bb);
00043      }
00044     else 
00045      { BBox bb(1,1); return (bb); }
00046   }
00047 
00048 template <class Type>
00049 void GridData(1)<Type>::gd_OperateRegion(is_eq) (Type const &val, 
00050                         BBox const &to, BBox const &from, Coords const &step, 
00051                         BBox &bb)
00052   {
00053    GridData(1)<Type> &dst = *this;
00054 
00055    BeginFastIndex1(dst, dst._bbox, dst._data, Type);
00056 
00057    for_1(i, to, step)
00058       if (FastIndex1(dst,i) == val) bb += Coords(1,i);
00059    end_for
00060 
00061    EndFastIndex1(dst);
00062   }
00063 
00064 template <class Type>
00065 void GridData(1)<Type>::gd_OperateRegion(is_eq) (GridData(1)<Type> const &src, 
00066                         BBox const &to, BBox const &from, Coords const &step,
00067                         BBox &bb)
00068   {
00069    GridData(1)<Type> &dst = *this;
00070    const int di = from.lower(0)-to.lower(0);
00071 
00072    BeginFastIndex1(src, src._bbox, src._data, const Type);
00073    BeginFastIndex1(dst, dst._bbox, dst._data, Type);
00074 
00075    for_1(i, to, step)
00076       if (FastIndex1(dst,i) == FastIndex1(src,i+di))
00077         bb += Coords(1,i);
00078    end_for
00079 
00080    EndFastIndex1(dst);
00081    EndFastIndex1(src);
00082   }
00083 
00084 /************************************************************************/
00085 
00086 /****************************** != ***************************************/
00087 
00088 template <class Type>
00089 BBox GridData(1)<Type>::is_neq (Type const &val, BBox const &where)
00090   {
00091     BBox intersection = _bbox * where;
00092     if (!intersection.empty())
00093       {
00094        Coords max_step = _step.getmax(where.stepsize());
00095        BBox to(intersection); to.setstepsize(_step);
00096        BBox from(intersection); from.setstepsize(where.stepsize());
00097        BBox bb(1,max_step);
00098        gd_OperateRegion(is_neq)(val, to, from, max_step, bb);
00099        return (bb);
00100       }
00101     else 
00102      { BBox bb(1,1); return (bb); }
00103   }
00104 
00105 template <class Type>
00106 BBox GridData(1)<Type>::is_neq (GridData(1)<Type> const &gd, BBox const &to,
00107                                                 BBox const &from)
00108   {
00109    const Coords  toshift = from.lower() - to.lower();
00110    BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
00111    if (!newfrom.empty())
00112      {
00113       BBox newto = shiftabs(newfrom, -toshift);
00114       Coords max_step = _step.getmax(gd._step);
00115       newto.setstepsize(_step);
00116       newfrom.setstepsize(gd._step);
00117       BBox bb(1,max_step);
00118       gd_OperateRegion(is_neq)(gd, newto, newfrom, max_step, bb);
00119       return (bb);
00120      }
00121     else 
00122      { BBox bb(1,1); return (bb); }
00123   }
00124 
00125 template <class Type>
00126 void GridData(1)<Type>::gd_OperateRegion(is_neq) (Type const &val, 
00127                         BBox const &to, BBox const &from, Coords const &step, 
00128                         BBox &bb)
00129   {
00130    GridData(1)<Type> &dst = *this;
00131 
00132    BeginFastIndex1(dst, dst._bbox, dst._data, Type);
00133 
00134    for_1(i, to, step)
00135       if (FastIndex1(dst,i) != val) bb += Coords(1,i);
00136    end_for
00137 
00138    EndFastIndex1(dst);
00139   }
00140 
00141 template <class Type>
00142 void GridData(1)<Type>::gd_OperateRegion(is_neq) (GridData(1)<Type> const &src, 
00143                         BBox const &to, BBox const &from, Coords const &step,
00144                         BBox &bb)
00145   {
00146    GridData(1)<Type> &dst = *this;
00147    const int di = from.lower(0)-to.lower(0);
00148 
00149    BeginFastIndex1(src, src._bbox, src._data, const Type);
00150    BeginFastIndex1(dst, dst._bbox, dst._data, Type);
00151 
00152    for_1(i, to, step)
00153       if (FastIndex1(dst,i) != FastIndex1(src,i+di))
00154         bb += Coords(1,i);
00155    end_for
00156 
00157    EndFastIndex1(dst);
00158    EndFastIndex1(src);
00159   }
00160 
00161 /************************************************************************/
00162 
00163 /****************************** > ***************************************/
00164 
00165 template <class Type>
00166 BBox GridData(1)<Type>::is_gt (Type const &val, BBox const &where)
00167   {
00168     BBox intersection = _bbox * where;
00169     if (!intersection.empty())
00170       {
00171        Coords max_step = _step.getmax(where.stepsize());
00172        BBox to(intersection); to.setstepsize(_step);
00173        BBox from(intersection); from.setstepsize(where.stepsize());
00174        BBox bb(1,max_step);
00175        gd_OperateRegion(is_gt)(val, to, from, max_step, bb);
00176        return (bb);
00177       }
00178     else 
00179      { BBox bb(1,1); return (bb); }
00180   }
00181 
00182 template <class Type>
00183 BBox GridData(1)<Type>::is_gt (GridData(1)<Type> const &gd, BBox const &to,
00184                                                 BBox const &from)
00185   {
00186    const Coords  toshift = from.lower() - to.lower();
00187    BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
00188    if (!newfrom.empty())
00189      {
00190       BBox newto = shiftabs(newfrom, -toshift);
00191       Coords max_step = _step.getmax(gd._step);
00192       newto.setstepsize(_step);
00193       newfrom.setstepsize(gd._step);
00194       BBox bb(1,max_step);
00195       gd_OperateRegion(is_gt)(gd, newto, newfrom, max_step, bb);
00196       return (bb);
00197      }
00198     else 
00199      { BBox bb(1,1); return (bb); }
00200   }
00201 
00202 template <class Type>
00203 void GridData(1)<Type>::gd_OperateRegion(is_gt) (Type const &val, 
00204                         BBox const &to, BBox const &from, Coords const &step, 
00205                         BBox &bb)
00206   {
00207    GridData(1)<Type> &dst = *this;
00208 
00209    BeginFastIndex1(dst, dst._bbox, dst._data, Type);
00210 
00211    for_1(i, to, step)
00212       if (FastIndex1(dst,i) > val) bb += Coords(1,i);
00213    end_for
00214 
00215    EndFastIndex1(dst);
00216   }
00217 
00218 template <class Type>
00219 void GridData(1)<Type>::gd_OperateRegion(is_gt) (GridData(1)<Type> const &src, 
00220                         BBox const &to, BBox const &from, Coords const &step,
00221                         BBox &bb)
00222   {
00223    GridData(1)<Type> &dst = *this;
00224    const int di = from.lower(0)-to.lower(0);
00225 
00226    BeginFastIndex1(src, src._bbox, src._data, const Type);
00227    BeginFastIndex1(dst, dst._bbox, dst._data, Type);
00228 
00229    for_1(i, to, step)
00230       if (FastIndex1(dst,i) > FastIndex1(src,i+di))
00231         bb += Coords(1,i);
00232    end_for
00233 
00234    EndFastIndex1(dst);
00235    EndFastIndex1(src);
00236   }
00237 
00238 /************************************************************************/
00239 
00240 /****************************** >= ***************************************/
00241 
00242 template <class Type>
00243 BBox GridData(1)<Type>::is_ge (Type const &val, BBox const &where)
00244   {
00245     BBox intersection = _bbox * where;
00246     if (!intersection.empty())
00247       {
00248        Coords max_step = _step.getmax(where.stepsize());
00249        BBox to(intersection); to.setstepsize(_step);
00250        BBox from(intersection); from.setstepsize(where.stepsize());
00251        BBox bb(1,max_step);
00252        gd_OperateRegion(is_ge)(val, to, from, max_step, bb);
00253        return (bb);
00254       }
00255     else 
00256      { BBox bb(1,1); return (bb); }
00257   }
00258 
00259 template <class Type>
00260 BBox GridData(1)<Type>::is_ge (GridData(1)<Type> const &gd, BBox const &to,
00261                                                 BBox const &from)
00262   {
00263    const Coords  toshift = from.lower() - to.lower();
00264    BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
00265    if (!newfrom.empty())
00266      {
00267       BBox newto = shiftabs(newfrom, -toshift);
00268       Coords max_step = _step.getmax(gd._step);
00269       newto.setstepsize(_step);
00270       newfrom.setstepsize(gd._step);
00271       BBox bb(1,max_step);
00272       gd_OperateRegion(is_ge)(gd, newto, newfrom, max_step, bb);
00273       return (bb);
00274      }
00275     else 
00276      { BBox bb(1,1); return (bb); }
00277   }
00278 
00279 template <class Type>
00280 void GridData(1)<Type>::gd_OperateRegion(is_ge) (Type const &val, 
00281                         BBox const &to, BBox const &from, Coords const &step, 
00282                         BBox &bb)
00283   {
00284    GridData(1)<Type> &dst = *this;
00285 
00286    BeginFastIndex1(dst, dst._bbox, dst._data, Type);
00287 
00288    for_1(i, to, step)
00289       if (FastIndex1(dst,i) >= val) bb += Coords(1,i);
00290    end_for
00291 
00292    EndFastIndex1(dst);
00293   }
00294 
00295 template <class Type>
00296 void GridData(1)<Type>::gd_OperateRegion(is_ge) (GridData(1)<Type> const &src, 
00297                         BBox const &to, BBox const &from, Coords const &step,
00298                         BBox &bb)
00299   {
00300    GridData(1)<Type> &dst = *this;
00301    const int di = from.lower(0)-to.lower(0);
00302 
00303    BeginFastIndex1(src, src._bbox, src._data, const Type);
00304    BeginFastIndex1(dst, dst._bbox, dst._data, Type);
00305 
00306    for_1(i, to, step)
00307       if (FastIndex1(dst,i) >= FastIndex1(src,i+di))
00308         bb += Coords(1,i);
00309    end_for
00310 
00311    EndFastIndex1(dst);
00312    EndFastIndex1(src);
00313   }
00314 
00315 /************************************************************************/
00316 
00317 /****************************** < ***************************************/
00318 
00319 template <class Type>
00320 BBox GridData(1)<Type>::is_lt (Type const &val, BBox const &where)
00321   {
00322     BBox intersection = _bbox * where;
00323     if (!intersection.empty())
00324       {
00325        Coords max_step = _step.getmax(where.stepsize());
00326        BBox to(intersection); to.setstepsize(_step);
00327        BBox from(intersection); from.setstepsize(where.stepsize());
00328        BBox bb(1,max_step);
00329        gd_OperateRegion(is_lt)(val, to, from, max_step, bb);
00330        return (bb);
00331       }
00332     else 
00333      { BBox bb(1,1); return (bb); }
00334   }
00335 
00336 template <class Type>
00337 BBox GridData(1)<Type>::is_lt (GridData(1)<Type> const &gd, BBox const &to,
00338                                                 BBox const &from)
00339   {
00340    const Coords  toshift = from.lower() - to.lower();
00341    BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
00342    if (!newfrom.empty())
00343      {
00344       BBox newto = shiftabs(newfrom, -toshift);
00345       Coords max_step = _step.getmax(gd._step);
00346       newto.setstepsize(_step);
00347       newfrom.setstepsize(gd._step);
00348       BBox bb(1,max_step);
00349       gd_OperateRegion(is_lt)(gd, newto, newfrom, max_step, bb);
00350       return (bb);
00351      }
00352     else 
00353      { BBox bb(1,1); return (bb); }
00354   }
00355 
00356 template <class Type>
00357 void GridData(1)<Type>::gd_OperateRegion(is_lt) (Type const &val, 
00358                         BBox const &to, BBox const &from, Coords const &step, 
00359                         BBox &bb)
00360   {
00361    GridData(1)<Type> &dst = *this;
00362 
00363    BeginFastIndex1(dst, dst._bbox, dst._data, Type);
00364 
00365    for_1(i, to, step)
00366       if (FastIndex1(dst,i) < val) bb += Coords(1,i);
00367    end_for
00368 
00369    EndFastIndex1(dst);
00370   }
00371 
00372 template <class Type>
00373 void GridData(1)<Type>::gd_OperateRegion(is_lt) (GridData(1)<Type> const &src, 
00374                         BBox const &to, BBox const &from, Coords const &step,
00375                         BBox &bb)
00376   {
00377    GridData(1)<Type> &dst = *this;
00378    const int di = from.lower(0)-to.lower(0);
00379 
00380    BeginFastIndex1(src, src._bbox, src._data, const Type);
00381    BeginFastIndex1(dst, dst._bbox, dst._data, Type);
00382 
00383    for_1(i, to, step)
00384       if (FastIndex1(dst,i) < FastIndex1(src,i+di))
00385         bb += Coords(1,i);
00386    end_for
00387 
00388    EndFastIndex1(dst);
00389    EndFastIndex1(src);
00390   }
00391 
00392 /************************************************************************/
00393 
00394 /****************************** <= ***************************************/
00395 
00396 template <class Type>
00397 BBox GridData(1)<Type>::is_le (Type const &val, BBox const &where)
00398   {
00399     BBox intersection = _bbox * where;
00400     if (!intersection.empty())
00401       {
00402        Coords max_step = _step.getmax(where.stepsize());
00403        BBox to(intersection); to.setstepsize(_step);
00404        BBox from(intersection); from.setstepsize(where.stepsize());
00405        BBox bb(1,max_step);
00406        gd_OperateRegion(is_le)(val, to, from, max_step, bb);
00407        return (bb);
00408       }
00409     else 
00410      { BBox bb(1,1); return (bb); }
00411   }
00412 
00413 template <class Type>
00414 BBox GridData(1)<Type>::is_le (GridData(1)<Type> const &gd, BBox const &to,
00415                                                 BBox const &from)
00416   {
00417    const Coords  toshift = from.lower() - to.lower();
00418    BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
00419    if (!newfrom.empty())
00420      {
00421       BBox newto = shiftabs(newfrom, -toshift);
00422       Coords max_step = _step.getmax(gd._step);
00423       newto.setstepsize(_step);
00424       newfrom.setstepsize(gd._step);
00425       BBox bb(1,max_step);
00426       gd_OperateRegion(is_le)(gd, newto, newfrom, max_step, bb);
00427       return (bb);
00428      }
00429     else 
00430      { BBox bb(1,1); return (bb); }
00431   }
00432 
00433 template <class Type>
00434 void GridData(1)<Type>::gd_OperateRegion(is_le) (Type const &val, 
00435                         BBox const &to, BBox const &from, Coords const &step, 
00436                         BBox &bb)
00437   {
00438    GridData(1)<Type> &dst = *this;
00439 
00440    BeginFastIndex1(dst, dst._bbox, dst._data, Type);
00441 
00442    for_1(i, to, step)
00443       if (FastIndex1(dst,i) <= val) bb += Coords(1,i);
00444    end_for
00445 
00446    EndFastIndex1(dst);
00447   }
00448 
00449 template <class Type>
00450 void GridData(1)<Type>::gd_OperateRegion(is_le) (GridData(1)<Type> const &src, 
00451                         BBox const &to, BBox const &from, Coords const &step,
00452                         BBox &bb)
00453   {
00454    GridData(1)<Type> &dst = *this;
00455    const int di = from.lower(0)-to.lower(0);
00456 
00457    BeginFastIndex1(src, src._bbox, src._data, const Type);
00458    BeginFastIndex1(dst, dst._bbox, dst._data, Type);
00459 
00460    for_1(i, to, step)
00461       if (FastIndex1(dst,i) <= FastIndex1(src,i+di))
00462         bb += Coords(1,i);
00463    end_for
00464 
00465    EndFastIndex1(dst);
00466    EndFastIndex1(src);
00467   }
00468 
00469 /************************************************************************/
00470 
00471 #endif


Quickstart     Users Guide     Programmers Reference     Installation      Examples     Download



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