source: XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/algorithm_transformation_transfer.cpp @ 1997

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

New transformation algorithm created that can be inherited more specifically for a given transformation :

  • no_data_modification : only the element is modifed, the data are not modofied
  • transfer : data is juste transfered from source element to destination element
  • weight : destination data is composed of sum of source data associated to a weight

YM

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.3 KB
Line 
1#include "algorithm_transformation_transfer.hpp"
2#include "array_new.hpp"
3#include "local_view.hpp"
4#include "transform_connector.hpp"
5#include "context.hpp"
6
7namespace xios
8{
9 
10 void CAlgorithmTransformationTransfer::computeAlgorithm(CLocalView* srcView, CLocalView* dstView)
11 {
12   set<size_t> srcIndex ;
13   for(auto& it : transformationMapping_) srcIndex.insert(it.second) ;
14
15    CArray<size_t,1> srcArrayIndex(srcIndex.size()) ;
16    int i=0 ;
17    for(size_t index : srcIndex) { srcArrayIndex(i) = index ; i++ ;}
18    CLocalElement recvElement(CContext::getCurrent()->getIntraCommRank(), srcView->getGlobalSize(), srcArrayIndex) ;
19    recvElement.addFullView() ;
20
21    transformConnector_ = new CTransformConnector(srcView, recvElement.getView(CElementView::FULL), CContext::getCurrent()->getIntraComm())  ;
22    transformConnector_->computeConnector() ;
23    transferTransformConnector_ = new  CTransferTransformConnector( recvElement.getView(CElementView::FULL), dstView, transformationMapping_) ; 
24  }
25 
26
27  void CAlgorithmTransformationTransfer::apply(int dimBefore, int dimAfter, const CArray<double,1>& dataIn, CArray<double,1>& dataOut)
28  {
29    CArray<double,1> dataOutTmp ;
30    transformConnector_->transfer(dimBefore, dimAfter, dataIn, dataOutTmp) ; 
31    transferTransformConnector_ -> transfer(dimBefore, dimAfter, dataOutTmp, dataOut) ; 
32  }
33 
34}
Note: See TracBrowser for help on using the repository browser.