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 | static bool registerTrans(); |
---|
34 | protected: |
---|
35 | void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs); |
---|
36 | |
---|
37 | private: |
---|
38 | void readInterpolationInfo(std::string& filename, std::map<int,std::vector<std::pair<int,double> > >& interpMapValue); |
---|
39 | void writeInterpolationInfo(std::string& filename, std::map<int,std::vector<std::pair<int,double> > >& interpMapValue); |
---|
40 | void processPole(std::map<int,std::vector<std::pair<int,double> > >& interMapValuePole, |
---|
41 | int nbGlobalPointOnPole); |
---|
42 | void computeRemap(); |
---|
43 | void readRemapInfo(); |
---|
44 | void writeRemapInfo(std::map<int,std::vector<std::pair<int,double> > >&); |
---|
45 | void exchangeRemapInfo(std::map<int,std::vector<std::pair<int,double> > >& interpMapValue); |
---|
46 | |
---|
47 | private: |
---|
48 | CInterpolateDomain* interpDomain_; |
---|
49 | bool writeToFile_; |
---|
50 | bool readFromFile_; |
---|
51 | StdString fileToReadWrite_; |
---|
52 | |
---|
53 | // class WriteNetCdf; |
---|
54 | class WriteNetCdf : public CNc4DataOutput |
---|
55 | { |
---|
56 | public: |
---|
57 | WriteNetCdf(const StdString& filename, const MPI_Comm comm); |
---|
58 | int addDimensionWrite(const StdString& name, const StdSize size = UNLIMITED_DIM); |
---|
59 | int addVariableWrite(const StdString& name, nc_type type, |
---|
60 | const std::vector<StdString>& dim); |
---|
61 | void endDefinition(); |
---|
62 | void writeDataIndex(const CArray<int,1>& data, const StdString& name, |
---|
63 | bool collective, StdSize record, |
---|
64 | const std::vector<StdSize>* start = NULL, |
---|
65 | const std::vector<StdSize>* count = NULL); |
---|
66 | void writeDataIndex(const CArray<double,1>& data, const StdString& name, |
---|
67 | bool collective, StdSize record, |
---|
68 | const std::vector<StdSize>* start = NULL, |
---|
69 | const std::vector<StdSize>* count = NULL); |
---|
70 | }; |
---|
71 | |
---|
72 | |
---|
73 | private: |
---|
74 | |
---|
75 | static CGenericAlgorithmTransformation* create(CGrid* gridDst, CGrid* gridSrc, |
---|
76 | CTransformation<CDomain>* transformation, |
---|
77 | int elementPositionInGrid, |
---|
78 | std::map<int, int>& elementPositionInGridSrc2ScalarPosition, |
---|
79 | std::map<int, int>& elementPositionInGridSrc2AxisPosition, |
---|
80 | std::map<int, int>& elementPositionInGridSrc2DomainPosition, |
---|
81 | std::map<int, int>& elementPositionInGridDst2ScalarPosition, |
---|
82 | std::map<int, int>& elementPositionInGridDst2AxisPosition, |
---|
83 | std::map<int, int>& elementPositionInGridDst2DomainPosition); |
---|
84 | }; |
---|
85 | |
---|
86 | } |
---|
87 | #endif // __XIOS_DOMAIN_ALGORITHM_INTERPOLATE_HPP__ |
---|