Ignore:
Timestamp:
11/24/20 11:33:59 (4 years ago)
Author:
yushan
Message:

trunk : axis interpolate can have coordinate source (coordinate_src) and coordinate destination (coordinate_dst), while previous attribute coordinate compatible to source

File:
1 edited

Legend:

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

    r1852 r1980  
    5050 
    5151CAxisAlgorithmInterpolate::CAxisAlgorithmInterpolate(CAxis* axisDestination, CAxis* axisSource, CInterpolateAxis* interpAxis) 
    52 : CAxisAlgorithmTransformation(axisDestination, axisSource), coordinate_(), transPosition_() 
     52: CAxisAlgorithmTransformation(axisDestination, axisSource), coordinate_(), coordinateDST_(),transPosition_() 
    5353TRY 
    5454{ 
    5555  interpAxis->checkValid(axisSource); 
    5656  order_ = interpAxis->order.getValue(); 
     57  this->idAuxInputs_.clear(); 
    5758  if (!interpAxis->coordinate.isEmpty()) 
    5859  { 
     
    6162    this->idAuxInputs_[0] = coordinate_; 
    6263  } 
     64  else if (!interpAxis->coordinate_src.isEmpty()) 
     65  { 
     66    coordinate_ = interpAxis->coordinate_src.getValue(); 
     67    this->idAuxInputs_.resize(1); 
     68    this->idAuxInputs_[0] = coordinate_; 
     69  } 
     70  if (!interpAxis->coordinate_dst.isEmpty()) 
     71  { 
     72    coordinateDST_ = interpAxis->coordinate_dst.getValue(); 
     73    this->idAuxInputs_.resize(this->idAuxInputs_.size()+1); 
     74    this->idAuxInputs_[this->idAuxInputs_.size()-1] = coordinateDST_; 
     75  } 
     76   
     77 
    6378} 
    6479CATCH 
     
    7186{ 
    7287  CTimer::get("CAxisAlgorithmInterpolate::computeIndexSourceMapping_").resume() ; 
    73   CContext* context = CContext::getCurrent(); 
    74   CContextClient* client=context->client; 
    75   int nbClient = client->clientSize; 
     88   
    7689  CArray<bool,1>& axisMask = axisSrc_->mask; 
    7790  int srcSize  = axisSrc_->n_glo.getValue(); 
     
    90103    XIOSAlgorithms::sortWithIndex<double, CVectorStorage>(recvBuff, indexVec); 
    91104    for (int i = 0; i < srcSize; ++i) valueSrc[i] = recvBuff[indexVec[i]]; 
    92     computeInterpolantPoint(valueSrc, indexVec, idx); 
     105    computeInterpolantPoint(valueSrc, indexVec, dataAuxInputs, idx); 
    93106  } 
    94107  CTimer::get("CAxisAlgorithmInterpolate::computeIndexSourceMapping_").suspend() ; 
     
    97110 
    98111/*! 
    99   Compute the interpolant points 
     112  Compute the interpolant points  
    100113  Assume that we have all value of axis source, with these values, need to calculate weight (coeff) of Lagrange polynomial 
    101114  \param [in] axisValue all value of axis source 
     115  \param [in] dataAuxInputs data for setting values of axis destination 
    102116  \param [in] tranPos position of axis on a domain 
    103117*/ 
    104118void CAxisAlgorithmInterpolate::computeInterpolantPoint(const std::vector<double>& axisValue, 
    105119                                                        const std::vector<int>& indexVec, 
     120                                                        const std::vector<CArray<double,1>* >& dataAuxInputs, 
    106121                                                        int transPos) 
    107122TRY 
     
    115130  CArray<double,1>& axisDestValue = axisDest_->value; 
    116131  int numValue = axisDestValue.numElements(); 
     132  if(!coordinateDST_.empty()) 
     133  { 
     134    int nDomPoint = (*dataAuxInputs[0]).numElements()/numValue ; 
     135    int dst_position_in_data = dataAuxInputs.size()-1; 
     136    for(int ii=0; ii<numValue; ii++) 
     137    { 
     138      axisDestValue(ii) = (*dataAuxInputs[dst_position_in_data])(ii*nDomPoint+transPos); 
     139    } 
     140  } 
     141   
    117142  std::map<int, std::vector<std::pair<int,double> > > interpolatingIndexValues; 
    118143 
     
    172197CATCH 
    173198 
     199 
     200 
    174201/*! 
    175202  Compute weight (coeff) of Lagrange's polynomial 
     
    233260  int numValue = axisValue.numElements(); 
    234261 
     262 
    235263  if (srcSize == numValue)  // Only one client or axis not distributed 
    236264  { 
     
    248276      } 
    249277    } 
    250  
    251278  } 
    252279  else // Axis distributed 
     
    304331TRY 
    305332{ 
    306   if (coordinate_.empty()) 
     333  bool has_src = !coordinate_.empty(); 
     334  bool has_dst = !coordinateDST_.empty(); 
     335   
     336  int nb_inputs=dataAuxInputs.size(); 
     337   
     338   
     339  if (!has_src) 
    307340  { 
    308341    vecAxisValue.resize(1); 
     
    312345    this->transformationWeight_.resize(1); 
    313346  } 
    314   else 
     347  else  
    315348  { 
    316349    CField* field = CField::get(coordinate_); 
Note: See TracChangeset for help on using the changeset viewer.