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 | |
---|
16 | namespace xios { |
---|
17 | |
---|
18 | class CDomain; |
---|
19 | class CInterpolateDomain; |
---|
20 | |
---|
21 | |
---|
22 | /*! |
---|
23 | \class CDomainAlgorithmInterpolate |
---|
24 | Reading interpolation from file then apply on a domain |
---|
25 | */ |
---|
26 | class CDomainAlgorithmInterpolate : public CDomainAlgorithmTransformation |
---|
27 | { |
---|
28 | public: |
---|
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 | protected: |
---|
42 | void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs); |
---|
43 | |
---|
44 | private: |
---|
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 | |
---|
55 | private: |
---|
56 | CArray<double,1> renormalizationFactor ; |
---|
57 | CArray<bool,1> allMissing ; |
---|
58 | bool detectMissingValue ; |
---|
59 | bool renormalize ; |
---|
60 | bool quantity ; |
---|
61 | |
---|
62 | CInterpolateDomain* interpDomain_; |
---|
63 | bool writeToFile_; |
---|
64 | bool readFromFile_; |
---|
65 | StdString fileToReadWrite_; |
---|
66 | bool fortranConvention ; |
---|
67 | |
---|
68 | // class WriteNetCdf; |
---|
69 | class WriteNetCdf : public CNc4DataOutput |
---|
70 | { |
---|
71 | public: |
---|
72 | WriteNetCdf(const StdString& filename, const MPI_Comm comm); |
---|
73 | int addDimensionWrite(const StdString& name, const StdSize size = UNLIMITED_DIM); |
---|
74 | int addVariableWrite(const StdString& name, nc_type type, |
---|
75 | const std::vector<StdString>& dim); |
---|
76 | void endDefinition(); |
---|
77 | void writeDataIndex(const CArray<int,1>& data, const StdString& name, |
---|
78 | bool collective, StdSize record, |
---|
79 | const std::vector<StdSize>* start = NULL, |
---|
80 | const std::vector<StdSize>* count = NULL); |
---|
81 | void writeDataIndex(const CArray<double,1>& data, const StdString& name, |
---|
82 | bool collective, StdSize record, |
---|
83 | const std::vector<StdSize>* start = NULL, |
---|
84 | const std::vector<StdSize>* count = NULL); |
---|
85 | }; |
---|
86 | |
---|
87 | |
---|
88 | private: |
---|
89 | |
---|
90 | static CGenericAlgorithmTransformation* create(CGrid* gridDst, CGrid* gridSrc, |
---|
91 | CTransformation<CDomain>* transformation, |
---|
92 | int elementPositionInGrid, |
---|
93 | std::map<int, int>& elementPositionInGridSrc2ScalarPosition, |
---|
94 | std::map<int, int>& elementPositionInGridSrc2AxisPosition, |
---|
95 | std::map<int, int>& elementPositionInGridSrc2DomainPosition, |
---|
96 | std::map<int, int>& elementPositionInGridDst2ScalarPosition, |
---|
97 | std::map<int, int>& elementPositionInGridDst2AxisPosition, |
---|
98 | std::map<int, int>& elementPositionInGridDst2DomainPosition); |
---|
99 | }; |
---|
100 | |
---|
101 | } |
---|
102 | #endif // __XIOS_DOMAIN_ALGORITHM_INTERPOLATE_HPP__ |
---|