source: XIOS/trunk/src/transformation/domain_algorithm_interpolate.hpp @ 1004

Last change on this file since 1004 was 1004, checked in by mhnguyen, 7 years ago

Some modifications of reading/writing interpolation weight from/into a file
There are 3 attributes concerning read/write weights from/into a file

  • write_weight: true/false. Default value: false
  • weight_filename.
  • mode: Default value: compute + read: read from file whose name is weight_filename + compute: compute weights + read_or_compute: if weight_filename already exists, the weights will be read from it; otherwise the weights will be computed

In mode compute and read_or_compute, if there is no weight_filename, a filename whose format
xios_interpolation_weight_nameOfContext_nameOfDomainSource_nameOfDomainDestination.nc will be used for read/write.

Test
+) On Curie
+) Work

File size: 3.4 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
16namespace xios {
17
18class CDomain;
19class CInterpolateDomain;
20
21
22/*!
23  \class CDomainAlgorithmInterpolate
24  Reading interpolation from file then apply on a domain
25*/
26class CDomainAlgorithmInterpolate : public CDomainAlgorithmTransformation
27{
28public:
29  CDomainAlgorithmInterpolate(CDomain* domainDestination, CDomain* domainSource, CInterpolateDomain* interpDomain);
30
31  virtual ~CDomainAlgorithmInterpolate() {}
32
33  static bool registerTrans();
34protected:
35  void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs);
36
37private:
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
47private:
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 writeDataIndex(const CArray<int,1>& data, const StdString& name,
62                        bool collective, StdSize record,
63                        const std::vector<StdSize>* start = NULL,
64                        const std::vector<StdSize>* count = NULL);
65    void writeDataIndex(const CArray<double,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  };
70
71
72private:
73
74  static CGenericAlgorithmTransformation* create(CGrid* gridDst, CGrid* gridSrc,
75                                                CTransformation<CDomain>* transformation,
76                                                int elementPositionInGrid,
77                                                std::map<int, int>& elementPositionInGridSrc2ScalarPosition,
78                                                std::map<int, int>& elementPositionInGridSrc2AxisPosition,
79                                                std::map<int, int>& elementPositionInGridSrc2DomainPosition,
80                                                std::map<int, int>& elementPositionInGridDst2ScalarPosition,
81                                                std::map<int, int>& elementPositionInGridDst2AxisPosition,
82                                                std::map<int, int>& elementPositionInGridDst2DomainPosition);
83};
84
85}
86#endif // __XIOS_DOMAIN_ALGORITHM_INTERPOLATE_HPP__
Note: See TracBrowser for help on using the repository browser.