Changeset 2033


Ignore:
Timestamp:
02/11/21 13:20:03 (3 years ago)
Author:
ymipsl
Message:

Add extrapolation to vertical interpolation.
YM

Location:
XIOS/trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/config/interpolate_axis_attribute.conf

    r1980 r2033  
    55DECLARE_ATTRIBUTE(StdString, coordinate_src) 
    66DECLARE_ATTRIBUTE(StdString, coordinate_dst) 
     7DECLARE_ATTRIBUTE(bool, extrapolate) 
    78 
  • XIOS/trunk/src/transformation/axis_algorithm_interpolate.cpp

    r1980 r2033  
    5555  interpAxis->checkValid(axisSource); 
    5656  order_ = interpAxis->order.getValue(); 
     57  if (interpAxis->extrapolate.isEmpty()) extrapolate_=false ; 
     58  else extrapolate_=interpAxis->extrapolate ; 
     59   
    5760  this->idAuxInputs_.clear(); 
    5861  if (!interpAxis->coordinate.isEmpty()) 
     
    132135  if(!coordinateDST_.empty()) 
    133136  { 
    134     int nDomPoint = (*dataAuxInputs[0]).numElements()/numValue ; 
    135137    int dst_position_in_data = dataAuxInputs.size()-1; 
     138    int nDomPoint = (*dataAuxInputs[dst_position_in_data]).numElements()/numValue ; 
    136139    for(int ii=0; ii<numValue; ii++) 
    137140    { 
     
    192195 
    193196    } 
    194   } 
    195   computeWeightedValueAndMapping(interpolatingIndexValues, transPos); 
     197    else 
     198    { 
     199      it=itb ; 
     200      if (destValue <= *it)  
     201      { 
     202        int numVal=0 ; 
     203        while(numVal <= order_ && it!=ite) 
     204        { 
     205          if (*it != sfmax) 
     206          {  
     207            interpolatingIndexValues[idx+ibegin].push_back(make_pair(indexVec[std::distance(itb, it)],*it)); 
     208            ++numVal ; 
     209          } 
     210          ++it ; 
     211        } 
     212      } 
     213       
     214      it=ite ; 
     215      --it ; 
     216      if (destValue >= *it)  
     217      { 
     218        int numVal=0 ; 
     219        do 
     220        { 
     221          if (*it != sfmax) 
     222          { 
     223            interpolatingIndexValues[idx+ibegin].push_back(make_pair(indexVec[std::distance(itb, it)],*it)); 
     224            ++numVal ; 
     225          } 
     226          --it ; 
     227        } while(it!=itb && numVal<=order_) ; 
     228      } 
     229    } 
     230  } 
     231   
     232  computeWeightedValueAndMapping(axisDestValue, interpolatingIndexValues, transPos); 
    196233} 
    197234CATCH 
     
    203240  \param [in] interpolatingIndexValues the necessary axis value to calculate the coeffs 
    204241*/ 
    205 void CAxisAlgorithmInterpolate::computeWeightedValueAndMapping(const std::map<int, std::vector<std::pair<int,double> > >& interpolatingIndexValues, int transPos) 
     242void CAxisAlgorithmInterpolate::computeWeightedValueAndMapping(CArray<double,1>& axisDestValue, const std::map<int, std::vector<std::pair<int,double> > >& interpolatingIndexValues, int transPos) 
    206243TRY 
    207244{ 
     
    214251  { 
    215252    int globalIndexDest = it->first; 
    216     double localValue = axisDest_->value(globalIndexDest - ibegin); 
     253//    double localValue = axisDest_->value(globalIndexDest - ibegin); 
     254    double localValue = axisDestValue(globalIndexDest - ibegin); 
    217255    const std::vector<std::pair<int,double> >& interpVal = it->second; 
    218256    int interpSize = interpVal.size(); 
  • XIOS/trunk/src/transformation/axis_algorithm_interpolate.hpp

    r1982 r2033  
    1818class CGrid; 
    1919class CInterpolateAxis; 
    20  
     20  
    2121/*! 
    2222  \class CAxisAlgorithmInterpolate 
     
    4545  void computeInterpolantPoint(const std::vector<double>& recvBuff, const std::vector<int>&,  
    4646                               const std::vector<CArray<double,1>* >& dataAuxInputs, int transPos = 0); 
    47   void computeWeightedValueAndMapping(const std::map<int, std::vector<std::pair<int,double> > >& interpolatingIndexValues, int transPos = 0); 
     47  void computeWeightedValueAndMapping(CArray<double,1>& axisDestValue, const std::map<int, std::vector<std::pair<int,double> > >& interpolatingIndexValues, int transPos = 0); 
    4848  void fillInAxisValue(std::vector<CArray<double,1> >& vecAxisValue, 
    4949                       const std::vector<CArray<double,1>* >& dataAuxInputs); 
     
    5252  // Interpolation order 
    5353  int order_; 
     54  bool extrapolate_ ; 
    5455  StdString coordinate_; 
    5556  StdString coordinateDST_; 
Note: See TracChangeset for help on using the changeset viewer.