source: XIOS3/trunk/src/distribution/transfer_transform_connector.cpp @ 2396

Last change on this file since 2396 was 2267, checked in by ymipsl, 3 years ago

tracking memory leak
Elements, views, and connectors are now managed with shared pointer.
YM

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.1 KB
Line 
1#include "transfer_transform_connector.hpp"
2
3namespace xios
4{
5
6  CTransferTransformConnector::CTransferTransformConnector(shared_ptr<CLocalView> srcView, shared_ptr<CLocalView> dstView, unordered_map<int, int>& indexMap) 
7    : srcView_(srcView), dstView_(dstView)
8  {
9    computeConnector(indexMap) ;
10  }
11
12  void CTransferTransformConnector::computeConnector(unordered_map<int, int>& indexMap)
13  {
14    CArray<size_t,1> dstGlobalIndex ;
15    CArray<size_t,1> srcGlobalIndex ;
16    dstView_->getGlobalIndexView(dstGlobalIndex) ;
17    srcView_->getGlobalIndexView(srcGlobalIndex) ;
18    unordered_map<size_t,int> srcMapIndex ;
19    srcSize_ = srcGlobalIndex.numElements() ;
20    dstSize_ = dstGlobalIndex.numElements() ;
21    mask_.resize(dstSize_) ;
22
23    for(int i=0;i<srcSize_;i++) srcMapIndex[srcGlobalIndex(i)]=i ;
24    for(int i=0; i<dstSize_;i++) 
25    {
26      if (indexMap.count(dstGlobalIndex(i))!=0)
27      {
28        int index  = indexMap[dstGlobalIndex(i)] ;
29        connector_.push_back(srcMapIndex[index]) ;
30        mask_[i]=true ;
31      }
32      else mask_[i]=false ;
33    }
34  }
35
36}
Note: See TracBrowser for help on using the repository browser.