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 | |
---|
17 | namespace xios { |
---|
18 | |
---|
19 | CGenericAlgorithmTransformation::CGenericAlgorithmTransformation() |
---|
20 | : transformationMapping_(), transformationWeight_(), transformationPosition_(), |
---|
21 | idAuxInputs_(), type_(ELEMENT_NO_MODIFICATION_WITH_DATA), indexElementSrc_(), |
---|
22 | computedProcSrcNonTransformedElement_(false), eliminateRedondantSrc_(true), isDistributedComputed_(false) |
---|
23 | { |
---|
24 | } |
---|
25 | |
---|
26 | void CGenericAlgorithmTransformation::updateData(CArray<double,1>& dataOut) |
---|
27 | { |
---|
28 | |
---|
29 | } |
---|
30 | |
---|
31 | void 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 ) |
---|
36 | TRY |
---|
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 | } |
---|
64 | CATCH |
---|
65 | |
---|
66 | |
---|
67 | /*! |
---|
68 | Compute index mapping between element source and element destination with an auxiliary inputs which determine |
---|
69 | position of each mapped index in global index of grid destination. |
---|
70 | \param [in] dataAuxInputs auxiliary inputs |
---|
71 | */ |
---|
72 | void CGenericAlgorithmTransformation::computeIndexSourceMapping(const std::vector<CArray<double,1>* >& dataAuxInputs) |
---|
73 | TRY |
---|
74 | { |
---|
75 | computeIndexSourceMapping_(dataAuxInputs); |
---|
76 | } |
---|
77 | CATCH |
---|
78 | |
---|
79 | std::vector<StdString> CGenericAlgorithmTransformation::getIdAuxInputs() |
---|
80 | TRY |
---|
81 | { |
---|
82 | return idAuxInputs_; |
---|
83 | } |
---|
84 | CATCH |
---|
85 | |
---|
86 | CGenericAlgorithmTransformation::AlgoTransType CGenericAlgorithmTransformation::type() |
---|
87 | TRY |
---|
88 | { |
---|
89 | return type_; |
---|
90 | } |
---|
91 | CATCH |
---|
92 | |
---|
93 | } |
---|