source: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/transfer_transform_connector.hpp @ 2230

Last change on this file since 2230 was 1999, checked in by ymipsl, 3 years ago

Adapt transformation algorithm to new infrastructure (on going...)

YM

  • Property svn:executable set to *
File size: 1.7 KB
Line 
1#ifndef __TRANSFER_TRANSFORM_CONNECTOR_HPP__
2#define __TRANSFER_TRANSFORM_CONNECTOR_HPP__
3
4#include "xios_spl.hpp"
5#include "array_new.hpp"
6#include "local_view.hpp"
7
8
9
10namespace xios
11{
12 
13  class CTransferTransformConnector
14  {
15   
16    private:
17      CLocalView* srcView_;
18      CLocalView* dstView_;
19
20      vector<int> connector_;   
21      vector<bool> mask_ ;  //  sizeof dstSize_
22      int srcSize_ ;
23      int dstSize_ ;
24
25     void computeConnector(unordered_map<int, int>& indexMap) ;
26     
27    public:
28
29    CTransferTransformConnector(CLocalView* srcView, CLocalView* dstView, unordered_map<int, int>& indexMap) ;
30 
31    void transfer(int repeat, int sizeT, const CArray<double,1>& dataIn, CArray<double,1>& dataOut)
32    {
33      int dstSlice = dstSize_*sizeT ;
34      int srcSlice = srcSize_*sizeT ;
35      dataOut.resize(repeat* dstSlice) ;
36      dataOut=0 ; // what to do about missing value => next step ?
37
38      const double* input = dataIn.dataFirst()  ;
39      double* output = dataOut.dataFirst()  ;
40
41      for(int r=0;r<repeat;r++, input+=srcSlice, output+=dstSlice)
42      {
43        const double* in = input;
44        double* out = output ;
45        int k=0 ;
46        for(int i=0; i<dstSize_; i++, out+=sizeT)
47          if (mask_[i])
48          {
49            for(int l=0; l<sizeT; l++) out[l] = in[connector_[k]*sizeT+l] ;
50            k++ ;
51          }
52      }
53    }
54
55    void transfer(int sizeT, const CArray<double,1>& dataIn, CArray<double,1>& dataOut)
56    { 
57      transfer(1,sizeT, dataIn, dataOut) ;
58    }
59   
60    void transfer(const CArray<double,1>& dataIn, CArray<double,1>& dataOut)
61    {
62      transfer(1,1,dataIn, dataOut) ;
63    }
64
65 
66  };
67
68}
69
70#endif
Note: See TracBrowser for help on using the repository browser.