Changeset 623 for XIOS/trunk/src/filter
- Timestamp:
- 06/22/15 13:36:31 (9 years ago)
- Location:
- XIOS/trunk/src/filter
- Files:
-
- 1 added
- 2 deleted
- 5 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/filter/axis_algorithm_inverse.cpp
r622 r623 1 #include "axis_ inverse.hpp"1 #include "axis_algorithm_inverse.hpp" 2 2 3 3 namespace xios { 4 4 5 CAxis Inverse::CAxisInverse(CAxis* axisDestination, CAxis* axisSource)5 CAxisAlgorithmInverse::CAxisAlgorithmInverse(CAxis* axisDestination, CAxis* axisSource) 6 6 : CAxisAlgorithmTransformation(axisDestination, axisSource) 7 7 { 8 8 if (axisDestination->size.getValue() != axisSource->size.getValue()) 9 9 { 10 ERROR("CAxis Inverse::CAxisInverse(CAxis* axisDestination, CAxis* axisSource)",10 ERROR("CAxisAlgorithmInverse::CAxisAlgorithmInverse(CAxis* axisDestination, CAxis* axisSource)", 11 11 << "Two axis have different size" 12 12 << "Size of axis source " <<axisSource->getId() << " is " << axisSource->size.getValue() << std::endl … … 19 19 int ibeginDest = axisDestination->ibegin.getValue(); 20 20 21 for (int idx = 0; idx < niDest; ++idx) axisDestGlobalIndex_.push_back(ibeginDest+idx); 21 for (int idx = 0; idx < niDest; ++idx) 22 if ((axisDestination->mask)(idx)) axisDestGlobalIndex_.push_back(ibeginDest+idx); 22 23 this->computeIndexSourceMapping(); 23 24 } 24 25 25 void CAxis Inverse::computeIndexSourceMapping()26 void CAxisAlgorithmInverse::computeIndexSourceMapping() 26 27 { 27 28 std::map<int, std::vector<int> >& transMap = this->transformationMapping_; -
XIOS/trunk/src/filter/axis_algorithm_inverse.hpp
r622 r623 7 7 namespace xios { 8 8 9 class CAxis Inverse : public CAxisAlgorithmTransformation //public CConcreteAlgo9 class CAxisAlgorithmInverse : public CAxisAlgorithmTransformation 10 10 { 11 11 public: 12 CAxis Inverse(CAxis* axisDestination, CAxis* axisSource);12 CAxisAlgorithmInverse(CAxis* axisDestination, CAxis* axisSource); 13 13 14 virtual ~CAxis Inverse() {}14 virtual ~CAxisAlgorithmInverse() {} 15 15 16 16 virtual void computeIndexSourceMapping(); -
XIOS/trunk/src/filter/axis_algorithm_zoom.hpp
r622 r623 8 8 namespace xios { 9 9 10 class CAxis Zoom : public CAxisAlgorithmTransformation10 class CAxisAlgorithmZoom : public CAxisAlgorithmTransformation 11 11 { 12 12 public: 13 CAxis Zoom(CAxis* axisDestination, CAxis* axisSource, CZoomAxis* zoomAxis);13 CAxisAlgorithmZoom(CAxis* axisDestination, CAxis* axisSource, CZoomAxis* zoomAxis); 14 14 15 virtual ~CAxis Zoom() {}15 virtual ~CAxisAlgorithmZoom() {} 16 16 17 17 virtual void computeIndexSourceMapping(); 18 18 19 private: 20 void updateAxisDestinationMask(); 21 void updateZoom(); 19 22 private: 20 23 StdSize zoomBegin_; -
XIOS/trunk/src/filter/generic_algorithm_transformation.hpp
r622 r623 20 20 std::map<size_t, std::set<size_t> >& globaIndexMapFromDestToSource); 21 21 22 22 /*! 23 23 Compute global index mapping from one element of destination grid to the corresponding element of source grid 24 24 */ -
XIOS/trunk/src/filter/grid_transformation.cpp
r622 r623 1 /*! 2 \file grid_transformation.cpp 3 \author Ha NGUYEN 4 \since 14 May 2015 5 \date 09 June 2015 6 7 \brief Interface for all transformations. 8 */ 1 9 #include "grid_transformation.hpp" 2 #include "axis_ inverse.hpp"3 #include "axis_ zoom.hpp"10 #include "axis_algorithm_inverse.hpp" 11 #include "axis_algorithm_zoom.hpp" 4 12 #include "context.hpp" 5 13 #include "context_client.hpp" … … 35 43 { 36 44 CAxis* axis = CAxis::createAxis(); 37 axis SrcTmp[idx]->duplicateAttributes(axis);45 axis->setAttributes(axisSrcTmp[idx]); 38 46 axisSrc.push_back(axis); 39 47 } … … 42 50 { 43 51 CDomain* domain = CDomain::createDomain(); 44 domain SrcTmp[idx]->duplicateAttributes(domain);52 domain->setAttributes(domainSrcTmp[idx]); 45 53 domainSrc.push_back(domain); 46 54 } … … 168 176 case TRANS_ZOOM_AXIS: 169 177 zoomAxis = dynamic_cast<CZoomAxis*> (it->second); 170 algo = new CAxis Zoom(axisListDestP[axisIndex], axisListSrcP[axisIndex], zoomAxis);178 algo = new CAxisAlgorithmZoom(axisListDestP[axisIndex], axisListSrcP[axisIndex], zoomAxis); 171 179 break; 172 180 case TRANS_INVERSE_AXIS: 173 algo = new CAxis Inverse(axisListDestP[axisIndex], axisListSrcP[axisIndex]);181 algo = new CAxisAlgorithmInverse(axisListDestP[axisIndex], axisListSrcP[axisIndex]); 174 182 break; 175 183 default: … … 196 204 case TRANS_INVERSE_AXIS: 197 205 axisIndex = elementPosition2AxisPositionInGrid_[elementPositionInGrid]; 198 axisList DestP[axisIndex]->duplicateAttributes(axisListSrcP[axisIndex]);206 axisListSrcP[axisIndex]->duplicateAttributes(axisListDestP[axisIndex]); 199 207 break; 200 208 default: … … 226 234 const CArray<size_t,1>& globalIndexGridDestSendToServer = distributionClientDest.getGlobalDataIndexSendToServer(); 227 235 236 std::cout << "global index grid dest send to server " << globalIndexGridDestSendToServer << std::endl; 228 237 // ComputeTransformation of global index of each element 229 238 std::vector<int> gridDestinationDimensionSize = gridDestination_->getGlobalDimension(); … … 241 250 } 242 251 243 std::cout << "global index destination 0 " << *globalIndexOfCurrentGridSource_ << std::endl; 244 std::cout << "global index destination 1 " << *globalIndexOfOriginalGridSource_ << std::endl; 252 std::cout << "global index destination 0 final " << *globalIndexOfCurrentGridSource_ << std::endl; 253 std::cout << "global index destination 1 final " << *globalIndexOfOriginalGridSource_ << std::endl; 254 updateFinalGridDestination(); 245 255 computeFinalTransformationMapping(); 246 256 } … … 248 258 249 259 /*! 250 Compute index mapping representing transformation between two grids 251 Each domain and each axis can contain some information of transformation, these information are then converted into 252 form of global index mapping reprensenting transformation between two grids. 260 After applying the algorithms, there are some informations on grid destination needing change, for now, there are: 261 +) mask 253 262 */ 254 void CGridTransformation::computeTransformation() 255 { 256 // const CArray<size_t,1>& globalIndexGridDestSendToServer = gridDestination_->getDistributionClient()->getGlobalDataIndexSendToServer(); 257 // std::list<std::pair<int,CGenericAlgorithmTransformation*> >::const_iterator itbMap, itMap, iteMap; 258 // itbMap = algoTransformation_.begin(); 259 // iteMap = algoTransformation_.end(); 260 // 261 // std::vector<CGenericAlgorithmTransformation*>::const_iterator itbVec, itVec, iteVec; 262 // 263 // for (itMap = itbMap; itMap != iteMap; ++itMap) 264 // { 265 // int elementPosition = itMap->first; 266 // itbVec = (itMap->second).begin(); 267 // iteVec = (itMap->second).end(); 268 // for (itVec = itbVec; itVec != iteVec; ++itVec) 269 // { 270 // (*itVec)->computeGlobalSourceIndex(elementPosition, 271 // gridDestinationDimensionSize_, 272 // globalIndexGridDestSendToServer, 273 // globaIndexMapFromDestToSource_); 274 // } 275 // } 263 void CGridTransformation::updateFinalGridDestination() 264 { 265 CContext* context = CContext::getCurrent(); 266 CContextClient* client=context->client; 267 268 //First of all, retrieve info of local mask of grid destination 269 CDistributionClient distributionClientDest(client->clientRank, gridDestination_); 270 const CArray<int, 1>& localMaskIndexOnClientDest = distributionClientDest.getLocalMaskIndexOnClient(); 271 std::cout << "local mask " << localMaskIndexOnClientDest << std::endl; 272 273 const CArray<size_t,1>& globalIndexOnClientDest = distributionClientDest.getGlobalDataIndexSendToServer(); 274 std::cout << "global index " << globalIndexOnClientDest << std::endl; 275 CArray<size_t, 1>::const_iterator itbArr, itArr, iteArr; 276 itbArr = globalIndexOnClientDest.begin(); 277 iteArr = globalIndexOnClientDest.end(); 278 279 // Then find out which index became invalid (become masked after being applied the algorithms, or demande some masked points from grid source) 280 int num = globalIndexOfOriginalGridSource_->numElements(); 281 const size_t sfmax = NumTraits<unsigned long>::sfmax(); 282 int maskIndexNum = 0; 283 for (int idx = 0; idx < num; ++idx) 284 { 285 if (sfmax == (*globalIndexOfOriginalGridSource_)(idx)) 286 { 287 size_t maskedGlobalIndex = (*globalIndexOfCurrentGridSource_)(idx); 288 itArr = std::find(itbArr, iteArr, maskedGlobalIndex); 289 if (iteArr != itArr) ++maskIndexNum; 290 } 291 } 292 293 CArray<int,1>* maskIndexToModify = new CArray<int,1>(maskIndexNum); 294 maskIndexNum = 0; 295 for (int idx = 0; idx < num; ++idx) 296 { 297 if (sfmax == (*globalIndexOfOriginalGridSource_)(idx)) 298 { 299 size_t maskedGlobalIndex = (*globalIndexOfCurrentGridSource_)(idx); 300 itArr = std::find(itbArr, iteArr, maskedGlobalIndex); 301 if (iteArr != itArr) 302 { 303 int localIdx = std::distance(itbArr, itArr); 304 (*maskIndexToModify)(maskIndexNum) = (localMaskIndexOnClientDest)(localIdx); 305 ++maskIndexNum; 306 } 307 } 308 } 309 310 std::cout << "index to modify " << *maskIndexToModify << std::endl; 311 gridDestination_->modifyMask(*maskIndexToModify); 312 313 delete maskIndexToModify; 276 314 } 277 315 … … 302 340 for (itSend = itbSend; itSend != iteSend; ++itSend) sendBuffSize += (itSend->second).size(); 303 341 342 std::cout << "global index destination 0 before" << *globalIndexOfCurrentGridSource_ << std::endl; 343 std::cout << "global index destination 1 before" << *globalIndexOfOriginalGridSource_ << std::endl; 344 345 typedef unsigned long Scalar; 304 346 unsigned long* sendBuff, *currentSendBuff; 305 347 if (0 != sendBuffSize) sendBuff = new unsigned long [sendBuffSize]; 348 for (StdSize idx = 0; idx < sendBuffSize; ++idx) sendBuff[idx] = NumTraits<Scalar>::sfmax(); 349 306 350 int currentBuffPosition = 0; 307 351 for (itSend = itbSend; itSend != iteSend; ++itSend) … … 332 376 unsigned long* recvBuff, *currentRecvBuff; 333 377 if (0 != recvBuffSize) recvBuff = new unsigned long [recvBuffSize]; 378 for (StdSize idx = 0; idx < recvBuffSize; ++idx) recvBuff[idx] = NumTraits<Scalar>::sfmax(); 379 334 380 int currentRecvBuffPosition = 0; 335 381 for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) … … 353 399 } 354 400 355 globalIndexOfCurrentGridSource_->resize(nbCurrentGridSource); 356 globalIndexOfOriginalGridSource_->resize(nbCurrentGridSource); 401 if (globalIndexOfCurrentGridSource_->numElements() != nbCurrentGridSource) 402 { 403 if ((0 != nbCurrentGridSource) && (0 != globalIndexOfCurrentGridSource_)) 404 { 405 delete globalIndexOfCurrentGridSource_; 406 globalIndexOfCurrentGridSource_ = new CArray<size_t,1>(nbCurrentGridSource); 407 } 408 } 409 410 if (globalIndexOfOriginalGridSource_->numElements() != nbCurrentGridSource) 411 { 412 if ((0 != nbCurrentGridSource) && (0 != globalIndexOfOriginalGridSource_)) 413 { 414 delete globalIndexOfOriginalGridSource_; 415 globalIndexOfOriginalGridSource_ = new CArray<size_t,1>(nbCurrentGridSource); 416 } 417 } 418 357 419 int k = 0; 358 420 currentRecvBuff = recvBuff; … … 372 434 } 373 435 436 std::cout << "global index destination 0 after " << *globalIndexOfCurrentGridSource_ << std::endl; 437 std::cout << "global index destination 1 after " << *globalIndexOfOriginalGridSource_ << std::endl; 374 438 if (0 != sendBuffSize) delete [] sendBuff; 375 439 if (0 != recvBuffSize) delete [] recvBuff; … … 391 455 392 456 int nb = globalIndexOfCurrentGridSource_->numElements(); 457 const size_t sfmax = NumTraits<unsigned long>::sfmax(); 393 458 for (int idx = 0; idx < nb; ++idx) 394 459 { 395 globaIndexMapFromDestToSource[(*globalIndexOfCurrentGridSource_)(idx)].insert((*globalIndexOfOriginalGridSource_)(idx)); 460 if (sfmax != (*globalIndexOfOriginalGridSource_)(idx)) 461 globaIndexMapFromDestToSource[(*globalIndexOfCurrentGridSource_)(idx)].insert((*globalIndexOfOriginalGridSource_)(idx)); 396 462 } 397 463 … … 403 469 404 470 CDistributionClient distributionClientDest(client->clientRank, gridDestination_); 405 CDistributionClient distributionClientSrc(client->clientRank, gridSource_); 406 407 CArray<int, 1> localIndexOnClientDest = distributionClientDest.getLocalDataIndexOnClient(); //gridDestination_->getDistributionClient()->getLocalDataIndexOnClient(); 408 CArray<size_t,1> globalIndexOnClientDest = distributionClientDest.getGlobalDataIndexSendToServer(); //gridDestination_->getDistributionClient()->getGlobalDataIndexSendToServer(); 471 CDistributionClient distributionClientSrc(client->clientRank, originalGridSource_); 472 473 // const CArray<int, 1>& localIndexOnClientDest = distributionClientDest.getLocalDataIndexOnClient(); //gridDestination_->getDistributionClient()->getLocalDataIndexOnClient(); 474 const CArray<int, 1>& localIndexOnClientDest = distributionClientDest.getLocalDataIndexSendToServer(); 475 const CArray<size_t,1>& globalIndexOnClientDest = distributionClientDest.getGlobalDataIndexSendToServer(); //gridDestination_->getDistributionClient()->getGlobalDataIndexSendToServer(); 409 476 410 477 std::cout << "dest: local index " << localIndexOnClientDest << std::endl; 411 478 std::cout << "dest: global index " << globalIndexOnClientDest << std::endl; 412 CArray<int, 1>localIndexOnClientSrc = distributionClientSrc.getLocalDataIndexOnClient(); //gridSource_->getDistributionClient()->getLocalDataIndexOnClient();413 CArray<size_t,1>globalIndexOnClientSrc = distributionClientSrc.getGlobalDataIndexSendToServer(); //gridSource_->getDistributionClient()->getGlobalDataIndexSendToServer();479 const CArray<int, 1>& localIndexOnClientSrc = distributionClientSrc.getLocalDataIndexOnClient(); //gridSource_->getDistributionClient()->getLocalDataIndexOnClient(); 480 const CArray<size_t,1>& globalIndexOnClientSrc = distributionClientSrc.getGlobalDataIndexSendToServer(); //gridSource_->getDistributionClient()->getGlobalDataIndexSendToServer(); 414 481 std::cout << "src: local index " << localIndexOnClientSrc << std::endl; 415 482 std::cout << "src: global index " << globalIndexOnClientSrc << std::endl; 416 483 std::vector<size_t>::const_iterator itbVec, itVec, iteVec; 417 CArray<size_t, 1>:: iterator itbArr, itArr, iteArr;484 CArray<size_t, 1>::const_iterator itbArr, itArr, iteArr; 418 485 419 486 std::map<int,std::vector<std::vector<size_t> > >::const_iterator itbMapRecv, itMapRecv, iteMapRecv; … … 439 506 { 440 507 int localIdx = std::distance(itbArr, itArr); 441 //(*localIndexToReceiveOnGridDest_[sourceRank][i])(idx) = localIndexOnClientDest(localIdx); // Local index of un-extracted data (only domain)442 (*localIndexToReceiveOnGridDest_[sourceRank][i])(idx) = (localIdx); // Local index of extracted data508 (*localIndexToReceiveOnGridDest_[sourceRank][i])(idx) = localIndexOnClientDest(localIdx); // Local index of un-extracted data (only domain) 509 // (*localIndexToReceiveOnGridDest_[sourceRank][i])(idx) = (localIdx); // Local index of extracted data 443 510 } 444 511 } 445 512 } 513 // std::cout << "local index to receive from source Rank = " << sourceRank << (*localIndexToReceiveOnGridDest_[sourceRank][i]) << std::endl; 446 514 } 447 515 … … 468 536 } 469 537 } 538 std::cout << "local index to send to dest Rank = " << destRank << (*localIndexToSendFromGridSource_[destRank]) << std::endl; 470 539 } 471 540 } -
XIOS/trunk/src/filter/grid_transformation.hpp
r622 r623 1 /*! 2 \file grid_transformation.hpp 3 \author Ha NGUYEN 4 \since 14 May 2015 5 \date 09 June 2015 6 7 \brief Interface for all transformations. 8 */ 1 9 #ifndef __XIOS_GRID_TRANSFORMATION_HPP__ 2 10 #define __XIOS_GRID_TRANSFORMATION_HPP__ … … 12 20 class CGrid; 13 21 22 /*! 23 \class CGridTransformation 24 This class is an interface for all transformations to interact with the rest of XIOS. 25 The class, firstly, tries to get all information relating to requested transformations by retrieving directly from grid. 26 Then with all these information, all necessary transformations will be be created by generic class \class CGenericAlgorithmTransformation. 27 Because there are information exchange among clients to accomplish the transformations (e.g: some index need retrieving from other clients), 28 this class uses class \class CTransformationMapping to fulfill this demand. 29 For each transformation, a new temporary grid source is created. 30 For a consequential transformations (e.g: inversing -> zoom -> inversing -> ...), 31 the grid destination of current transformation will be grid source of the next transformation 32 */ 14 33 class CGridTransformation 15 34 { … … 38 57 void computeFinalTransformationMapping(); 39 58 void computeTransformationFromOriginalGridSource(const std::map<size_t, std::set<size_t> >& globaIndexMapFromDestToSource); 59 void updateFinalGridDestination(); 40 60 41 61 private: 62 //! Grid source on transformation 42 63 CGrid* gridSource_; 64 65 //! Grid destination on transformation 43 66 CGrid* gridDestination_; 67 68 //! The grid source of the first transformation (original grid source) 44 69 CGrid* originalGridSource_; 45 70 71 //! Grid source dimension size 46 72 std::vector<int> gridSourceDimensionSize_; 73 74 //! Grid destination dimension size 47 75 std::vector<int> gridDestinationDimensionSize_; 48 76 49 77 private: 50 78 typedef std::list<std::pair<int,std::pair<ETranformationType,int> > > ListAlgoType; 79 //! List of algorithm types and their order 80 ListAlgoType listAlgos_; 51 81 52 82 // Mapping between position of an element in grid and its transformation (if any) 53 83 std::list<CGenericAlgorithmTransformation*> algoTransformation_; 54 ListAlgoType listAlgos_; 84 85 //! Mapping of (grid) global index representing tranformation. 55 86 std::map<size_t, std::set<size_t> > globaIndexMapFromDestToSource_; 56 87 88 //! Local index of data to send from grid source 57 89 std::map<int, CArray<int,1>* > localIndexToSendFromGridSource_; 90 91 //! Local index of data to receive on grid destination 58 92 std::map<int, std::vector<CArray<int,1>* > > localIndexToReceiveOnGridDest_; 59 93 94 //! Position of axis and domain in grid 60 95 std::map<int, int> elementPosition2AxisPositionInGrid_, elementPosition2DomainPositionInGrid_; 61 96 97 //! (Grid) Global index of grid source 62 98 CArray<size_t,1>* globalIndexOfCurrentGridSource_; 63 99 CArray<size_t,1>* globalIndexOfOriginalGridSource_; -
XIOS/trunk/src/filter/transformation_mapping.cpp
r622 r623 1 /*! 2 \file transformation_mapping.cpp 3 \author Ha NGUYEN 4 \since 14 May 2015 5 \date 09 June 2015 6 7 \brief Take charge of communication among clients to exchange transformed data. 8 */ 9 1 10 #include "transformation_mapping.hpp" 2 11 #include <boost/unordered_map.hpp> … … 14 23 int clientRank = client->clientRank; 15 24 16 CDistributionClient distributionClient Dest(client->clientRank, gridSource_);25 CDistributionClient distributionClientSrc(client->clientRank, gridSource_); 17 26 18 const CArray<size_t,1>& globalIndexGridSrc = distributionClient Dest.getGlobalDataIndexSendToServer(); //gridSource_->getDistributionClient()->getGlobalDataIndexSendToServer();27 const CArray<size_t,1>& globalIndexGridSrc = distributionClientSrc.getGlobalDataIndexSendToServer(); //gridSource_->getDistributionClient()->getGlobalDataIndexSendToServer(); 19 28 boost::unordered_map<size_t,int> globalIndexOfServer; 20 29 int globalIndexSize = globalIndexGridSrc.numElements(); … … 24 33 } 25 34 35 std::cout << "global index grid src " << globalIndexGridSrc << std::endl; 26 36 gridIndexClientClientMapping_ = new CClientServerMappingDistributed(globalIndexOfServer, 27 37 client->intraComm, … … 151 161 } 152 162 163 /*! 164 Return (grid) global index on grid destination. This mapping contains the rank of client source (that sends info to grid destination) 165 and the corresponding global index to write on grid destination. 166 \return global index mapping to receive on grid destination 167 */ 153 168 const std::map<int,std::vector<std::vector<size_t> > >& CTransformationMapping::getGlobalIndexReceivedOnGridDestMapping() const 154 169 { … … 156 171 } 157 172 173 /*! 174 Return (grid) global index on grid source. This mapping contains the rank of client destination (which receives transformation info) and 175 the corresponding global index to send 176 \return global index mapping to send on grid source 177 */ 158 178 const std::map<int,std::vector<size_t> >& CTransformationMapping::getGlobalIndexSendToGridDestMapping() const 159 179 { -
XIOS/trunk/src/filter/transformation_mapping.hpp
r620 r623 1 /*! 2 \file transformation_mapping.hpp 3 \author Ha NGUYEN 4 \since 14 May 2015 5 \date 09 June 2015 6 7 \brief Take charge of communication among clients to exchange transformed data. 8 */ 1 9 #ifndef __XIOS_TRANSFORMATION_MAPPING_HPP__ 2 10 #define __XIOS_TRANSFORMATION_MAPPING_HPP__
Note: See TracChangeset
for help on using the changeset viewer.