- Timestamp:
- 10/24/16 16:16:40 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/transformation/scalar_algorithm_reduce_axis.cpp
r979 r980 18 18 19 19 namespace xios { 20 CGenericAlgorithmTransformation* CScalarAlgorithmReduce Scalar::create(CGrid* gridDst, CGrid* gridSrc,20 CGenericAlgorithmTransformation* CScalarAlgorithmReduceAxis::create(CGrid* gridDst, CGrid* gridSrc, 21 21 CTransformation<CScalar>* transformation, 22 22 int elementPositionInGrid, … … 35 35 int axisSrcIndex = elementPositionInGridSrc2AxisPosition[elementPositionInGrid]; 36 36 37 return (new CScalarAlgorithmReduce Scalar(scalarListDestP[scalarDstIndex], axisListSrcP[axisSrcIndex], reduceAxis));37 return (new CScalarAlgorithmReduceAxis(scalarListDestP[scalarDstIndex], axisListSrcP[axisSrcIndex], reduceAxis)); 38 38 } 39 39 40 bool CScalarAlgorithmReduce Scalar::registerTrans()40 bool CScalarAlgorithmReduceAxis::registerTrans() 41 41 { 42 42 CGridTransformationFactory<CScalar>::registerTransformation(TRANS_REDUCE_AXIS_TO_SCALAR, create); 43 43 } 44 44 45 CScalarAlgorithmReduce Scalar::CScalarAlgorithmReduceScalar(CScalar* scalarDestination, CAxis* axisSource, CReduceAxisToScalar* algo)45 CScalarAlgorithmReduceAxis::CScalarAlgorithmReduceAxis(CScalar* scalarDestination, CAxis* axisSource, CReduceAxisToScalar* algo) 46 46 : CScalarAlgorithmTransformation(scalarDestination, axisSource), 47 47 reduction_(0) 48 48 { 49 49 if (algo->operation.isEmpty()) 50 ERROR("CScalarAlgorithmReduce Scalar::CScalarAlgorithmReduceScalar(CAxis* axisDestination, CAxis* axisSource, CReduceAxisToScalar* algo)",50 ERROR("CScalarAlgorithmReduceAxis::CScalarAlgorithmReduceAxis(CAxis* axisDestination, CAxis* axisSource, CReduceAxisToScalar* algo)", 51 51 << "Operation must be defined." 52 52 << "Axis source " <<axisSource->getId() << std::endl 53 53 << "Scalar destination " << scalarDestination->getId()); 54 StdString op = algo->operation; 54 StdString op; 55 switch (algo->operation) 56 { 57 case CReduceAxisToScalar::operation_attr::sum: 58 op = "sum"; 59 break; 60 case CReduceAxisToScalar::operation_attr::min: 61 op = "min"; 62 break; 63 case CReduceAxisToScalar::operation_attr::max: 64 op = "max"; 65 break; 66 case CReduceAxisToScalar::operation_attr::average: 67 op = "average"; 68 break; 69 default: 70 ERROR("CScalarAlgorithmReduceAxis::CScalarAlgorithmReduceAxis(CScalar* scalarDestination, CAxis* axisSource, CReduceAxisToScalar* algo)", 71 << "Operation is wrongly defined. Supported operations: sum, min, max, average." << std::endl 72 << "Domain source " <<axisSource->getId() << std::endl 73 << "Scalar destination " << scalarDestination->getId()); 74 75 } 76 55 77 if (CReductionAlgorithm::ReductionOperations.end() == CReductionAlgorithm::ReductionOperations.find(op)) 56 ERROR("CScalarAlgorithmReduce Scalar::CScalarAlgorithmReduceScalar(CAxis* axisDestination, CAxis* axisSource, CReduceAxisToScalar* algo)",78 ERROR("CScalarAlgorithmReduceAxis::CScalarAlgorithmReduceAxis(CAxis* axisDestination, CAxis* axisSource, CReduceAxisToScalar* algo)", 57 79 << "Operation '" << op << "' not found. Please make sure to use a supported one" 58 80 << "Axis source " <<axisSource->getId() << std::endl … … 62 84 } 63 85 64 void CScalarAlgorithmReduce Scalar::apply(const std::vector<std::pair<int,double> >& localIndex,86 void CScalarAlgorithmReduceAxis::apply(const std::vector<std::pair<int,double> >& localIndex, 65 87 const double* dataInput, 66 88 CArray<double,1>& dataOut, … … 71 93 } 72 94 73 void CScalarAlgorithmReduce Scalar::updateData(CArray<double,1>& dataOut)95 void CScalarAlgorithmReduceAxis::updateData(CArray<double,1>& dataOut) 74 96 { 75 97 reduction_->updateData(dataOut); 76 98 } 77 99 78 CScalarAlgorithmReduce Scalar::~CScalarAlgorithmReduceScalar()100 CScalarAlgorithmReduceAxis::~CScalarAlgorithmReduceAxis() 79 101 { 80 102 if (0 != reduction_) delete reduction_; 81 103 } 82 104 83 void CScalarAlgorithmReduce Scalar::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs)105 void CScalarAlgorithmReduceAxis::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 84 106 { 85 107 this->transformationMapping_.resize(1);
Note: See TracChangeset
for help on using the changeset viewer.