Changeset 1999


Ignore:
Timestamp:
01/03/21 18:00:43 (9 months ago)
Author:
ymipsl
Message:

Adapt transformation algorithm to new infrastructure (on going...)

YM

Location:
XIOS/dev/dev_ym/XIOS_COUPLING/src
Files:
8 added
33 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/element.hpp

    r1930 r1999  
    3232    void recvFromClient(CEventServer& event) ; 
    3333    size_t getGlobalSize(void) { return globalSize_;} 
    34  
     34    std::map<int, CArray<size_t,1>>& getGlobalIndex(void) { return globalIndex_;} 
     35     
    3536    CDistributedView* getView(CElementView::type type)  
    3637    {  
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_local_view.hpp

    r1930 r1999  
    1919      CGridLocalView(CGridLocalElements* parent, CElementView::type type) ; 
    2020      std::vector<CLocalView*>& getViews(void) {return views_ ;} 
     21      CLocalView* getView(int i) {return views_[i] ;} 
    2122      int getSize() { return size_ ;} 
    2223  } ; 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_remote_connector.cpp

    r1984 r1999  
    1111                       : srcView_(srcView), dstView_(dstView), localComm_(localComm), remoteSize_(remoteSize)  
    1212  {} 
     13 
     14  CGridRemoteConnector::CGridRemoteConnector(vector<CLocalView*>& srcView, vector<CLocalView*>& dstView, MPI_Comm localComm, int remoteSize)  
     15                       : srcView_(srcView), localComm_(localComm), remoteSize_(remoteSize)  
     16  { 
     17    for(auto& it : dstView) dstView_.push_back((CDistributedView*) it) ;  
     18  } 
    1319 
    1420  void CGridRemoteConnector::computeConnector(void) 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_remote_connector.hpp

    r1938 r1999  
    1919 
    2020      CGridRemoteConnector(vector<CLocalView*>& srcView, vector<CDistributedView*>& dstView, MPI_Comm localComm, int remoteSize) ; 
     21      CGridRemoteConnector(vector<CLocalView*>& srcView, vector<CLocalView*>& dstView, MPI_Comm localComm, int remoteSize) ; 
    2122      void computeConnector(void) ; 
    2223      void computeGenericMethod(void) ; 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/transfer_transform_connector.hpp

    r1996 r1999  
    4747          if (mask_[i]) 
    4848          { 
    49             for(int l=0; l<sizeT; l++) out[l] += in[connector_[k]*sizeT+l] ; 
     49            for(int l=0; l<sizeT; l++) out[l] = in[connector_[k]*sizeT+l] ; 
    5050            k++ ; 
    5151          } 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/filter/transform_filter.cpp

    r1984 r1999  
    11#include "transform_filter.hpp" 
     2#include "grid_algorithm.hpp" 
    23 
    34namespace xios 
    45{ 
    56   
    6   CTransformFilter::CTransformFilter( CGarbageCollector& gc, CGenericAlgorithmTransformation* algo, int dimBefore, int dimAfter,  
    7                                       bool detectMissingValues, double defaultValue)  
    8                                     : CFilter(gc, 1, this), algorithm_(algo), dimBefore_(dimBefore), dimAfter_(dimAfter),  
     7  CTransformFilter::CTransformFilter( CGarbageCollector& gc, CGridAlgorithm* algo, bool detectMissingValues, double defaultValue)  
     8                                    : CFilter(gc, 1, this), algorithm_(algo),  
    99                                      detectMissingValues_(detectMissingValues), defaultValue_(defaultValue) 
    1010  { 
     
    2020    packet->status = data[0]->status; 
    2121 
    22     if (packet->status == CDataPacket::NO_ERROR) algorithm_->apply(dimBefore_, dimAfter_, data[0]->data, packet->data); 
     22    if (packet->status == CDataPacket::NO_ERROR) algorithm_->apply(data[0]->data, packet->data); 
    2323    return packet; 
    2424  } 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/filter/transform_filter.hpp

    r1984 r1999  
    33 
    44#include "filter.hpp" 
    5 #include "generic_algorithm_transformation.hpp" 
     5#include "grid_algorithm.hpp" 
    66 
    77namespace xios 
     
    1515    public: 
    1616 
    17       CTransformFilter(CGarbageCollector& gc, CGenericAlgorithmTransformation* algo, int dimBefore, int dimAfter,  
    18                               bool detectMissingValues, double defaultValue) ; 
     17      CTransformFilter(CGarbageCollector& gc, CGridAlgorithm* algo, bool detectMissingValues, double defaultValue) ; 
    1918 
    2019    protected: 
     
    2726    private : 
    2827      
    29      CGenericAlgorithmTransformation* algorithm_ ; 
    30      int dimBefore_ ; 
    31      int dimAfter_ ; 
     28     CGridAlgorithm* algorithm_ ; 
    3229     bool detectMissingValues_ ; 
    3330     bool defaultValue_ ; 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.cpp

    r1988 r1999  
    850850        CGrid* newGrid ; 
    851851        std::pair<std::shared_ptr<CFilter>, std::shared_ptr<CFilter> > filters = grid_->buildTransformationGraph(gc, true, nullptr, detectMissingValues, defaultValue, newGrid) ; 
     852        newGrid->duplicateAttributes(grid_) ; // for grid attributes (mask) 
    852853        grid_ = newGrid ; 
    853854        grid_ref=grid_->getId() ; // for server  
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp

    r1994 r1999  
    2727#include "grid_transformation_factory_impl.hpp" 
    2828#include "transform_filter.hpp" 
     29#include "grid_algorithm.hpp" 
    2930 
    3031 
     
    241242     for (int idx = 0; idx < order_.size(); ++idx) axis_domain_order(idx)=order_[idx]; 
    242243     CDomain* domain = vDomainGroup_->createChild(id); 
     244     isDomListSet=false ; 
    243245     computeElements(); 
    244246     return domain ; 
     
    253255     for (int idx = 0; idx < order_.size(); ++idx) axis_domain_order(idx)=order_[idx]; 
    254256     CAxis* axis=vAxisGroup_->createChild(id); 
     257     isAxisListSet=false ; 
    255258     computeElements();  
    256259     return axis ; 
     
    265268     for (int idx = 0; idx < order_.size(); ++idx) axis_domain_order(idx)=order_[idx]; 
    266269     CScalar* scalar =  vScalarGroup_->createChild(id); 
     270     isScalarListSet=false ; 
    267271     computeElements(); 
    268272     return scalar; 
     
    19221926    else   
    19231927    { 
    1924       newGrid = CGrid::create(newId) ; // give it an id later ?? 
     1928      newGrid = CGrid::create(newId) ; 
    19251929      isNewGrid = true ; 
    19261930    } 
     
    19301934    bool hasRemainTransform=false ; 
    19311935    CGenericAlgorithmTransformation* algo ; 
    1932     int dimBefore=1 ; 
    1933     int dimAfter=1 ; 
     1936    int pos ; 
    19341937 
    19351938    for(int i=0 ; i<elements_.size(); i++) 
     
    19581961      if (hasTransform && !hadTransform) 
    19591962      { 
     1963        pos=i ; 
    19601964        EElement dstElementType=transformationPath.getNextElementType() ; 
    19611965        string dstElementId=transformationPath.getNextElementId() ; 
     
    20752079          domain->checkAttributes() ; 
    20762080          
    2077           if (hadTransform) dimBefore*=domain->getLocalView(CElementView::WORKFLOW)->getLocalSize() ; 
    2078           else dimAfter*=domain->getLocalView(CElementView::WORKFLOW)->getLocalSize() ; 
    20792081          if (isNewGrid) newGrid->addDomain(srcElementId) ; 
    20802082        } 
     
    20912093          axis->checkAttributes() ; 
    20922094          
    2093           if (hadTransform) dimBefore*=axis->getLocalView(CElementView::WORKFLOW)->getLocalSize() ; 
    2094           else dimAfter*=axis->getLocalView(CElementView::WORKFLOW)->getLocalSize() ; 
    20952095          if (isNewGrid) newGrid->addAxis(srcElementId) ; 
    20962096        } 
     
    21072107          scalar->checkAttributes() ; 
    21082108          
    2109           if (hadTransform) dimBefore*=scalar->getLocalView(CElementView::WORKFLOW)->getLocalSize() ; 
    2110           else dimAfter*=scalar->getLocalView(CElementView::WORKFLOW)->getLocalSize() ; 
    21112109          if (isNewGrid) newGrid->addScalar(srcElementId) ; 
    21122110        } 
     
    21212119      if (!isSource) 
    21222120      { 
    2123         shared_ptr<CTransformFilter> transformFilter = shared_ptr<CTransformFilter>(new CTransformFilter(gc, algo, dimBefore, dimAfter, detectMissingValues, defaultValue)) ; 
     2121        CGridAlgorithm* gridAlgorithm  ; 
     2122        if (isNewGrid) 
     2123        {  
     2124          gridAlgorithm = algo->createGridAlgorithm(gridSrc, newGrid, pos) ; 
     2125          newGrid->setGridAlgorithm(gridAlgorithm); 
     2126        } 
     2127        else gridAlgorithm = newGrid->getGridAlgorithm() ; 
     2128 
     2129        shared_ptr<CTransformFilter> transformFilter = shared_ptr<CTransformFilter>(new CTransformFilter(gc, gridAlgorithm, detectMissingValues, defaultValue)) ; 
    21242130        outputFilter->connectOutput(transformFilter,0) ; 
    21252131        outputFilter = transformFilter ; 
     
    21292135      { 
    21302136        gridSrc=newGrid ; 
    2131         pair<shared_ptr<CFilter>, shared_ptr<CFilter> > filters = gridSrc->buildTransformationGraph(gc, isSource, gridSrc, detectMissingValues, defaultValue, newGrid) ; 
     2137        pair<shared_ptr<CFilter>, shared_ptr<CFilter> > filters = this->buildTransformationGraph(gc, isSource, gridSrc, detectMissingValues, defaultValue, newGrid) ; 
    21322138        outputFilter->connectOutput(filters.first,0) ; 
    21332139        outputFilter=filters.second ; 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.hpp

    r1988 r1999  
    2222#include "transformation_path.hpp" 
    2323#include "filter.hpp" 
     24#include "grid_algorithm.hpp" 
    2425 
    2526 
     
    239240                                                                                  double defaultValue, CGrid*& newGrid) ; 
    240241      private: 
     242        CGridAlgorithm* gridAlgorithm_ = nullptr ; 
     243      public: 
     244        void setGridAlgorithm(CGridAlgorithm* gridAlgorithm) {gridAlgorithm_ = gridAlgorithm;} 
     245        CGridAlgorithm* getGridAlgorithm(void) { return gridAlgorithm_ ;} 
     246      private: 
    241247         bool isTransformed_, isGenerated_; 
    242248         CGridTransformation* transformations_; 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/Functions/reduction_types.hpp

    r979 r1999  
    1010#define __XIOS_REDUCTION_TYPES_HPP__ 
    1111 
    12 namespace xios { 
     12namespace xios 
     13{ 
    1314 
    14   typedef enum reduction_alogirthm_type 
     15  typedef enum reduction_algurithm_type 
    1516  { 
    1617    TRANS_REDUCE_SUM = 0, 
     
    2122  } EReductionType; 
    2223 
     24  enum class EReduction 
     25  { 
     26    sum, min, max, extract, average 
     27  } ; 
    2328} 
    2429#endif // __XIOS_REDUCTION_TYPES_HPP__ 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/algorithm_transformation_transfer.cpp

    r1997 r1999  
    3232  } 
    3333   
     34  void CAlgorithmTransformationTransfer::computeRecvElement(CLocalView* srcView, CLocalView* dstView) 
     35  { 
     36    set<size_t> srcIndex ; 
     37    for(auto& it : transformationMapping_) srcIndex.insert(it.second) ; 
     38 
     39    CArray<size_t,1> srcArrayIndex(srcIndex.size()) ; 
     40    int i=0 ; 
     41    for(size_t index : srcIndex) { srcArrayIndex(i) = index ; i++ ;} 
     42    recvElement_ = new CLocalElement(CContext::getCurrent()->getIntraCommRank(), srcView->getGlobalSize(), srcArrayIndex) ; 
     43    recvElement_->addFullView() ; 
     44  } 
     45 
    3446} 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/algorithm_transformation_transfer.hpp

    r1997 r1999  
    1616      virtual ~CAlgorithmTransformationTransfer() {}; 
    1717      virtual void apply(int dimBefore, int dimAfter, const CArray<double,1>& dataIn, CArray<double,1>& dataOut); 
     18      void computeRecvElement(CLocalView* srcView, CLocalView* dstView) ; 
    1819    
    1920    protected: 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/algorithm_transformation_weight.cpp

    r1997 r1999  
    88  void CAlgorithmTransformationWeight::computeAlgorithm(CLocalView* srcView, CLocalView* dstView) 
    99 { 
    10    auto& srcMap = transformationMapping_ ; 
    11    set<size_t> srcIndex ; 
    12    for(auto& it : srcMap) 
    13      for(size_t index : it.second) srcIndex.insert(index) ; 
    14  
    15     CArray<size_t,1> srcArrayIndex(srcIndex.size()) ; 
    16     int i=0 ; 
    17     for(size_t index : srcIndex) { srcArrayIndex(i) = index ; i++ ;} 
    18     CLocalElement recvElement(CContext::getCurrent()->getIntraCommRank(), srcView->getGlobalSize(), srcArrayIndex) ; 
    19     recvElement.addFullView() ; 
    20  
    21     transformConnector_ = new CTransformConnector(srcView, recvElement.getView(CElementView::FULL), CContext::getCurrent()->getIntraComm())  ; 
    22     transformConnector_->computeConnector() ; 
    23     weightTransformConnector_ = new  CWeightTransformConnector( recvElement.getView(CElementView::FULL), dstView, transformationMapping_, transformationWeight_) ;  
     10    this->computeRecvElement(srcView, dstView) ; 
     11    weightTransformConnector_ = new  CWeightTransformConnector( recvElement_->getView(CElementView::FULL), dstView, transformationMapping_, transformationWeight_) ;  
    2412  } 
    2513  
     
    3220  } 
    3321 
     22  void CAlgorithmTransformationWeight::computeRecvElement(CLocalView* srcView, CLocalView* dstView) 
     23  { 
     24    auto& srcMap = transformationMapping_ ; 
     25    set<size_t> srcIndex ; 
     26    for(auto& it : srcMap) 
     27      for(size_t index : it.second) srcIndex.insert(index) ; 
     28 
     29    CArray<size_t,1> srcArrayIndex(srcIndex.size()) ; 
     30    int i=0 ; 
     31    for(size_t index : srcIndex) { srcArrayIndex(i) = index ; i++ ;} 
     32    recvElement_ = new CLocalElement(CContext::getCurrent()->getIntraCommRank(), srcView->getGlobalSize(), srcArrayIndex) ; 
     33    recvElement_->addFullView() ; 
     34  } 
    3435} 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/algorithm_transformation_weight.hpp

    r1997 r1999  
    1818      virtual ~CAlgorithmTransformationWeight() {}; 
    1919      virtual void apply(int dimBefore, int dimAfter, const CArray<double,1>& dataIn, CArray<double,1>& dataOut); 
    20        
     20      void computeRecvElement(CLocalView* srcView, CLocalView* dstView); 
    2121    protected: 
    2222      virtual void computeAlgorithm(CLocalView* srcView, CLocalView* dstView) ; 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_duplicate_scalar.cpp

    r1998 r1999  
    4747{ 
    4848   
    49   CArray<int,1>& axisDstIndex = axisDest_->index; 
     49  CArray<int,1>& axisDstIndex = axisDestination->index; 
    5050 
    5151  int nbAxisIdx = axisDstIndex.numElements(); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_duplicate_scalar.hpp

    r1998 r1999  
    3636private: 
    3737 
    38   CAxis* axisSrc_; 
    39   CAxis* axisDest_; 
    40  
    4138  static CGenericAlgorithmTransformation* create(bool isSource, CGrid* gridDst, CGrid* gridSrc, 
    4239                                                CTransformation<CAxis>* transformation, 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_extract_domain.cpp

    r1988 r1999  
    4848 
    4949CAxisAlgorithmExtractDomain::CAxisAlgorithmExtractDomain(bool isSource, CAxis* axisDestination, CDomain* domainSource, CExtractDomainToAxis* algo) 
    50  : CAxisAlgorithmTransformation(isSource, axisDestination, domainSource), pos_(-1), reduction_(0) 
     50 : CAlgorithmTransformationTransfer(isSource), pos_(-1), axisDest_(axisDestination), domainSrc_(domainSource) 
    5151TRY 
    5252{ 
     
    6767 
    6868  pos_ = algo->position; 
    69   reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 
    70 } 
    71 CATCH 
    7269 
    73 void CAxisAlgorithmExtractDomain::apply(const std::vector<std::pair<int,double> >& localIndex, 
    74                                         const double* dataInput, 
    75                                         CArray<double,1>& dataOut, 
    76                                         std::vector<bool>& flagInitial,                      
    77                                         bool ignoreMissingValue, bool firstPass) 
    78 TRY 
    79 { 
    80   reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 
    81 } 
    82 CATCH 
    83  
    84 CAxisAlgorithmExtractDomain::~CAxisAlgorithmExtractDomain() 
    85 TRY 
    86 { 
    87   if (0 != reduction_) delete reduction_; 
    88 } 
    89 CATCH 
    90  
    91 void CAxisAlgorithmExtractDomain::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 
    92 TRY 
    93 { 
    94   this->transformationMapping_.resize(1); 
    95   this->transformationWeight_.resize(1); 
    96  
    97   TransformationIndexMap& transMap = this->transformationMapping_[0]; 
    98   TransformationWeightMap& transWeight = this->transformationWeight_[0]; 
     70  auto& transMap = this->transformationMapping_; 
    9971 
    10072  CArray<int,1>& axisDstIndex = axisDest_->index; 
     
    10678    { 
    10779      int globalAxisIdx = axisDstIndex(idxAxis); 
    108       transMap[globalAxisIdx].resize(1); 
    109       transWeight[globalAxisIdx].resize(1); 
    110       transMap[globalAxisIdx][0] = globalAxisIdx * ni_glo + pos_; 
    111       transWeight[globalAxisIdx][0] = 1.0; 
    112  
     80      transMap[globalAxisIdx] = globalAxisIdx * ni_glo + pos_; 
    11381    } 
    11482  } 
     
    11987    { 
    12088      int globalAxisIdx = axisDstIndex(idxAxis); 
    121       transMap[globalAxisIdx].resize(1); 
    122       transWeight[globalAxisIdx].resize(1); 
    123       transMap[globalAxisIdx][0] = globalAxisIdx + ni_glo * pos_; 
    124       transWeight[globalAxisIdx][0] = 1.0; 
     89      transMap[globalAxisIdx] = globalAxisIdx + ni_glo * pos_; 
    12590    } 
    12691  } 
    12792  else 
    12893  {} 
     94 
     95  axisDestination->checkAttributes() ; 
     96  this->computeAlgorithm(domainSource->getLocalView(CElementView::WORKFLOW), axisDestination->getLocalView(CElementView::WORKFLOW)) ; 
    12997} 
    13098CATCH 
     99 
     100 
     101CAxisAlgorithmExtractDomain::~CAxisAlgorithmExtractDomain() 
     102TRY 
     103{ 
    131104} 
     105CATCH 
     106 
     107} 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_extract_domain.hpp

    r1988 r1999  
    1010#define __XIOS_AXIS_ALGORITHM_EXTRACT_DOMAIN_HPP__ 
    1111 
    12 #include "axis_algorithm_transformation.hpp" 
     12#include "algorithm_transformation_transfer.hpp" 
    1313#include "transformation.hpp" 
    1414 
     
    2525  Extract a domain to an axis 
    2626*/ 
    27 class CAxisAlgorithmExtractDomain : public CAxisAlgorithmTransformation 
     27class CAxisAlgorithmExtractDomain : public CAlgorithmTransformationTransfer 
    2828{ 
    2929public: 
    3030  CAxisAlgorithmExtractDomain(bool isSource, CAxis* axisDestination, CDomain* domainSource, CExtractDomainToAxis* algo); 
    3131 
    32   virtual void apply(const std::vector<std::pair<int,double> >& localIndex, 
    33                      const double* dataInput, 
    34                      CArray<double,1>& dataOut, 
    35                      std::vector<bool>& flagInitial,                      
    36                      bool ignoreMissingValue, bool firstPass); 
    37  
    38   virtual ~CAxisAlgorithmExtractDomain(); 
     32   virtual ~CAxisAlgorithmExtractDomain(); 
    3933 
    4034  static bool registerTrans(); 
     
    4842  ExtractDirection dir_; 
    4943  int pos_; //! Position to extract 
    50 protected: 
    51   void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs); 
    52  
    53 protected: 
    54   CReductionAlgorithm* reduction_; 
    55  
     44   
    5645private: 
     46  CDomain* domainSrc_; 
     47  CAxis* axisDest_ ; 
    5748  static CGenericAlgorithmTransformation* create(bool isSource, CGrid* gridDst, CGrid* gridSrc, 
    5849                                                CTransformation<CAxis>* transformation, 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_inverse.cpp

    r1988 r1999  
    4949 
    5050CAxisAlgorithmInverse::CAxisAlgorithmInverse(bool isSource, CAxis* axisDestination, CAxis* axisSource, CInverseAxis* inverseAxis) 
    51  : CAxisAlgorithmTransformation(isSource, axisDestination, axisSource) 
     51 : CAlgorithmTransformationTransfer(isSource), axisDest_(axisDestination), axisSrc_(axisSource) 
    5252TRY 
    5353{ 
     
    5959           << "Size of axis destination " <<axisDestination->getId() << " is " << axisDestination->n_glo.getValue()); 
    6060  } 
    61 } 
    62 CATCH 
    63  
    64 void CAxisAlgorithmInverse::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 
    65 TRY 
    66 { 
    67   this->transformationMapping_.resize(1); 
    68   this->transformationWeight_.resize(1); 
    69  
    70   TransformationIndexMap& transMap = this->transformationMapping_[0]; 
    71   TransformationWeightMap& transWeight = this->transformationWeight_[0]; 
    72  
    73   int globalIndexSize = axisDestGlobalIndex_.size(); 
     61 
     62  auto& transMap = this->transformationMapping_; 
     63 
     64  int globalIndexSize = axisDestination->index.size(); 
    7465  for (int idx = 0; idx < globalIndexSize; ++idx) 
    7566  { 
    76     transMap[axisDestGlobalIndex_[idx]].push_back(axisDestGlobalSize_-axisDestGlobalIndex_[idx]-1); 
    77     transWeight[axisDestGlobalIndex_[idx]].push_back(1.0); 
     67    transMap[axisDestination->index(idx)] = globalIndexSize-axisDestination->index(idx)-1; 
    7868  } 
    7969 
     
    8878    } 
    8979  } 
    90 } 
    91 CATCH 
     80 
     81  axisDestination->checkAttributes() ; 
     82  this->computeAlgorithm(axisSource->getLocalView(CElementView::WORKFLOW), axisDestination->getLocalView(CElementView::WORKFLOW)) ; 
     83 
     84} 
     85CATCH 
     86 
    9287 
    9388/*! 
     
    118113  typedef std::unordered_map<size_t, std::vector<double> > GlobalIndexMapFromSrcToDest; 
    119114  GlobalIndexMapFromSrcToDest globalIndexMapFromSrcToDest; 
    120   TransformationIndexMap& transMap = this->transformationMapping_[0]; 
    121   TransformationIndexMap::const_iterator itb = transMap.begin(), ite = transMap.end(), it; 
     115  auto& transMap = this->transformationMapping_; 
    122116  CArray<size_t,1> globalSrcIndex(transMap.size()); 
    123117  int localIndex = 0; 
    124   for (it = itb; it != ite; ++it) 
    125   { 
    126     size_t srcIndex = it->second[0]; 
     118  for (auto it = transMap.begin(); it != transMap.end(); ++it) 
     119  { 
     120    size_t srcIndex = it->second; 
    127121    globalIndexMapFromSrcToDest[srcIndex].resize(1); 
    128122    globalIndexMapFromSrcToDest[srcIndex][0] = it->first; 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_inverse.hpp

    r1988 r1999  
    1010#define __XIOS_AXIS_ALGORITHM_INVERSE_HPP__ 
    1111 
    12 #include "axis_algorithm_transformation.hpp" 
     12#include "algorithm_transformation_transfer.hpp" 
    1313#include "transformation.hpp" 
    1414 
     
    2222  Inversing an axis 
    2323*/ 
    24 class CAxisAlgorithmInverse : public CAxisAlgorithmTransformation 
     24class CAxisAlgorithmInverse : public CAlgorithmTransformationTransfer 
    2525{ 
    2626public: 
     
    3131  static bool registerTrans(); 
    3232 
    33 protected: 
    34   void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs); 
    3533 
    3634private: 
     35  CAxis* axisSrc_; 
     36  CAxis* axisDest_; 
    3737  void updateAxisValue(); 
    3838 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_reduce_axis.cpp

    r1988 r1999  
    1212#include "grid.hpp" 
    1313#include "grid_transformation_factory_impl.hpp" 
    14 #include "reduction.hpp" 
     14 
    1515 
    1616namespace xios { 
     
    4747 
    4848CAxisAlgorithmReduceAxis::CAxisAlgorithmReduceAxis(bool isSource, CAxis* axisDestination, CAxis* axisSource, CReduceAxisToAxis* algo) 
    49  : CAxisAlgorithmTransformation(isSource, axisDestination, axisSource), reduction_(0) 
     49 : CAlgorithmTransformationReduce(isSource) 
    5050TRY 
    5151{ 
    5252  eliminateRedondantSrc_= false ; 
    5353  algo->checkValid(axisDestination, axisSource); 
    54   StdString op; 
     54 
    5555  switch (algo->operation) 
    5656  { 
    5757    case CReduceAxisToAxis::operation_attr::sum: 
    58       op = "sum"; 
     58      operator_ = EReduction::sum; 
    5959      break; 
    6060    case CReduceAxisToAxis::operation_attr::min: 
    61       op = "min"; 
     61      operator_ = EReduction::min; 
    6262      break; 
    6363    case CReduceAxisToAxis::operation_attr::max: 
    64       op = "max"; 
     64      operator_ = EReduction::max; 
    6565      break; 
    6666    case CReduceAxisToAxis::operation_attr::average: 
    67       op = "average"; 
     67      operator_ = EReduction::average; 
    6868      break; 
    6969    default: 
     
    7373         << "Axis destination " << axisDestination->getId()); 
    7474 
     75    TransformationIndexMap& transMap = this->transformationMapping_; 
     76    CArray<int,1>& axisDstIndex = axisDestination->index; 
     77    int nbAxisIdx = axisDstIndex.numElements(); 
     78    for (int idxAxis = 0; idxAxis < nbAxisIdx; ++idxAxis) 
     79    { 
     80      int globalAxisIdx = axisDstIndex(idxAxis); 
     81      transMap[globalAxisIdx].resize(1); 
     82      transMap[globalAxisIdx][0]=globalAxisIdx ;       
     83    } 
     84 
    7585  } 
    76  
    77   reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 
     86  
     87  axisDestination->checkAttributes() ; 
     88  this->computeAlgorithm(axisSource->getLocalView(CElementView::WORKFLOW), axisDestination->getLocalView(CElementView::WORKFLOW)) ; 
    7889} 
    7990CATCH 
    8091 
    81 void CAxisAlgorithmReduceAxis::apply(const std::vector<std::pair<int,double> >& localIndex, 
    82                                        const double* dataInput, 
    83                                        CArray<double,1>& dataOut, 
    84                                        std::vector<bool>& flagInitial,                      
    85                                        bool ignoreMissingValue, bool firstPass) 
    86 TRY 
    87 { 
    88   reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 
    89 } 
    90 CATCH 
    91  
    92 void CAxisAlgorithmReduceAxis::updateData(CArray<double,1>& dataOut) 
    93 TRY 
    94 { 
    95   reduction_->updateData(dataOut); 
    96 } 
    97 CATCH 
    9892 
    9993CAxisAlgorithmReduceAxis::~CAxisAlgorithmReduceAxis() 
    10094TRY 
    10195{ 
    102   if (0 != reduction_) delete reduction_; 
     96  
    10397} 
    10498CATCH 
    10599 
    106 void CAxisAlgorithmReduceAxis::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 
    107 TRY 
    108 { 
    109   this->transformationMapping_.resize(1); 
    110   this->transformationWeight_.resize(1); 
    111  
    112   TransformationIndexMap& transMap = this->transformationMapping_[0]; 
    113   TransformationWeightMap& transWeight = this->transformationWeight_[0]; 
    114   CArray<int,1>& axisDstIndex = axisDest_->index; 
    115   int nbAxisIdx = axisDstIndex.numElements(); 
    116   for (int idxAxis = 0; idxAxis < nbAxisIdx; ++idxAxis) 
    117   { 
    118     int globalAxisIdx = axisDstIndex(idxAxis); 
    119     transMap[globalAxisIdx].resize(1); 
    120     transWeight[globalAxisIdx].resize(1); 
    121     transMap[globalAxisIdx][0]=globalAxisIdx ;       
    122     transWeight[globalAxisIdx][0] = 1.0 ;       
    123   } 
    124 } 
    125 CATCH 
    126100 
    127101} 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_reduce_axis.hpp

    r1988 r1999  
    1010#define __XIOS_AXIS_ALGORITHM_REDUCE_AXIS_HPP__ 
    1111 
    12 #include "axis_algorithm_transformation.hpp" 
     12#include "algorithm_transformation_reduce.hpp" 
    1313#include "transformation.hpp" 
    1414 
     
    2323  Reduce a axis to an axis 
    2424*/ 
    25 class CAxisAlgorithmReduceAxis : public CAxisAlgorithmTransformation 
     25class CAxisAlgorithmReduceAxis : public CAlgorithmTransformationReduce 
    2626{ 
    2727public: 
    2828  CAxisAlgorithmReduceAxis(bool isSource, CAxis* axisDestination, CAxis* axisSource, CReduceAxisToAxis* algo); 
    2929 
    30   virtual void apply(const std::vector<std::pair<int,double> >& localIndex, 
    31                      const double* dataInput, 
    32                      CArray<double,1>& dataOut, 
    33                      std::vector<bool>& flagInitial,                      
    34                      bool ignoreMissingValue, bool firstPass); 
    35  
    36   virtual void updateData(CArray<double,1>& dataOut); 
    3730   
    3831  virtual ~CAxisAlgorithmReduceAxis(); 
    3932 
    4033  static bool registerTrans(); 
    41 protected: 
    4234   
    43 protected: 
    44   void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs);  
    45    
    46 protected: 
    47   CReductionAlgorithm* reduction_; 
    48  
    4935private: 
    5036  static CGenericAlgorithmTransformation* create(bool isSource, CGrid* gridDst, CGrid* gridSrc, 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_reduce_domain.cpp

    r1988 r1999  
    4848 
    4949CAxisAlgorithmReduceDomain::CAxisAlgorithmReduceDomain(bool isSource, CAxis* axisDestination, CDomain* domainSource, CReduceDomainToAxis* algo) 
    50  : CAxisAlgorithmTransformation(isSource, axisDestination, domainSource), reduction_(0) 
     50 : CAlgorithmTransformationReduce(isSource), domainSrc_(domainSource), axisDest_(axisDestination) 
    5151TRY 
    5252{ 
    5353  algo->checkValid(axisDestination, domainSource); 
    54   StdString op; 
    5554  switch (algo->operation) 
    5655  { 
    5756    case CReduceDomainToAxis::operation_attr::sum: 
    58       op = "sum"; 
     57       operator_ = EReduction::sum; 
    5958      break; 
    6059    case CReduceDomainToAxis::operation_attr::min: 
    61       op = "min"; 
     60       operator_ = EReduction::min; 
    6261      break; 
    6362    case CReduceDomainToAxis::operation_attr::max: 
    64       op = "max"; 
     63       operator_ = EReduction::max; 
    6564      break; 
    6665    case CReduceDomainToAxis::operation_attr::average: 
    67       op = "average"; 
     66       operator_ = EReduction::average; 
    6867      break; 
    6968    default: 
     
    7675 
    7776  dir_ = (CReduceDomainToAxis::direction_attr::iDir == algo->direction)  ? iDir : jDir; 
    78   reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 
    79   local = algo->local ; 
    80 } 
    81 CATCH 
     77  bool local = algo->local ; 
    8278 
    83 void CAxisAlgorithmReduceDomain::apply(const std::vector<std::pair<int,double> >& localIndex, 
    84                                        const double* dataInput, 
    85                                        CArray<double,1>& dataOut, 
    86                                        std::vector<bool>& flagInitial,                      
    87                                        bool ignoreMissingValue, bool firstPass) 
    88 TRY 
    89 { 
    90   reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 
    91 } 
    92 CATCH 
    93  
    94 void CAxisAlgorithmReduceDomain::updateData(CArray<double,1>& dataOut) 
    95 TRY 
    96 { 
    97   reduction_->updateData(dataOut); 
    98 } 
    99 CATCH 
    100  
    101 CAxisAlgorithmReduceDomain::~CAxisAlgorithmReduceDomain() 
    102 TRY 
    103 { 
    104   if (0 != reduction_) delete reduction_; 
    105 } 
    106 CATCH 
    107  
    108 void CAxisAlgorithmReduceDomain::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 
    109 TRY 
    110 { 
    111   this->transformationMapping_.resize(1); 
    112   this->transformationWeight_.resize(1); 
    113  
    114   TransformationIndexMap& transMap = this->transformationMapping_[0]; 
    115   TransformationWeightMap& transWeight = this->transformationWeight_[0]; 
     79  TransformationIndexMap& transMap = transformationMapping_; 
    11680 
    11781  CArray<int,1>& axisDstIndex = axisDest_->index; 
     
    13195        {  
    13296          transMap[j_index(idxDomain)].push_back(j_index(idxDomain)* ni_glo + i_index(idxDomain)); 
    133           transWeight[j_index(idxDomain)].push_back(1.0) ; 
    13497        } 
    13598      } 
     
    142105        int globalAxisIdx = axisDstIndex(idxAxis); 
    143106        transMap[globalAxisIdx].resize(ni_glo); 
    144         transWeight[globalAxisIdx].resize(ni_glo); 
    145107        for (int idx = 0; idx < ni_glo; ++idx) 
    146108        { 
    147109          transMap[globalAxisIdx][idx] = globalAxisIdx * ni_glo + idx; 
    148           transWeight[globalAxisIdx][idx] = 1.0; 
    149110        } 
    150111      } 
     
    166127        {  
    167128          transMap[i_index(idxDomain)].push_back(j_index(idxDomain)* ni_glo + i_index(idxDomain)); 
    168           transWeight[i_index(idxDomain)].push_back(1.0) ; 
    169129        } 
    170130      } 
     
    176136        int globalAxisIdx = axisDstIndex(idxAxis); 
    177137        transMap[globalAxisIdx].resize(nj_glo); 
    178         transWeight[globalAxisIdx].resize(nj_glo); 
    179138        for (int idx = 0; idx < nj_glo; ++idx) 
    180139        { 
    181140          transMap[globalAxisIdx][idx] = globalAxisIdx + ni_glo*idx; 
    182           transWeight[globalAxisIdx][idx] = 1.0; 
    183141        } 
    184142      } 
     
    187145  else 
    188146  {} 
     147 
     148  axisDestination->checkAttributes() ; 
     149  this->computeAlgorithm(domainSource->getLocalView(CElementView::WORKFLOW), axisDestination->getLocalView(CElementView::WORKFLOW)) ; 
     150 
    189151} 
    190152CATCH 
    191153 
     154 
     155CAxisAlgorithmReduceDomain::~CAxisAlgorithmReduceDomain() 
     156TRY 
     157{ 
    192158} 
     159CATCH 
     160 
     161 
     162} 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_reduce_domain.hpp

    r1988 r1999  
    1010#define __XIOS_AXIS_ALGORITHM_REDUCE_DOMAIN_HPP__ 
    1111 
    12 #include "axis_algorithm_transformation.hpp" 
     12#include "algorithm_transformation_reduce.hpp" 
    1313#include "transformation.hpp" 
    1414 
     
    2424  Reduce a domain to an axis 
    2525*/ 
    26 class CAxisAlgorithmReduceDomain : public CAxisAlgorithmTransformation 
     26class CAxisAlgorithmReduceDomain : public CAlgorithmTransformationReduce 
    2727{ 
    2828public: 
    2929  CAxisAlgorithmReduceDomain(bool isSource, CAxis* axisDestination, CDomain* domainSource, CReduceDomainToAxis* algo); 
    30  
    31   virtual void apply(const std::vector<std::pair<int,double> >& localIndex, 
    32                      const double* dataInput, 
    33                      CArray<double,1>& dataOut, 
    34                      std::vector<bool>& flagInitial,                      
    35                      bool ignoreMissingValue, bool firstPass); 
    36  
    37   virtual void updateData(CArray<double,1>& dataOut); 
    3830   
    3931  virtual ~CAxisAlgorithmReduceDomain(); 
     
    5042  bool local ; 
    5143   
    52 protected: 
    53   void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs);  
    54    
    55 protected: 
    56   CReductionAlgorithm* reduction_; 
     44  CDomain* domainSrc_ ; 
     45  CAxis* axisDest_ ; 
    5746 
    5847private: 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/generic_algorithm_transformation.cpp

    r1988 r1999  
    11431143/////////////////////////////////////////////////////////////// 
    11441144 
     1145CGridAlgorithm* CGenericAlgorithmTransformation::createGridAlgorithm(CGrid* gridSrc, CGrid* gridDst, int pos) 
     1146{ 
     1147  return new CGridAlgorithm(gridSrc, gridDst, pos, this) ; 
     1148} 
    11451149 
    11461150 
    11471151void CGenericAlgorithmTransformation::computeAlgorithm(CLocalView* srcView, CLocalView* dstView) 
     1152{ 
     1153  
     1154  this->computeRecvElement(srcView, dstView) ; 
     1155/* 
     1156  transformConnector_ = new CTransformConnector(srcView, recvElement.getView(CElementView::FULL), CContext::getCurrent()->getIntraComm())  ; 
     1157  transformConnector_->computeConnector() ;  
     1158*/ 
     1159  weightTransformConnector_ = new  CWeightTransformConnector(recvElement_->getView(CElementView::FULL), dstView, transformationMapping_[0], transformationWeight_[0]) ;  
     1160} 
     1161  
     1162void CGenericAlgorithmTransformation::computeRecvElement(CLocalView* srcView, CLocalView* dstView) 
    11481163{ 
    11491164  auto& srcMap = transformationMapping_[0] ; 
     
    11551170  int i=0 ; 
    11561171  for(size_t index : srcIndex) { srcArrayIndex(i) = index ; i++ ;} 
    1157   CLocalElement recvElement(CContext::getCurrent()->getIntraCommRank(), srcView->getGlobalSize(), srcArrayIndex) ; 
    1158   recvElement.addFullView() ; 
    1159  
    1160   transformConnector_ = new CTransformConnector(srcView, recvElement.getView(CElementView::FULL), CContext::getCurrent()->getIntraComm())  ; 
    1161   transformConnector_->computeConnector() ; 
    1162   weightTransformConnector_ = new  CWeightTransformConnector( recvElement.getView(CElementView::FULL), dstView, transformationMapping_[0], transformationWeight_[0]) ;  
    1163 } 
    1164   
     1172  recvElement_ = new CLocalElement(CContext::getCurrent()->getIntraCommRank(), srcView->getGlobalSize(), srcArrayIndex) ; 
     1173  recvElement_->addFullView() ; 
     1174} 
    11651175 
    11661176void CGenericAlgorithmTransformation::apply(int dimBefore, int dimAfter, const CArray<double,1>& dataIn, CArray<double,1>& dataOut) 
    11671177{ 
    1168   CArray<double,1> dataOutTmp ; 
    1169   transformConnector_->transfer(dimBefore, dimAfter, dataIn, dataOutTmp) ; 
    1170   weightTransformConnector_ -> transfer(dimBefore, dimAfter, dataOutTmp, dataOut) ; 
    1171 } 
    1172  
    1173  
    1174  
    1175  
    1176  
    1177  
    1178 } 
     1178  //CArray<double,1> dataOutTmp ; 
     1179  //transformConnector_->transfer(dimBefore, dimAfter, dataIn, dataOutTmp) ; 
     1180  weightTransformConnector_ -> transfer(dimBefore, dimAfter, dataIn, dataOut) ; 
     1181} 
     1182 
     1183} 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/generic_algorithm_transformation.hpp

    r1998 r1999  
    2424  class CAxis; 
    2525  class CScalar; 
     26  class CGridAlgorithm ; 
    2627 
    2728  /*! 
     
    183184    virtual void computeAlgorithm(CLocalView* srcView, CLocalView* dstView) ; 
    184185    virtual void apply(int dimBefore, int dimAfter, const CArray<double,1>& dataIn, CArray<double,1>& dataOut); 
    185      
     186    virtual CGridAlgorithm* createGridAlgorithm(CGrid* gridSrc, CGrid* newGrid, int pos) ; 
     187    virtual void computeRecvElement(CLocalView* srcView, CLocalView* dstView) ; 
     188  protected : 
     189 
     190    CLocalElement* recvElement_=nullptr ; 
     191  public: 
     192    CLocalElement* getRecvElement(void) { return recvElement_ ;} 
     193   
     194  protected: 
    186195    CTransformConnector* transformConnector_ ; 
    187196    CWeightTransformConnector* weightTransformConnector_ ; 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/scalar_algorithm/scalar_algorithm_extract_axis.cpp

    r1988 r1999  
    4848 
    4949CScalarAlgorithmExtractAxis::CScalarAlgorithmExtractAxis(bool isSource, CScalar* scalarDestination, CAxis* axisSource, CExtractAxisToScalar* algo) 
    50  : CScalarAlgorithmTransformation(isSource, scalarDestination, axisSource), reduction_(0) 
     50 : CAlgorithmTransformationTransfer(isSource) 
    5151TRY 
    5252{ 
    5353  algo->checkValid(scalarDestination, axisSource); 
    54   StdString op = "extract"; 
    5554  pos_ = algo->position; 
    56   reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 
     55  this->transformationMapping_[0]=pos_ ; 
     56 
     57  scalarDestination->checkAttributes() ; 
     58  this->computeAlgorithm(axisSource->getLocalView(CElementView::WORKFLOW), scalarDestination->getLocalView(CElementView::WORKFLOW)) ; 
    5759} 
    5860CATCH 
    5961 
    60 void CScalarAlgorithmExtractAxis::apply(const std::vector<std::pair<int,double> >& localIndex, 
    61                                          const double* dataInput, 
    62                                          CArray<double,1>& dataOut, 
    63                                          std::vector<bool>& flagInitial,                      
    64                                          bool ignoreMissingValue, bool firstPass) 
    65 TRY 
    66 { 
    67   reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 
    68 } 
    69 CATCH 
    7062 
    71 CScalarAlgorithmExtractAxis::~CScalarAlgorithmExtractAxis() 
    72 TRY 
    73 { 
    74   if (0 != reduction_) delete reduction_; 
    75 } 
    76 CATCH 
    77  
    78 void CScalarAlgorithmExtractAxis::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 
    79 TRY 
    80 { 
    81   this->transformationMapping_.resize(1); 
    82   this->transformationWeight_.resize(1); 
    83  
    84   TransformationIndexMap& transMap = this->transformationMapping_[0]; 
    85   TransformationWeightMap& transWeight = this->transformationWeight_[0]; 
    86  
    87   transMap[0].push_back(pos_); 
    88   transWeight[0].push_back(1.0); 
    89 } 
    90 CATCH 
    9163 
    9264} 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/scalar_algorithm/scalar_algorithm_extract_axis.hpp

    r1988 r1999  
    1010#define __XIOS_SCALAR_ALGORITHM_EXTRACT_AXIS_HPP__ 
    1111 
    12 #include "scalar_algorithm_transformation.hpp" 
     12#include "algorithm_transformation_transfer.hpp" 
    1313#include "transformation.hpp" 
    1414 
     
    2424  Extract a scalar from an axis 
    2525*/ 
    26 class CScalarAlgorithmExtractAxis : public CScalarAlgorithmTransformation 
     26class CScalarAlgorithmExtractAxis : public CAlgorithmTransformationTransfer 
    2727{ 
    2828public: 
    2929  CScalarAlgorithmExtractAxis(bool isSource, CScalar* scalarDestination, CAxis* axisSource, CExtractAxisToScalar* algo); 
    3030 
    31   virtual void apply(const std::vector<std::pair<int,double> >& localIndex, 
    32                      const double* dataInput, 
    33                      CArray<double,1>& dataOut, 
    34                      std::vector<bool>& flagInitial,                      
    35                      bool ignoreMissingValue, bool firstPass); 
    36  
    37   virtual ~CScalarAlgorithmExtractAxis(); 
     31   
     32  virtual ~CScalarAlgorithmExtractAxis() {} ; 
    3833 
    3934  static bool registerTrans(); 
     
    4136protected: 
    4237  int pos_; 
    43  
    44 protected: 
    45   void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs); 
    46  
    47 protected: 
    48   CReductionAlgorithm* reduction_; 
    4938 
    5039private: 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/scalar_algorithm/scalar_algorithm_reduce_axis.cpp

    r1988 r1999  
    4949 
    5050CScalarAlgorithmReduceAxis::CScalarAlgorithmReduceAxis(bool isSource, CScalar* scalarDestination, CAxis* axisSource, CReduceAxisToScalar* algo) 
    51  : CScalarAlgorithmTransformation(isSource, scalarDestination, axisSource),reduction_(0) 
     51 : CAlgorithmTransformationReduce(isSource) 
    5252TRY 
    5353{ 
     
    6161  { 
    6262    case CReduceAxisToScalar::operation_attr::sum: 
    63       op = "sum"; 
     63      operator_ = EReduction::sum; 
    6464      break; 
    6565    case CReduceAxisToScalar::operation_attr::min: 
    66       op = "min"; 
     66      operator_ = EReduction::min; 
    6767      break; 
    6868    case CReduceAxisToScalar::operation_attr::max: 
    69       op = "max"; 
     69      operator_ = EReduction::max; 
    7070      break; 
    7171    case CReduceAxisToScalar::operation_attr::average: 
    72       op = "average"; 
     72      operator_ = EReduction::average; 
    7373      break; 
    7474    default: 
     
    7878         << "Scalar destination " << scalarDestination->getId()); 
    7979 
    80   } 
     80  }  
    8181   
    82   if (CReductionAlgorithm::ReductionOperations.end() == CReductionAlgorithm::ReductionOperations.find(op)) 
    83     ERROR("CScalarAlgorithmReduceAxis::CScalarAlgorithmReduceAxis(CAxis* axisDestination, CAxis* axisSource, CReduceAxisToScalar* algo)", 
    84        << "Operation '" << op << "' not found. Please make sure to use a supported one" 
    85        << "Axis source " <<axisSource->getId() << std::endl 
    86        << "Scalar destination " << scalarDestination->getId()); 
     82  int globalIndexSize = axisSource-> n_glo; 
     83  for (int idx = 0; idx < globalIndexSize; ++idx)  transformationMapping_[0].push_back(idx); 
    8784 
    88   reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 
     85  scalarDestination->checkAttributes() ; 
     86  this->computeAlgorithm(axisSource->getLocalView(CElementView::WORKFLOW), scalarDestination->getLocalView(CElementView::WORKFLOW)) ; 
     87   
    8988} 
    9089CATCH 
    9190 
    92 void CScalarAlgorithmReduceAxis::apply(const std::vector<std::pair<int,double> >& localIndex, const double* dataInput, CArray<double,1>& dataOut, 
    93                                          std::vector<bool>& flagInitial, bool ignoreMissingValue, bool firstPass) 
    94 TRY 
    95 { 
    96   reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 
    97 } 
    98 CATCH 
    99  
    100 void CScalarAlgorithmReduceAxis::updateData(CArray<double,1>& dataOut) 
    101 TRY 
    102 { 
    103   reduction_->updateData(dataOut); 
    104 } 
    105 CATCH 
    10691 
    10792CScalarAlgorithmReduceAxis::~CScalarAlgorithmReduceAxis() 
    10893TRY 
    10994{ 
    110   if (0 != reduction_) delete reduction_; 
    111 } 
    112 CATCH 
    113  
    114 void CScalarAlgorithmReduceAxis::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 
    115 TRY 
    116 { 
    117   this->transformationMapping_.resize(1); 
    118   this->transformationWeight_.resize(1); 
    119  
    120   TransformationIndexMap& transMap = this->transformationMapping_[0]; 
    121   TransformationWeightMap& transWeight = this->transformationWeight_[0]; 
    122  
    123   int globalIndexSize = axisSrc_-> n_glo; 
    124  
    125   for (int idx = 0; idx < globalIndexSize; ++idx) 
    126   { 
    127     transMap[0].push_back(idx); 
    128     transWeight[0].push_back(1.0); 
    129   } 
    13095} 
    13196CATCH 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/scalar_algorithm/scalar_algorithm_reduce_axis.hpp

    r1988 r1999  
    1010#define __XIOS_SCALAR_ALGORITHM_REDUCE_AXIS_HPP__ 
    1111 
    12 #include "scalar_algorithm_transformation.hpp" 
     12#include "algorithm_transformation_reduce.hpp" 
    1313#include "transformation.hpp" 
    1414 
     
    2424  Reducing an axis to a scalar 
    2525*/ 
    26 class CScalarAlgorithmReduceAxis : public CScalarAlgorithmTransformation 
     26class CScalarAlgorithmReduceAxis : public CAlgorithmTransformationReduce 
    2727{ 
    2828public: 
    2929  CScalarAlgorithmReduceAxis(bool isSource, CScalar* scalarDestination, CAxis* axisSource, CReduceAxisToScalar* algo); 
    3030 
    31   virtual void apply(const std::vector<std::pair<int,double> >& localIndex, 
    32                      const double* dataInput, 
    33                      CArray<double,1>& dataOut, 
    34                      std::vector<bool>& flagInitial, 
    35                      bool ignoreMissingValue, bool firstPass); 
    36  
    37   virtual void updateData(CArray<double,1>& dataOut); 
    3831   
    3932  virtual ~CScalarAlgorithmReduceAxis(); 
    4033 
    4134  static bool registerTrans(); 
    42 protected: 
    43   void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs); 
    44  
    45 protected: 
    46   CReductionAlgorithm* reduction_; 
    4735 
    4836private: 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/scalar_algorithm/scalar_algorithm_reduce_domain.cpp

    r1988 r1999  
    1313#include "grid.hpp" 
    1414#include "grid_transformation_factory_impl.hpp" 
    15  
    16 #include "reduction.hpp" 
    1715 
    1816namespace xios { 
     
    4846 
    4947CScalarAlgorithmReduceDomain::CScalarAlgorithmReduceDomain(bool isSource, CScalar* scalarDestination, CDomain* domainSource, CReduceDomainToScalar* algo) 
    50  : CScalarAlgorithmTransformation(isSource, scalarDestination, domainSource), 
    51    reduction_(0) 
     48 : CAlgorithmTransformationReduce(isSource), domainSrc_(domainSource) 
    5249TRY 
    5350{ 
     
    5855  { 
    5956    case CReduceDomainToScalar::operation_attr::sum: 
    60       op = "sum"; 
     57      operator_ = EReduction::sum; 
    6158      break; 
    6259    case CReduceDomainToScalar::operation_attr::min: 
    63       op = "min"; 
     60      operator_ = EReduction::min; 
    6461      break; 
    6562    case CReduceDomainToScalar::operation_attr::max: 
    66       op = "max"; 
     63      operator_ = EReduction::max; 
    6764      break; 
    6865    case CReduceDomainToScalar::operation_attr::average: 
    69       op = "average"; 
     66      operator_ = EReduction::average; 
    7067      break; 
    7168    default: 
     
    7673 
    7774  } 
    78    
    79   if (CReductionAlgorithm::ReductionOperations.end() == CReductionAlgorithm::ReductionOperations.find(op)) 
    80     ERROR("CScalarAlgorithmReduceDomain::CScalarAlgorithmReduceDomain(CDomain* domainDestination, CDomain* domainSource, CReduceDomainToScalar* algo)", 
    81        << "Operation '" << op << "' not found. Please make sure to use a supported one" 
    82        << "Domain source " <<domainSource->getId() << std::endl 
    83        << "Scalar destination " << scalarDestination->getId()); 
    8475 
    85   reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 
    86   local = algo->local ; 
    87 } 
    88 CATCH 
    89  
    90 void CScalarAlgorithmReduceDomain::apply(const std::vector<std::pair<int,double> >& localIndex, 
    91                                          const double* dataInput, 
    92                                          CArray<double,1>& dataOut, 
    93                                          std::vector<bool>& flagInitial,                      
    94                                          bool ignoreMissingValue, bool firstPass) 
    95 TRY 
    96 { 
    97   reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 
    98 } 
    99 CATCH 
    100  
    101 void CScalarAlgorithmReduceDomain::updateData(CArray<double,1>& dataOut) 
    102 TRY 
    103 { 
    104   reduction_->updateData(dataOut); 
    105 } 
    106 CATCH 
    107  
    108 CScalarAlgorithmReduceDomain::~CScalarAlgorithmReduceDomain() 
    109 TRY 
    110 { 
    111   if (0 != reduction_) delete reduction_; 
    112 } 
    113 CATCH 
    114  
    115 void CScalarAlgorithmReduceDomain::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 
    116 TRY 
    117 { 
    118   this->transformationMapping_.resize(1); 
    119   this->transformationWeight_.resize(1); 
    120  
    121   TransformationIndexMap& transMap = this->transformationMapping_[0]; 
    122   TransformationWeightMap& transWeight = this->transformationWeight_[0]; 
     76  TransformationIndexMap& transMap = this->transformationMapping_; 
    12377 
    12478  int ni_glo = domainSrc_->ni_glo ; 
    12579  int nj_glo = domainSrc_->nj_glo ; 
    12680  int nbDomainIdx ; 
     81   
     82  bool  local = algo->local ; 
    12783   
    12884  if (local) 
     
    13894        {  
    13995          transMap[0].push_back(j_index(idxDomain)* ni_glo + i_index(idxDomain)); 
    140           transWeight[0].push_back(1.0) ; 
    14196        } 
    14297      } 
     
    145100  {   
    146101    nbDomainIdx = ni_glo * nj_glo; 
    147     transMap[0].resize(nbDomainIdx); 
    148     transWeight[0].resize(nbDomainIdx, 1.0); 
    149     for (int idxDomain = 0; idxDomain < nbDomainIdx; ++idxDomain) transMap[0][idxDomain] = idxDomain;     
     102    for (int idxDomain = 0; idxDomain < nbDomainIdx; ++idxDomain) transMap[0].push_back(idxDomain);     
    150103  } 
    151104   
     105  scalarDestination->checkAttributes() ; 
     106  this->computeAlgorithm(domainSource->getLocalView(CElementView::WORKFLOW), scalarDestination->getLocalView(CElementView::WORKFLOW)) ; 
    152107} 
    153108CATCH 
    154109 
     110 
     111 
     112CScalarAlgorithmReduceDomain::~CScalarAlgorithmReduceDomain() 
     113TRY 
     114{ 
    155115} 
     116CATCH 
     117 
     118 
     119} 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/scalar_algorithm/scalar_algorithm_reduce_domain.hpp

    r1988 r1999  
    1010#define __XIOS_SCALAR_ALGORITHM_REDUCE_DOMAIN_HPP__ 
    1111 
    12 #include "scalar_algorithm_transformation.hpp" 
     12#include "algorithm_transformation_reduce.hpp" 
    1313#include "transformation.hpp" 
    1414 
     
    2424  Reducing an DOMAIN to a scalar 
    2525*/ 
    26 class CScalarAlgorithmReduceDomain : public CScalarAlgorithmTransformation 
     26class CScalarAlgorithmReduceDomain : public CAlgorithmTransformationReduce 
    2727{ 
    2828public: 
    2929  CScalarAlgorithmReduceDomain(bool isSource, CScalar* scalarDestination, CDomain* domainSource, CReduceDomainToScalar* algo); 
    3030 
    31   virtual void apply(const std::vector<std::pair<int,double> >& localIndex, 
    32                      const double* dataInput, 
    33                      CArray<double,1>& dataOut, 
    34                      std::vector<bool>& flagInitial,                      
    35                      bool ignoreMissingValue, bool firstPass); 
    36  
    37   virtual void updateData(CArray<double,1>& dataOut); 
    38    
    3931  virtual ~CScalarAlgorithmReduceDomain(); 
    4032 
    4133  static bool registerTrans(); 
    42 protected: 
    43   bool local ; 
    44   void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs); 
    4534 
    4635protected: 
    47   CReductionAlgorithm* reduction_; 
     36  CDomain* domainSrc_ ; 
    4837 
    4938private: 
Note: See TracChangeset for help on using the changeset viewer.