Changeset 979


Ignore:
Timestamp:
10/24/16 16:16:31 (5 years ago)
Author:
mhnguyen
Message:

Implementing AVERAGE operation

+) Add average operation for reduction transformation

Test
+) On Curie
+) Correct

Location:
XIOS/trunk/src
Files:
2 added
13 edited
6 moved

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/filter/spatial_transform_filter.cpp

    r918 r979  
    206206      } 
    207207 
     208      (*itAlgo)->updateData(dataCurrentDest); 
     209 
    208210      idxSendBuff = 0; 
    209211      for (itSend = itbSend; itSend != iteSend; ++itSend, ++idxSendBuff) 
  • XIOS/trunk/src/transformation/Functions/max_reduction.cpp

    r978 r979  
    77   \brief max reduction 
    88 */ 
    9 #include "max.hpp" 
     9#include "max_reduction.hpp" 
    1010 
    1111namespace xios { 
  • XIOS/trunk/src/transformation/Functions/min_reduction.cpp

    r978 r979  
    77   \brief min reduction 
    88 */ 
    9 #include "min.hpp" 
     9#include "min_reduction.hpp" 
    1010 
    1111namespace xios { 
  • XIOS/trunk/src/transformation/Functions/reduction.cpp

    r904 r979  
    11#include "reduction.hpp" 
    2 #include "sum.hpp" 
    3 #include "min.hpp" 
    4 #include "max.hpp" 
     2#include "sum_reduction.hpp" 
     3#include "min_reduction.hpp" 
     4#include "max_reduction.hpp" 
    55#include "extract.hpp" 
     6#include "average_reduction.hpp" 
    67 
    78namespace xios { 
     
    2324  m["extract"] = TRANS_REDUCE_EXTRACT; 
    2425  CExtractReductionAlgorithm::registerTrans(); 
     26 
     27  m["average"] = TRANS_REDUCE_AVERAGE; 
     28  CAverageReductionAlgorithm::registerTrans(); 
    2529} 
    2630 
  • XIOS/trunk/src/transformation/Functions/reduction.hpp

    r888 r979  
    4040    \param [in] dataInput Pointer to the first element of data input array (in form of buffer) 
    4141    \param [in/out] dataOut Array contains local data 
    42     \param [in/out] flagInitial vector of boolean to mark the local index already initialized. True means there is a need for initalization 
     42    \param [in/out] flagInitial vector of boolean to mark the local index already initialized. True means there is a need for initialization 
    4343  */ 
    4444  virtual void apply(const std::vector<std::pair<int,double> >& localIndex, 
     
    4646                     CArray<double,1>& dataOut, 
    4747                     std::vector<bool>& flagInitial) = 0; 
     48  /*! 
     49    Update local data  
     50    In some case (e.g average) we need global information (e.g weights) then update data with this information 
     51    \param [in] dataOut local data output 
     52  */ 
     53  virtual void updateData(CArray<double,1>& dataOut) {} 
    4854 
    4955  virtual ~CReductionAlgorithm() {} 
  • XIOS/trunk/src/transformation/Functions/reduction_types.hpp

    r895 r979  
    1717    TRANS_REDUCE_MIN = 1, 
    1818    TRANS_REDUCE_MAX = 2, 
    19     TRANS_REDUCE_EXTRACT = 3 
     19    TRANS_REDUCE_EXTRACT = 3, 
     20    TRANS_REDUCE_AVERAGE = 4 
    2021  } EReductionType; 
    2122 
  • XIOS/trunk/src/transformation/Functions/sum_reduction.cpp

    r978 r979  
    77   \brief sum reduction 
    88 */ 
    9 #include "sum.hpp" 
     9#include "sum_reduction.hpp" 
    1010 
    1111namespace xios { 
  • XIOS/trunk/src/transformation/axis_algorithm_extract_domain.cpp

    • Property svn:executable set to *
    r977 r979  
    1313#include "grid.hpp" 
    1414#include "grid_transformation_factory_impl.hpp" 
    15  
    1615#include "reduction.hpp" 
    1716 
  • XIOS/trunk/src/transformation/axis_algorithm_reduce_domain.cpp

    • Property svn:executable set to *
    r977 r979  
    1313#include "grid.hpp" 
    1414#include "grid_transformation_factory_impl.hpp" 
    15  
    1615#include "reduction.hpp" 
    1716 
     
    5958{ 
    6059  reduction_->apply(localIndex, dataInput, dataOut, flagInitial); 
     60} 
     61 
     62void CAxisAlgorithmReduceDomain::updateData(CArray<double,1>& dataOut) 
     63{ 
     64  reduction_->updateData(dataOut); 
    6165} 
    6266 
  • XIOS/trunk/src/transformation/axis_algorithm_reduce_domain.hpp

    r933 r979  
    3535                     const double& defaultValue); 
    3636 
     37  virtual void updateData(CArray<double,1>& dataOut); 
     38   
    3739  virtual ~CAxisAlgorithmReduceDomain(); 
    3840 
     
    4749  ReduceDirection dir_; 
    4850protected: 
    49   void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs); 
    50  
     51  void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs);  
     52   
    5153protected: 
    5254  CReductionAlgorithm* reduction_; 
  • XIOS/trunk/src/transformation/generic_algorithm_transformation.cpp

    r977 r979  
    1818   idAuxInputs_(), type_(ELEMENT_NO_MODIFICATION_WITH_DATA) 
    1919{ 
     20} 
     21 
     22void CGenericAlgorithmTransformation::updateData(CArray<double,1>& dataOut) 
     23{ 
     24 
    2025} 
    2126 
  • XIOS/trunk/src/transformation/generic_algorithm_transformation.hpp

    r933 r979  
    7070                     const double& defaultValue); 
    7171 
     72  /*! 
     73   * Update whole dataOut (on necessary). 
     74   * (Example:  Impose a weight, whose value is only known after being applied an operation, on dataOut) 
     75   * \param [in/out] dataOut dataOut 
     76   */ 
     77  virtual void updateData(CArray<double,1>& dataOut); 
     78 
    7279  std::vector<StdString> getIdAuxInputs(); 
    7380  AlgoTransType type(); 
     
    129136  AlgoTransType type_; 
    130137 
    131  
    132138  std::map<int, int> elementPositionInGridSrc2AxisPosition_, elementPositionInGridSrc2DomainPosition_, elementPositionInGridSrc2ScalarPosition_; 
    133139  std::map<int, int> elementPositionInGridDst2AxisPosition_, elementPositionInGridDst2DomainPosition_, elementPositionInGridDst2ScalarPosition_; 
  • XIOS/trunk/src/transformation/scalar_algorithm_reduce_axis.cpp

    r977 r979  
    1313#include "grid.hpp" 
    1414#include "grid_transformation_factory_impl.hpp" 
     15#include "reduction.hpp" 
    1516 
    1617#include "reduction.hpp" 
     
    7071} 
    7172 
     73void CScalarAlgorithmReduceScalar::updateData(CArray<double,1>& dataOut) 
     74{ 
     75  reduction_->updateData(dataOut); 
     76} 
     77 
    7278CScalarAlgorithmReduceScalar::~CScalarAlgorithmReduceScalar() 
    7379{ 
  • XIOS/trunk/src/transformation/scalar_algorithm_reduce_axis.hpp

    r933 r979  
    3535                     const double& defaultValue); 
    3636 
     37  virtual void updateData(CArray<double,1>& dataOut); 
     38   
    3739  virtual ~CScalarAlgorithmReduceScalar(); 
    3840 
  • XIOS/trunk/src/transformation/scalar_algorithm_reduce_domain.cpp

    r976 r979  
    8787} 
    8888 
     89void CScalarAlgorithmReduceDomain::updateData(CArray<double,1>& dataOut) 
     90{ 
     91  reduction_->updateData(dataOut); 
     92} 
     93 
    8994CScalarAlgorithmReduceDomain::~CScalarAlgorithmReduceDomain() 
    9095{ 
  • XIOS/trunk/src/transformation/scalar_algorithm_reduce_domain.hpp

    r976 r979  
    3535                     const double& defaultValue); 
    3636 
     37  virtual void updateData(CArray<double,1>& dataOut); 
     38   
    3739  virtual ~CScalarAlgorithmReduceDomain(); 
    3840 
Note: See TracChangeset for help on using the changeset viewer.