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