Ignore:
Timestamp:
02/01/22 15:28:48 (2 years ago)
Author:
ymipsl
Message:

Improve reduction transformation

  • make the difference between reduction over geometry or reduction between process.
  • geometrical reduction :

domain -> axis
axis -> scalar
domain -> scalar

  • reduction across processes for redondant geometrical cell :

axis -> axis
scalar -> scalar

Reduction can be local (only for the geometrical cell owned by current process) or global, using the "local" attribute (bool) over the reduction.

YM

Location:
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/Functions/reduction_types.hpp

    r1999 r2291  
    1313{ 
    1414 
    15   typedef enum reduction_algurithm_type 
     15  typedef enum reduction_algorithm_type 
    1616  { 
    17     TRANS_REDUCE_SUM = 0, 
    18     TRANS_REDUCE_MIN = 1, 
    19     TRANS_REDUCE_MAX = 2, 
    20     TRANS_REDUCE_EXTRACT = 3, 
    21     TRANS_REDUCE_AVERAGE = 4 
     17    TRANS_REDUCE_NONE = 0,  
     18    TRANS_REDUCE_SUM = 1, 
     19    TRANS_REDUCE_MIN = 2, 
     20    TRANS_REDUCE_MAX = 3, 
     21    TRANS_REDUCE_EXTRACT = 4, 
     22    TRANS_REDUCE_AVERAGE = 5 
    2223  } EReductionType; 
    2324 
    2425  enum class EReduction 
    2526  { 
    26     sum, min, max, extract, average 
     27    none, sum, min, max, extract, average 
    2728  } ; 
    2829} 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/algorithm_transformation_no_data_modification.cpp

    r2270 r2291  
    1212  shared_ptr<CGridAlgorithm> CAlgorithmTransformationNoDataModification::createGridAlgorithm(CGrid* gridSrc, CGrid* gridDst, int pos) 
    1313  { 
    14     return make_shared<CGridAlgorithmNoDataModification>(static_pointer_cast<CAlgorithmTransformationNoDataModification>(shared_from_this())) ; 
     14    auto algo=make_shared<CGridAlgorithmNoDataModification>(static_pointer_cast<CAlgorithmTransformationNoDataModification>(shared_from_this())) ; 
     15    algo->computeAlgorithm() ; 
     16    return algo ;  
    1517  } 
    1618} 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/algorithm_transformation_reduce.hpp

    r2267 r2291  
    2828      shared_ptr<CReduceTransformConnector> reduceTransformConnector_ ; 
    2929      bool detectMissingValue_=true ; 
    30       bool eliminateRedondantSrc_ = true ;  
    3130  }; 
    3231 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_reduce_axis.cpp

    r2270 r2291  
    1212#include "grid.hpp" 
    1313#include "grid_transformation_factory_impl.hpp" 
     14#include "grid_algorithm_reduce.hpp" 
    1415 
    1516 
     
    5051TRY 
    5152{ 
    52   eliminateRedondantSrc_= false ; 
     53  if (!axisDestination->checkGeometricAttributes(false)) 
     54  { 
     55    axisDestination->resetGeometricAttributes(); 
     56    axisDestination->setGeometricAttributes(*axisSource) ; 
     57  } 
     58  axisDestination->checkAttributes() ;  
    5359  algo->checkValid(axisDestination, axisSource); 
    54   axisDestination->checkAttributes() ; 
     60   
    5561 
    5662  switch (algo->operation) 
     
    7581  } 
    7682 
    77   TransformationIndexMap& transMap = this->transformationMapping_; 
    78   CArray<int,1>& axisDstIndex = axisDestination->index; 
    79   int nbAxisIdx = axisDstIndex.numElements(); 
    80   for (int idxAxis = 0; idxAxis < nbAxisIdx; ++idxAxis) 
     83  //TransformationIndexMap& transMap = this->transformationMapping_; 
     84  //CArray<int,1>& axisDstIndex = axisDestination->index; 
     85  //int nbAxisIdx = axisDstIndex.numElements(); 
     86 
     87 
     88 
     89  auto& transMap = this->transformationMapping_; 
     90   
     91  CArray<size_t,1> dstGlobalIndex ; 
     92  axisDestination->getLocalView(CElementView::WORKFLOW)->getGlobalIndexView(dstGlobalIndex) ; 
     93  size_t nbIdx = dstGlobalIndex.numElements(); 
     94 
     95  for (size_t idx = 0; idx < nbIdx; ++idx) 
    8196  { 
    82     int globalAxisIdx = axisDstIndex(idxAxis); 
    83     transMap[globalAxisIdx].resize(1); 
    84     transMap[globalAxisIdx][0]=globalAxisIdx ;       
     97    size_t globalIdx = dstGlobalIndex(idx); 
     98    transMap[globalIdx].resize(1); 
     99    transMap[globalIdx][0]=globalIdx ;       
    85100  } 
    86101 
    87   
    88   axisDestination->checkAttributes() ; 
    89102  this->computeAlgorithm(axisSource->getLocalView(CElementView::WORKFLOW), axisDestination->getLocalView(CElementView::WORKFLOW)) ; 
    90103} 
    91104CATCH 
    92105 
     106shared_ptr<CGridAlgorithm> CAxisAlgorithmReduceAxis::createGridAlgorithm(CGrid* gridSrc, CGrid* gridDst, int pos) 
     107{ 
     108  auto algo=make_shared<CGridAlgorithmReduce>(gridSrc, gridDst, pos, shared_from_this(), operator_) ; 
     109  algo->computeAlgorithm(false) ; 
     110  return algo ;  
     111} 
    93112 
    94113CAxisAlgorithmReduceAxis::~CAxisAlgorithmReduceAxis() 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_reduce_axis.hpp

    r2270 r2291  
    4444                                                std::map<int, int>& elementPositionInGridDst2AxisPosition, 
    4545                                                std::map<int, int>& elementPositionInGridDst2DomainPosition); 
     46 
     47  virtual shared_ptr<CGridAlgorithm> createGridAlgorithm(CGrid* gridSrc, CGrid* gridDst, int pos); 
    4648  static bool dummyRegistered_; 
    4749}; 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_reduce_domain.cpp

    r2270 r2291  
    5151TRY 
    5252{ 
    53   algo->checkValid(axisDestination, domainSource); 
    54   axisDestination->checkAttributes() ; 
    5553  switch (algo->operation) 
    5654  { 
     
    7472 
    7573  } 
    76  
     74   
     75  algo->checkValid(axisDestination, domainSource); 
    7776  dir_ = (CReduceDomainToAxis::direction_attr::iDir == algo->direction)  ? iDir : jDir; 
    78   bool local = algo->local ; 
     77 
     78  bool local = false; 
     79  if (!algo->local.isEmpty()) local=algo->local ; 
     80   
     81  size_t nj_glo = domainSource->nj_glo ; 
     82  size_t ni_glo = domainSource->ni_glo ; 
     83 
     84  bool validAxis = axisDestination->checkGeometricAttributes(false) ; 
     85  if (validAxis && !local)  
     86  { 
     87     
     88    axisDestination->checkAttributes() ;  
     89    if (dir_==jDir) 
     90    { 
     91        if (axisDestination->n_glo != domainSource->nj_glo) 
     92          ERROR("CAxisAlgorithmReduceDomain::CAxisAlgorithmReduceDomain(bool isSource, CAxis* axisDestination, CDomain* domainSource, CReduceDomainToAxis* algo)", 
     93            << "Extract domain along j, axis destination should have n_glo equal to nj_glo of domain source" 
     94            << "Domain source " <<domainSource->getId() << " has nj_glo " << domainSource->nj_glo << std::endl 
     95            << "Axis destination " << axisDestination->getId() << " has n_glo " << axisDestination->n_glo) 
     96    } 
     97    else 
     98    { 
     99      if (axisDestination->n_glo != domainSource->ni_glo) 
     100          ERROR("CAxisAlgorithmReduceDomain::CAxisAlgorithmReduceDomain(bool isSource, CAxis* axisDestination, CDomain* domainSource, CReduceDomainToAxis* algo)", 
     101            << "Extract domain along j, axis destination should have n_glo equal to ni_glo of domain source" 
     102            << "Domain source " <<domainSource->getId() << " has ni_glo " << domainSource->ni_glo << std::endl 
     103            << "Axis destination " << axisDestination->getId() << " has n_glo " << axisDestination->n_glo); 
     104    } 
     105  } 
     106  else 
     107  { 
     108    // create axis destination from source domain 
     109 
     110    axisDestination->resetGeometricAttributes(); 
     111    if (dir_== jDir) 
     112    { 
     113      axisDestination->n_glo = domainSource->nj_glo ; 
     114       
     115      CArray<size_t, 1> srcGlobalIndex ; 
     116      set<size_t> indexFullView; 
     117      set<size_t> indexWorkflowView; 
     118      domainSource->getLocalView(CElementView::FULL)->getGlobalIndexView(srcGlobalIndex) ; 
     119      for(int i=0; i<srcGlobalIndex.numElements(); i++) indexFullView.insert(srcGlobalIndex(i)/ni_glo) ; 
     120      domainSource->getLocalView(CElementView::WORKFLOW)->getGlobalIndexView(srcGlobalIndex) ; 
     121      for(int i=0; i<srcGlobalIndex.numElements(); i++) indexWorkflowView.insert(srcGlobalIndex(i)/ni_glo) ; 
     122 
     123      axisDestination-> n = indexFullView.size() ; 
     124      axisDestination-> index.resize(axisDestination-> n) ; 
     125      axisDestination-> mask.resize(axisDestination-> n) ; 
     126       
     127      map<size_t,int> globalToLocalIndex ; 
     128      auto it=indexFullView.begin(); 
     129      for(int i=0; it!=indexFullView.end(); ++i,++it)  
     130      { 
     131        axisDestination->index(i) = *it ; 
     132        if (indexWorkflowView.count(*it)==0) axisDestination->mask(i) = false ; 
     133        else axisDestination->mask(i) = true ; 
     134        globalToLocalIndex[*it] = i ; 
     135      } 
     136      if (domainSource->hasLonLat && domainSource->type == CDomain::type_attr::rectilinear) 
     137      { 
     138        axisDestination->value.resize(axisDestination-> n) ; 
     139        axisDestination->axis_type.setValue(CAxis::axis_type_attr::Y) ; 
     140        if (domainSource->hasBounds) axisDestination-> bounds.resize(axisDestination-> n, 2) ; 
     141 
     142        domainSource->getLocalView(CElementView::FULL)->getGlobalIndexView(srcGlobalIndex) ; 
     143        for(int i=0; i<srcGlobalIndex.numElements(); i++)  
     144        { 
     145          axisDestination->value(globalToLocalIndex[srcGlobalIndex(i)/ni_glo]) = domainSource->latvalue(i) ; 
     146          if (domainSource->hasBounds)  
     147          { 
     148            axisDestination->bounds(globalToLocalIndex[srcGlobalIndex(i)/ni_glo,0]) = domainSource->bounds_latvalue(i,0) ; 
     149            axisDestination->bounds(globalToLocalIndex[srcGlobalIndex(i)/ni_glo,1]) = domainSource->bounds_latvalue(i,1) ; 
     150          } 
     151        }  
     152      } 
     153       
     154    } 
     155    else // dir_== iDir 
     156    { 
     157      axisDestination->n_glo = domainSource->ni_glo ; 
     158       
     159      CArray<size_t, 1> srcGlobalIndex ; 
     160      set<size_t> indexFullView; 
     161      set<size_t> indexWorkflowView; 
     162      domainSource->getLocalView(CElementView::FULL)->getGlobalIndexView(srcGlobalIndex) ; 
     163      for(int i=0; i<srcGlobalIndex.numElements(); i++) indexFullView.insert(srcGlobalIndex(i)%ni_glo) ; 
     164      domainSource->getLocalView(CElementView::WORKFLOW)->getGlobalIndexView(srcGlobalIndex) ; 
     165      for(int i=0; i<srcGlobalIndex.numElements(); i++) indexWorkflowView.insert(srcGlobalIndex(i)%ni_glo) ; 
     166 
     167      axisDestination-> n = indexFullView.size() ; 
     168      axisDestination-> index.resize(axisDestination-> n) ; 
     169      axisDestination-> mask.resize(axisDestination-> n) ; 
     170      map<size_t,int> globalToLocalIndex ; 
     171      auto it=indexFullView.begin(); 
     172      for(int i=0; it!=indexFullView.end(); ++i,++it)  
     173      { 
     174        axisDestination->index(i) = *it ; 
     175        if (indexWorkflowView.count(*it)==0) axisDestination->mask(i) = false ; 
     176        else axisDestination->mask(i) = true ; 
     177        globalToLocalIndex[*it] = i ; 
     178      } 
     179     
     180      if (domainSource->hasLonLat && domainSource->type == CDomain::type_attr::rectilinear) 
     181      { 
     182        axisDestination-> value.resize(axisDestination-> n) ; 
     183        axisDestination-> axis_type.setValue(CAxis::axis_type_attr::X) ; 
     184        if (domainSource->hasBounds) axisDestination->bounds.resize(axisDestination-> n, 2) ; 
     185 
     186        domainSource->getLocalView(CElementView::FULL)->getGlobalIndexView(srcGlobalIndex) ; 
     187        for(int i=0; i<srcGlobalIndex.numElements(); i++)  
     188        { 
     189          axisDestination->value(globalToLocalIndex[srcGlobalIndex(i)%ni_glo]) = domainSource->lonvalue(i) ; 
     190          if (domainSource->hasBounds)  
     191          { 
     192            axisDestination->bounds(globalToLocalIndex[srcGlobalIndex(i)%ni_glo,0]) = domainSource->bounds_lonvalue(i,0) ; 
     193            axisDestination->bounds(globalToLocalIndex[srcGlobalIndex(i)%ni_glo,1]) = domainSource->bounds_lonvalue(i,1) ; 
     194          } 
     195        }  
     196      } 
     197     
     198    } 
     199    
     200    axisDestination->checkAttributes() ;    
     201  } 
     202   
     203  // compute needed index for tranformation 
     204 
     205  TransformationIndexMap& transMap = transformationMapping_; 
     206 
     207  CArray<size_t, 1> srcGlobalIndex ; 
     208  domainSource->getLocalView(CElementView::WORKFLOW)->getGlobalIndexView(srcGlobalIndex) ; 
     209  CArray<size_t, 1> dstGlobalIndex ; 
     210  axisDestination->getLocalView(CElementView::WORKFLOW)->getGlobalIndexView(dstGlobalIndex) ; 
     211   
     212  if (local) 
     213  { 
     214     
     215    set<size_t> dstGlobalIndexSet ; 
     216    for(int i=0; i<dstGlobalIndex.numElements() ; i++) dstGlobalIndexSet.insert(dstGlobalIndex(i)) ; // for mask 
     217 
     218    size_t dstInd ;  
     219    for(int i=0; i<srcGlobalIndex.numElements(); i++)  
     220    { 
     221      if (dir_== jDir) dstInd=srcGlobalIndex(i)/ni_glo ; 
     222      else dstInd=srcGlobalIndex(i)%ni_glo ; 
     223      if (dstGlobalIndexSet.count(dstInd)!=0) transMap[dstInd].push_back(srcGlobalIndex(i)) ;  
     224    } 
     225  } 
     226  else 
     227  { 
     228    for(int i=0; i<dstGlobalIndex.numElements() ;i++) 
     229    { 
     230      if (dir_== jDir)  
     231        for(size_t j=0; j<ni_glo;j++) transMap[dstGlobalIndex(i)].push_back(dstGlobalIndex(i)*ni_glo+j) ; 
     232      else 
     233        for(size_t j=0; j<nj_glo;j++) transMap[dstGlobalIndex(i)].push_back(ni_glo*j+dstGlobalIndex(i)) ; 
     234    } 
     235  } 
     236 
     237/* 
     238 
    79239 
    80240  TransformationIndexMap& transMap = transformationMapping_; 
     
    148308 
    149309  axisDestination->checkAttributes() ; 
     310*/ 
    150311  this->computeAlgorithm(domainSource->getLocalView(CElementView::WORKFLOW), axisDestination->getLocalView(CElementView::WORKFLOW)) ; 
    151312 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/generic_algorithm_transformation.cpp

    r2270 r2291  
    3535shared_ptr<CGridAlgorithm> CGenericAlgorithmTransformation::createGridAlgorithm(CGrid* gridSrc, CGrid* gridDst, int pos) 
    3636{ 
    37   return make_shared<CGridAlgorithmGeneric>(gridSrc, gridDst, pos, shared_from_this()) ; 
     37  auto algo = make_shared<CGridAlgorithmGeneric>(gridSrc, gridDst, pos, shared_from_this()) ; 
     38  algo->computeAlgorithm() ; 
     39  return algo ;  
    3840} 
    3941 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/grid_algorithm_generic.cpp

    r2270 r2291  
    1313  : CGridAlgorithm(algo), gridSrc_(gridSrc), gridDst_(gridDst), pos_(pos) 
    1414  { 
    15     computeAlgorithm() ; 
    1615  } 
    1716 
    18   void CGridAlgorithmGeneric::computeAlgorithm(void) 
     17  void CGridAlgorithmGeneric::computeAlgorithm(bool eliminateRedondant) 
    1918  { 
    2019    shared_ptr<CGridLocalElements> gridSrcElements = gridSrc_->getGridLocalElements() ; 
     
    4847 
    4948    gridTransformConnector_ = make_shared<CGridTransformConnector>(srcView->getViews(), remoteViews, comm ) ; 
     49    gridTransformConnector_->computeConnector(eliminateRedondant) ; 
    5050  
    5151  } 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/grid_algorithm_generic.hpp

    r2270 r2291  
    2626    virtual ~CGridAlgorithmGeneric() {} ; 
    2727 
    28     void computeAlgorithm(void) ; 
     28    void computeAlgorithm(bool eliminateRedundant=true) ; 
    2929    virtual void apply(const CArray<double,1>& dataIn, CArray<double,1>& dataOut) ; 
    3030    virtual void apply(const CArray<double,1>& dataIn, const vector<CArray<double,1>>& auxData, CArray<double,1>& dataOut) ; 
    3131     
    3232  protected: 
     33 
    3334    shared_ptr<CGridTransformConnector> gridTransformConnector_=nullptr ; 
    3435    CGrid* gridSrc_ = nullptr ; 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/scalar_algorithm/scalar_algorithm_reduce_axis.cpp

    r2270 r2291  
    7979 
    8080  }  
     81 
     82  bool local=false ; 
     83  if (!algo->local.isEmpty()) local=algo->local ; 
    8184   
    82   int globalIndexSize = axisSource-> n_glo; 
    83   for (int idx = 0; idx < globalIndexSize; ++idx)  transformationMapping_[0].push_back(idx); 
     85  auto& transMap = this->transformationMapping_;   
     86   
     87  if (local) 
     88  { 
     89    scalarDestination->n=1 ; // no mask 
     90    scalarDestination->mask.reset() ; 
     91     
     92    CArray<size_t,1> srcGlobalIndex ; 
     93    axisSource->getLocalView(CElementView::WORKFLOW)->getGlobalIndexView(srcGlobalIndex) ; 
     94    size_t nbIdx = srcGlobalIndex.numElements(); 
     95    if (nbIdx==0) scalarDestination->n=0 ; 
     96    scalarDestination->checkAttributes() ; 
    8497 
    85   scalarDestination->checkAttributes() ; 
     98    for (size_t idx = 0; idx < nbIdx; ++idx) 
     99    { 
     100      size_t globalIdx = srcGlobalIndex(idx); 
     101      transformationMapping_[0].push_back(globalIdx); 
     102    } 
     103 
     104  } 
     105  else 
     106  { 
     107   scalarDestination->checkAttributes() ; 
     108 
     109   int globalIndexSize = axisSource->getLocalView(CElementView::WORKFLOW)->getGlobalSize(); 
     110   CArray<size_t,1> dstGlobalIndex ; 
     111   scalarDestination->getLocalView(CElementView::WORKFLOW)->getGlobalIndexView(dstGlobalIndex) ; 
     112   if (dstGlobalIndex.numElements()!=0) 
     113     for (int idx = 0; idx < globalIndexSize; ++idx)  transformationMapping_[0].push_back(idx); 
     114  } 
     115 
    86116  this->computeAlgorithm(axisSource->getLocalView(CElementView::WORKFLOW), scalarDestination->getLocalView(CElementView::WORKFLOW)) ; 
    87117   
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/scalar_algorithm/scalar_algorithm_reduce_domain.cpp

    r2270 r2291  
    7474  } 
    7575 
    76   TransformationIndexMap& transMap = this->transformationMapping_; 
    77  
    78   int ni_glo = domainSrc_->ni_glo ; 
    79   int nj_glo = domainSrc_->nj_glo ; 
    80   int nbDomainIdx ; 
     76  bool local=false ; 
     77  if (!algo->local.isEmpty()) local=algo->local ; 
    8178   
    82   bool  local = algo->local ; 
     79  auto& transMap = this->transformationMapping_;   
    8380   
    8481  if (local) 
    8582  { 
    86       const CArray<int, 1>& i_index = domainSrc_-> i_index.getValue() ; 
    87       const CArray<int, 1>& j_index = domainSrc_-> j_index.getValue() ; 
    88       const CArray<bool,1>& localMask = domainSrc_-> localMask ; 
    89       int nbDomainIdx = i_index.numElements(); 
     83    scalarDestination->n=1 ; // no mask 
     84    scalarDestination->mask.reset() ; 
     85     
     86    CArray<size_t,1> srcGlobalIndex ; 
     87    domainSource->getLocalView(CElementView::WORKFLOW)->getGlobalIndexView(srcGlobalIndex) ; 
     88    size_t nbIdx = srcGlobalIndex.numElements(); 
     89    if (nbIdx==0) scalarDestination->n=0 ; 
     90    scalarDestination->checkAttributes() ; 
    9091 
    91       for (int idxDomain = 0; idxDomain < nbDomainIdx; ++idxDomain) 
    92       { 
    93         if (localMask(idxDomain)) 
    94         {  
    95           transMap[0].push_back(j_index(idxDomain)* ni_glo + i_index(idxDomain)); 
    96         } 
    97       } 
     92    for (size_t idx = 0; idx < nbIdx; ++idx) 
     93    { 
     94      size_t globalIdx = srcGlobalIndex(idx); 
     95      transformationMapping_[0].push_back(globalIdx); 
     96    } 
     97 
    9898  } 
    9999  else 
    100   {   
    101     nbDomainIdx = ni_glo * nj_glo; 
    102     for (int idxDomain = 0; idxDomain < nbDomainIdx; ++idxDomain) transMap[0].push_back(idxDomain);     
     100  { 
     101   scalarDestination->checkAttributes() ; 
     102 
     103   int globalIndexSize = domainSource->getLocalView(CElementView::WORKFLOW)->getGlobalSize(); 
     104   CArray<size_t,1> dstGlobalIndex ; 
     105   scalarDestination->getLocalView(CElementView::WORKFLOW)->getGlobalIndexView(dstGlobalIndex) ; 
     106   if (dstGlobalIndex.numElements()!=0) 
     107     for (int idx = 0; idx < globalIndexSize; ++idx)  transformationMapping_[0].push_back(idx); 
    103108  } 
    104    
    105   scalarDestination->checkAttributes() ; 
     109 
    106110  this->computeAlgorithm(domainSource->getLocalView(CElementView::WORKFLOW), scalarDestination->getLocalView(CElementView::WORKFLOW)) ; 
     111 
    107112} 
    108113CATCH 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/scalar_algorithm/scalar_algorithm_reduce_scalar.cpp

    r2270 r2291  
    1010#include "grid_transformation_factory_impl.hpp" 
    1111#include "reduction.hpp" 
     12#include "grid_algorithm_reduce.hpp" 
     13 
    1214 
    1315 
     
    4749TRY 
    4850{ 
    49   eliminateRedondantSrc_= false ; 
     51  scalarDestination->checkAttributes() ; 
    5052  if (algo->operation.isEmpty()) 
    5153    ERROR("CScalarAlgorithmReduceScalar::CScalarAlgorithmReduceScalar(CScalar* scalarDestination, CScalar* scalarSource, CReduceScalarToScalar* algo)", 
     
    7577 
    7678  } 
    77   transformationMapping_[0].push_back(0) ; 
     79   
     80  auto& transMap = this->transformationMapping_; 
     81   
     82  CArray<size_t,1> dstGlobalIndex ; 
     83  scalarDestination->getLocalView(CElementView::WORKFLOW)->getGlobalIndexView(dstGlobalIndex) ; 
     84  size_t nbIdx = dstGlobalIndex.numElements(); 
    7885 
    79   scalarDestination->checkAttributes() ; 
     86  for (size_t idx = 0; idx < nbIdx; ++idx) 
     87  { 
     88    size_t globalIdx = dstGlobalIndex(idx); 
     89    transMap[globalIdx].resize(1); 
     90    transMap[globalIdx][0]=globalIdx ;       
     91  } 
     92 
    8093  this->computeAlgorithm(scalarSource->getLocalView(CElementView::WORKFLOW), scalarDestination->getLocalView(CElementView::WORKFLOW)) ;  
    8194} 
    8295CATCH 
     96 
     97shared_ptr<CGridAlgorithm> CScalarAlgorithmReduceScalar::createGridAlgorithm(CGrid* gridSrc, CGrid* gridDst, int pos) 
     98{ 
     99  auto algo=make_shared<CGridAlgorithmReduce>(gridSrc, gridDst, pos, shared_from_this(), operator_) ; 
     100  algo->computeAlgorithm(false) ; 
     101  return algo ;  
     102} 
    83103 
    84104CScalarAlgorithmReduceScalar::~CScalarAlgorithmReduceScalar() 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/scalar_algorithm/scalar_algorithm_reduce_scalar.hpp

    r2270 r2291  
    4242                                                std::map<int, int>& elementPositionInGridDst2AxisPosition, 
    4343                                                std::map<int, int>& elementPositionInGridDst2DomainPosition); 
     44  virtual shared_ptr<CGridAlgorithm> createGridAlgorithm(CGrid* gridSrc, CGrid* gridDst, int pos); 
    4445  static bool dummyRegistered_; 
    4546}; 
Note: See TracChangeset for help on using the changeset viewer.