source: XIOS/trunk/src/transformation/axis_algorithm_extract_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.6 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 extract a domain to an axis
8 */
9#include "axis_algorithm_extract_domain.hpp"
10#include "extract_domain_to_axis.hpp"
11#include "axis.hpp"
12#include "domain.hpp"
13
14#include "sum.hpp"
15
16namespace xios {
17
18CAxisAlgorithmExtractDomain::CAxisAlgorithmExtractDomain(CAxis* axisDestination, CDomain* domainSource, CExtractDomainToAxis* algo)
19 : CAxisAlgorithmTransformation(axisDestination, domainSource), pos_(-1), reduction_(0)
20{
21  algo->checkValid(axisDestination, domainSource);
22  StdString op = "extract";
23  StdString direction = algo->direction;
24  dir_ = (0 == direction.compare("i")) ? iDir : jDir;
25  pos_ = algo->position;
26  reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]);
27}
28
29void CAxisAlgorithmExtractDomain::apply(const std::vector<std::pair<int,double> >& localIndex,
30                                        const double* dataInput,
31                                        CArray<double,1>& dataOut,
32                                        std::vector<bool>& flagInitial,
33                                        const double& defaultValue)
34{
35  reduction_->apply(localIndex, dataInput, dataOut, flagInitial);
36}
37
38CAxisAlgorithmExtractDomain::~CAxisAlgorithmExtractDomain()
39{
40  if (0 != reduction_) delete reduction_;
41}
42
43void CAxisAlgorithmExtractDomain::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs)
44{
45  this->transformationMapping_.resize(1);
46  this->transformationWeight_.resize(1);
47
48  TransformationIndexMap& transMap = this->transformationMapping_[0];
49  TransformationWeightMap& transWeight = this->transformationWeight_[0];
50
51  CArray<int,1>& axisDstIndex = axisDest_->index;
52  int ni_glo = domainSrc_->ni_glo, nj_glo = domainSrc_->nj_glo;
53  if (jDir == dir_)
54  {
55    int nbAxisIdx = axisDstIndex.numElements();
56    for (int idxAxis = 0; idxAxis < nbAxisIdx; ++idxAxis)
57    {
58      int globalAxisIdx = axisDstIndex(idxAxis);
59      transMap[globalAxisIdx].resize(1);
60      transWeight[globalAxisIdx].resize(1);
61      transMap[globalAxisIdx][0] = globalAxisIdx * ni_glo + pos_;
62      transWeight[globalAxisIdx][0] = 1.0;
63
64    }
65  }
66  else if (iDir == dir_)
67  {
68    int nbAxisIdx = axisDstIndex.numElements();
69    for (int idxAxis = 0; idxAxis < nbAxisIdx; ++idxAxis)
70    {
71      int globalAxisIdx = axisDstIndex(idxAxis);
72      transMap[globalAxisIdx].resize(1);
73      transWeight[globalAxisIdx].resize(1);
74      transMap[globalAxisIdx][0] = globalAxisIdx + ni_glo * pos_;
75      transWeight[globalAxisIdx][0] = 1.0;
76    }
77  }
78  else
79  {}
80}
81
82}
Note: See TracBrowser for help on using the repository browser.