[689] | 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" |
---|
[933] | 13 | #include "transformation.hpp" |
---|
[982] | 14 | #include "nc4_data_output.hpp" |
---|
[1134] | 15 | #ifdef _usingEP |
---|
| 16 | #include "ep_declaration.hpp" |
---|
| 17 | #endif |
---|
[689] | 18 | |
---|
| 19 | namespace xios { |
---|
[933] | 20 | |
---|
| 21 | class CDomain; |
---|
| 22 | class CInterpolateDomain; |
---|
| 23 | |
---|
[982] | 24 | |
---|
[689] | 25 | /*! |
---|
| 26 | \class CDomainAlgorithmInterpolate |
---|
| 27 | Reading interpolation from file then apply on a domain |
---|
| 28 | */ |
---|
| 29 | class CDomainAlgorithmInterpolate : public CDomainAlgorithmTransformation |
---|
| 30 | { |
---|
| 31 | public: |
---|
| 32 | CDomainAlgorithmInterpolate(CDomain* domainDestination, CDomain* domainSource, CInterpolateDomain* interpDomain); |
---|
| 33 | |
---|
| 34 | virtual ~CDomainAlgorithmInterpolate() {} |
---|
| 35 | |
---|
[933] | 36 | static bool registerTrans(); |
---|
[827] | 37 | protected: |
---|
| 38 | void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs); |
---|
[689] | 39 | |
---|
| 40 | private: |
---|
| 41 | void readInterpolationInfo(std::string& filename, std::map<int,std::vector<std::pair<int,double> > >& interpMapValue); |
---|
[982] | 42 | void writeInterpolationInfo(std::string& filename, std::map<int,std::vector<std::pair<int,double> > >& interpMapValue); |
---|
[743] | 43 | void processPole(std::map<int,std::vector<std::pair<int,double> > >& interMapValuePole, |
---|
| 44 | int nbGlobalPointOnPole); |
---|
[689] | 45 | void computeRemap(); |
---|
| 46 | void readRemapInfo(); |
---|
[982] | 47 | void writeRemapInfo(std::map<int,std::vector<std::pair<int,double> > >&); |
---|
[856] | 48 | void exchangeRemapInfo(std::map<int,std::vector<std::pair<int,double> > >& interpMapValue); |
---|
[982] | 49 | |
---|
[689] | 50 | private: |
---|
| 51 | CInterpolateDomain* interpDomain_; |
---|
[982] | 52 | bool writeToFile_; |
---|
[1004] | 53 | bool readFromFile_; |
---|
| 54 | StdString fileToReadWrite_; |
---|
[689] | 55 | |
---|
[982] | 56 | // class WriteNetCdf; |
---|
| 57 | class WriteNetCdf : public CNc4DataOutput |
---|
| 58 | { |
---|
| 59 | public: |
---|
| 60 | WriteNetCdf(const StdString& filename, const MPI_Comm comm); |
---|
| 61 | int addDimensionWrite(const StdString& name, const StdSize size = UNLIMITED_DIM); |
---|
| 62 | int addVariableWrite(const StdString& name, nc_type type, |
---|
| 63 | const std::vector<StdString>& dim); |
---|
[1014] | 64 | void endDefinition(); |
---|
[982] | 65 | void writeDataIndex(const CArray<int,1>& data, const StdString& name, |
---|
| 66 | bool collective, StdSize record, |
---|
| 67 | const std::vector<StdSize>* start = NULL, |
---|
| 68 | const std::vector<StdSize>* count = NULL); |
---|
| 69 | void writeDataIndex(const CArray<double,1>& data, const StdString& name, |
---|
| 70 | bool collective, StdSize record, |
---|
| 71 | const std::vector<StdSize>* start = NULL, |
---|
| 72 | const std::vector<StdSize>* count = NULL); |
---|
| 73 | }; |
---|
| 74 | |
---|
| 75 | |
---|
[933] | 76 | private: |
---|
| 77 | |
---|
| 78 | static CGenericAlgorithmTransformation* create(CGrid* gridDst, CGrid* gridSrc, |
---|
| 79 | CTransformation<CDomain>* transformation, |
---|
| 80 | int elementPositionInGrid, |
---|
| 81 | std::map<int, int>& elementPositionInGridSrc2ScalarPosition, |
---|
| 82 | std::map<int, int>& elementPositionInGridSrc2AxisPosition, |
---|
| 83 | std::map<int, int>& elementPositionInGridSrc2DomainPosition, |
---|
| 84 | std::map<int, int>& elementPositionInGridDst2ScalarPosition, |
---|
| 85 | std::map<int, int>& elementPositionInGridDst2AxisPosition, |
---|
| 86 | std::map<int, int>& elementPositionInGridDst2DomainPosition); |
---|
[689] | 87 | }; |
---|
| 88 | |
---|
| 89 | } |
---|
| 90 | #endif // __XIOS_DOMAIN_ALGORITHM_INTERPOLATE_HPP__ |
---|