source: XIOS/trunk/src/filter/axis_inverse.cpp @ 621

Last change on this file since 621 was 621, checked in by mhnguyen, 6 years ago

Implementing generic transformation algorithm (local commit)

+) Change a little bit to make sure everything work in order

Test
+) test_new_features passe with inverse

File size: 1.6 KB
Line 
1#include "axis_inverse.hpp"
2
3namespace xios {
4
5CAxisInverse::CAxisInverse(CAxis* axisDestination, CAxis* axisSource)
6 : CConcreteAlgo()
7{
8  if (axisDestination->size.getValue() != axisSource->size.getValue())
9  {
10    ERROR("CAxisInverse::CAxisInverse(CAxis* axisDestination, CAxis* axisSource)",
11           << "Two axis have different size"
12           << "Size of axis source " <<axisSource->getId() << " is " << axisSource->size.getValue()  << std::endl
13           << "Size of axis destionation " <<axisDestination->getId() << " is " << axisDestination->size.getValue());
14  }
15
16
17  axisDestGlobalSize_ = axisDestination->size.getValue();
18  int niDest = axisDestination->ni.getValue();
19  int ibeginDest = axisDestination->ibegin.getValue();
20
21  for (int idx = 0; idx < niDest; ++idx) axisDestGlobalIndex_.push_back(ibeginDest+idx);
22}
23
24void CAxisInverse::computeIndexSourceMapping(const std::map<int, std::vector<int> >& transformationMappingOfPreviousAlgo)
25{
26  std::map<int, std::vector<int> >& transMap = this->transformationMapping_;
27  if (transformationMappingOfPreviousAlgo.empty())
28  {
29    int globalIndexSize = axisDestGlobalIndex_.size();
30    for (int idx = 0; idx < globalIndexSize; ++idx)
31      transMap[axisDestGlobalIndex_[idx]].push_back(axisDestGlobalSize_-axisDestGlobalIndex_[idx]-1);
32  }
33  else
34  {
35    std::map<int, std::vector<int> >::const_iterator itb = transformationMappingOfPreviousAlgo.begin(), it,
36                                                     ite = transformationMappingOfPreviousAlgo.end();
37    for (it = itb; it != ite; ++it)
38    {
39      transMap[it->first].push_back(axisDestGlobalSize_-it->first-1);
40    }
41  }
42}
43
44}
Note: See TracBrowser for help on using the repository browser.