Changeset 2313


Ignore:
Timestamp:
03/21/22 15:27:07 (2 years ago)
Author:
ymipsl
Message:

Take into account detect_missing_value and renormalize attribute for interpolate class transformation.

YM

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

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/weight_transform_connector.cpp

    r2267 r2313  
    55 
    66  CWeightTransformConnector::CWeightTransformConnector(shared_ptr<CLocalView> srcView, shared_ptr<CLocalView> dstView, unordered_map<int, std::vector<int>>& indexMap,  
    7                                                    unordered_map<int, std::vector<double>>& weightMap) : srcView_(srcView), dstView_(dstView) 
     7                                                       unordered_map<int, std::vector<double>>& weightMap,  bool detectMissingValue, bool renormalize) :  
     8                                                       srcView_(srcView), dstView_(dstView), detectMissingValue_(detectMissingValue), renormalize_(renormalize) 
    89  { 
    910    computeConnector(indexMap, weightMap) ; 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/weight_transform_connector.hpp

    r2267 r2313  
    2323      int srcSize_ ; 
    2424      int dstSize_ ; 
     25      bool detectMissingValue_ ; 
     26      bool renormalize_ ; 
    2527 
    2628     void computeConnector(unordered_map<int, std::vector<int>>& indexMap, unordered_map<int, std::vector<double>>& weightMap) ; 
     
    2931 
    3032    CWeightTransformConnector(shared_ptr<CLocalView> srcView, shared_ptr<CLocalView> dstView, unordered_map<int, std::vector<int>>& indexMap,  
    31                               unordered_map<int, std::vector<double>>& weightMap) ; 
     33                              unordered_map<int, std::vector<double>>& weightMap, bool detectMissingValue, bool renormalize) ; 
    3234  
    3335    void transfer(int repeat, int sizeT, const CArray<double,1>& dataIn, CArray<double,1>& dataOut) 
     
    3638      int srcSlice = srcSize_*sizeT ; 
    3739      dataOut.resize(repeat* dstSlice) ; 
    38       dataOut=0 ; // what to do about missing value => next step ? 
    39  
     40      double defaultValue = std::numeric_limits<double>::quiet_NaN(); 
     41      dataOut = defaultValue ; // what to do about missing value => next step ? 
    4042      const double* input = dataIn.dataFirst()  ; 
    4143      double* output = dataOut.dataFirst()  ; 
     44      vector<bool> isFirst(dstSlice) ; 
     45      size_t pos ; 
     46       
     47      if (renormalize_) 
     48      { 
     49        double inVal ; 
     50        vector<double> renormalizeFactor(repeat*dstSlice,1) ; 
     51        double* renorm = renormalizeFactor.data() ; 
     52        for(int r=0;r<repeat;r++, input+=srcSlice, output+=dstSlice, renorm+=dstSlice) 
     53        { 
     54          const double* in = input; 
     55          double* out = output ; 
     56          double* ren = renorm ; 
     57          isFirst.assign(dstSlice,true) ; 
     58          pos=0 ; 
     59          int k=0 ; 
     60          for(int i=0; i<dstSize_; i++, out+=sizeT, pos+=sizeT, ren+=sizeT) 
     61            for(int j=0 ; j<nWeights_[i] ; j++,k++) 
     62              for(int l=0; l<sizeT; l++) 
     63              { 
     64                inVal=in[connector_[k]*sizeT+l] ; 
     65                if (!std::isnan(inVal)) 
     66                { 
     67                  if (isFirst[pos+l])  { out[l] = inVal*weights_[k] ; isFirst[pos+l]=false ;} 
     68                  else out[l] += inVal*weights_[k] ; 
     69                } 
     70                else  ren[l] -= weights_[k] ; 
     71              } 
     72          for(int i=0; i<dstSlice; i++) output[i] /= renorm[i] ;  
     73        } 
     74      } 
     75      else if (detectMissingValue_) 
     76      { 
     77        double inVal ; 
     78        for(int r=0;r<repeat;r++, input+=srcSlice, output+=dstSlice) 
     79        { 
     80          const double* in = input; 
     81          double* out = output ; 
     82          isFirst.assign(dstSlice,true) ; 
     83          pos=0 ; 
     84          int k=0 ; 
     85          for(int i=0; i<dstSize_; i++, out+=sizeT, pos+=sizeT) 
     86            for(int j=0 ; j<nWeights_[i] ; j++,k++) 
     87              for(int l=0; l<sizeT; l++) 
     88              { 
     89                inVal=in[connector_[k]*sizeT+l] ; 
     90                if (!std::isnan(inVal)) 
     91                { 
     92                  if (isFirst[pos+l])  { out[l] = inVal*weights_[k] ; isFirst[pos+l]=false ;} 
     93                  else out[l] += inVal*weights_[k] ; 
     94                } 
     95              } 
     96        } 
    4297 
    43       for(int r=0;r<repeat;r++, input+=srcSlice, output+=dstSlice) 
     98      } 
     99      else 
    44100      { 
    45         const double* in = input; 
    46         double* out = output ; 
    47         int k=0 ; 
    48         for(int i=0; i<dstSize_; i++, out+=sizeT) 
    49           for(int j=0 ; j<nWeights_[i] ; j++,k++) 
    50             for(int l=0; l<sizeT; l++) out[l] += in[connector_[k]*sizeT+l]*weights_[k] ; 
     101        for(int r=0;r<repeat;r++, input+=srcSlice, output+=dstSlice) 
     102        { 
     103          const double* in = input; 
     104          double* out = output ; 
     105          isFirst.assign(dstSlice,true) ; 
     106          pos=0 ; 
     107          int k=0 ; 
     108          for(int i=0; i<dstSize_; i++, out+=sizeT, pos+=sizeT) 
     109            for(int j=0 ; j<nWeights_[i] ; j++,k++) 
     110              for(int l=0; l<sizeT; l++)  
     111                if (isFirst[pos+l])  { out[l] = in[connector_[k]*sizeT+l]*weights_[k] ; isFirst[pos+l]=false ;} 
     112                else out[l] += in[connector_[k]*sizeT+l]*weights_[k] ; 
     113        } 
    51114      } 
    52115    } 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/algorithm_transformation_weight.cpp

    r2267 r2313  
    66 
    77 
    8   void CAlgorithmTransformationWeight::computeAlgorithm(shared_ptr<CLocalView> srcView, shared_ptr<CLocalView> dstView) 
     8  void CAlgorithmTransformationWeight::computeAlgorithm(shared_ptr<CLocalView> srcView, shared_ptr<CLocalView> dstView, bool detectMissingValue, bool renormalize) 
    99  { 
    1010    this->computeRecvElement(srcView, dstView) ; 
    11     weightTransformConnector_ = make_shared<CWeightTransformConnector>(recvElement_->getView(CElementView::FULL), dstView, transformationMapping_, transformationWeight_) ;  
     11    weightTransformConnector_ = make_shared<CWeightTransformConnector>(recvElement_->getView(CElementView::FULL), dstView, transformationMapping_, transformationWeight_, detectMissingValue, renormalize) ;  
    1212  } 
    1313  
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/algorithm_transformation_weight.hpp

    r2267 r2313  
    1515    public: 
    1616 
    17       CAlgorithmTransformationWeight(bool isSource) : CGenericAlgorithmTransformation(isSource) {} 
     17      CAlgorithmTransformationWeight(bool isSource) : CGenericAlgorithmTransformation(isSource) {}  
     18                                                                                                  
    1819      virtual ~CAlgorithmTransformationWeight() {}; 
    1920      virtual void apply(int dimBefore, int dimAfter, const CArray<double,1>& dataIn, CArray<double,1>& dataOut); 
    2021      virtual void computeRecvElement(shared_ptr<CLocalView> srcView, shared_ptr<CLocalView> dstView); 
    2122    protected: 
    22       virtual void computeAlgorithm(shared_ptr<CLocalView> srcView, shared_ptr<CLocalView> dstView) ; 
     23      virtual void computeAlgorithm(shared_ptr<CLocalView> srcView, shared_ptr<CLocalView> dstView, bool detectMissingValue, bool renormalize) ; 
    2324 
    2425      //! Map between global index of destination element and source element 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_interpolate.cpp

    r2270 r2313  
    6868  std::vector<CArray<double,1>* > dataAuxInputs ; 
    6969  computeRemap(dataAuxInputs) ; 
    70   this->computeAlgorithm(axisSource->getLocalView(CElementView::WORKFLOW), axisDestination->getLocalView(CElementView::WORKFLOW)) ; 
     70  this->computeAlgorithm(axisSource->getLocalView(CElementView::WORKFLOW), axisDestination->getLocalView(CElementView::WORKFLOW), false, false) ; 
    7171} 
    7272CATCH 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/domain_algorithm/domain_algorithm_interpolate.cpp

    r2270 r2313  
    102102  else computeRemap();  
    103103 
    104     this->computeAlgorithm(domainSource->getLocalView(CElementView::WORKFLOW), domainDestination->getLocalView(CElementView::WORKFLOW)) ; 
     104    this->computeAlgorithm(domainSource->getLocalView(CElementView::WORKFLOW), domainDestination->getLocalView(CElementView::WORKFLOW), detectMissingValue, renormalize) ; 
    105105     
    106106} 
Note: See TracChangeset for help on using the changeset viewer.