source: XIOS/dev/branch_openmp/src/transformation/domain_algorithm_interpolate.hpp @ 1460

Last change on this file since 1460 was 1460, checked in by yushan, 6 years ago

branch_openmp merged with XIOS_DEV_CMIP6@1459

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#include "mpi_std.hpp"
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  bool fortranConvention ;
66
67  // class WriteNetCdf;
68  class WriteNetCdf : public CNc4DataOutput
69  {
70  public:
71    WriteNetCdf(const StdString& filename, const ep_lib::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
87private:
88
89  static CGenericAlgorithmTransformation* create(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);
98};
99
100}
101#endif // __XIOS_DOMAIN_ALGORITHM_INTERPOLATE_HPP__
Note: See TracBrowser for help on using the repository browser.