Ignore:
Timestamp:
06/22/15 13:36:37 (9 years ago)
Author:
mhnguyen
Message:

Final tests of zoom and inverse on axis

+) Modify test_client and test_complete to work with new grid definition
+) Correct some bugs causing memory leak
+) Clean abundant code
+) Add more comments to new files

Test
+) On Curie
+) test_client and test_complete pass with correct results

Location:
XIOS/trunk/src/transformation
Files:
1 added
1 moved

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/transformation/grid_transformation.cpp

    r623 r624  
    33   \author Ha NGUYEN 
    44   \since 14 May 2015 
    5    \date 09 June 2015 
     5   \date 18 June 2015 
    66 
    77   \brief Interface for all transformations. 
     
    6262} 
    6363 
     64/*! 
     65  Initialize the mapping between the first grid source and the original one 
     66  In a series of transformation, for each step, there is a need to "create" a new grid that plays a role of "temporary" source. 
     67Because at the end of the series, we need to know about the index mapping between the final grid destination and original grid source, 
     68for each transformation, we need to make sure that the current "temporary source" maps its global index correctly to the original one. 
     69*/ 
    6470void CGridTransformation::initializeMappingOfOriginalGridSource() 
    6571{ 
     
    100106} 
    101107 
     108/*! 
     109  Initialize the algorithms (transformations) 
     110*/ 
    102111void CGridTransformation::initializeAlgorithms() 
    103112{ 
     
    154163} 
    155164 
     165/*! 
     166  Select algorithm correspoding to its transformation type and its position in each element 
     167  \param [in] elementPositionInGrid position of element in grid. e.g: a grid has 1 domain and 1 axis, then position of domain is 1 (because it contains 2 basic elements) 
     168                                             and position of axis is 2 
     169  \param [in] transType transformation type, for now we have Zoom_axis, inverse_axis 
     170  \param [in] transformationOrder position of the transformation in an element (an element can have several transformation) 
     171*/ 
    156172void CGridTransformation::selectAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder) 
    157173{ 
     
    159175} 
    160176 
     177/*! 
     178  Select algorithm of an axis correspoding to its transformation type and its position in each element 
     179  \param [in] elementPositionInGrid position of element in grid. e.g: a grid has 1 domain and 1 axis, then position of domain is 1 (because it contains 2 basic elements) 
     180                                             and position of axis is 2 
     181  \param [in] transType transformation type, for now we have Zoom_axis, inverse_axis 
     182  \param [in] transformationOrder position of the transformation in an element (an element can have several transformation) 
     183*/ 
    161184void CGridTransformation::selectAxisAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder) 
    162185{ 
     
    188211} 
    189212 
     213/*! 
     214  Select algorithm of a domain correspoding to its transformation type and its position in each element 
     215  \param [in] elementPositionInGrid position of element in grid. e.g: a grid has 1 domain and 1 axis, then position of domain is 1 (because it contains 2 basic elements) 
     216                                             and position of axis is 2 
     217  \param [in] transType transformation type, for now we have Zoom_axis, inverse_axis 
     218  \param [in] transformationOrder position of the transformation in an element (an element can have several transformation) 
     219*/ 
    190220void CGridTransformation::selectDomainAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder) 
    191221{ 
    192  
    193 } 
    194  
     222} 
     223 
     224/*! 
     225  Assign the current grid destination to the grid source in the new transformation. 
     226The current grid destination plays the role of grid source in next transformation (if any). 
     227Only element on which the transformation is performed is modified 
     228  \param [in] elementPositionInGrid position of element in grid 
     229  \param [in] transType transformation type 
     230*/ 
    195231void CGridTransformation::setUpGrid(int elementPositionInGrid, ETranformationType transType) 
    196232{ 
     
    211247} 
    212248 
     249/*! 
     250  Perform all transformations 
     251  For each transformation, there are some things to do: 
     252  -) Chose the correct algorithm by transformation type and position of element 
     253  -) Calculate the mapping of global index between the current grid source and grid destination 
     254  -) Calculate the mapping of global index between current grid DESTINATION and ORIGINAL grid SOURCE 
     255  -) Make current grid destination become grid source in the next transformation 
     256*/ 
    213257void CGridTransformation::computeAll() 
    214258{ 
     
    234278    const CArray<size_t,1>& globalIndexGridDestSendToServer = distributionClientDest.getGlobalDataIndexSendToServer(); 
    235279 
    236    std::cout << "global index grid  dest send to server " << globalIndexGridDestSendToServer << std::endl; 
    237280    // ComputeTransformation of global index of each element 
    238281    std::vector<int> gridDestinationDimensionSize = gridDestination_->getGlobalDimension(); 
     
    250293  } 
    251294 
    252  std::cout << "global index destination 0 final " << *globalIndexOfCurrentGridSource_ << std::endl; 
    253  std::cout << "global index destination 1 final " << *globalIndexOfOriginalGridSource_ << std::endl; 
    254295  updateFinalGridDestination(); 
    255296  computeFinalTransformationMapping(); 
     
    269310  CDistributionClient distributionClientDest(client->clientRank, gridDestination_); 
    270311  const CArray<int, 1>& localMaskIndexOnClientDest = distributionClientDest.getLocalMaskIndexOnClient(); 
    271   std::cout << "local mask " << localMaskIndexOnClientDest << std::endl; 
    272  
    273312  const CArray<size_t,1>& globalIndexOnClientDest = distributionClientDest.getGlobalDataIndexSendToServer(); 
    274   std::cout << "global index " << globalIndexOnClientDest <<  std::endl; 
     313 
    275314  CArray<size_t, 1>::const_iterator itbArr, itArr, iteArr; 
    276315  itbArr = globalIndexOnClientDest.begin(); 
     
    308347  } 
    309348 
    310   std::cout << "index to modify " << *maskIndexToModify << std::endl; 
    311349  gridDestination_->modifyMask(*maskIndexToModify); 
    312350 
     
    339377 int sendBuffSize = 0; 
    340378 for (itSend = itbSend; itSend != iteSend; ++itSend) sendBuffSize += (itSend->second).size(); 
    341  
    342  std::cout << "global index destination 0 before" << *globalIndexOfCurrentGridSource_ << std::endl; 
    343  std::cout << "global index destination 1 before" << *globalIndexOfOriginalGridSource_ << std::endl; 
    344379 
    345380 typedef unsigned long Scalar; 
     
    401436 if (globalIndexOfCurrentGridSource_->numElements()  != nbCurrentGridSource) 
    402437 { 
    403    if ((0 != nbCurrentGridSource) && (0 != globalIndexOfCurrentGridSource_)) 
    404    { 
    405      delete globalIndexOfCurrentGridSource_; 
    406      globalIndexOfCurrentGridSource_ = new CArray<size_t,1>(nbCurrentGridSource); 
    407    } 
     438   delete globalIndexOfCurrentGridSource_; 
     439   globalIndexOfCurrentGridSource_ = new CArray<size_t,1>(nbCurrentGridSource); 
    408440 } 
    409441 
    410442 if (globalIndexOfOriginalGridSource_->numElements() != nbCurrentGridSource) 
    411443 { 
    412    if ((0 != nbCurrentGridSource) && (0 != globalIndexOfOriginalGridSource_)) 
    413    { 
    414      delete globalIndexOfOriginalGridSource_; 
    415      globalIndexOfOriginalGridSource_ = new CArray<size_t,1>(nbCurrentGridSource); 
    416    } 
     444   delete globalIndexOfOriginalGridSource_; 
     445   globalIndexOfOriginalGridSource_ = new CArray<size_t,1>(nbCurrentGridSource); 
    417446 } 
    418447 
     
    434463 } 
    435464 
    436  std::cout << "global index destination 0 after " << *globalIndexOfCurrentGridSource_ << std::endl; 
    437  std::cout << "global index destination 1 after " << *globalIndexOfOriginalGridSource_ << std::endl; 
    438465 if (0 != sendBuffSize) delete [] sendBuff; 
    439466 if (0 != recvBuffSize) delete [] recvBuff; 
     
    475502  const CArray<size_t,1>& globalIndexOnClientDest = distributionClientDest.getGlobalDataIndexSendToServer(); //gridDestination_->getDistributionClient()->getGlobalDataIndexSendToServer(); 
    476503 
    477  std::cout << "dest: local index " << localIndexOnClientDest << std::endl; 
    478  std::cout << "dest: global index " << globalIndexOnClientDest << std::endl; 
    479504  const CArray<int, 1>& localIndexOnClientSrc = distributionClientSrc.getLocalDataIndexOnClient(); //gridSource_->getDistributionClient()->getLocalDataIndexOnClient(); 
    480505  const CArray<size_t,1>& globalIndexOnClientSrc = distributionClientSrc.getGlobalDataIndexSendToServer(); //gridSource_->getDistributionClient()->getGlobalDataIndexSendToServer(); 
    481  std::cout << "src: local index " << localIndexOnClientSrc << std::endl; 
    482  std::cout << "src: global index " << globalIndexOnClientSrc << std::endl; 
     506 
    483507  std::vector<size_t>::const_iterator itbVec, itVec, iteVec; 
    484508  CArray<size_t, 1>::const_iterator itbArr, itArr, iteArr; 
     
    506530        { 
    507531          int localIdx = std::distance(itbArr, itArr); 
    508           (*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 
     532//          (*localIndexToReceiveOnGridDest_[sourceRank][i])(idx) = localIndexOnClientDest(localIdx); // Local index of un-extracted data (only domain) 
     533          (*localIndexToReceiveOnGridDest_[sourceRank][i])(idx) = (localIdx); // Local index of extracted data 
    510534        } 
    511535      } 
    512536    } 
    513 //    std::cout << "local index to receive from source Rank = " << sourceRank << (*localIndexToReceiveOnGridDest_[sourceRank][i]) << std::endl; 
    514537  } 
    515538 
     
    536559      } 
    537560    } 
    538     std::cout << "local index to send to dest Rank = " << destRank << (*localIndexToSendFromGridSource_[destRank]) << std::endl; 
    539561  } 
    540562} 
     
    544566  \return local index of data 
    545567*/ 
    546 std::map<int, CArray<int,1>* > CGridTransformation::getLocalIndexToSendFromGridSource() 
     568const std::map<int, CArray<int,1>* >& CGridTransformation::getLocalIndexToSendFromGridSource() const 
    547569{ 
    548570  return localIndexToSendFromGridSource_; 
     
    553575  \return local index of data 
    554576*/ 
    555 std::map<int, std::vector<CArray<int,1>* > > CGridTransformation::getLocalIndexToReceiveOnGridDest() 
     577const std::map<int, std::vector<CArray<int,1>* > >& CGridTransformation::getLocalIndexToReceiveOnGridDest() const 
    556578{ 
    557579  return localIndexToReceiveOnGridDest_; 
Note: See TracChangeset for help on using the changeset viewer.