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
12 moved

Legend:

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

    r623 r624  
     1/*! 
     2   \file axis_algorithm_inverse.hpp 
     3   \author Ha NGUYEN 
     4   \since 14 May 2015 
     5   \date 09 June 2015 
     6 
     7   \brief Algorithm for inversing an axis.. 
     8 */ 
    19#include "axis_algorithm_inverse.hpp" 
    210 
  • XIOS/trunk/src/transformation/axis_algorithm_inverse.hpp

    r623 r624  
     1/*! 
     2   \file axis_algorithm_inverse.hpp 
     3   \author Ha NGUYEN 
     4   \since 14 May 2015 
     5   \date 09 June 2015 
     6 
     7   \brief Algorithm for inversing an axis.. 
     8 */ 
    19#ifndef __XIOS_AXIS_ALGORITHM_INVERSE_HPP__ 
    210#define __XIOS_AXIS_ALGORITHM_INVERSE_HPP__ 
     
    614 
    715namespace xios { 
    8  
     16/*! 
     17  \class CAxisAlgorithmInverse 
     18  Inversing an axis 
     19*/ 
    920class CAxisAlgorithmInverse : public CAxisAlgorithmTransformation 
    1021{ 
  • XIOS/trunk/src/transformation/axis_algorithm_transformation.cpp

    r623 r624  
     1/*! 
     2   \file axis_algorithm_transformation.hpp 
     3   \author Ha NGUYEN 
     4   \since 14 May 2015 
     5   \date 09 June 2015 
     6 
     7   \brief Interface for all axis transformation algorithms. 
     8 */ 
     9 
    110#include "axis_algorithm_transformation.hpp" 
    2 #include "axis_inverse.hpp" 
    3 #include "axis_zoom.hpp" 
     11#include "axis_algorithm_inverse.hpp" 
     12#include "axis_algorithm_zoom.hpp" 
    413 
    514namespace xios { 
     
    817 : CGenericAlgorithmTransformation() 
    918{ 
    10 //  if (axisDestination->size.getValue() != axisSource->size.getValue()) 
    11 //  { 
    12 //    ERROR("CAxisZoom::CAxisZoom(CAxis* axisDestination, CAxis* axisSource)", 
    13 //           << "Two axis have different size" 
    14 //           << "Size of axis source " <<axisSource->getId() << " is " << axisSource->size.getValue()  << std::endl 
    15 //           << "Size of axis destionation " <<axisDestination->getId() << " is " << axisDestination->size.getValue()); 
    16 //  } 
    17 // 
    18 // 
    19 //  axisDestGlobalSize_ = axisDestination->size.getValue(); 
    20 //  int niDest = axisDestination->ni.getValue(); 
    21 //  int ibeginDest = axisDestination->ibegin.getValue(); 
    22 // 
    23 //  for (int idx = 0; idx < niDest; ++idx) axisDestGlobalIndex_.push_back(ibeginDest+idx); 
    2419} 
    2520 
    2621CAxisAlgorithmTransformation::~CAxisAlgorithmTransformation() 
    2722{ 
    28 //  for (int idx = 0; idx < algosOfAnAxis_.size(); ++idx) delete algosOfAnAxis_[idx]; 
    2923} 
    3024 
    3125void CAxisAlgorithmTransformation::computeIndexSourceMapping() 
    3226{ 
    33 //  if (!algosOfAnAxis_.empty()) 
    34 //  { 
    35 //    algosOfAnAxis_[0]->computeIndexSourceMapping(this->transformationMapping_); 
    36 //    for (int idx = 1; idx < algosOfAnAxis_.size(); ++idx) 
    37 //    { 
    38 //      algosOfAnAxis_[idx]->computeIndexSourceMapping(algosOfAnAxis_[idx-1]->getTransformationMapping()); 
    39 //    } 
    40 //    this->transformationMapping_ = algosOfAnAxis_[algosOfAnAxis_.size()-1]->getTransformationMapping(); 
    41 //  } 
    4227} 
    4328 
     
    162147  } 
    163148} 
    164  
    165  
    166149} 
  • XIOS/trunk/src/transformation/axis_algorithm_transformation.hpp

    r623 r624  
     1/*! 
     2   \file axis_algorithm_transformation.hpp 
     3   \author Ha NGUYEN 
     4   \since 14 May 2015 
     5   \date 09 June 2015 
     6 
     7   \brief Interface for all axis transformation algorithms. 
     8 */ 
    19#ifndef __XIOS_AXIS_ALGORITHM_TRANSFORMATION_HPP__ 
    210#define __XIOS_AXIS_ALGORITHM_TRANSFORMATION_HPP__ 
     
    412#include "generic_algorithm_transformation.hpp" 
    513#include "axis.hpp" 
    6 #include "concrete_algo.hpp" 
    714 
    815namespace xios { 
    916 
     17/*! 
     18  \class CAxisAlgorithmTransformation 
     19  Algorithms for axis. 
     20*/ 
    1021class CAxisAlgorithmTransformation : public virtual CGenericAlgorithmTransformation 
    1122{ 
     
    2435                                                        std::vector<CArray<size_t,1> >& globalIndexSrcGrid); 
    2536  void computeIndexSourceMapping(); 
     37 
    2638protected: 
     39  //! Global index of an axis on grid destination 
    2740  std::vector<int> axisDestGlobalIndex_; 
     41 
     42  //! Size of 
    2843  int axisDestGlobalSize_; 
    2944 
  • XIOS/trunk/src/transformation/axis_algorithm_zoom.cpp

    r623 r624  
     1/*! 
     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. 
     8 */ 
    19#include "axis_algorithm_zoom.hpp" 
    210 
     
    2230} 
    2331 
     32/*! 
     33  Compute the index mapping between axis on grid source and one on grid destination 
     34*/ 
    2435void CAxisAlgorithmZoom::computeIndexSourceMapping() 
    2536{ 
     
    4354} 
    4455 
     56/*! 
     57  After a zoom on axis, it should be certain that (global) zoom begin and (global) zoom size are updated 
     58*/ 
    4559void CAxisAlgorithmZoom::updateZoom() 
    4660{ 
     
    4963} 
    5064 
     65/*! 
     66  Update mask on axis 
     67  Because only zoomed region on axis is not masked, the remaining must be masked to make sure 
     68correct index be extracted 
     69*/ 
    5170void CAxisAlgorithmZoom::updateAxisDestinationMask() 
    5271{ 
  • XIOS/trunk/src/transformation/axis_algorithm_zoom.hpp

    r623 r624  
     1/*! 
     2   \file axis_algorithm_zoom.hpp 
     3   \author Ha NGUYEN 
     4   \since 03 June 2015 
     5   \date 12 June 2015 
     6 
     7   \brief Algorithm for zooming on an axis. 
     8 */ 
    19#ifndef __XIOS_AXIS_ALGORITHM_ZOOM_HPP__ 
    210#define __XIOS_AXIS_ALGORITHM_ZOOM_HPP__ 
     
    715 
    816namespace xios { 
    9  
     17/*! 
     18  \class CAxisAlgorithmZoom 
     19  Implementing zoom on axis 
     20  A zoomed region can be considered as region that isnt masked. 
     21  Only this zoomed region is extracted to write on Netcdf. 
     22*/ 
    1023class CAxisAlgorithmZoom : public CAxisAlgorithmTransformation 
    1124{ 
     
    2033  void updateAxisDestinationMask(); 
    2134  void updateZoom(); 
     35 
    2236private: 
     37  //! Global zoom begin on axis 
    2338  StdSize zoomBegin_; 
     39 
     40  //! Global zoom end on axis 
    2441  StdSize zoomEnd_; 
     42 
     43  //! Global zoom size on axis 
    2544  StdSize zoomSize_; 
    2645 
    2746private: 
     47  //! Axis on grid destination 
    2848  CAxis* axisDest_; 
     49 
     50  //! Axis on grid source 
    2951  CAxis* axisSrc_; 
    3052}; 
  • XIOS/trunk/src/transformation/generic_algorithm_transformation.cpp

    r623 r624  
     1/*! 
     2   \file generic_algorithm_transformation.hpp 
     3   \author Ha NGUYEN 
     4   \since 14 May 2015 
     5   \date 09 June 2015 
     6 
     7   \brief Interface for all transformation algorithms. 
     8 */ 
    19#include "generic_algorithm_transformation.hpp" 
    210 
     
    2634                                                   iteTransMap = transformationMapping_.end(); 
    2735  std::vector<int>::const_iterator itbVec, itVec, iteVec; 
    28   std::vector<CArray<size_t,1> > globalIndexSrcGrid((itTransMap->second).size()); 
     36  std::vector<CArray<size_t,1> > globalIndexSrcGrid; //((itTransMap->second).size()); 
    2937  CArray<size_t,1> globalIndexDestGrid; 
    30  
    3138  for (itTransMap = itbTransMap; itTransMap != iteTransMap; ++itTransMap) 
    3239  { 
     40 
    3341    this->computeGlobalIndexFromGlobalIndexElement(itTransMap->first, 
    3442                                                   itTransMap->second, 
  • XIOS/trunk/src/transformation/generic_algorithm_transformation.hpp

    r623 r624  
     1/*! 
     2   \file generic_algorithm_transformation.hpp 
     3   \author Ha NGUYEN 
     4   \since 14 May 2015 
     5   \date 09 June 2015 
     6 
     7   \brief Interface for all transformation algorithms. 
     8 */ 
    19#ifndef __XIOS_GENERIC_ALGORITHM_TRANSFORMATION_HPP__ 
    210#define __XIOS_GENERIC_ALGORITHM_TRANSFORMATION_HPP__ 
     
    715 
    816namespace xios { 
    9  
     17  /*! 
     18  \class CGenericAlgorithmTransformation 
     19  This class defines the interface for all other inherted algorithms class 
     20  */ 
    1021class CGenericAlgorithmTransformation 
    1122{ 
  • 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_; 
  • XIOS/trunk/src/transformation/grid_transformation.hpp

    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. 
     
    4040  void computeAll(); 
    4141 
    42  
    43   std::map<int, CArray<int,1>* > getLocalIndexToSendFromGridSource(); 
    44   std::map<int, std::vector<CArray<int,1>* > > getLocalIndexToReceiveOnGridDest(); 
     42  const std::map<int, CArray<int,1>* >& getLocalIndexToSendFromGridSource() const; 
     43  const std::map<int, std::vector<CArray<int,1>* > >& getLocalIndexToReceiveOnGridDest() const; 
    4544 
    4645private: 
  • XIOS/trunk/src/transformation/transformation_mapping.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 Take charge of communication among clients to exchange transformed data. 
     
    3333  } 
    3434 
    35   std::cout << "global index grid src " << globalIndexGridSrc << std::endl; 
    3635  gridIndexClientClientMapping_ = new CClientServerMappingDistributed(globalIndexOfServer, 
    3736                                                                      client->intraComm, 
  • XIOS/trunk/src/transformation/transformation_mapping.hpp

    r623 r624  
    4747  //! Mapping of client rank of grid destination and global index to send from grid source 
    4848  std::map<int,std::vector<size_t> > globalIndexSendToGridDestMapping_; 
    49  
    5049}; 
    5150 
Note: See TracChangeset for help on using the changeset viewer.