- Timestamp:
- 01/23/19 10:31:44 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_openmp/src/transformation/axis_algorithm_zoom.cpp
r1460 r1642 1 1 /*! 2 2 \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. 8 4 */ 9 5 #include "axis_algorithm_zoom.hpp" … … 23 19 std::map<int, int>& elementPositionInGridDst2AxisPosition, 24 20 std::map<int, int>& elementPositionInGridDst2DomainPosition) 21 TRY 25 22 { 26 23 std::vector<CAxis*> axisListDestP = gridDst->getAxis(); … … 33 30 return (new CAxisAlgorithmZoom(axisListDestP[axisDstIndex], axisListSrcP[axisSrcIndex], zoomAxis)); 34 31 } 32 CATCH 33 35 34 bool CAxisAlgorithmZoom::registerTrans() 35 TRY 36 36 { 37 37 CGridTransformationFactory<CAxis>::registerTransformation(TRANS_ZOOM_AXIS, create); 38 38 } 39 CATCH 39 40 40 41 CAxisAlgorithmZoom::CAxisAlgorithmZoom(CAxis* axisDestination, CAxis* axisSource, CZoomAxis* zoomAxis) 41 42 : CAxisAlgorithmTransformation(axisDestination, axisSource) 43 TRY 42 44 { 43 45 zoomAxis->checkValid(axisSource); 44 46 zoomBegin_ = zoomAxis->begin.getValue(); 45 zoom Size_ = zoomAxis->n.getValue();46 zoomEnd_ = zoomBegin_ + zoom Size_ - 1;47 zoomN_ = zoomAxis->n.getValue(); 48 zoomEnd_ = zoomBegin_ + zoomN_ - 1; 47 49 48 if (zoom Size_ > axisSource->n_glo.getValue())50 if (zoomN_ > axisSource->n_glo.getValue()) 49 51 { 50 52 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::endl53 << "Zoom size is " << zoom Size_ );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_ ); 54 56 } 55 57 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++) 57 61 { 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); 62 74 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 64 110 } 65 66 111 } 112 CATCH 67 113 68 114 /*! 69 Compute the index mapping between axison grid source and one on grid destination115 Compute the index mapping between domain on grid source and one on grid destination 70 116 */ 71 117 void CAxisAlgorithmZoom::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 72 118 { 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 file75 // 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 else103 {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();113 119 } 114 120 115 /*!116 After a zoom on axis, it should be certain that (global) zoom begin and (global) zoom size are updated117 */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 }127 121 } 128 129 /*!130 Update mask on axis131 Because only zoomed region on axis is not masked, the remaining must be masked to make sure132 correct index be extracted133 */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.