source: XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/generic_algorithm_transformation_new.cpp.xxx @ 1984

Last change on this file since 1984 was 1984, checked in by ymipsl, 4 years ago

intermediate commit for new tranformation engine?
YM

  • Property svn:executable set to *
File size: 2.7 KB
Line 
1/*!
2   \file generic_algorithm_transformation.hpp
3   \author Ha NGUYEN
4   \since 14 May 2015
5   \date 21 Mars 2016
6
7   \brief Interface for all transformation algorithms.
8 */
9#include "generic_algorithm_transformation.hpp"
10#include "context.hpp"
11#include "context_client.hpp"
12#include "client_client_dht_template.hpp"
13#include "utils.hpp"
14#include "timer.hpp"
15#include "mpi.hpp"
16
17namespace xios {
18
19CGenericAlgorithmTransformation::CGenericAlgorithmTransformation()
20 : transformationMapping_(), transformationWeight_(), transformationPosition_(),
21   idAuxInputs_(), type_(ELEMENT_NO_MODIFICATION_WITH_DATA), indexElementSrc_(),
22   computedProcSrcNonTransformedElement_(false), eliminateRedondantSrc_(true), isDistributedComputed_(false)
23{
24}
25
26void CGenericAlgorithmTransformation::updateData(CArray<double,1>& dataOut)
27{
28
29}
30
31void CGenericAlgorithmTransformation::apply(const std::vector<std::pair<int,double> >& localIndex,
32                                            const double* dataInput,
33                                            CArray<double,1>& dataOut,
34                                            std::vector<bool>& flagInitial,
35                                            bool ignoreMissingValue, bool firstPass  )
36TRY
37{
38  int nbLocalIndex = localIndex.size();   
39  double defaultValue = std::numeric_limits<double>::quiet_NaN();
40   
41  if (ignoreMissingValue)
42  {
43    if (firstPass) dataOut=defaultValue ;
44   
45    for (int idx = 0; idx < nbLocalIndex; ++idx)
46    {
47      if (! NumTraits<double>::isNan(*(dataInput + idx)))
48      {
49        if (flagInitial[localIndex[idx].first]) dataOut(localIndex[idx].first) = *(dataInput + idx) * localIndex[idx].second;
50        else dataOut(localIndex[idx].first) += *(dataInput + idx) * localIndex[idx].second;
51        flagInitial[localIndex[idx].first] = false; // Reset flag to indicate not all data source are nan
52      }
53    }
54
55  }
56  else
57  {
58    for (int idx = 0; idx < nbLocalIndex; ++idx)
59    {
60      dataOut(localIndex[idx].first) += *(dataInput + idx) * localIndex[idx].second;
61    }
62  }
63}
64CATCH
65
66
67/*!
68  Compute index mapping between element source and element destination with an auxiliary inputs which determine
69position of each mapped index in global index of grid destination.
70  \param [in] dataAuxInputs auxiliary inputs
71*/
72void CGenericAlgorithmTransformation::computeIndexSourceMapping(const std::vector<CArray<double,1>* >& dataAuxInputs)
73TRY
74{
75  computeIndexSourceMapping_(dataAuxInputs);
76}
77CATCH
78
79std::vector<StdString> CGenericAlgorithmTransformation::getIdAuxInputs()
80TRY
81{
82  return idAuxInputs_;
83}
84CATCH
85
86CGenericAlgorithmTransformation::AlgoTransType CGenericAlgorithmTransformation::type()
87TRY
88{
89  return type_;
90}
91CATCH
92
93}
Note: See TracBrowser for help on using the repository browser.