source: XIOS/dev/dev_trunk_graph/src/transformation/domain_algorithm/domain_algorithm_interpolate.hpp @ 2028

Last change on this file since 2028 was 2028, checked in by yushan, 3 years ago

Graph intermediate commit to a tmp branch.

  • Property svn:executable set to *
File size: 4.2 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 "algorithm_transformation_weight.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 CAlgorithmTransformationWeight
27{
28public:
29  CDomainAlgorithmInterpolate(bool isSource, 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();
41  virtual StdString getAlgoName() {return "\\ninterpolate_domain";}
42
43private:
44  void readInterpolationInfo(std::string& filename, std::map<int,std::vector<std::pair<int,double> > >& interpMapValue);
45  void writeInterpolationInfo(std::string& filename, std::map<int,std::vector<std::pair<int,double> > >& interpMapValue);
46  void processPole(std::map<int,std::vector<std::pair<int,double> > >& interMapValuePole,
47                   int nbGlobalPointOnPole);
48  void computeRemap();
49  void readRemapInfo();
50  void writeRemapInfo(std::map<int,std::vector<std::pair<int,double> > >&);
51  void exchangeRemapInfo(std::map<int,std::vector<std::pair<int,double> > >& interpMapValue);
52  void convertRemapInfo(std::map<int,std::vector<std::pair<int,double> > >& interpMapValue);
53
54private:
55  CArray<double,1> renormalizationFactor ;
56  CArray<bool,1> allMissing ;
57  bool detectMissingValue ;
58  bool renormalize ;
59  bool quantity ;
60 
61  CInterpolateDomain* interpDomain_;
62  bool writeToFile_;
63  bool readFromFile_;
64  StdString fileToReadWrite_;
65  bool fortranConvention ;
66
67  // class WriteNetCdf;
68  class WriteNetCdf : public CNc4DataOutput
69  {
70  public:
71    WriteNetCdf(const StdString& filename, const MPI_Comm comm);
72    int addDimensionWrite(const StdString& name, const StdSize size = UNLIMITED_DIM);
73    int addVariableWrite(const StdString& name, nc_type type,
74                         const std::vector<StdString>& dim);
75    void endDefinition();
76    void writeDataIndex(const CArray<int,1>& data, const StdString& name,
77                        bool collective, StdSize record,
78                        const std::vector<StdSize>* start = NULL,
79                        const std::vector<StdSize>* count = NULL);
80    void writeDataIndex(const CArray<double,1>& data, const StdString& name,
81                        bool collective, StdSize record,
82                        const std::vector<StdSize>* start = NULL,
83                        const std::vector<StdSize>* count = NULL);
84  };
85
86
87public:
88
89  static CGenericAlgorithmTransformation* create(bool isSource, CGrid* gridDst, CGrid* gridSrc,
90                                                CTransformation<CDomain>* transformation,
91                                                int elementPositionInGrid,
92                                                std::map<int, int>& elementPositionInGridSrc2ScalarPosition,
93                                                std::map<int, int>& elementPositionInGridSrc2AxisPosition,
94                                                std::map<int, int>& elementPositionInGridSrc2DomainPosition,
95                                                std::map<int, int>& elementPositionInGridDst2ScalarPosition,
96                                                std::map<int, int>& elementPositionInGridDst2AxisPosition,
97                                                std::map<int, int>& elementPositionInGridDst2DomainPosition);
98private: 
99  CDomain* domainSrc_ ;
100  CDomain* domainDest_ ;
101
102public:
103  static bool dummyRegistered_;
104
105
106};
107
108}
109#endif // __XIOS_DOMAIN_ALGORITHM_INTERPOLATE_HPP__
Note: See TracBrowser for help on using the repository browser.