source: XIOS/trunk/src/transformation/domain_algorithm_interpolate.hpp @ 1982

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

trunk : workflow graph big fixed for chained spatial filters. Filter name simplified for graph

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