Changeset 937


Ignore:
Timestamp:
09/22/16 10:59:04 (8 years ago)
Author:
mhnguyen
Message:

Smalll improvements for interpolation axis

+) Strictly check order of interpolation
+) Change default order to 1
+) Add precision check

Test
+) On Curie
+) Correct

Location:
XIOS/trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/interpolate_axis.cpp

    r836 r937  
    4040  void CInterpolateAxis::checkValid(CAxis* axisSrc) 
    4141  { 
    42     if (this->order.isEmpty()) this->order.setValue(2); 
     42    if (this->order.isEmpty()) this->order.setValue(1); 
    4343    int order = this->order.getValue(); 
    4444    if (order >= axisSrc->n_glo.getValue()) 
     
    4646      ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)", 
    4747             << "Order of interpolation is greater than global size of axis source" 
     48             << "Size of axis source " <<axisSrc->getId() << " is " << axisSrc->n_glo.getValue()  << std::endl 
     49             << "Order of interpolation is " << order ); 
     50    } 
     51 
     52    if (order < 1) 
     53    { 
     54      ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)", 
     55             << "Order of interpolation is smaller than 1" 
    4856             << "Size of axis source " <<axisSrc->getId() << " is " << axisSrc->n_glo.getValue()  << std::endl 
    4957             << "Order of interpolation is " << order ); 
  • XIOS/trunk/src/transformation/axis_algorithm_interpolate.cpp

    r933 r937  
    9797{ 
    9898  std::vector<double>::const_iterator itb = axisValue.begin(), ite = axisValue.end(); 
    99   std::vector<double>::const_iterator itLowerBound, itUpperBound, it, iteRange; 
     99  std::vector<double>::const_iterator itLowerBound, itUpperBound, it, iteRange, itfirst, itsecond; 
    100100  const double sfmax = NumTraits<double>::sfmax(); 
     101  const double precision = NumTraits<double>::dummy_precision(); 
    101102 
    102103  int ibegin = axisDest_->begin.getValue(); 
     
    116117 
    117118    if ((ite == itLowerBound) || (ite == itUpperBound)) outOfRange = true; 
    118     // If the value is not in the range, that means we'll do extra-polation 
    119 //    if (ite == itLowerBound) // extra-polation 
    120 //    { 
    121 //      itLowerBound = itb; 
    122 //      itUpperBound = itb + order_+1; 
    123 //    } 
    124 //    else if (ite == itUpperBound) // extra-polation 
    125 //    { 
    126 //      itLowerBound = itUpperBound - order_-1; 
    127 //    } 
    128 //else 
     119 
    129120    // We don't do extrapolation FOR NOW, maybe in the future 
    130121    if (!outOfRange) 
    131122    { 
    132123      if ((itLowerBound == itUpperBound) && (itb != itLowerBound)) --itLowerBound; 
     124      double distanceToLower = destValue - *itLowerBound; 
     125      double distanceToUpper = *itUpperBound - destValue; 
    133126      int order = (order_ + 1) - 2; 
    134       bool down = true; 
     127      bool down = (distanceToLower < distanceToUpper) ? true : false; 
    135128      for (int k = 0; k < order; ++k) 
    136129      { 
     
    138131        { 
    139132          --itLowerBound; 
    140           down = false; 
     133          distanceToLower = destValue - *itLowerBound; 
     134          down = (distanceToLower < distanceToUpper) ? true : false; 
    141135          continue; 
    142136        } 
     
    144138        { 
    145139          ++itUpperBound; 
    146           down = true; 
    147         } 
    148       } 
    149  
     140          distanceToUpper = *itUpperBound - destValue; 
     141          down = (distanceToLower < distanceToUpper) ? true : false; 
     142 
     143        } 
     144      } 
    150145 
    151146      iteRange = (ite == itUpperBound) ? itUpperBound : itUpperBound + 1; 
    152       for (it = itLowerBound; it != iteRange; ++it) 
    153       { 
     147      itsecond = it = itLowerBound; ++itsecond; 
     148      while (it < iteRange) 
     149      { 
     150        while (((*itsecond -*it) < precision) && itsecond < ite) 
     151        { ++itsecond; ++it; } 
    154152        int index = std::distance(itb, it); 
    155153        interpolatingIndexValues[idx+ibegin].push_back(make_pair(indexVec[index],*it)); 
    156       } 
     154        ++it; ++itsecond; 
     155      } 
     156 
    157157    } 
    158158  } 
Note: See TracChangeset for help on using the changeset viewer.