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

Last change on this file since 2230 was 1960, checked in by ymipsl, 4 years ago

Bug fix when using grid masking. Grid local connector apply systematicalling grid masking need for data coming from model.
Add a flag to chose using masking or not.

YM

  • Property svn:executable set to *
File size: 1.8 KB
Line 
1#ifndef __GRID_LOCAL_CONNECTOR_HPP__
2#define __GRID_LOCAL_CONNECTOR_HPP__
3
4#include "xios_spl.hpp"
5#include "array_new.hpp"
6#include "local_connector.hpp"
7
8
9
10namespace xios
11{
12
13  class CGridLocalElements;
14
15  class CGridLocalConnector
16  {
17
18    private: 
19      std::vector<CLocalConnector*> elementsConnector_ ;
20      int srcSize_ ;
21      int dstSize_ ;
22      vector<bool> mask_ ;
23
24    public:
25     
26      CGridLocalConnector(const std::vector<CLocalConnector*>& elementsConnector)  ;
27      CGridLocalConnector(CGridLocalElements* parent, CElementView::type srcType, CElementView::type dstType, bool withMask=false) ;
28      int getSrcSize(void) { return srcSize_ ;}
29      int getDstSize(void) { return dstSize_ ;}
30
31      void computeMask(void) ;
32      bool computeMask_done_=false ;
33
34     
35      template<typename T, int Nin, int Nout> 
36      void transfer(const CArray<T,Nin>& input, CArray<T,Nout>& output)
37      {
38        int n = elementsConnector_.size()-1 ;
39        CLocalConnector** connector = elementsConnector_.data() + n ;
40        elementsConnector_[n]->transfer(connector, n, input.dataFirst(), output.dataFirst()) ;
41      }
42     
43      template<typename T, int Nin, int Nout> 
44      void transfer(const CArray<T,Nin>& input, CArray<T,Nout>& output, T missingValue)
45      {
46        int n = elementsConnector_.size()-1 ;
47        CLocalConnector** connector = elementsConnector_.data() + n ;
48        elementsConnector_[n]->transfer(connector, n, input.dataFirst(), output.dataFirst(), missingValue) ;
49        if (!computeMask_done_) computeMask() ;
50        if (!mask_.empty()) 
51        {
52          T* out = output.dataFirst() ;
53          for(auto mask : mask_) { if (!mask) *out=missingValue ; out++;}
54        }
55      }
56
57  } ;
58
59}
60
61#endif
Note: See TracBrowser for help on using the repository browser.