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_domain.cpp

    r2117 r2255  
    5151TRY 
    5252{ 
    53   axisDestination->checkAttributes() ; 
     53  axisDestination->axis_type.reset(); 
     54  axisDestination->n_glo.reset(); 
     55  axisDestination->index.reset(); 
     56  axisDestination->n.reset(); 
     57  axisDestination->begin.reset(); 
     58 
     59  axisDestination->mask.reset(); 
     60  axisDestination->data_index.reset(); 
     61  axisDestination->data_n.reset(); 
     62  axisDestination->data_begin.reset(); 
     63 
     64  axisDestination->value.reset(); 
     65  axisDestination->label.reset(); 
     66  axisDestination->bounds.reset(); 
     67 
    5468  algo->checkValid(axisDestination, domainSource); 
    5569  StdString op = "extract"; 
    5670 
     71  int nglo,nloc; 
    5772  switch (algo->direction) 
    5873  { 
    5974    case CExtractDomainToAxis::direction_attr::jDir: 
    6075      dir_ = jDir; 
     76      nglo = domainSource->nj_glo.getValue(); 
     77      nloc = domainSource->nj.getValue(); 
    6178      break; 
    6279    case CExtractDomainToAxis::direction_attr::iDir: 
    6380      dir_ = iDir; 
     81      nglo = domainSource->ni_glo.getValue(); 
     82      nloc = domainSource->ni.getValue(); 
    6483      break; 
    6584    default: 
    6685      break; 
     86  } 
     87   
     88  axisDestination->n_glo.setValue( nglo ); 
     89  axisDestination->index.resize( nloc ); 
     90  axisDestination->data_index.resize( nloc ); 
     91  axisDestination->data_index = -1; 
     92 
     93  if ( axisDestination->index.isEmpty() ) 
     94  { 
     95    axisDestination->n.setValue( 0 ); 
     96    axisDestination->begin.setValue( 0 ); 
    6797  } 
    6898 
     
    70100 
    71101  auto& transMap = this->transformationMapping_; 
     102   
     103  CArray<size_t,1> sourceGlobalIdx = domainSource->getLocalElement()->getGlobalIndex(); 
     104  int indexSize = sourceGlobalIdx.numElements(); 
    72105 
    73   CArray<int,1>& axisDstIndex = axisDest_->index; 
    74   int ni_glo = domainSrc_->ni_glo, nj_glo = domainSrc_->nj_glo; 
     106  CArray<int,1> sourceWorkflowIdx = domainSource->getLocalView(CElementView::WORKFLOW)->getIndex(); 
     107  int srcWorkflowSize = sourceWorkflowIdx.numElements(); 
     108   
     109  int iIdxSrcMin = INT_MAX; 
     110  int jIdxSrcMin = INT_MAX; 
     111  int IdxMin = INT_MAX; 
     112  for (int countSrc = 0; countSrc < indexSize ; ++countSrc) 
     113  { 
     114    if ( sourceGlobalIdx(countSrc)%domainSource->ni_glo < iIdxSrcMin ) 
     115      iIdxSrcMin = sourceGlobalIdx(countSrc)%domainSource->ni_glo; 
     116    if ( sourceGlobalIdx(countSrc)/domainSource->ni_glo < jIdxSrcMin ) 
     117      jIdxSrcMin = sourceGlobalIdx(countSrc)/domainSource->ni_glo; 
     118    if ( sourceGlobalIdx(countSrc) < IdxMin ) 
     119      IdxMin = sourceGlobalIdx(countSrc); 
     120  } 
     121   
    75122  if (jDir == dir_) 
    76123  { 
    77     int nbAxisIdx = axisDstIndex.numElements(); 
    78     for (int idxAxis = 0; idxAxis < nbAxisIdx; ++idxAxis) 
     124    int countDest(0); 
     125    for (int countSrc = 0; countSrc < indexSize ; ++countSrc) 
    79126    { 
    80       int globalAxisIdx = axisDstIndex(idxAxis); 
    81       transMap[globalAxisIdx] = globalAxisIdx * ni_glo + pos_; 
     127      if ( sourceGlobalIdx(countSrc)%domainSource->ni_glo == pos_ ) 
     128      { 
     129        axisDest_->index(countDest) = sourceGlobalIdx(countSrc)/domainSource->ni_glo; 
     130        int iIdxSrc2 = (countSrc+IdxMin)%domainSource->ni_glo; 
     131        int jIdxSrc2 = (countSrc+IdxMin)/domainSource->ni_glo; 
     132        int convert_locally_global_idx = (jIdxSrc2-jIdxSrcMin)*domainSource->ni + (iIdxSrc2-iIdxSrcMin) ; 
     133        bool concerned_by_WF(false); 
     134        for ( int i = 0 ; i<sourceWorkflowIdx.numElements() ; ++i ) 
     135        { 
     136          if (sourceWorkflowIdx(i)==convert_locally_global_idx) 
     137          {       
     138                concerned_by_WF = true; 
     139                break; 
     140          } 
     141        } 
     142        if (concerned_by_WF) 
     143        { 
     144          axisDest_->data_index(countDest) = countDest; 
     145          transMap[axisDest_->index(countDest)] = sourceGlobalIdx(countSrc); 
     146        } 
     147        countDest++; 
     148      } 
    82149    } 
    83150  } 
    84151  else if (iDir == dir_) 
    85152  { 
    86     int nbAxisIdx = axisDstIndex.numElements(); 
    87     for (int idxAxis = 0; idxAxis < nbAxisIdx; ++idxAxis) 
     153    int countDest(0); 
     154    for (int countSrc = 0; countSrc < indexSize ; ++countSrc) 
    88155    { 
    89       int globalAxisIdx = axisDstIndex(idxAxis); 
    90       transMap[globalAxisIdx] = globalAxisIdx + ni_glo * pos_; 
     156      if ( sourceGlobalIdx(countSrc)/domainSource->ni_glo == pos_ ) 
     157      { 
     158        axisDest_->index(countDest) = sourceGlobalIdx(countSrc)%domainSource->ni_glo; 
     159        int iIdxSrc2 = (countSrc+IdxMin)%domainSource->ni_glo; 
     160        int jIdxSrc2 = (countSrc+IdxMin)/domainSource->ni_glo; 
     161        int convert_locally_global_idx = (jIdxSrc2-jIdxSrcMin)*domainSource->ni + (iIdxSrc2-iIdxSrcMin) ; 
     162        bool concerned_by_WF(false); 
     163        for ( int i = 0 ; i<sourceWorkflowIdx.numElements() ; ++i ) 
     164        { 
     165          if (sourceWorkflowIdx(i)==convert_locally_global_idx) 
     166          {       
     167                concerned_by_WF = true; 
     168                break; 
     169          } 
     170        } 
     171        if (concerned_by_WF) 
     172        { 
     173          axisDest_->data_index(countDest) = countDest; 
     174          transMap[axisDest_->index(countDest)] = sourceGlobalIdx(countSrc); 
     175        } 
     176        countDest++; 
     177      } 
    91178    } 
    92179  } 
Note: See TracChangeset for help on using the changeset viewer.