source: XIOS/trunk/src/transformation/Functions/reduction.hpp @ 1076

Last change on this file since 1076 was 1076, checked in by mhnguyen, 7 years ago

Correcting behavior of detecting_missing_value:

  • Missing value detection is activated only when detecting_missing_value = true

and a default_value is defined.

  • By default, undefined value by the computation of vertical (horizontal) interpolation will be NaN (not a number).

They are only converted to default_value if missing value detection is activated

Test

  • On Curie
  • Work
File size: 2.2 KB
Line 
1/*!
2   \file reduction.hpp
3   \author Ha NGUYEN
4   \since 27 June 2016
5   \date 27 June 2016
6
7   \brief Parent class for all reduction
8 */
9#ifndef __XIOS_REDUCTION_ALGORITHM_HPP__
10#define __XIOS_REDUCTION_ALGORITHM_HPP__
11
12#include <vector>
13#include "array_new.hpp"
14#include "reduction_types.hpp"
15
16namespace xios {
17
18/*!
19  \class CReductionAlgorithm
20  Interface for all reduction alogrithms.
21*/
22class CReductionAlgorithm
23{
24public:
25  static std::map<StdString,EReductionType> ReductionOperations;
26
27public:
28  CReductionAlgorithm() {}
29
30  /*!
31    Create an operation (sum, max, min) based on type
32    \param [in] reduceType type to create
33    return pointer to base class
34  */
35  static CReductionAlgorithm* createOperation(EReductionType reduceType);
36
37  /*!
38    Apply a reduction operation on local data.
39    \param [in] localIndex vector contains local index of local data output and the corresponding weight
40    \param [in] dataInput Pointer to the first element of data input array (in form of buffer)
41    \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 initialization
43  */
44  virtual void apply(const std::vector<std::pair<int,double> >& localIndex,
45                     const double* dataInput,
46                     CArray<double,1>& dataOut,
47                     std::vector<bool>& flagInitial,                     
48                     bool ignoreMissingValue) = 0;
49  /*!
50    Update local data
51    In some case (e.g average) we need global information (e.g weights) then update data with this information
52    \param [in] dataOut local data output
53  */
54  virtual void updateData(CArray<double,1>& dataOut) {}
55
56  virtual ~CReductionAlgorithm() {}
57
58protected:
59  typedef CReductionAlgorithm* (*CreateOperationCallBack)();
60  typedef std::map<EReductionType, CreateOperationCallBack> CallBackMap;
61  static CallBackMap* reductionCreationCallBacks_;
62
63  static bool registerOperation(EReductionType reduceType, CreateOperationCallBack createFn);
64  static bool unregisterOperation(EReductionType reduceType);
65
66protected:
67  static bool initReductionOperation(std::map<StdString,EReductionType>& m);
68  static bool _dummyInit;
69};
70
71}
72#endif // __XIOS_REDUCTION_ALGORITHM_HPP__
Note: See TracBrowser for help on using the repository browser.