1 | #include "algorithm_transformation_weight.hpp" |
---|
2 | #include "context.hpp" |
---|
3 | |
---|
4 | namespace 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 | } |
---|