source: XIOS/trunk/src/transformation/axis_algorithm_reduce_domain.cpp @ 918

Last change on this file since 918 was 918, checked in by mhnguyen, 8 years ago

Modifying vertical interpolation

+) Only process interpolation, the extrapolation will be ignored (value will be unidentified (masked))
+) Make sure even unidenfitified from one transformation can be known in the next transformation

Test
+) On Curie
+) Vertical interpolation: Correct
+) Vertical interpolation + horizontal interpolation: Correct

File size: 2.7 KB
Line 
1/*!
2   \file axis_algorithm_reduce_domain.cpp
3   \author Ha NGUYEN
4   \since 23 June 2016
5   \date 23 June 2016
6
7   \brief Algorithm for reduce a domain to an axis
8 */
9#include "axis_algorithm_reduce_domain.hpp"
10#include "reduce_domain_to_axis.hpp"
11#include "axis.hpp"
12#include "domain.hpp"
13
14#include "sum.hpp"
15
16namespace xios {
17
18CAxisAlgorithmReduceDomain::CAxisAlgorithmReduceDomain(CAxis* axisDestination, CDomain* domainSource, CReduceDomainToAxis* algo)
19 : CAxisAlgorithmTransformation(axisDestination, domainSource), reduction_(0)
20{
21  algo->checkValid(axisDestination, domainSource);
22  StdString op = algo->operation;
23  StdString direction = algo->direction;
24  dir_ = (0 == direction.compare("i")) ? iDir : jDir;
25  reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]);
26}
27
28void CAxisAlgorithmReduceDomain::apply(const std::vector<std::pair<int,double> >& localIndex,
29                                       const double* dataInput,
30                                       CArray<double,1>& dataOut,
31                                       std::vector<bool>& flagInitial,
32                                       const double& defaultValue)
33{
34  reduction_->apply(localIndex, dataInput, dataOut, flagInitial);
35}
36
37CAxisAlgorithmReduceDomain::~CAxisAlgorithmReduceDomain()
38{
39  if (0 != reduction_) delete reduction_;
40}
41
42void CAxisAlgorithmReduceDomain::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs)
43{
44  this->transformationMapping_.resize(1);
45  this->transformationWeight_.resize(1);
46
47  TransformationIndexMap& transMap = this->transformationMapping_[0];
48  TransformationWeightMap& transWeight = this->transformationWeight_[0];
49
50  CArray<int,1>& axisDstIndex = axisDest_->index;
51  int ni_glo = domainSrc_->ni_glo, nj_glo = domainSrc_->nj_glo;
52  if (jDir == dir_)
53  {
54    int nbAxisIdx = axisDstIndex.numElements();
55    for (int idxAxis = 0; idxAxis < nbAxisIdx; ++idxAxis)
56    {
57      int globalAxisIdx = axisDstIndex(idxAxis);
58      transMap[globalAxisIdx].resize(ni_glo);
59      transWeight[globalAxisIdx].resize(ni_glo);
60      for (int idx = 0; idx < ni_glo; ++idx)
61      {
62        transMap[globalAxisIdx][idx] = globalAxisIdx * ni_glo + idx;
63        transWeight[globalAxisIdx][idx] = 1.0;
64      }
65    }
66  }
67  else if (iDir == dir_)
68  {
69    int nbAxisIdx = axisDstIndex.numElements();
70    for (int idxAxis = 0; idxAxis < nbAxisIdx; ++idxAxis)
71    {
72      int globalAxisIdx = axisDstIndex(idxAxis);
73      transMap[globalAxisIdx].resize(nj_glo);
74      transWeight[globalAxisIdx].resize(nj_glo);
75      for (int idx = 0; idx < nj_glo; ++idx)
76      {
77        transMap[globalAxisIdx][idx] = globalAxisIdx + ni_glo*idx;
78        transWeight[globalAxisIdx][idx] = 1.0;
79      }
80    }
81  }
82  else
83  {}
84}
85
86}
Note: See TracBrowser for help on using the repository browser.