Ignore:
Timestamp:
Jun 8, 2016, 10:45:28 PM (9 years ago)
Author:
Frederik Heber <heber@…>
Children:
26f238
Parents:
6369bc
git-author:
Frederik Heber <heber@…> (05/26/16 09:46:06)
git-committer:
Frederik Heber <heber@…> (06/08/16 22:45:28)
Message:

SamplingGridUnitTest checks downsample on window.

  • FIX: getLengthsOfGrid() asserted that total equals 2level which is only true if the window spans the whole grid. We now assert for equal or less.
  • Renamed getLengthsOfGrid -> getLengthsOfWindow.
  • Extended downsample() tests to check for level difference of one to three.
File:
1 edited

Legend:

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

    r6369bc r6c0b3f  
    674674};
    675675
    676 static void getLengthsOfGrid(
     676static void getLengthsOfWindow(
    677677    int _total[NDIM],
    678678    const SamplingGrid &_grid)
     
    688688          } else
    689689            _total[index] = 0;
    690           ASSERT (_total[index] == ::pow(2, _grid.level),
     690          // we can only assert that its atmost the maximum number of grid points
     691          ASSERT (_total[index] <= ::pow(2, _grid.level),
    691692              "SamplingGrid::downsample() - total "+toString(_total[index])
    692               +" does not match 2^level: "+toString(_grid.level));
     693              +" is not equal or less than 2^level: "+toString(_grid.level));
    693694        }
    694695}
     
    788789    static_cast<SamplingGridProperties &>(instance) = other;
    789790    instance.setWindowSize(other.begin_window, other.end_window);
    790     if (_level >= other.level) {
     791    ASSERT( _level <= other.level,
     792        "SamplingGrid::downsample() - desired level "+toString(_level)
     793        +" larger than level "+toString(other.level)+" of the given values.");
     794    if (_level == other.level) {
    791795      instance.sampled_grid = other.sampled_grid;
    792796    } else {
     
    801805      int length_d[3];
    802806      int length_s[3];
    803       getLengthsOfGrid(length_s, other);
     807      getLengthsOfWindow(length_s, other);
    804808      for (instance.level = other.level-1; instance.level >= _level; --instance.level) {
    805         getLengthsOfGrid(length_d, instance);
     809        getLengthsOfWindow(length_d, instance);
    806810        // we always have an eighth of the number of sample points as we stop
     811        ASSERT( sourcevalues->size() % 8 == 0,
     812            "SamplingGrid::downsample() - at level "+toString( instance.level)
     813            +" given grid points "+toString(sourcevalues->size())+" are not even numbered per axis anymore.");
    807814        sampledvalues_t downsampled(sourcevalues->size()/(size_t)8, 0.);
    808815        restrictFullWeight(downsampled, length_d, *sourcevalues, length_s);
Note: See TracChangeset for help on using the changeset viewer.