source: XIOS/dev/XIOS_DEV_CMIP6/src/transformation/domain_algorithm_interpolate.hpp @ 1264

Last change on this file since 1264 was 1264, checked in by ymipsl, 7 years ago
  • Add new attribute : detect_missing_value on "interpolate_domain" element. It will replace the standard detect_missing_value set on the field. It will be added progressively to all spatial transformation.
  • Now, when detecting missing value, horizontal interpolation do a correct renormalization.

YM

File size: 4.0 KB
Line 
1/*!
2   \file domain_algorithm_interpolate_from_file.hpp
3   \author Ha NGUYEN
4   \since 09 July 2015
5   \date 09 Sep 2015
6
7   \brief Algorithm for interpolation on a domain.
8 */
9#ifndef __XIOS_DOMAIN_ALGORITHM_INTERPOLATE_HPP__
10#define __XIOS_DOMAIN_ALGORITHM_INTERPOLATE_HPP__
11
12#include "domain_algorithm_transformation.hpp"
13#include "transformation.hpp"
14#include "nc4_data_output.hpp"
15
16namespace xios {
17
18class CDomain;
19class CInterpolateDomain;
20
21
22/*!
23  \class CDomainAlgorithmInterpolate
24  Reading interpolation from file then apply on a domain
25*/
26class CDomainAlgorithmInterpolate : public CDomainAlgorithmTransformation
27{
28public:
29  CDomainAlgorithmInterpolate(CDomain* domainDestination, CDomain* domainSource, CInterpolateDomain* interpDomain);
30
31  virtual ~CDomainAlgorithmInterpolate() {}
32
33  virtual void apply(const std::vector<std::pair<int,double> >& localIndex,
34                     const double* dataInput,
35                     CArray<double,1>& dataOut,
36                     std::vector<bool>& flagInitial,                     
37                     bool ignoreMissingValue, bool firstPass);
38  virtual void updateData(CArray<double,1>& dataOut);
39
40  static bool registerTrans();
41protected:
42  void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs);
43
44private:
45  void readInterpolationInfo(std::string& filename, std::map<int,std::vector<std::pair<int,double> > >& interpMapValue);
46  void writeInterpolationInfo(std::string& filename, std::map<int,std::vector<std::pair<int,double> > >& interpMapValue);
47  void processPole(std::map<int,std::vector<std::pair<int,double> > >& interMapValuePole,
48                   int nbGlobalPointOnPole);
49  void computeRemap();
50  void readRemapInfo();
51  void writeRemapInfo(std::map<int,std::vector<std::pair<int,double> > >&);
52  void exchangeRemapInfo(std::map<int,std::vector<std::pair<int,double> > >& interpMapValue);
53  void convertRemapInfo(std::map<int,std::vector<std::pair<int,double> > >& interpMapValue);
54
55private:
56  CArray<double,1> renormalizationFactor ;
57  bool detectMissingValue ;
58  bool renormalize ;
59  bool quantity ;
60 
61  CInterpolateDomain* interpDomain_;
62  bool writeToFile_;
63  bool readFromFile_;
64  StdString fileToReadWrite_;
65
66  // class WriteNetCdf;
67  class WriteNetCdf : public CNc4DataOutput
68  {
69  public:
70    WriteNetCdf(const StdString& filename, const MPI_Comm comm);
71    int addDimensionWrite(const StdString& name, const StdSize size = UNLIMITED_DIM);
72    int addVariableWrite(const StdString& name, nc_type type,
73                         const std::vector<StdString>& dim);
74    void endDefinition();
75    void writeDataIndex(const CArray<int,1>& data, const StdString& name,
76                        bool collective, StdSize record,
77                        const std::vector<StdSize>* start = NULL,
78                        const std::vector<StdSize>* count = NULL);
79    void writeDataIndex(const CArray<double,1>& data, const StdString& name,
80                        bool collective, StdSize record,
81                        const std::vector<StdSize>* start = NULL,
82                        const std::vector<StdSize>* count = NULL);
83  };
84
85
86private:
87
88  static CGenericAlgorithmTransformation* create(CGrid* gridDst, CGrid* gridSrc,
89                                                CTransformation<CDomain>* transformation,
90                                                int elementPositionInGrid,
91                                                std::map<int, int>& elementPositionInGridSrc2ScalarPosition,
92                                                std::map<int, int>& elementPositionInGridSrc2AxisPosition,
93                                                std::map<int, int>& elementPositionInGridSrc2DomainPosition,
94                                                std::map<int, int>& elementPositionInGridDst2ScalarPosition,
95                                                std::map<int, int>& elementPositionInGridDst2AxisPosition,
96                                                std::map<int, int>& elementPositionInGridDst2DomainPosition);
97};
98
99}
100#endif // __XIOS_DOMAIN_ALGORITHM_INTERPOLATE_HPP__
Note: See TracBrowser for help on using the repository browser.