[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__ |
---|
[1642] | 11 | |
---|
[689] | 12 | #include "domain_algorithm_transformation.hpp" |
---|
[933] | 13 | #include "transformation.hpp" |
---|
[982] | 14 | #include "nc4_data_output.hpp" |
---|
[689] | 15 | |
---|
| 16 | namespace xios { |
---|
[933] | 17 | |
---|
| 18 | class CDomain; |
---|
| 19 | class CInterpolateDomain; |
---|
| 20 | |
---|
[982] | 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 | |
---|
[1460] | 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 | |
---|
[933] | 40 | static bool registerTrans(); |
---|
[827] | 41 | protected: |
---|
| 42 | void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs); |
---|
[689] | 43 | |
---|
| 44 | private: |
---|
| 45 | void readInterpolationInfo(std::string& filename, std::map<int,std::vector<std::pair<int,double> > >& interpMapValue); |
---|
[982] | 46 | void writeInterpolationInfo(std::string& filename, std::map<int,std::vector<std::pair<int,double> > >& interpMapValue); |
---|
[743] | 47 | void processPole(std::map<int,std::vector<std::pair<int,double> > >& interMapValuePole, |
---|
| 48 | int nbGlobalPointOnPole); |
---|
[689] | 49 | void computeRemap(); |
---|
| 50 | void readRemapInfo(); |
---|
[982] | 51 | void writeRemapInfo(std::map<int,std::vector<std::pair<int,double> > >&); |
---|
[856] | 52 | void exchangeRemapInfo(std::map<int,std::vector<std::pair<int,double> > >& interpMapValue); |
---|
[1205] | 53 | void convertRemapInfo(std::map<int,std::vector<std::pair<int,double> > >& interpMapValue); |
---|
[982] | 54 | |
---|
[689] | 55 | private: |
---|
[1460] | 56 | CArray<double,1> renormalizationFactor ; |
---|
[1482] | 57 | CArray<bool,1> allMissing ; |
---|
[1460] | 58 | bool detectMissingValue ; |
---|
| 59 | bool renormalize ; |
---|
| 60 | bool quantity ; |
---|
| 61 | |
---|
[689] | 62 | CInterpolateDomain* interpDomain_; |
---|
[982] | 63 | bool writeToFile_; |
---|
[1004] | 64 | bool readFromFile_; |
---|
| 65 | StdString fileToReadWrite_; |
---|
[1460] | 66 | bool fortranConvention ; |
---|
[689] | 67 | |
---|
[982] | 68 | // class WriteNetCdf; |
---|
| 69 | class WriteNetCdf : public CNc4DataOutput |
---|
| 70 | { |
---|
| 71 | public: |
---|
[1328] | 72 | WriteNetCdf(const StdString& filename, const ep_lib::MPI_Comm comm); |
---|
[982] | 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); |
---|
[1014] | 76 | void endDefinition(); |
---|
[982] | 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 | |
---|
[933] | 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); |
---|
[689] | 99 | }; |
---|
| 100 | |
---|
| 101 | } |
---|
| 102 | #endif // __XIOS_DOMAIN_ALGORITHM_INTERPOLATE_HPP__ |
---|