/*! \file generic_algorithm_transformation.hpp \author Ha NGUYEN \since 14 May 2015 \date 21 Mars 2016 \brief Interface for all transformation algorithms. */ #include "generic_algorithm_transformation.hpp" #include "context.hpp" #include "context_client.hpp" #include "client_client_dht_template.hpp" #include "utils.hpp" #include "timer.hpp" #include "mpi.hpp" namespace xios { CGenericAlgorithmTransformation::CGenericAlgorithmTransformation() : transformationMapping_(), transformationWeight_(), transformationPosition_(), idAuxInputs_(), type_(ELEMENT_NO_MODIFICATION_WITH_DATA), indexElementSrc_(), computedProcSrcNonTransformedElement_(false), eliminateRedondantSrc_(true), isDistributedComputed_(false) { } void CGenericAlgorithmTransformation::updateData(CArray& dataOut) { } void CGenericAlgorithmTransformation::apply(const std::vector >& localIndex, const double* dataInput, CArray& dataOut, std::vector& flagInitial, bool ignoreMissingValue, bool firstPass ) TRY { int nbLocalIndex = localIndex.size(); double defaultValue = std::numeric_limits::quiet_NaN(); if (ignoreMissingValue) { if (firstPass) dataOut=defaultValue ; for (int idx = 0; idx < nbLocalIndex; ++idx) { if (! NumTraits::isNan(*(dataInput + idx))) { if (flagInitial[localIndex[idx].first]) dataOut(localIndex[idx].first) = *(dataInput + idx) * localIndex[idx].second; else dataOut(localIndex[idx].first) += *(dataInput + idx) * localIndex[idx].second; flagInitial[localIndex[idx].first] = false; // Reset flag to indicate not all data source are nan } } } else { for (int idx = 0; idx < nbLocalIndex; ++idx) { dataOut(localIndex[idx].first) += *(dataInput + idx) * localIndex[idx].second; } } } CATCH /*! Compute index mapping between element source and element destination with an auxiliary inputs which determine position of each mapped index in global index of grid destination. \param [in] dataAuxInputs auxiliary inputs */ void CGenericAlgorithmTransformation::computeIndexSourceMapping(const std::vector* >& dataAuxInputs) TRY { computeIndexSourceMapping_(dataAuxInputs); } CATCH std::vector CGenericAlgorithmTransformation::getIdAuxInputs() TRY { return idAuxInputs_; } CATCH CGenericAlgorithmTransformation::AlgoTransType CGenericAlgorithmTransformation::type() TRY { return type_; } CATCH }