Ignore:
Timestamp:
Jun 8, 2016, 6:12:12 PM (9 years ago)
Author:
Frederik Heber <heber@…>
Children:
e480fc
Parents:
c9b843
git-author:
Frederik Heber <heber@…> (05/26/16 09:51:07)
git-committer:
Frederik Heber <heber@…> (06/08/16 18:12:12)
Message:

FIX: Replaced 3 by NDIM in SamplingGrid which avoids some confusion with numeric grid levels.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Summation/SetValues/SamplingGrid.cpp

    rc9b843 rc805f7  
    5151
    5252// static instances
    53 const double SamplingGrid::zeroOffset[3] = { 0., 0., 0. };
     53const double SamplingGrid::zeroOffset[NDIM] = { 0., 0., 0. };
    5454
    5555SamplingGrid::SamplingGrid() :
     
    6161}
    6262
    63 SamplingGrid::SamplingGrid(const double _begin[3],
    64     const double _end[3],
     63SamplingGrid::SamplingGrid(const double _begin[NDIM],
     64    const double _end[NDIM],
    6565    const int _level) :
    6666  SamplingGridProperties(_begin, _end, _level)
     
    7171}
    7272
    73 SamplingGrid::SamplingGrid(const double _begin[3],
    74     const double _end[3],
     73SamplingGrid::SamplingGrid(const double _begin[NDIM],
     74    const double _end[NDIM],
    7575    const int _level,
    7676    const sampledvalues_t &_sampled_grid) :
     
    119119  status &= (static_cast<const SamplingGridProperties &>(*this) ==
    120120      static_cast<const SamplingGridProperties &>(_props));
    121   for(size_t i = 0; i<3; ++i) {
     121  for(size_t i = 0; i<NDIM; ++i) {
    122122    status &= begin_window[i] == _props.begin_window[i];
    123123    status &= end_window[i] == _props.end_window[i];
     
    160160  if (isCompatible(other)) {
    161161    /// get minimum of window
    162     double min_begin_window[3];
    163     double min_end_window[3];
     162    double min_begin_window[NDIM];
     163    double min_end_window[NDIM];
    164164    bool doShrink = false;
    165     for (size_t index=0; index<3;++index) {
     165    for (size_t index=0; index<NDIM;++index) {
    166166      if (begin_window[index] <= other.begin_window[index]) {
    167167        min_begin_window[index] = other.begin_window[index];
     
    201201  if (isCompatible(other)) {
    202202    /// get maximum of window
    203     double max_begin_window[3];
    204     double max_end_window[3];
     203    double max_begin_window[NDIM];
     204    double max_end_window[NDIM];
    205205    bool doExtend = false;
    206     for (size_t index=0; index<3;++index) {
     206    for (size_t index=0; index<NDIM;++index) {
    207207      if (begin_window[index] >= other.begin_window[index]) {
    208208        max_begin_window[index] = other.begin_window[index];
     
    273273}
    274274void SamplingGrid::setWindowSize(
    275     const double _begin_window[3],
    276     const double _end_window[3])
    277 {
    278   for (size_t index=0;index<3;++index) {
     275    const double _begin_window[NDIM],
     276    const double _end_window[NDIM])
     277{
     278  for (size_t index=0;index<NDIM;++index) {
    279279    begin_window[index] = getNearestLowerGridPoint(_begin_window[index], index);
    280280    ASSERT( begin_window[index] >= begin[index],
     
    289289
    290290void SamplingGrid::setWindow(
    291     const double _begin_window[3],
    292     const double _end_window[3])
     291    const double _begin_window[NDIM],
     292    const double _end_window[NDIM])
    293293{
    294294  setWindowSize(_begin_window, _end_window);
     
    299299
    300300void SamplingGrid::setDomain(
    301     const double _begin[3],
    302     const double _end[3])
     301    const double _begin[NDIM],
     302    const double _end[NDIM])
    303303{
    304304  setDomainSize(_begin, _end);
     
    309309
    310310void SamplingGrid::extendWindow(
    311     const double _begin_window[3],
    312     const double _end_window[3])
     311    const double _begin_window[NDIM],
     312    const double _end_window[NDIM])
    313313{
    314314#ifndef NDEBUG
    315   for(size_t index=0;index < 3; ++index) {
     315  for(size_t index=0;index < NDIM; ++index) {
    316316    // check that we truly have to extend the window
    317317    ASSERT ( begin_window[index] >= _begin_window[index],
     
    332332#endif
    333333  // copy old window size and values
    334   double old_begin_window[3];
    335   double old_end_window[3];
    336   for(size_t index=0;index<3;++index) {
     334  double old_begin_window[NDIM];
     335  double old_end_window[NDIM];
     336  for(size_t index=0;index<NDIM;++index) {
    337337    old_begin_window[index] = begin_window[index];
    338338    old_end_window[index] = end_window[index];
     
    347347
    348348void SamplingGrid::shrinkWindow(
    349     const double _begin_window[3],
    350     const double _end_window[3])
     349    const double _begin_window[NDIM],
     350    const double _end_window[NDIM])
    351351{
    352352#ifndef NDEBUG
    353   for(size_t index=0;index < 3; ++index) {
     353  for(size_t index=0;index < NDIM; ++index) {
    354354    // check that we truly have to shrink the window
    355355    ASSERT ( begin_window[index] <= _begin_window[index],
     
    370370#endif
    371371  // copy old window size and values
    372   double old_begin_window[3];
    373   double old_end_window[3];
    374   for(size_t index=0;index<3;++index) {
     372  double old_begin_window[NDIM];
     373  double old_end_window[NDIM];
     374  for(size_t index=0;index<NDIM;++index) {
    375375    old_begin_window[index] = begin_window[index];
    376376    old_end_window[index] = end_window[index];
     
    393393
    394394void SamplingGrid::addOntoWindow(
    395     const double _begin_window[3],
    396     const double _end_window[3],
     395    const double _begin_window[NDIM],
     396    const double _end_window[NDIM],
    397397    const sampledvalues_t &_sampled_grid,
    398398    const double prefactor)
     
    410410
    411411void SamplingGrid::addIntoWindow(
    412     const double _begin_window[3],
    413     const double _end_window[3],
     412    const double _begin_window[NDIM],
     413    const double _end_window[NDIM],
    414414    const sampledvalues_t &_sampled_grid,
    415415    const double prefactor)
     
    440440      (std::numeric_limits<size_t>::round_style == std::round_toward_zero) ?
    441441          0.5 : 0.; // need offset to get to round_toward_nearest behavior
    442   for(size_t index=0;index<3;++index) {
     442  for(size_t index=0;index<NDIM;++index) {
    443443    if (fabs(end[index] - begin[index]) > std::numeric_limits<double>::epsilon()*1e4) {
    444444      // we refrain from using floor/ceil as the window's starts and ends,
     
    465465
    466466void SamplingGrid::addWindowOntoWindow(
    467     const double larger_wbegin[3],
    468     const double larger_wend[3],
    469     const double smaller_wbegin[3],
    470     const double smaller_wend[3],
     467    const double larger_wbegin[NDIM],
     468    const double larger_wend[NDIM],
     469    const double smaller_wbegin[NDIM],
     470    const double smaller_wend[NDIM],
    471471    sampledvalues_t &dest_sampled_grid,
    472472    const sampledvalues_t &source_sampled_grid,
     
    475475{
    476476#ifndef NDEBUG
    477   for(size_t index=0;index<3;++index) {
     477  for(size_t index=0;index<NDIM;++index) {
    478478    ASSERT( smaller_wbegin[index] >= larger_wbegin[index],
    479479        "SamplingGrid::addWindowOntoWindow() - given smaller window starts earlier than larger window in component "
     
    485485#endif
    486486  // the only issue are indices
    487   size_t pre_offset[3];
    488   size_t post_offset[3];
    489   size_t length[3];
    490   size_t total[3];
     487  size_t pre_offset[NDIM];
     488  size_t post_offset[NDIM];
     489  size_t length[NDIM];
     490  size_t total[NDIM];
    491491  getDiscreteWindowIndices(
    492492      larger_wbegin, larger_wend,
     
    526526  }
    527527#endif
    528   size_t N[3];
     528  size_t N[NDIM];
    529529//  size_t counter = 0;
    530530  sampledvalues_t::iterator destiter = dest_sampled_grid.begin();
     
    585585  if (status) {
    586586    // compare windows
    587     for (size_t i=0; i<3; ++i) {
     587    for (size_t i=0; i<NDIM; ++i) {
    588588      status &= begin_window[i] == other.begin_window[i];
    589589      status &= end_window[i] == other.end_window[i];
Note: See TracChangeset for help on using the changeset viewer.