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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 
Note: See TracChangeset for help on using the changeset viewer.