Changeset 896


Ignore:
Timestamp:
07/11/16 17:36:08 (8 years ago)
Author:
mhnguyen
Message:

Correcting a bug in axis interpolation

+) Ascending or Descending values of source axis wont affect on the results

Test
+) On Curie
+) Test is correct

Location:
XIOS/trunk/src/transformation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/transformation/axis_algorithm_interpolate.cpp

    r867 r896  
    4444  // Fill in axis value from coordinate 
    4545  fillInAxisValue(vecAxisValue, dataAuxInputs); 
     46  std::vector<double> valueSrc(srcSize); 
     47  std::vector<double> recvBuff(srcSize); 
     48  std::vector<int> indexVec(srcSize); 
    4649 
    4750  for (int idx = 0; idx < vecAxisValue.size(); ++idx) 
    4851  { 
    4952    CArray<double,1>& axisValue = vecAxisValue[idx]; 
    50     std::vector<double> recvBuff(srcSize); 
    51     std::vector<int> indexVec(srcSize); 
    5253    retrieveAllAxisValue(axisValue, axisMask, recvBuff, indexVec); 
    5354    XIOSAlgorithms::sortWithIndex<double, CVectorStorage>(recvBuff, indexVec); 
    54     computeInterpolantPoint(recvBuff, indexVec, idx); 
     55    for (int i = 0; i < srcSize; ++i) valueSrc[i] = recvBuff[indexVec[i]]; 
     56    computeInterpolantPoint(valueSrc, idx); 
    5557  } 
    5658} 
     
    6062  Assume that we have all value of axis source, with these values, need to calculate weight (coeff) of Lagrange polynomial 
    6163  \param [in] axisValue all value of axis source 
    62   \param [in] indexVec permutation index of axisValue 
    63 */ 
    64 void CAxisAlgorithmInterpolate::computeInterpolantPoint(const std::vector<double>& axisValue, const std::vector<int>& indexVec, int transPos) 
     64  \param [in] tranPos position of axis on a domain 
     65*/ 
     66void CAxisAlgorithmInterpolate::computeInterpolantPoint(const std::vector<double>& axisValue, int transPos) 
    6567{ 
    6668  std::vector<double>::const_iterator itb = axisValue.begin(), ite = axisValue.end(); 
    6769  std::vector<double>::const_iterator itLowerBound, itUpperBound, it; 
    68   std::vector<int>::const_iterator itbVec = indexVec.begin(), itVec; 
    6970  const double sfmax = NumTraits<double>::sfmax(); 
    7071 
     
    116117    { 
    117118      int index = std::distance(itb, it); 
    118       interpolatingIndexValues[idx+ibegin].push_back(make_pair(indexVec[index],*it)); 
     119      interpolatingIndexValues[idx+ibegin].push_back(make_pair(index,*it)); 
    119120    } 
    120121  } 
     
    186187        indexVec[idx] = idx; 
    187188      } 
    188       else recvBuff[idx] = NumTraits<double>::sfmax(); 
     189      else 
     190      { 
     191        recvBuff[idx] = NumTraits<double>::sfmax(); 
     192        indexVec[idx] = -1; 
     193      } 
    189194    } 
    190195 
  • XIOS/trunk/src/transformation/axis_algorithm_interpolate.hpp

    r827 r896  
    3333  void retrieveAllAxisValue(const CArray<double,1>& axisValue, const CArray<bool,1>& axisMask, 
    3434                            std::vector<double>& recvBuff, std::vector<int>& indexVec); 
    35   void computeInterpolantPoint(const std::vector<double>& recvBuff, const std::vector<int>& indexVec, int transPos = 0); 
     35  void computeInterpolantPoint(const std::vector<double>& recvBuff, int transPos = 0); 
    3636  void computeWeightedValueAndMapping(const std::map<int, std::vector<std::pair<int,double> > >& interpolatingIndexValues, int transPos = 0); 
    3737  void fillInAxisValue(std::vector<CArray<double,1> >& vecAxisValue, 
     
    4646 
    4747} 
     48 
    4849#endif // __XIOS_AXIS_ALGORITHM_INTERPOLATE_HPP__ 
Note: See TracChangeset for help on using the changeset viewer.