source: XIOS/trunk/src/transformation/axis_algorithm_inverse.cpp @ 624

Last change on this file since 624 was 624, checked in by mhnguyen, 9 years ago

Final tests of zoom and inverse on axis

+) Modify test_client and test_complete to work with new grid definition
+) Correct some bugs causing memory leak
+) Clean abundant code
+) Add more comments to new files

Test
+) On Curie
+) test_client and test_complete pass with correct results

File size: 1.5 KB
Line 
1/*!
2   \file axis_algorithm_inverse.hpp
3   \author Ha NGUYEN
4   \since 14 May 2015
5   \date 09 June 2015
6
7   \brief Algorithm for inversing an axis..
8 */
9#include "axis_algorithm_inverse.hpp"
10
11namespace xios {
12
13CAxisAlgorithmInverse::CAxisAlgorithmInverse(CAxis* axisDestination, CAxis* axisSource)
14 : CAxisAlgorithmTransformation(axisDestination, axisSource)
15{
16  if (axisDestination->size.getValue() != axisSource->size.getValue())
17  {
18    ERROR("CAxisAlgorithmInverse::CAxisAlgorithmInverse(CAxis* axisDestination, CAxis* axisSource)",
19           << "Two axis have different size"
20           << "Size of axis source " <<axisSource->getId() << " is " << axisSource->size.getValue()  << std::endl
21           << "Size of axis destionation " <<axisDestination->getId() << " is " << axisDestination->size.getValue());
22  }
23
24
25  axisDestGlobalSize_ = axisDestination->size.getValue();
26  int niDest = axisDestination->ni.getValue();
27  int ibeginDest = axisDestination->ibegin.getValue();
28
29  for (int idx = 0; idx < niDest; ++idx)
30    if ((axisDestination->mask)(idx)) axisDestGlobalIndex_.push_back(ibeginDest+idx);
31  this->computeIndexSourceMapping();
32}
33
34void CAxisAlgorithmInverse::computeIndexSourceMapping()
35{
36  std::map<int, std::vector<int> >& transMap = this->transformationMapping_;
37
38  int globalIndexSize = axisDestGlobalIndex_.size();
39  for (int idx = 0; idx < globalIndexSize; ++idx)
40    transMap[axisDestGlobalIndex_[idx]].push_back(axisDestGlobalSize_-axisDestGlobalIndex_[idx]-1);
41}
42
43}
Note: See TracBrowser for help on using the repository browser.