Changeset 2011 for XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/scalar_algorithm/scalar_algorithm_reduce_scalar.cpp
- Timestamp:
- 01/12/21 23:05:02 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/scalar_algorithm/scalar_algorithm_reduce_scalar.cpp
r1988 r2011 44 44 45 45 CScalarAlgorithmReduceScalar::CScalarAlgorithmReduceScalar(bool isSource, CScalar* scalarDestination, CScalar* scalarSource, CReduceScalarToScalar* algo) 46 : C ScalarAlgorithmTransformation(isSource, scalarDestination, scalarSource), reduction_(0)46 : CAlgorithmTransformationReduce(isSource) 47 47 TRY 48 48 { … … 57 57 { 58 58 case CReduceScalarToScalar::operation_attr::sum: 59 op = "sum";59 operator_ = EReduction::sum; 60 60 break; 61 61 case CReduceScalarToScalar::operation_attr::min: 62 op = "min";62 operator_ = EReduction::min; 63 63 break; 64 64 case CReduceScalarToScalar::operation_attr::max: 65 op = "max";65 operator_ = EReduction::max; 66 66 break; 67 67 case CReduceScalarToScalar::operation_attr::average: 68 op = "average";68 operator_ = EReduction::average; 69 69 break; 70 70 default: … … 75 75 76 76 } 77 78 if (CReductionAlgorithm::ReductionOperations.end() == CReductionAlgorithm::ReductionOperations.find(op)) 79 ERROR("CScalarAlgorithmReduceScalar::CScalarAlgorithmReduceScalar(CScalar* scalarDestination, CScalar* scalarSource, CReduceScalarToScalar* algo)", 80 << "Operation '" << op << "' not found. Please make sure to use a supported one" 81 << "Scalar source " <<scalarSource->getId() << std::endl 82 << "Scalar destination " << scalarDestination->getId()); 77 transformationMapping_[0].push_back(0) ; 83 78 84 reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 85 } 86 CATCH 87 88 void CScalarAlgorithmReduceScalar::apply(const std::vector<std::pair<int,double> >& localIndex, const double* dataInput, CArray<double,1>& dataOut, 89 std::vector<bool>& flagInitial, bool ignoreMissingValue, bool firstPass) 90 TRY 91 { 92 reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 93 } 94 CATCH 95 96 void CScalarAlgorithmReduceScalar::updateData(CArray<double,1>& dataOut) 97 TRY 98 { 99 reduction_->updateData(dataOut); 79 scalarDestination->checkAttributes() ; 80 this->computeAlgorithm(scalarSource->getLocalView(CElementView::WORKFLOW), scalarDestination->getLocalView(CElementView::WORKFLOW)) ; 100 81 } 101 82 CATCH … … 104 85 TRY 105 86 { 106 if (0 != reduction_) delete reduction_;107 87 } 108 88 CATCH 109 89 110 void CScalarAlgorithmReduceScalar::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs)111 TRY112 {113 this->transformationMapping_.resize(1);114 this->transformationWeight_.resize(1);115 116 TransformationIndexMap& transMap = this->transformationMapping_[0];117 TransformationWeightMap& transWeight = this->transformationWeight_[0];118 119 transMap[0].push_back(0);120 transWeight[0].push_back(1.0);121 90 122 91 } 123 CATCH124 125 }
Note: See TracChangeset
for help on using the changeset viewer.