Ignore:
Timestamp:
01/23/19 10:31:44 (5 years ago)
Author:
yushan
Message:

dev on ADA. add flag switch _usingEP/_usingMPI

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_openmp/src/transformation/axis_algorithm_zoom.cpp

    r1460 r1642  
    11/*! 
    22   \file axis_algorithm_zoom.cpp 
    3    \author Ha NGUYEN 
    4    \since 03 June 2015 
    5    \date 12 June 2015 
    6  
    7    \brief Algorithm for zooming on an axis. 
     3   \brief Algorithm for zooming an axis. 
    84 */ 
    95#include "axis_algorithm_zoom.hpp" 
     
    2319                                                           std::map<int, int>& elementPositionInGridDst2AxisPosition, 
    2420                                                           std::map<int, int>& elementPositionInGridDst2DomainPosition) 
     21TRY 
    2522{ 
    2623  std::vector<CAxis*> axisListDestP = gridDst->getAxis(); 
     
    3330  return (new CAxisAlgorithmZoom(axisListDestP[axisDstIndex], axisListSrcP[axisSrcIndex], zoomAxis)); 
    3431} 
     32CATCH 
     33 
    3534bool CAxisAlgorithmZoom::registerTrans() 
     35TRY 
    3636{ 
    3737  CGridTransformationFactory<CAxis>::registerTransformation(TRANS_ZOOM_AXIS, create); 
    3838} 
     39CATCH 
    3940 
    4041CAxisAlgorithmZoom::CAxisAlgorithmZoom(CAxis* axisDestination, CAxis* axisSource, CZoomAxis* zoomAxis) 
    4142: CAxisAlgorithmTransformation(axisDestination, axisSource) 
     43TRY 
    4244{ 
    4345  zoomAxis->checkValid(axisSource); 
    4446  zoomBegin_ = zoomAxis->begin.getValue(); 
    45   zoomSize_  = zoomAxis->n.getValue(); 
    46   zoomEnd_   = zoomBegin_ + zoomSize_ - 1; 
     47  zoomN_  = zoomAxis->n.getValue(); 
     48  zoomEnd_   = zoomBegin_ + zoomN_ - 1; 
    4749 
    48   if (zoomSize_ > axisSource->n_glo.getValue()) 
     50  if (zoomN_ > axisSource->n_glo.getValue()) 
    4951  { 
    5052    ERROR("CAxisAlgorithmZoom::CAxisAlgorithmZoom(CAxis* axisDestination, CAxis* axisSource, CZoomAxis* zoomAxis)", 
    51            << "Zoom size is greater than global size of axis source" 
    52            << "Global size of axis source " <<axisSource->getId() << " is " << axisSource->n_glo.getValue()  << std::endl 
    53            << "Zoom size is " << zoomSize_ ); 
     53           << "Zoom size is greater than global size of source axis" 
     54           << "Global size of source axis " <<axisSource->getId() << " is " << axisSource->n_glo.getValue()  << std::endl 
     55           << "Zoom size is " << zoomN_ ); 
    5456  } 
    5557 
    56   if (!zoomAxis->index.isEmpty()) 
     58  int idxSrc, nDest = 0, beginDestLoc, beginDestGlo = 0 ; 
     59  int indGloDest, indGloSrc, iSrc; 
     60  for (int i = 0; i < axisSrc_->n.getValue(); i++) 
    5761  { 
    58     int sz = zoomAxis->index.numElements(); 
    59     zoomIndex_.resize(sz); 
    60     for (int i = 0; i < sz; ++i) 
    61       zoomIndex_[i] = zoomAxis->index(i); 
     62    idxSrc = axisSrc_->index(i); 
     63    if ((idxSrc >= zoomBegin_) && (idxSrc <= zoomEnd_)) 
     64    { 
     65      if (nDest == 0) beginDestLoc = i; 
     66      ++nDest; 
     67    } 
     68  } 
     69  beginDestGlo = beginDestLoc + axisSrc_->begin - zoomBegin_; 
     70  axisDest_->n_glo.setValue(zoomN_); 
     71  axisDest_->n.setValue(nDest); 
     72  axisDest_->begin.setValue(beginDestGlo); 
     73  axisDest_->index.resize(nDest); 
    6274 
    63     std::sort(zoomIndex_.begin(), zoomIndex_.end()); 
     75  axisDest_->data_n.setValue(nDest); 
     76  axisDest_->data_begin.setValue(0); 
     77  axisDest_->data_index.resize(nDest); 
     78 
     79  axisDest_->mask.resize(nDest); 
     80  if (axisSrc_->hasValue) axisDest_->value.resize(nDest); 
     81  if (axisSrc_->hasLabel) axisDest_->label.resize(nDest); 
     82  if (axisSrc_->hasBounds) axisDest_->bounds.resize(2,nDest); 
     83 
     84  this->transformationMapping_.resize(1); 
     85  this->transformationWeight_.resize(1); 
     86  TransformationIndexMap& transMap = this->transformationMapping_[0]; 
     87  TransformationWeightMap& transWeight = this->transformationWeight_[0]; 
     88 
     89  for (int iDest = 0; iDest < nDest; iDest++) 
     90  { 
     91    iSrc = iDest + beginDestLoc; 
     92    axisDest_->index(iDest) = iDest + beginDestGlo; 
     93    axisDest_->data_index(iDest) = axisSrc_->data_index(iSrc) - beginDestLoc; 
     94    axisDest_->mask(iDest) = axisSrc_->mask(iSrc); 
     95 
     96    if (axisSrc_->hasValue) 
     97      axisDest_->value(iDest) = axisSrc_->value(iSrc); 
     98    if (axisSrc_->hasLabel) 
     99      axisDest_->label(iDest) = axisSrc_->label(iSrc); 
     100    if (axisSrc_->hasBounds) 
     101    { 
     102      axisDest_->bounds(0,iDest) = axisSrc_->bounds(0,iSrc); 
     103      axisDest_->bounds(1,iDest) = axisSrc_->bounds(1,iSrc); 
     104    } 
     105    indGloDest = axisDest_->index(iDest); 
     106    indGloSrc = axisSrc_->index(iSrc); 
     107    transMap[indGloDest].push_back(indGloSrc); 
     108    transWeight[indGloDest].push_back(1.0); 
     109 
    64110  } 
    65  
    66111} 
     112CATCH 
    67113 
    68114/*! 
    69   Compute the index mapping between axis on grid source and one on grid destination 
     115  Compute the index mapping between domain on grid source and one on grid destination 
    70116*/ 
    71117void CAxisAlgorithmZoom::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 
    72118{ 
    73   // We use all index of source and destination to calculate the mapping index of zoom. 
    74   // The server who receives the "zoomed" fields will decide whether it will forward these fields or write "real zoomed" fields into file 
    75   // That means servers need to change to cover this problem. 
    76   StdSize niSource = axisSrc_->n.getValue(); 
    77   StdSize ibeginSource = axisSrc_->begin.getValue(); 
    78   StdSize iendSource = ibeginSource + niSource - 1; 
    79  
    80   StdSize ibegin = std::max(ibeginSource, zoomBegin_); 
    81   StdSize iend = std::min(iendSource, zoomEnd_); 
    82   StdSize ni = iend + 1 - ibegin; 
    83   if (iend < ibegin) ni = 0; 
    84  
    85   this->transformationMapping_.resize(1); 
    86   this->transformationWeight_.resize(1); 
    87  
    88   TransformationIndexMap& transMap = this->transformationMapping_[0]; 
    89   TransformationWeightMap& transWeight = this->transformationWeight_[0]; 
    90  
    91   if (!zoomIndex_.empty()) 
    92   { 
    93     std::vector<int>::iterator itZoomBegin, itZoomEnd; 
    94     itZoomBegin = std::lower_bound(zoomIndex_.begin(), zoomIndex_.end(), ibeginSource); 
    95     itZoomEnd   = std::upper_bound(zoomIndex_.begin(), zoomIndex_.end(), iendSource);             
    96     for (; itZoomBegin != itZoomEnd; ++itZoomBegin) 
    97     { 
    98       transMap[*itZoomBegin].push_back(*itZoomBegin); 
    99       transWeight[*itZoomBegin].push_back(1.0); 
    100     } 
    101   } 
    102   else 
    103   { 
    104     for (StdSize idx = 0; idx < ni; ++idx) 
    105     { 
    106       transMap[ibegin+idx].push_back(ibegin+idx); 
    107       transWeight[ibegin+idx].push_back(1.0); 
    108     } 
    109   } 
    110  
    111   updateZoom(); 
    112   // updateAxisDestinationMask(); 
    113119} 
    114120 
    115 /*! 
    116   After a zoom on axis, it should be certain that (global) zoom begin and (global) zoom size are updated 
    117 */ 
    118 void CAxisAlgorithmZoom::updateZoom() 
    119 { 
    120   axisDest_->global_zoom_begin = zoomBegin_; 
    121   axisDest_->global_zoom_n  = zoomSize_; 
    122   if (!zoomIndex_.empty()) 
    123   { 
    124     axisDest_->global_zoom_index.resize(zoomIndex_.size()); 
    125     std::copy(zoomIndex_.begin(), zoomIndex_.end(), axisDest_->global_zoom_index.begin()); 
    126   } 
    127121} 
    128  
    129 /*! 
    130   Update mask on axis 
    131   Because only zoomed region on axis is not masked, the remaining must be masked to make sure 
    132 correct index be extracted 
    133 */ 
    134 // void CAxisAlgorithmZoom::updateAxisDestinationMask() 
    135 // { 
    136 //   StdSize niMask = axisDest_->mask.numElements(); 
    137 //   StdSize iBeginMask = axisDest_->begin.getValue(); 
    138 //   StdSize globalIndexMask = 0; 
    139 //   TransformationIndexMap& transMap = this->transformationMapping_[0]; 
    140 //   TransformationIndexMap::const_iterator ite = (transMap).end(); 
    141 //   for (StdSize idx = 0; idx < niMask; ++idx) 
    142 //   { 
    143 //     globalIndexMask = iBeginMask + idx; 
    144 //     if (transMap.find(globalIndexMask) == ite) 
    145 //       (axisDest_->mask)(idx) = false; 
    146 //   } 
    147 // } 
    148  
    149 } 
Note: See TracChangeset for help on using the changeset viewer.