Changeset 2328


Ignore:
Timestamp:
05/13/22 09:49:18 (2 years ago)
Author:
jderouillat
Message:

Set extrapolation as an option (set by default to true) in axis interpolation using the coordinate attribute

Location:
XIOS/dev/dev_ym/XIOS_COUPLING/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/config/interpolate_axis_attribute.conf

    r2122 r2328  
    55DECLARE_ATTRIBUTE(StdString, coordinate_src) 
    66DECLARE_ATTRIBUTE(StdString, coordinate_dst) 
     7DECLARE_ATTRIBUTE(bool, extrapolate) 
     8 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_interpolate_coordinate.cpp

    r2282 r2328  
    8282 
    8383    order_ = interpAxis->order.getValue(); 
     84     
     85    if (interpAxis->extrapolate.isEmpty()) extrapolate_=true ; 
     86    else extrapolate_=interpAxis->extrapolate ; 
     87 
    8488    if (!interpAxis->coordinate.isEmpty()) 
    8589    { 
     
    287291        for(int i=0; i < ndst;i++) 
    288292        { 
     293          bool intrapolating( true ); 
    289294          x=dstCoordinate[dstIndex[i]] ; 
    290           if ( x<=srcCoordinate[srcIndex[0]]) lastj=0 ; 
    291           else if (x>=srcCoordinate[srcIndex[nsrc-1]]) lastj=nsrc-2 ; 
     295          if ( x<=srcCoordinate[srcIndex[0]]) 
     296          { 
     297            lastj=0 ; 
     298            intrapolating = false; 
     299          } 
     300          else if (x>=srcCoordinate[srcIndex[nsrc-1]]) 
     301          { 
     302            lastj=nsrc-2 ; 
     303            intrapolating = false; 
     304          } 
    292305          else 
    293306          { 
     
    298311            }   
    299312          } 
    300           x0=srcCoordinate[srcIndex[lastj]] ; 
    301           x1=srcCoordinate[srcIndex[lastj+1]] ; 
    302           y0=srcValue[srcIndex[lastj]] ; 
    303           y1=srcValue[srcIndex[lastj+1]] ; 
    304           y=((x-x1)*y0-(x-x0)*y1)/(x0-x1) ; 
    305           dstValue[dstIndex[i]]=y ; 
     313          if ((!extrapolate_) && (!intrapolating)) 
     314          { 
     315            dstValue[dstIndex[i]]= std::numeric_limits<double>::quiet_NaN() ; 
     316          } 
     317          else 
     318          { 
     319            x0=srcCoordinate[srcIndex[lastj]] ; 
     320            x1=srcCoordinate[srcIndex[lastj+1]] ; 
     321            y0=srcValue[srcIndex[lastj]] ; 
     322            y1=srcValue[srcIndex[lastj+1]] ; 
     323            y=((x-x1)*y0-(x-x0)*y1)/(x0-x1) ; 
     324            dstValue[dstIndex[i]]=y ; 
     325          } 
    306326        } 
    307327      } 
     
    315335      for(int i=0; i < ndst;i++) 
    316336      { 
     337        bool intrapolating( true ); 
    317338        x=dstCoordinate[dstIndex[i]] ; 
    318         if ( x<=srcCoordinate[srcIndex[0]]) lastj=0 ; 
    319         else if (x>=srcCoordinate[srcIndex[nsrc-1]]) lastj=nsrc-2 ; 
     339        if ( x<=srcCoordinate[srcIndex[0]]) 
     340        { 
     341          lastj=0 ; 
     342          intrapolating = false; 
     343        } 
     344        else if (x>=srcCoordinate[srcIndex[nsrc-1]]) 
     345        { 
     346          lastj=nsrc-2 ; 
     347          intrapolating = false; 
     348        } 
    320349        else 
    321350        { 
     
    333362          if ( (x-srcCoordinate[srcIndex[lastj-1]]) > (srcCoordinate[srcIndex[lastj+2]]-x) ) cj=lastj ; 
    334363          else cj=lastj+1 ; 
    335         }  
    336         x0=srcCoordinate[srcIndex[cj-1]] ; 
    337         x1=srcCoordinate[srcIndex[cj]] ; 
    338         x2=srcCoordinate[srcIndex[cj+1]] ; 
    339         y0=srcValue[srcIndex[cj-1]] ; 
    340         y1=srcValue[srcIndex[cj]] ; 
    341         y2=srcValue[srcIndex[cj+1]] ; 
    342              
    343         y=y0*(x-x1)*(x-x2)/((x0-x1)*(x0-x2)) + y1*(x-x0)*(x-x2)/((x1-x0)*(x1-x2)) + y2*(x-x0)*(x-x1)/((x2-x0)*(x2-x1))  ; 
    344         dstValue[dstIndex[i]]=y ; 
     364        } 
     365        if ((!extrapolate_) && (!intrapolating)) 
     366        { 
     367          dstValue[dstIndex[i]]= std::numeric_limits<double>::quiet_NaN() ; 
     368        } 
     369        else 
     370        { 
     371          x0=srcCoordinate[srcIndex[cj-1]] ; 
     372          x1=srcCoordinate[srcIndex[cj]] ; 
     373          x2=srcCoordinate[srcIndex[cj+1]] ; 
     374          y0=srcValue[srcIndex[cj-1]] ; 
     375          y1=srcValue[srcIndex[cj]] ; 
     376          y2=srcValue[srcIndex[cj+1]] ; 
     377           
     378          y=y0*(x-x1)*(x-x2)/((x0-x1)*(x0-x2)) + y1*(x-x0)*(x-x2)/((x1-x0)*(x1-x2)) + y2*(x-x0)*(x-x1)/((x2-x0)*(x2-x1))  ; 
     379          dstValue[dstIndex[i]]=y ; 
     380        } 
     381 
    345382      } 
    346383    } 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_interpolate_coordinate.hpp

    r2270 r2328  
    4545  // Interpolation order 
    4646  int order_; 
     47  bool extrapolate_ ; 
    4748  StdString coordinateSrc_; // pressure src 
    4849  StdString coordinateDest_; // pressure dst 
Note: See TracChangeset for help on using the changeset viewer.