Ignore:
Timestamp:
11/10/21 11:47:59 (3 years ago)
Author:
jderouillat
Message:

Implement extract axis transformations (from axis and from domain) using source views. extract_domain_to_axis do not require n_glo any more, n_glo is defined using the domain source dimension and the direction requested.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_extract.cpp

    r1998 r2255  
    4444TRY 
    4545{ 
     46  axisDestination->axis_type.reset(); 
     47  axisDestination->n_glo.reset(); 
     48  axisDestination->index.reset(); 
     49  axisDestination->n.reset(); 
     50  axisDestination->begin.reset(); 
     51 
     52  axisDestination->mask.reset(); 
     53  axisDestination->data_index.reset(); 
     54  axisDestination->data_n.reset(); 
     55  axisDestination->data_begin.reset(); 
     56 
     57  axisDestination->value.reset(); 
     58  axisDestination->label.reset(); 
     59  axisDestination->bounds.reset(); 
     60 
    4661  extractAxis->checkValid(axisSource); 
    4762  extractBegin_ = extractAxis->begin.getValue(); 
     
    6883    } 
    6984  } 
    70   beginDestGlo = beginDestLoc + axisSrc_->begin - extractBegin_; 
     85   
    7186  axisDest_->n_glo.setValue(extractN_); 
    72   axisDest_->n.setValue(nDest); 
    73   axisDest_->begin.setValue(beginDestGlo); 
    7487  axisDest_->index.resize(nDest); 
     88  if (nDest==0) 
     89  { 
     90    axisDest_->n.setValue( 0 ); 
     91    axisDest_->begin.setValue( 0 ); 
     92  } 
    7593 
    76   axisDest_->data_n.setValue(nDest); 
    77   axisDest_->data_begin.setValue(0); 
    78   axisDest_->data_index.resize(nDest); 
    79  
    80   axisDest_->mask.resize(nDest); 
    8194  if (axisSrc_->hasValue) axisDest_->value.resize(nDest); 
    8295  if (axisSrc_->hasLabel) axisDest_->label.resize(nDest); 
     
    8598  auto& transMap = this->transformationMapping_; 
    8699 
    87   for (int iDest = 0; iDest < nDest; iDest++) 
     100  // Set attributes required to define domainDestination->localElement_ and associated views, full and workflow) 
     101  CArray<size_t,1> sourceGlobalIdx = axisSource->getLocalElement()->getGlobalIndex(); 
     102  int indexSize = sourceGlobalIdx.numElements(); 
     103 
     104  CArray<int,1> sourceWorkflowIdx = axisSource->getLocalView(CElementView::WORKFLOW)->getIndex(); 
     105  int srcWorkflowSize = sourceWorkflowIdx.numElements(); 
     106  axisDest_->data_index.resize(nDest); 
     107  axisDest_->data_index = -1; 
     108 
     109  int idxMin = INT_MAX; 
     110  for (int countSrc = 0; countSrc < indexSize ; ++countSrc) 
    88111  { 
    89     iSrc = iDest + beginDestLoc; 
    90     axisDest_->index(iDest) = iDest + beginDestGlo; 
    91     axisDest_->data_index(iDest) = axisSrc_->data_index(iSrc) - beginDestLoc; 
    92     axisDest_->mask(iDest) = axisSrc_->mask(iSrc); 
    93  
    94     if (axisSrc_->hasValue) 
    95       axisDest_->value(iDest) = axisSrc_->value(iSrc); 
    96     if (axisSrc_->hasLabel) 
    97       axisDest_->label(iDest) = axisSrc_->label(iSrc); 
    98     if (axisSrc_->hasBounds) 
    99     { 
    100       axisDest_->bounds(0,iDest) = axisSrc_->bounds(0,iSrc); 
    101       axisDest_->bounds(1,iDest) = axisSrc_->bounds(1,iSrc); 
    102     } 
    103     indGloDest = axisDest_->index(iDest); 
    104     indGloSrc = axisSrc_->index(iSrc); 
    105      
    106     transMap[indGloDest]=indGloSrc; 
    107  
     112    if ( sourceGlobalIdx(countSrc) < idxMin ) 
     113      idxMin = sourceGlobalIdx(countSrc); 
    108114  } 
    109115 
     116  int countDest(0); // increment of the position in destination domain  
     117  for (int countSrc = 0; countSrc < indexSize ; ++countSrc) 
     118  { 
     119    int idxSrc = sourceGlobalIdx(countSrc); 
     120    if ( (idxSrc >= extractBegin_) && (idxSrc <= extractEnd_) ) 
     121    { 
     122      axisDest_->index(countDest) = idxSrc-extractBegin_; 
     123 
     124      // ------------------ define transformation only if in the WF ------------------  
     125      int iIdxSrc2 = (countSrc+idxMin)%axisSource->n_glo; 
     126      int convert_locally_global_idx = (iIdxSrc2-idxMin) ; 
     127      bool concerned_by_WF(false); 
     128      for ( int i = 0 ; i<sourceWorkflowIdx.numElements() ; ++i ) 
     129      { 
     130        if (sourceWorkflowIdx(i)==convert_locally_global_idx) 
     131        {       
     132          concerned_by_WF = true; 
     133          break; 
     134        } 
     135      } 
     136 
     137      if (concerned_by_WF) 
     138      { 
     139        transformationMapping_[idxSrc-extractBegin_]=sourceGlobalIdx(countSrc); 
     140        axisDest_->data_index( countDest ) = countDest; 
     141      } 
     142      // ----------------------------------------------------------------------------- 
     143 
     144      if (axisSrc_->hasValue) 
     145      { 
     146        axisDest_->value(countDest) = axisSrc_->value(countSrc); 
     147      } 
     148      if (axisSrc_->hasLabel) 
     149      { 
     150        axisDest_->label(countDest) = axisSrc_->label(countSrc); 
     151      } 
     152      if (axisSrc_->hasBounds) 
     153      { 
     154        axisDest_->bounds(0,countDest) = axisSrc_->bounds(0,countSrc); 
     155        axisDest_->bounds(1,countDest) = axisSrc_->bounds(1,countSrc); 
     156      } 
     157       
     158      // if point i has been identified as extracted, increment position in destination domain for the next point 
     159      countDest++; 
     160    } 
     161  } 
     162   
    110163  axisDestination->checkAttributes() ; 
    111164 
Note: See TracChangeset for help on using the changeset viewer.