source: XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/algorithm_transformation_weight.cpp @ 1999

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

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

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    this->computeRecvElement(srcView, dstView) ;
11    weightTransformConnector_ = new  CWeightTransformConnector( recvElement_->getView(CElementView::FULL), dstView, transformationMapping_, transformationWeight_) ; 
12  }
13 
14
15  void CAlgorithmTransformationWeight::apply(int dimBefore, int dimAfter, const CArray<double,1>& dataIn, CArray<double,1>& dataOut)
16  {
17    CArray<double,1> dataOutTmp ;
18    transformConnector_->transfer(dimBefore, dimAfter, dataIn, dataOutTmp) ;
19    weightTransformConnector_ -> transfer(dimBefore, dimAfter, dataOutTmp, dataOut) ;
20  }
21
22  void CAlgorithmTransformationWeight::computeRecvElement(CLocalView* srcView, CLocalView* dstView)
23  {
24    auto& srcMap = transformationMapping_ ;
25    set<size_t> srcIndex ;
26    for(auto& it : srcMap)
27      for(size_t index : it.second) srcIndex.insert(index) ;
28
29    CArray<size_t,1> srcArrayIndex(srcIndex.size()) ;
30    int i=0 ;
31    for(size_t index : srcIndex) { srcArrayIndex(i) = index ; i++ ;}
32    recvElement_ = new CLocalElement(CContext::getCurrent()->getIntraCommRank(), srcView->getGlobalSize(), srcArrayIndex) ;
33    recvElement_->addFullView() ;
34  }
35}
Note: See TracBrowser for help on using the repository browser.