Ignore:
Timestamp:
10/24/16 16:16:40 (8 years ago)
Author:
mhnguyen
Message:

Minor improvements:

+) Change some type of variable to avoid some error-prone inputs
+) Change some class name to make it meaningful

Test
+) On Curie
+) Okie

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/transformation/scalar_algorithm_reduce_axis.cpp

    r979 r980  
    1818 
    1919namespace xios { 
    20 CGenericAlgorithmTransformation* CScalarAlgorithmReduceScalar::create(CGrid* gridDst, CGrid* gridSrc, 
     20CGenericAlgorithmTransformation* CScalarAlgorithmReduceAxis::create(CGrid* gridDst, CGrid* gridSrc, 
    2121                                                                     CTransformation<CScalar>* transformation, 
    2222                                                                     int elementPositionInGrid, 
     
    3535  int axisSrcIndex = elementPositionInGridSrc2AxisPosition[elementPositionInGrid]; 
    3636 
    37   return (new CScalarAlgorithmReduceScalar(scalarListDestP[scalarDstIndex], axisListSrcP[axisSrcIndex], reduceAxis)); 
     37  return (new CScalarAlgorithmReduceAxis(scalarListDestP[scalarDstIndex], axisListSrcP[axisSrcIndex], reduceAxis)); 
    3838} 
    3939 
    40 bool CScalarAlgorithmReduceScalar::registerTrans() 
     40bool CScalarAlgorithmReduceAxis::registerTrans() 
    4141{ 
    4242  CGridTransformationFactory<CScalar>::registerTransformation(TRANS_REDUCE_AXIS_TO_SCALAR, create); 
    4343} 
    4444 
    45 CScalarAlgorithmReduceScalar::CScalarAlgorithmReduceScalar(CScalar* scalarDestination, CAxis* axisSource, CReduceAxisToScalar* algo) 
     45CScalarAlgorithmReduceAxis::CScalarAlgorithmReduceAxis(CScalar* scalarDestination, CAxis* axisSource, CReduceAxisToScalar* algo) 
    4646 : CScalarAlgorithmTransformation(scalarDestination, axisSource), 
    4747   reduction_(0) 
    4848{ 
    4949  if (algo->operation.isEmpty()) 
    50     ERROR("CScalarAlgorithmReduceScalar::CScalarAlgorithmReduceScalar(CAxis* axisDestination, CAxis* axisSource, CReduceAxisToScalar* algo)", 
     50    ERROR("CScalarAlgorithmReduceAxis::CScalarAlgorithmReduceAxis(CAxis* axisDestination, CAxis* axisSource, CReduceAxisToScalar* algo)", 
    5151           << "Operation must be defined." 
    5252           << "Axis source " <<axisSource->getId() << std::endl 
    5353           << "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   
    5577  if (CReductionAlgorithm::ReductionOperations.end() == CReductionAlgorithm::ReductionOperations.find(op)) 
    56     ERROR("CScalarAlgorithmReduceScalar::CScalarAlgorithmReduceScalar(CAxis* axisDestination, CAxis* axisSource, CReduceAxisToScalar* algo)", 
     78    ERROR("CScalarAlgorithmReduceAxis::CScalarAlgorithmReduceAxis(CAxis* axisDestination, CAxis* axisSource, CReduceAxisToScalar* algo)", 
    5779       << "Operation '" << op << "' not found. Please make sure to use a supported one" 
    5880       << "Axis source " <<axisSource->getId() << std::endl 
     
    6284} 
    6385 
    64 void CScalarAlgorithmReduceScalar::apply(const std::vector<std::pair<int,double> >& localIndex, 
     86void CScalarAlgorithmReduceAxis::apply(const std::vector<std::pair<int,double> >& localIndex, 
    6587                                         const double* dataInput, 
    6688                                         CArray<double,1>& dataOut, 
     
    7193} 
    7294 
    73 void CScalarAlgorithmReduceScalar::updateData(CArray<double,1>& dataOut) 
     95void CScalarAlgorithmReduceAxis::updateData(CArray<double,1>& dataOut) 
    7496{ 
    7597  reduction_->updateData(dataOut); 
    7698} 
    7799 
    78 CScalarAlgorithmReduceScalar::~CScalarAlgorithmReduceScalar() 
     100CScalarAlgorithmReduceAxis::~CScalarAlgorithmReduceAxis() 
    79101{ 
    80102  if (0 != reduction_) delete reduction_; 
    81103} 
    82104 
    83 void CScalarAlgorithmReduceScalar::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 
     105void CScalarAlgorithmReduceAxis::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 
    84106{ 
    85107  this->transformationMapping_.resize(1); 
Note: See TracChangeset for help on using the changeset viewer.