source: XIOS/dev/branch_yushan_merged/src/transformation/domain_algorithm_interpolate.hpp @ 1134

Last change on this file since 1134 was 1134, checked in by yushan, 7 years ago

branch merged with trunk r1130

File size: 3.5 KB
Line 
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#ifdef _usingEP
16#include "ep_declaration.hpp"
17#endif
18
19namespace xios {
20
21class CDomain;
22class CInterpolateDomain;
23
24
25/*!
26  \class CDomainAlgorithmInterpolate
27  Reading interpolation from file then apply on a domain
28*/
29class CDomainAlgorithmInterpolate : public CDomainAlgorithmTransformation
30{
31public:
32  CDomainAlgorithmInterpolate(CDomain* domainDestination, CDomain* domainSource, CInterpolateDomain* interpDomain);
33
34  virtual ~CDomainAlgorithmInterpolate() {}
35
36  static bool registerTrans();
37protected:
38  void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs);
39
40private:
41  void readInterpolationInfo(std::string& filename, std::map<int,std::vector<std::pair<int,double> > >& interpMapValue);
42  void writeInterpolationInfo(std::string& filename, std::map<int,std::vector<std::pair<int,double> > >& interpMapValue);
43  void processPole(std::map<int,std::vector<std::pair<int,double> > >& interMapValuePole,
44                   int nbGlobalPointOnPole);
45  void computeRemap();
46  void readRemapInfo();
47  void writeRemapInfo(std::map<int,std::vector<std::pair<int,double> > >&);
48  void exchangeRemapInfo(std::map<int,std::vector<std::pair<int,double> > >& interpMapValue);
49
50private:
51  CInterpolateDomain* interpDomain_;
52  bool writeToFile_;
53  bool readFromFile_;
54  StdString fileToReadWrite_;
55
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);
64    void endDefinition();
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
76private:
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);
87};
88
89}
90#endif // __XIOS_DOMAIN_ALGORITHM_INTERPOLATE_HPP__
Note: See TracBrowser for help on using the repository browser.