source: XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/algorithm_transformation_weight.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_weight.hpp"
2#include "context.hpp"
3
4namespace xios
5{
6
7
8  void CAlgorithmTransformationWeight::computeAlgorithm(CLocalView* srcView, CLocalView* dstView)
9 {
10   auto& srcMap = transformationMapping_ ;
11   set<size_t> srcIndex ;
12   for(auto& it : srcMap)
13     for(size_t index : it.second) srcIndex.insert(index) ;
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    weightTransformConnector_ = new  CWeightTransformConnector( recvElement.getView(CElementView::FULL), dstView, transformationMapping_, transformationWeight_) ; 
24  }
25 
26
27  void CAlgorithmTransformationWeight::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    weightTransformConnector_ -> transfer(dimBefore, dimAfter, dataOutTmp, dataOut) ;
32  }
33
34}
Note: See TracBrowser for help on using the repository browser.