- Timestamp:
- 01/03/21 18:00:43 (3 years ago)
- Location:
- XIOS/dev/dev_ym/XIOS_COUPLING/src
- Files:
-
- 8 added
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/element.hpp
r1930 r1999 32 32 void recvFromClient(CEventServer& event) ; 33 33 size_t getGlobalSize(void) { return globalSize_;} 34 34 std::map<int, CArray<size_t,1>>& getGlobalIndex(void) { return globalIndex_;} 35 35 36 CDistributedView* getView(CElementView::type type) 36 37 { -
XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_local_view.hpp
r1930 r1999 19 19 CGridLocalView(CGridLocalElements* parent, CElementView::type type) ; 20 20 std::vector<CLocalView*>& getViews(void) {return views_ ;} 21 CLocalView* getView(int i) {return views_[i] ;} 21 22 int getSize() { return size_ ;} 22 23 } ; -
XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_remote_connector.cpp
r1984 r1999 11 11 : srcView_(srcView), dstView_(dstView), localComm_(localComm), remoteSize_(remoteSize) 12 12 {} 13 14 CGridRemoteConnector::CGridRemoteConnector(vector<CLocalView*>& srcView, vector<CLocalView*>& dstView, MPI_Comm localComm, int remoteSize) 15 : srcView_(srcView), localComm_(localComm), remoteSize_(remoteSize) 16 { 17 for(auto& it : dstView) dstView_.push_back((CDistributedView*) it) ; 18 } 13 19 14 20 void CGridRemoteConnector::computeConnector(void) -
XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_remote_connector.hpp
r1938 r1999 19 19 20 20 CGridRemoteConnector(vector<CLocalView*>& srcView, vector<CDistributedView*>& dstView, MPI_Comm localComm, int remoteSize) ; 21 CGridRemoteConnector(vector<CLocalView*>& srcView, vector<CLocalView*>& dstView, MPI_Comm localComm, int remoteSize) ; 21 22 void computeConnector(void) ; 22 23 void computeGenericMethod(void) ; -
XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/transfer_transform_connector.hpp
r1996 r1999 47 47 if (mask_[i]) 48 48 { 49 for(int l=0; l<sizeT; l++) out[l] += in[connector_[k]*sizeT+l] ;49 for(int l=0; l<sizeT; l++) out[l] = in[connector_[k]*sizeT+l] ; 50 50 k++ ; 51 51 } -
XIOS/dev/dev_ym/XIOS_COUPLING/src/filter/transform_filter.cpp
r1984 r1999 1 1 #include "transform_filter.hpp" 2 #include "grid_algorithm.hpp" 2 3 3 4 namespace xios 4 5 { 5 6 6 CTransformFilter::CTransformFilter( CGarbageCollector& gc, CGenericAlgorithmTransformation* algo, int dimBefore, int dimAfter, 7 bool detectMissingValues, double defaultValue) 8 : CFilter(gc, 1, this), algorithm_(algo), dimBefore_(dimBefore), dimAfter_(dimAfter), 7 CTransformFilter::CTransformFilter( CGarbageCollector& gc, CGridAlgorithm* algo, bool detectMissingValues, double defaultValue) 8 : CFilter(gc, 1, this), algorithm_(algo), 9 9 detectMissingValues_(detectMissingValues), defaultValue_(defaultValue) 10 10 { … … 20 20 packet->status = data[0]->status; 21 21 22 if (packet->status == CDataPacket::NO_ERROR) algorithm_->apply(d imBefore_, dimAfter_, data[0]->data, packet->data);22 if (packet->status == CDataPacket::NO_ERROR) algorithm_->apply(data[0]->data, packet->data); 23 23 return packet; 24 24 } -
XIOS/dev/dev_ym/XIOS_COUPLING/src/filter/transform_filter.hpp
r1984 r1999 3 3 4 4 #include "filter.hpp" 5 #include "g eneric_algorithm_transformation.hpp"5 #include "grid_algorithm.hpp" 6 6 7 7 namespace xios … … 15 15 public: 16 16 17 CTransformFilter(CGarbageCollector& gc, CGenericAlgorithmTransformation* algo, int dimBefore, int dimAfter, 18 bool detectMissingValues, double defaultValue) ; 17 CTransformFilter(CGarbageCollector& gc, CGridAlgorithm* algo, bool detectMissingValues, double defaultValue) ; 19 18 20 19 protected: … … 27 26 private : 28 27 29 CGenericAlgorithmTransformation* algorithm_ ; 30 int dimBefore_ ; 31 int dimAfter_ ; 28 CGridAlgorithm* algorithm_ ; 32 29 bool detectMissingValues_ ; 33 30 bool defaultValue_ ; -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.cpp
r1988 r1999 850 850 CGrid* newGrid ; 851 851 std::pair<std::shared_ptr<CFilter>, std::shared_ptr<CFilter> > filters = grid_->buildTransformationGraph(gc, true, nullptr, detectMissingValues, defaultValue, newGrid) ; 852 newGrid->duplicateAttributes(grid_) ; // for grid attributes (mask) 852 853 grid_ = newGrid ; 853 854 grid_ref=grid_->getId() ; // for server -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp
r1994 r1999 27 27 #include "grid_transformation_factory_impl.hpp" 28 28 #include "transform_filter.hpp" 29 #include "grid_algorithm.hpp" 29 30 30 31 … … 241 242 for (int idx = 0; idx < order_.size(); ++idx) axis_domain_order(idx)=order_[idx]; 242 243 CDomain* domain = vDomainGroup_->createChild(id); 244 isDomListSet=false ; 243 245 computeElements(); 244 246 return domain ; … … 253 255 for (int idx = 0; idx < order_.size(); ++idx) axis_domain_order(idx)=order_[idx]; 254 256 CAxis* axis=vAxisGroup_->createChild(id); 257 isAxisListSet=false ; 255 258 computeElements(); 256 259 return axis ; … … 265 268 for (int idx = 0; idx < order_.size(); ++idx) axis_domain_order(idx)=order_[idx]; 266 269 CScalar* scalar = vScalarGroup_->createChild(id); 270 isScalarListSet=false ; 267 271 computeElements(); 268 272 return scalar; … … 1922 1926 else 1923 1927 { 1924 newGrid = CGrid::create(newId) ; // give it an id later ??1928 newGrid = CGrid::create(newId) ; 1925 1929 isNewGrid = true ; 1926 1930 } … … 1930 1934 bool hasRemainTransform=false ; 1931 1935 CGenericAlgorithmTransformation* algo ; 1932 int dimBefore=1 ; 1933 int dimAfter=1 ; 1936 int pos ; 1934 1937 1935 1938 for(int i=0 ; i<elements_.size(); i++) … … 1958 1961 if (hasTransform && !hadTransform) 1959 1962 { 1963 pos=i ; 1960 1964 EElement dstElementType=transformationPath.getNextElementType() ; 1961 1965 string dstElementId=transformationPath.getNextElementId() ; … … 2075 2079 domain->checkAttributes() ; 2076 2080 2077 if (hadTransform) dimBefore*=domain->getLocalView(CElementView::WORKFLOW)->getLocalSize() ;2078 else dimAfter*=domain->getLocalView(CElementView::WORKFLOW)->getLocalSize() ;2079 2081 if (isNewGrid) newGrid->addDomain(srcElementId) ; 2080 2082 } … … 2091 2093 axis->checkAttributes() ; 2092 2094 2093 if (hadTransform) dimBefore*=axis->getLocalView(CElementView::WORKFLOW)->getLocalSize() ;2094 else dimAfter*=axis->getLocalView(CElementView::WORKFLOW)->getLocalSize() ;2095 2095 if (isNewGrid) newGrid->addAxis(srcElementId) ; 2096 2096 } … … 2107 2107 scalar->checkAttributes() ; 2108 2108 2109 if (hadTransform) dimBefore*=scalar->getLocalView(CElementView::WORKFLOW)->getLocalSize() ;2110 else dimAfter*=scalar->getLocalView(CElementView::WORKFLOW)->getLocalSize() ;2111 2109 if (isNewGrid) newGrid->addScalar(srcElementId) ; 2112 2110 } … … 2121 2119 if (!isSource) 2122 2120 { 2123 shared_ptr<CTransformFilter> transformFilter = shared_ptr<CTransformFilter>(new CTransformFilter(gc, algo, dimBefore, dimAfter, detectMissingValues, defaultValue)) ; 2121 CGridAlgorithm* gridAlgorithm ; 2122 if (isNewGrid) 2123 { 2124 gridAlgorithm = algo->createGridAlgorithm(gridSrc, newGrid, pos) ; 2125 newGrid->setGridAlgorithm(gridAlgorithm); 2126 } 2127 else gridAlgorithm = newGrid->getGridAlgorithm() ; 2128 2129 shared_ptr<CTransformFilter> transformFilter = shared_ptr<CTransformFilter>(new CTransformFilter(gc, gridAlgorithm, detectMissingValues, defaultValue)) ; 2124 2130 outputFilter->connectOutput(transformFilter,0) ; 2125 2131 outputFilter = transformFilter ; … … 2129 2135 { 2130 2136 gridSrc=newGrid ; 2131 pair<shared_ptr<CFilter>, shared_ptr<CFilter> > filters = gridSrc->buildTransformationGraph(gc, isSource, gridSrc, detectMissingValues, defaultValue, newGrid) ;2137 pair<shared_ptr<CFilter>, shared_ptr<CFilter> > filters = this->buildTransformationGraph(gc, isSource, gridSrc, detectMissingValues, defaultValue, newGrid) ; 2132 2138 outputFilter->connectOutput(filters.first,0) ; 2133 2139 outputFilter=filters.second ; -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.hpp
r1988 r1999 22 22 #include "transformation_path.hpp" 23 23 #include "filter.hpp" 24 #include "grid_algorithm.hpp" 24 25 25 26 … … 239 240 double defaultValue, CGrid*& newGrid) ; 240 241 private: 242 CGridAlgorithm* gridAlgorithm_ = nullptr ; 243 public: 244 void setGridAlgorithm(CGridAlgorithm* gridAlgorithm) {gridAlgorithm_ = gridAlgorithm;} 245 CGridAlgorithm* getGridAlgorithm(void) { return gridAlgorithm_ ;} 246 private: 241 247 bool isTransformed_, isGenerated_; 242 248 CGridTransformation* transformations_; -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/Functions/reduction_types.hpp
r979 r1999 10 10 #define __XIOS_REDUCTION_TYPES_HPP__ 11 11 12 namespace xios { 12 namespace xios 13 { 13 14 14 typedef enum reduction_al ogirthm_type15 typedef enum reduction_algurithm_type 15 16 { 16 17 TRANS_REDUCE_SUM = 0, … … 21 22 } EReductionType; 22 23 24 enum class EReduction 25 { 26 sum, min, max, extract, average 27 } ; 23 28 } 24 29 #endif // __XIOS_REDUCTION_TYPES_HPP__ -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/algorithm_transformation_transfer.cpp
r1997 r1999 32 32 } 33 33 34 void CAlgorithmTransformationTransfer::computeRecvElement(CLocalView* srcView, CLocalView* dstView) 35 { 36 set<size_t> srcIndex ; 37 for(auto& it : transformationMapping_) srcIndex.insert(it.second) ; 38 39 CArray<size_t,1> srcArrayIndex(srcIndex.size()) ; 40 int i=0 ; 41 for(size_t index : srcIndex) { srcArrayIndex(i) = index ; i++ ;} 42 recvElement_ = new CLocalElement(CContext::getCurrent()->getIntraCommRank(), srcView->getGlobalSize(), srcArrayIndex) ; 43 recvElement_->addFullView() ; 44 } 45 34 46 } -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/algorithm_transformation_transfer.hpp
r1997 r1999 16 16 virtual ~CAlgorithmTransformationTransfer() {}; 17 17 virtual void apply(int dimBefore, int dimAfter, const CArray<double,1>& dataIn, CArray<double,1>& dataOut); 18 void computeRecvElement(CLocalView* srcView, CLocalView* dstView) ; 18 19 19 20 protected: -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/algorithm_transformation_weight.cpp
r1997 r1999 8 8 void CAlgorithmTransformationWeight::computeAlgorithm(CLocalView* srcView, CLocalView* dstView) 9 9 { 10 auto& srcMap = transformationMapping_ ; 11 set<size_t> srcIndex ; 12 for(auto& it : srcMap) 13 for(size_t index : it.second) srcIndex.insert(index) ; 14 15 CArray<size_t,1> srcArrayIndex(srcIndex.size()) ; 16 int i=0 ; 17 for(size_t index : srcIndex) { srcArrayIndex(i) = index ; i++ ;} 18 CLocalElement recvElement(CContext::getCurrent()->getIntraCommRank(), srcView->getGlobalSize(), srcArrayIndex) ; 19 recvElement.addFullView() ; 20 21 transformConnector_ = new CTransformConnector(srcView, recvElement.getView(CElementView::FULL), CContext::getCurrent()->getIntraComm()) ; 22 transformConnector_->computeConnector() ; 23 weightTransformConnector_ = new CWeightTransformConnector( recvElement.getView(CElementView::FULL), dstView, transformationMapping_, transformationWeight_) ; 10 this->computeRecvElement(srcView, dstView) ; 11 weightTransformConnector_ = new CWeightTransformConnector( recvElement_->getView(CElementView::FULL), dstView, transformationMapping_, transformationWeight_) ; 24 12 } 25 13 … … 32 20 } 33 21 22 void CAlgorithmTransformationWeight::computeRecvElement(CLocalView* srcView, CLocalView* dstView) 23 { 24 auto& srcMap = transformationMapping_ ; 25 set<size_t> srcIndex ; 26 for(auto& it : srcMap) 27 for(size_t index : it.second) srcIndex.insert(index) ; 28 29 CArray<size_t,1> srcArrayIndex(srcIndex.size()) ; 30 int i=0 ; 31 for(size_t index : srcIndex) { srcArrayIndex(i) = index ; i++ ;} 32 recvElement_ = new CLocalElement(CContext::getCurrent()->getIntraCommRank(), srcView->getGlobalSize(), srcArrayIndex) ; 33 recvElement_->addFullView() ; 34 } 34 35 } -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/algorithm_transformation_weight.hpp
r1997 r1999 18 18 virtual ~CAlgorithmTransformationWeight() {}; 19 19 virtual void apply(int dimBefore, int dimAfter, const CArray<double,1>& dataIn, CArray<double,1>& dataOut); 20 20 void computeRecvElement(CLocalView* srcView, CLocalView* dstView); 21 21 protected: 22 22 virtual void computeAlgorithm(CLocalView* srcView, CLocalView* dstView) ; -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_duplicate_scalar.cpp
r1998 r1999 47 47 { 48 48 49 CArray<int,1>& axisDstIndex = axisDest _->index;49 CArray<int,1>& axisDstIndex = axisDestination->index; 50 50 51 51 int nbAxisIdx = axisDstIndex.numElements(); -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_duplicate_scalar.hpp
r1998 r1999 36 36 private: 37 37 38 CAxis* axisSrc_;39 CAxis* axisDest_;40 41 38 static CGenericAlgorithmTransformation* create(bool isSource, CGrid* gridDst, CGrid* gridSrc, 42 39 CTransformation<CAxis>* transformation, -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_extract_domain.cpp
r1988 r1999 48 48 49 49 CAxisAlgorithmExtractDomain::CAxisAlgorithmExtractDomain(bool isSource, CAxis* axisDestination, CDomain* domainSource, CExtractDomainToAxis* algo) 50 : CA xisAlgorithmTransformation(isSource, axisDestination, domainSource), pos_(-1), reduction_(0)50 : CAlgorithmTransformationTransfer(isSource), pos_(-1), axisDest_(axisDestination), domainSrc_(domainSource) 51 51 TRY 52 52 { … … 67 67 68 68 pos_ = algo->position; 69 reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]);70 }71 CATCH72 69 73 void CAxisAlgorithmExtractDomain::apply(const std::vector<std::pair<int,double> >& localIndex, 74 const double* dataInput, 75 CArray<double,1>& dataOut, 76 std::vector<bool>& flagInitial, 77 bool ignoreMissingValue, bool firstPass) 78 TRY 79 { 80 reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 81 } 82 CATCH 83 84 CAxisAlgorithmExtractDomain::~CAxisAlgorithmExtractDomain() 85 TRY 86 { 87 if (0 != reduction_) delete reduction_; 88 } 89 CATCH 90 91 void CAxisAlgorithmExtractDomain::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 92 TRY 93 { 94 this->transformationMapping_.resize(1); 95 this->transformationWeight_.resize(1); 96 97 TransformationIndexMap& transMap = this->transformationMapping_[0]; 98 TransformationWeightMap& transWeight = this->transformationWeight_[0]; 70 auto& transMap = this->transformationMapping_; 99 71 100 72 CArray<int,1>& axisDstIndex = axisDest_->index; … … 106 78 { 107 79 int globalAxisIdx = axisDstIndex(idxAxis); 108 transMap[globalAxisIdx].resize(1); 109 transWeight[globalAxisIdx].resize(1); 110 transMap[globalAxisIdx][0] = globalAxisIdx * ni_glo + pos_; 111 transWeight[globalAxisIdx][0] = 1.0; 112 80 transMap[globalAxisIdx] = globalAxisIdx * ni_glo + pos_; 113 81 } 114 82 } … … 119 87 { 120 88 int globalAxisIdx = axisDstIndex(idxAxis); 121 transMap[globalAxisIdx].resize(1); 122 transWeight[globalAxisIdx].resize(1); 123 transMap[globalAxisIdx][0] = globalAxisIdx + ni_glo * pos_; 124 transWeight[globalAxisIdx][0] = 1.0; 89 transMap[globalAxisIdx] = globalAxisIdx + ni_glo * pos_; 125 90 } 126 91 } 127 92 else 128 93 {} 94 95 axisDestination->checkAttributes() ; 96 this->computeAlgorithm(domainSource->getLocalView(CElementView::WORKFLOW), axisDestination->getLocalView(CElementView::WORKFLOW)) ; 129 97 } 130 98 CATCH 99 100 101 CAxisAlgorithmExtractDomain::~CAxisAlgorithmExtractDomain() 102 TRY 103 { 131 104 } 105 CATCH 106 107 } -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_extract_domain.hpp
r1988 r1999 10 10 #define __XIOS_AXIS_ALGORITHM_EXTRACT_DOMAIN_HPP__ 11 11 12 #include "a xis_algorithm_transformation.hpp"12 #include "algorithm_transformation_transfer.hpp" 13 13 #include "transformation.hpp" 14 14 … … 25 25 Extract a domain to an axis 26 26 */ 27 class CAxisAlgorithmExtractDomain : public CA xisAlgorithmTransformation27 class CAxisAlgorithmExtractDomain : public CAlgorithmTransformationTransfer 28 28 { 29 29 public: 30 30 CAxisAlgorithmExtractDomain(bool isSource, CAxis* axisDestination, CDomain* domainSource, CExtractDomainToAxis* algo); 31 31 32 virtual void apply(const std::vector<std::pair<int,double> >& localIndex, 33 const double* dataInput, 34 CArray<double,1>& dataOut, 35 std::vector<bool>& flagInitial, 36 bool ignoreMissingValue, bool firstPass); 37 38 virtual ~CAxisAlgorithmExtractDomain(); 32 virtual ~CAxisAlgorithmExtractDomain(); 39 33 40 34 static bool registerTrans(); … … 48 42 ExtractDirection dir_; 49 43 int pos_; //! Position to extract 50 protected: 51 void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs); 52 53 protected: 54 CReductionAlgorithm* reduction_; 55 44 56 45 private: 46 CDomain* domainSrc_; 47 CAxis* axisDest_ ; 57 48 static CGenericAlgorithmTransformation* create(bool isSource, CGrid* gridDst, CGrid* gridSrc, 58 49 CTransformation<CAxis>* transformation, -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_inverse.cpp
r1988 r1999 49 49 50 50 CAxisAlgorithmInverse::CAxisAlgorithmInverse(bool isSource, CAxis* axisDestination, CAxis* axisSource, CInverseAxis* inverseAxis) 51 : CA xisAlgorithmTransformation(isSource, axisDestination,axisSource)51 : CAlgorithmTransformationTransfer(isSource), axisDest_(axisDestination), axisSrc_(axisSource) 52 52 TRY 53 53 { … … 59 59 << "Size of axis destination " <<axisDestination->getId() << " is " << axisDestination->n_glo.getValue()); 60 60 } 61 } 62 CATCH 63 64 void CAxisAlgorithmInverse::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 65 TRY 66 { 67 this->transformationMapping_.resize(1); 68 this->transformationWeight_.resize(1); 69 70 TransformationIndexMap& transMap = this->transformationMapping_[0]; 71 TransformationWeightMap& transWeight = this->transformationWeight_[0]; 72 73 int globalIndexSize = axisDestGlobalIndex_.size(); 61 62 auto& transMap = this->transformationMapping_; 63 64 int globalIndexSize = axisDestination->index.size(); 74 65 for (int idx = 0; idx < globalIndexSize; ++idx) 75 66 { 76 transMap[axisDestGlobalIndex_[idx]].push_back(axisDestGlobalSize_-axisDestGlobalIndex_[idx]-1); 77 transWeight[axisDestGlobalIndex_[idx]].push_back(1.0); 67 transMap[axisDestination->index(idx)] = globalIndexSize-axisDestination->index(idx)-1; 78 68 } 79 69 … … 88 78 } 89 79 } 90 } 91 CATCH 80 81 axisDestination->checkAttributes() ; 82 this->computeAlgorithm(axisSource->getLocalView(CElementView::WORKFLOW), axisDestination->getLocalView(CElementView::WORKFLOW)) ; 83 84 } 85 CATCH 86 92 87 93 88 /*! … … 118 113 typedef std::unordered_map<size_t, std::vector<double> > GlobalIndexMapFromSrcToDest; 119 114 GlobalIndexMapFromSrcToDest globalIndexMapFromSrcToDest; 120 TransformationIndexMap& transMap = this->transformationMapping_[0]; 121 TransformationIndexMap::const_iterator itb = transMap.begin(), ite = transMap.end(), it; 115 auto& transMap = this->transformationMapping_; 122 116 CArray<size_t,1> globalSrcIndex(transMap.size()); 123 117 int localIndex = 0; 124 for ( it = itb; it != ite; ++it)125 { 126 size_t srcIndex = it->second [0];118 for (auto it = transMap.begin(); it != transMap.end(); ++it) 119 { 120 size_t srcIndex = it->second; 127 121 globalIndexMapFromSrcToDest[srcIndex].resize(1); 128 122 globalIndexMapFromSrcToDest[srcIndex][0] = it->first; -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_inverse.hpp
r1988 r1999 10 10 #define __XIOS_AXIS_ALGORITHM_INVERSE_HPP__ 11 11 12 #include "a xis_algorithm_transformation.hpp"12 #include "algorithm_transformation_transfer.hpp" 13 13 #include "transformation.hpp" 14 14 … … 22 22 Inversing an axis 23 23 */ 24 class CAxisAlgorithmInverse : public CA xisAlgorithmTransformation24 class CAxisAlgorithmInverse : public CAlgorithmTransformationTransfer 25 25 { 26 26 public: … … 31 31 static bool registerTrans(); 32 32 33 protected:34 void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs);35 33 36 34 private: 35 CAxis* axisSrc_; 36 CAxis* axisDest_; 37 37 void updateAxisValue(); 38 38 -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_reduce_axis.cpp
r1988 r1999 12 12 #include "grid.hpp" 13 13 #include "grid_transformation_factory_impl.hpp" 14 #include "reduction.hpp" 14 15 15 16 16 namespace xios { … … 47 47 48 48 CAxisAlgorithmReduceAxis::CAxisAlgorithmReduceAxis(bool isSource, CAxis* axisDestination, CAxis* axisSource, CReduceAxisToAxis* algo) 49 : CA xisAlgorithmTransformation(isSource, axisDestination, axisSource), reduction_(0)49 : CAlgorithmTransformationReduce(isSource) 50 50 TRY 51 51 { 52 52 eliminateRedondantSrc_= false ; 53 53 algo->checkValid(axisDestination, axisSource); 54 StdString op; 54 55 55 switch (algo->operation) 56 56 { 57 57 case CReduceAxisToAxis::operation_attr::sum: 58 op = "sum";58 operator_ = EReduction::sum; 59 59 break; 60 60 case CReduceAxisToAxis::operation_attr::min: 61 op = "min";61 operator_ = EReduction::min; 62 62 break; 63 63 case CReduceAxisToAxis::operation_attr::max: 64 op = "max";64 operator_ = EReduction::max; 65 65 break; 66 66 case CReduceAxisToAxis::operation_attr::average: 67 op = "average";67 operator_ = EReduction::average; 68 68 break; 69 69 default: … … 73 73 << "Axis destination " << axisDestination->getId()); 74 74 75 TransformationIndexMap& transMap = this->transformationMapping_; 76 CArray<int,1>& axisDstIndex = axisDestination->index; 77 int nbAxisIdx = axisDstIndex.numElements(); 78 for (int idxAxis = 0; idxAxis < nbAxisIdx; ++idxAxis) 79 { 80 int globalAxisIdx = axisDstIndex(idxAxis); 81 transMap[globalAxisIdx].resize(1); 82 transMap[globalAxisIdx][0]=globalAxisIdx ; 83 } 84 75 85 } 76 77 reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 86 87 axisDestination->checkAttributes() ; 88 this->computeAlgorithm(axisSource->getLocalView(CElementView::WORKFLOW), axisDestination->getLocalView(CElementView::WORKFLOW)) ; 78 89 } 79 90 CATCH 80 91 81 void CAxisAlgorithmReduceAxis::apply(const std::vector<std::pair<int,double> >& localIndex,82 const double* dataInput,83 CArray<double,1>& dataOut,84 std::vector<bool>& flagInitial,85 bool ignoreMissingValue, bool firstPass)86 TRY87 {88 reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass);89 }90 CATCH91 92 void CAxisAlgorithmReduceAxis::updateData(CArray<double,1>& dataOut)93 TRY94 {95 reduction_->updateData(dataOut);96 }97 CATCH98 92 99 93 CAxisAlgorithmReduceAxis::~CAxisAlgorithmReduceAxis() 100 94 TRY 101 95 { 102 if (0 != reduction_) delete reduction_;96 103 97 } 104 98 CATCH 105 99 106 void CAxisAlgorithmReduceAxis::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs)107 TRY108 {109 this->transformationMapping_.resize(1);110 this->transformationWeight_.resize(1);111 112 TransformationIndexMap& transMap = this->transformationMapping_[0];113 TransformationWeightMap& transWeight = this->transformationWeight_[0];114 CArray<int,1>& axisDstIndex = axisDest_->index;115 int nbAxisIdx = axisDstIndex.numElements();116 for (int idxAxis = 0; idxAxis < nbAxisIdx; ++idxAxis)117 {118 int globalAxisIdx = axisDstIndex(idxAxis);119 transMap[globalAxisIdx].resize(1);120 transWeight[globalAxisIdx].resize(1);121 transMap[globalAxisIdx][0]=globalAxisIdx ;122 transWeight[globalAxisIdx][0] = 1.0 ;123 }124 }125 CATCH126 100 127 101 } -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_reduce_axis.hpp
r1988 r1999 10 10 #define __XIOS_AXIS_ALGORITHM_REDUCE_AXIS_HPP__ 11 11 12 #include "a xis_algorithm_transformation.hpp"12 #include "algorithm_transformation_reduce.hpp" 13 13 #include "transformation.hpp" 14 14 … … 23 23 Reduce a axis to an axis 24 24 */ 25 class CAxisAlgorithmReduceAxis : public CA xisAlgorithmTransformation25 class CAxisAlgorithmReduceAxis : public CAlgorithmTransformationReduce 26 26 { 27 27 public: 28 28 CAxisAlgorithmReduceAxis(bool isSource, CAxis* axisDestination, CAxis* axisSource, CReduceAxisToAxis* algo); 29 29 30 virtual void apply(const std::vector<std::pair<int,double> >& localIndex,31 const double* dataInput,32 CArray<double,1>& dataOut,33 std::vector<bool>& flagInitial,34 bool ignoreMissingValue, bool firstPass);35 36 virtual void updateData(CArray<double,1>& dataOut);37 30 38 31 virtual ~CAxisAlgorithmReduceAxis(); 39 32 40 33 static bool registerTrans(); 41 protected:42 34 43 protected:44 void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs);45 46 protected:47 CReductionAlgorithm* reduction_;48 49 35 private: 50 36 static CGenericAlgorithmTransformation* create(bool isSource, CGrid* gridDst, CGrid* gridSrc, -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_reduce_domain.cpp
r1988 r1999 48 48 49 49 CAxisAlgorithmReduceDomain::CAxisAlgorithmReduceDomain(bool isSource, CAxis* axisDestination, CDomain* domainSource, CReduceDomainToAxis* algo) 50 : CA xisAlgorithmTransformation(isSource, axisDestination, domainSource), reduction_(0)50 : CAlgorithmTransformationReduce(isSource), domainSrc_(domainSource), axisDest_(axisDestination) 51 51 TRY 52 52 { 53 53 algo->checkValid(axisDestination, domainSource); 54 StdString op;55 54 switch (algo->operation) 56 55 { 57 56 case CReduceDomainToAxis::operation_attr::sum: 58 op = "sum";57 operator_ = EReduction::sum; 59 58 break; 60 59 case CReduceDomainToAxis::operation_attr::min: 61 op = "min";60 operator_ = EReduction::min; 62 61 break; 63 62 case CReduceDomainToAxis::operation_attr::max: 64 op = "max";63 operator_ = EReduction::max; 65 64 break; 66 65 case CReduceDomainToAxis::operation_attr::average: 67 op = "average";66 operator_ = EReduction::average; 68 67 break; 69 68 default: … … 76 75 77 76 dir_ = (CReduceDomainToAxis::direction_attr::iDir == algo->direction) ? iDir : jDir; 78 reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 79 local = algo->local ; 80 } 81 CATCH 77 bool local = algo->local ; 82 78 83 void CAxisAlgorithmReduceDomain::apply(const std::vector<std::pair<int,double> >& localIndex, 84 const double* dataInput, 85 CArray<double,1>& dataOut, 86 std::vector<bool>& flagInitial, 87 bool ignoreMissingValue, bool firstPass) 88 TRY 89 { 90 reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 91 } 92 CATCH 93 94 void CAxisAlgorithmReduceDomain::updateData(CArray<double,1>& dataOut) 95 TRY 96 { 97 reduction_->updateData(dataOut); 98 } 99 CATCH 100 101 CAxisAlgorithmReduceDomain::~CAxisAlgorithmReduceDomain() 102 TRY 103 { 104 if (0 != reduction_) delete reduction_; 105 } 106 CATCH 107 108 void CAxisAlgorithmReduceDomain::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 109 TRY 110 { 111 this->transformationMapping_.resize(1); 112 this->transformationWeight_.resize(1); 113 114 TransformationIndexMap& transMap = this->transformationMapping_[0]; 115 TransformationWeightMap& transWeight = this->transformationWeight_[0]; 79 TransformationIndexMap& transMap = transformationMapping_; 116 80 117 81 CArray<int,1>& axisDstIndex = axisDest_->index; … … 131 95 { 132 96 transMap[j_index(idxDomain)].push_back(j_index(idxDomain)* ni_glo + i_index(idxDomain)); 133 transWeight[j_index(idxDomain)].push_back(1.0) ;134 97 } 135 98 } … … 142 105 int globalAxisIdx = axisDstIndex(idxAxis); 143 106 transMap[globalAxisIdx].resize(ni_glo); 144 transWeight[globalAxisIdx].resize(ni_glo);145 107 for (int idx = 0; idx < ni_glo; ++idx) 146 108 { 147 109 transMap[globalAxisIdx][idx] = globalAxisIdx * ni_glo + idx; 148 transWeight[globalAxisIdx][idx] = 1.0;149 110 } 150 111 } … … 166 127 { 167 128 transMap[i_index(idxDomain)].push_back(j_index(idxDomain)* ni_glo + i_index(idxDomain)); 168 transWeight[i_index(idxDomain)].push_back(1.0) ;169 129 } 170 130 } … … 176 136 int globalAxisIdx = axisDstIndex(idxAxis); 177 137 transMap[globalAxisIdx].resize(nj_glo); 178 transWeight[globalAxisIdx].resize(nj_glo);179 138 for (int idx = 0; idx < nj_glo; ++idx) 180 139 { 181 140 transMap[globalAxisIdx][idx] = globalAxisIdx + ni_glo*idx; 182 transWeight[globalAxisIdx][idx] = 1.0;183 141 } 184 142 } … … 187 145 else 188 146 {} 147 148 axisDestination->checkAttributes() ; 149 this->computeAlgorithm(domainSource->getLocalView(CElementView::WORKFLOW), axisDestination->getLocalView(CElementView::WORKFLOW)) ; 150 189 151 } 190 152 CATCH 191 153 154 155 CAxisAlgorithmReduceDomain::~CAxisAlgorithmReduceDomain() 156 TRY 157 { 192 158 } 159 CATCH 160 161 162 } -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_reduce_domain.hpp
r1988 r1999 10 10 #define __XIOS_AXIS_ALGORITHM_REDUCE_DOMAIN_HPP__ 11 11 12 #include "a xis_algorithm_transformation.hpp"12 #include "algorithm_transformation_reduce.hpp" 13 13 #include "transformation.hpp" 14 14 … … 24 24 Reduce a domain to an axis 25 25 */ 26 class CAxisAlgorithmReduceDomain : public CA xisAlgorithmTransformation26 class CAxisAlgorithmReduceDomain : public CAlgorithmTransformationReduce 27 27 { 28 28 public: 29 29 CAxisAlgorithmReduceDomain(bool isSource, CAxis* axisDestination, CDomain* domainSource, CReduceDomainToAxis* algo); 30 31 virtual void 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 37 virtual void updateData(CArray<double,1>& dataOut);38 30 39 31 virtual ~CAxisAlgorithmReduceDomain(); … … 50 42 bool local ; 51 43 52 protected: 53 void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs); 54 55 protected: 56 CReductionAlgorithm* reduction_; 44 CDomain* domainSrc_ ; 45 CAxis* axisDest_ ; 57 46 58 47 private: -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/generic_algorithm_transformation.cpp
r1988 r1999 1143 1143 /////////////////////////////////////////////////////////////// 1144 1144 1145 CGridAlgorithm* CGenericAlgorithmTransformation::createGridAlgorithm(CGrid* gridSrc, CGrid* gridDst, int pos) 1146 { 1147 return new CGridAlgorithm(gridSrc, gridDst, pos, this) ; 1148 } 1145 1149 1146 1150 1147 1151 void CGenericAlgorithmTransformation::computeAlgorithm(CLocalView* srcView, CLocalView* dstView) 1152 { 1153 1154 this->computeRecvElement(srcView, dstView) ; 1155 /* 1156 transformConnector_ = new CTransformConnector(srcView, recvElement.getView(CElementView::FULL), CContext::getCurrent()->getIntraComm()) ; 1157 transformConnector_->computeConnector() ; 1158 */ 1159 weightTransformConnector_ = new CWeightTransformConnector(recvElement_->getView(CElementView::FULL), dstView, transformationMapping_[0], transformationWeight_[0]) ; 1160 } 1161 1162 void CGenericAlgorithmTransformation::computeRecvElement(CLocalView* srcView, CLocalView* dstView) 1148 1163 { 1149 1164 auto& srcMap = transformationMapping_[0] ; … … 1155 1170 int i=0 ; 1156 1171 for(size_t index : srcIndex) { srcArrayIndex(i) = index ; i++ ;} 1157 CLocalElement recvElement(CContext::getCurrent()->getIntraCommRank(), srcView->getGlobalSize(), srcArrayIndex) ; 1158 recvElement.addFullView() ; 1159 1160 transformConnector_ = new CTransformConnector(srcView, recvElement.getView(CElementView::FULL), CContext::getCurrent()->getIntraComm()) ; 1161 transformConnector_->computeConnector() ; 1162 weightTransformConnector_ = new CWeightTransformConnector( recvElement.getView(CElementView::FULL), dstView, transformationMapping_[0], transformationWeight_[0]) ; 1163 } 1164 1172 recvElement_ = new CLocalElement(CContext::getCurrent()->getIntraCommRank(), srcView->getGlobalSize(), srcArrayIndex) ; 1173 recvElement_->addFullView() ; 1174 } 1165 1175 1166 1176 void CGenericAlgorithmTransformation::apply(int dimBefore, int dimAfter, const CArray<double,1>& dataIn, CArray<double,1>& dataOut) 1167 1177 { 1168 CArray<double,1> dataOutTmp ; 1169 transformConnector_->transfer(dimBefore, dimAfter, dataIn, dataOutTmp) ; 1170 weightTransformConnector_ -> transfer(dimBefore, dimAfter, dataOutTmp, dataOut) ; 1171 } 1172 1173 1174 1175 1176 1177 1178 } 1178 //CArray<double,1> dataOutTmp ; 1179 //transformConnector_->transfer(dimBefore, dimAfter, dataIn, dataOutTmp) ; 1180 weightTransformConnector_ -> transfer(dimBefore, dimAfter, dataIn, dataOut) ; 1181 } 1182 1183 } -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/generic_algorithm_transformation.hpp
r1998 r1999 24 24 class CAxis; 25 25 class CScalar; 26 class CGridAlgorithm ; 26 27 27 28 /*! … … 183 184 virtual void computeAlgorithm(CLocalView* srcView, CLocalView* dstView) ; 184 185 virtual void apply(int dimBefore, int dimAfter, const CArray<double,1>& dataIn, CArray<double,1>& dataOut); 185 186 virtual CGridAlgorithm* createGridAlgorithm(CGrid* gridSrc, CGrid* newGrid, int pos) ; 187 virtual void computeRecvElement(CLocalView* srcView, CLocalView* dstView) ; 188 protected : 189 190 CLocalElement* recvElement_=nullptr ; 191 public: 192 CLocalElement* getRecvElement(void) { return recvElement_ ;} 193 194 protected: 186 195 CTransformConnector* transformConnector_ ; 187 196 CWeightTransformConnector* weightTransformConnector_ ; -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/scalar_algorithm/scalar_algorithm_extract_axis.cpp
r1988 r1999 48 48 49 49 CScalarAlgorithmExtractAxis::CScalarAlgorithmExtractAxis(bool isSource, CScalar* scalarDestination, CAxis* axisSource, CExtractAxisToScalar* algo) 50 : C ScalarAlgorithmTransformation(isSource, scalarDestination, axisSource), reduction_(0)50 : CAlgorithmTransformationTransfer(isSource) 51 51 TRY 52 52 { 53 53 algo->checkValid(scalarDestination, axisSource); 54 StdString op = "extract";55 54 pos_ = algo->position; 56 reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 55 this->transformationMapping_[0]=pos_ ; 56 57 scalarDestination->checkAttributes() ; 58 this->computeAlgorithm(axisSource->getLocalView(CElementView::WORKFLOW), scalarDestination->getLocalView(CElementView::WORKFLOW)) ; 57 59 } 58 60 CATCH 59 61 60 void CScalarAlgorithmExtractAxis::apply(const std::vector<std::pair<int,double> >& localIndex,61 const double* dataInput,62 CArray<double,1>& dataOut,63 std::vector<bool>& flagInitial,64 bool ignoreMissingValue, bool firstPass)65 TRY66 {67 reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass);68 }69 CATCH70 62 71 CScalarAlgorithmExtractAxis::~CScalarAlgorithmExtractAxis()72 TRY73 {74 if (0 != reduction_) delete reduction_;75 }76 CATCH77 78 void CScalarAlgorithmExtractAxis::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs)79 TRY80 {81 this->transformationMapping_.resize(1);82 this->transformationWeight_.resize(1);83 84 TransformationIndexMap& transMap = this->transformationMapping_[0];85 TransformationWeightMap& transWeight = this->transformationWeight_[0];86 87 transMap[0].push_back(pos_);88 transWeight[0].push_back(1.0);89 }90 CATCH91 63 92 64 } -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/scalar_algorithm/scalar_algorithm_extract_axis.hpp
r1988 r1999 10 10 #define __XIOS_SCALAR_ALGORITHM_EXTRACT_AXIS_HPP__ 11 11 12 #include " scalar_algorithm_transformation.hpp"12 #include "algorithm_transformation_transfer.hpp" 13 13 #include "transformation.hpp" 14 14 … … 24 24 Extract a scalar from an axis 25 25 */ 26 class CScalarAlgorithmExtractAxis : public C ScalarAlgorithmTransformation26 class CScalarAlgorithmExtractAxis : public CAlgorithmTransformationTransfer 27 27 { 28 28 public: 29 29 CScalarAlgorithmExtractAxis(bool isSource, CScalar* scalarDestination, CAxis* axisSource, CExtractAxisToScalar* algo); 30 30 31 virtual void 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 37 virtual ~CScalarAlgorithmExtractAxis(); 31 32 virtual ~CScalarAlgorithmExtractAxis() {} ; 38 33 39 34 static bool registerTrans(); … … 41 36 protected: 42 37 int pos_; 43 44 protected:45 void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs);46 47 protected:48 CReductionAlgorithm* reduction_;49 38 50 39 private: -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/scalar_algorithm/scalar_algorithm_reduce_axis.cpp
r1988 r1999 49 49 50 50 CScalarAlgorithmReduceAxis::CScalarAlgorithmReduceAxis(bool isSource, CScalar* scalarDestination, CAxis* axisSource, CReduceAxisToScalar* algo) 51 : C ScalarAlgorithmTransformation(isSource, scalarDestination, axisSource),reduction_(0)51 : CAlgorithmTransformationReduce(isSource) 52 52 TRY 53 53 { … … 61 61 { 62 62 case CReduceAxisToScalar::operation_attr::sum: 63 op = "sum";63 operator_ = EReduction::sum; 64 64 break; 65 65 case CReduceAxisToScalar::operation_attr::min: 66 op = "min";66 operator_ = EReduction::min; 67 67 break; 68 68 case CReduceAxisToScalar::operation_attr::max: 69 op = "max";69 operator_ = EReduction::max; 70 70 break; 71 71 case CReduceAxisToScalar::operation_attr::average: 72 op = "average";72 operator_ = EReduction::average; 73 73 break; 74 74 default: … … 78 78 << "Scalar destination " << scalarDestination->getId()); 79 79 80 } 80 } 81 81 82 if (CReductionAlgorithm::ReductionOperations.end() == CReductionAlgorithm::ReductionOperations.find(op)) 83 ERROR("CScalarAlgorithmReduceAxis::CScalarAlgorithmReduceAxis(CAxis* axisDestination, CAxis* axisSource, CReduceAxisToScalar* algo)", 84 << "Operation '" << op << "' not found. Please make sure to use a supported one" 85 << "Axis source " <<axisSource->getId() << std::endl 86 << "Scalar destination " << scalarDestination->getId()); 82 int globalIndexSize = axisSource-> n_glo; 83 for (int idx = 0; idx < globalIndexSize; ++idx) transformationMapping_[0].push_back(idx); 87 84 88 reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 85 scalarDestination->checkAttributes() ; 86 this->computeAlgorithm(axisSource->getLocalView(CElementView::WORKFLOW), scalarDestination->getLocalView(CElementView::WORKFLOW)) ; 87 89 88 } 90 89 CATCH 91 90 92 void CScalarAlgorithmReduceAxis::apply(const std::vector<std::pair<int,double> >& localIndex, const double* dataInput, CArray<double,1>& dataOut,93 std::vector<bool>& flagInitial, bool ignoreMissingValue, bool firstPass)94 TRY95 {96 reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass);97 }98 CATCH99 100 void CScalarAlgorithmReduceAxis::updateData(CArray<double,1>& dataOut)101 TRY102 {103 reduction_->updateData(dataOut);104 }105 CATCH106 91 107 92 CScalarAlgorithmReduceAxis::~CScalarAlgorithmReduceAxis() 108 93 TRY 109 94 { 110 if (0 != reduction_) delete reduction_;111 }112 CATCH113 114 void CScalarAlgorithmReduceAxis::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs)115 TRY116 {117 this->transformationMapping_.resize(1);118 this->transformationWeight_.resize(1);119 120 TransformationIndexMap& transMap = this->transformationMapping_[0];121 TransformationWeightMap& transWeight = this->transformationWeight_[0];122 123 int globalIndexSize = axisSrc_-> n_glo;124 125 for (int idx = 0; idx < globalIndexSize; ++idx)126 {127 transMap[0].push_back(idx);128 transWeight[0].push_back(1.0);129 }130 95 } 131 96 CATCH -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/scalar_algorithm/scalar_algorithm_reduce_axis.hpp
r1988 r1999 10 10 #define __XIOS_SCALAR_ALGORITHM_REDUCE_AXIS_HPP__ 11 11 12 #include " scalar_algorithm_transformation.hpp"12 #include "algorithm_transformation_reduce.hpp" 13 13 #include "transformation.hpp" 14 14 … … 24 24 Reducing an axis to a scalar 25 25 */ 26 class CScalarAlgorithmReduceAxis : public C ScalarAlgorithmTransformation26 class CScalarAlgorithmReduceAxis : public CAlgorithmTransformationReduce 27 27 { 28 28 public: 29 29 CScalarAlgorithmReduceAxis(bool isSource, CScalar* scalarDestination, CAxis* axisSource, CReduceAxisToScalar* algo); 30 30 31 virtual void 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 37 virtual void updateData(CArray<double,1>& dataOut);38 31 39 32 virtual ~CScalarAlgorithmReduceAxis(); 40 33 41 34 static bool registerTrans(); 42 protected:43 void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs);44 45 protected:46 CReductionAlgorithm* reduction_;47 35 48 36 private: -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/scalar_algorithm/scalar_algorithm_reduce_domain.cpp
r1988 r1999 13 13 #include "grid.hpp" 14 14 #include "grid_transformation_factory_impl.hpp" 15 16 #include "reduction.hpp"17 15 18 16 namespace xios { … … 48 46 49 47 CScalarAlgorithmReduceDomain::CScalarAlgorithmReduceDomain(bool isSource, CScalar* scalarDestination, CDomain* domainSource, CReduceDomainToScalar* algo) 50 : CScalarAlgorithmTransformation(isSource, scalarDestination, domainSource), 51 reduction_(0) 48 : CAlgorithmTransformationReduce(isSource), domainSrc_(domainSource) 52 49 TRY 53 50 { … … 58 55 { 59 56 case CReduceDomainToScalar::operation_attr::sum: 60 op = "sum";57 operator_ = EReduction::sum; 61 58 break; 62 59 case CReduceDomainToScalar::operation_attr::min: 63 op = "min";60 operator_ = EReduction::min; 64 61 break; 65 62 case CReduceDomainToScalar::operation_attr::max: 66 op = "max";63 operator_ = EReduction::max; 67 64 break; 68 65 case CReduceDomainToScalar::operation_attr::average: 69 op = "average";66 operator_ = EReduction::average; 70 67 break; 71 68 default: … … 76 73 77 74 } 78 79 if (CReductionAlgorithm::ReductionOperations.end() == CReductionAlgorithm::ReductionOperations.find(op))80 ERROR("CScalarAlgorithmReduceDomain::CScalarAlgorithmReduceDomain(CDomain* domainDestination, CDomain* domainSource, CReduceDomainToScalar* algo)",81 << "Operation '" << op << "' not found. Please make sure to use a supported one"82 << "Domain source " <<domainSource->getId() << std::endl83 << "Scalar destination " << scalarDestination->getId());84 75 85 reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 86 local = algo->local ; 87 } 88 CATCH 89 90 void CScalarAlgorithmReduceDomain::apply(const std::vector<std::pair<int,double> >& localIndex, 91 const double* dataInput, 92 CArray<double,1>& dataOut, 93 std::vector<bool>& flagInitial, 94 bool ignoreMissingValue, bool firstPass) 95 TRY 96 { 97 reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 98 } 99 CATCH 100 101 void CScalarAlgorithmReduceDomain::updateData(CArray<double,1>& dataOut) 102 TRY 103 { 104 reduction_->updateData(dataOut); 105 } 106 CATCH 107 108 CScalarAlgorithmReduceDomain::~CScalarAlgorithmReduceDomain() 109 TRY 110 { 111 if (0 != reduction_) delete reduction_; 112 } 113 CATCH 114 115 void CScalarAlgorithmReduceDomain::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 116 TRY 117 { 118 this->transformationMapping_.resize(1); 119 this->transformationWeight_.resize(1); 120 121 TransformationIndexMap& transMap = this->transformationMapping_[0]; 122 TransformationWeightMap& transWeight = this->transformationWeight_[0]; 76 TransformationIndexMap& transMap = this->transformationMapping_; 123 77 124 78 int ni_glo = domainSrc_->ni_glo ; 125 79 int nj_glo = domainSrc_->nj_glo ; 126 80 int nbDomainIdx ; 81 82 bool local = algo->local ; 127 83 128 84 if (local) … … 138 94 { 139 95 transMap[0].push_back(j_index(idxDomain)* ni_glo + i_index(idxDomain)); 140 transWeight[0].push_back(1.0) ;141 96 } 142 97 } … … 145 100 { 146 101 nbDomainIdx = ni_glo * nj_glo; 147 transMap[0].resize(nbDomainIdx); 148 transWeight[0].resize(nbDomainIdx, 1.0); 149 for (int idxDomain = 0; idxDomain < nbDomainIdx; ++idxDomain) transMap[0][idxDomain] = idxDomain; 102 for (int idxDomain = 0; idxDomain < nbDomainIdx; ++idxDomain) transMap[0].push_back(idxDomain); 150 103 } 151 104 105 scalarDestination->checkAttributes() ; 106 this->computeAlgorithm(domainSource->getLocalView(CElementView::WORKFLOW), scalarDestination->getLocalView(CElementView::WORKFLOW)) ; 152 107 } 153 108 CATCH 154 109 110 111 112 CScalarAlgorithmReduceDomain::~CScalarAlgorithmReduceDomain() 113 TRY 114 { 155 115 } 116 CATCH 117 118 119 } -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/scalar_algorithm/scalar_algorithm_reduce_domain.hpp
r1988 r1999 10 10 #define __XIOS_SCALAR_ALGORITHM_REDUCE_DOMAIN_HPP__ 11 11 12 #include " scalar_algorithm_transformation.hpp"12 #include "algorithm_transformation_reduce.hpp" 13 13 #include "transformation.hpp" 14 14 … … 24 24 Reducing an DOMAIN to a scalar 25 25 */ 26 class CScalarAlgorithmReduceDomain : public C ScalarAlgorithmTransformation26 class CScalarAlgorithmReduceDomain : public CAlgorithmTransformationReduce 27 27 { 28 28 public: 29 29 CScalarAlgorithmReduceDomain(bool isSource, CScalar* scalarDestination, CDomain* domainSource, CReduceDomainToScalar* algo); 30 30 31 virtual void 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 37 virtual void updateData(CArray<double,1>& dataOut);38 39 31 virtual ~CScalarAlgorithmReduceDomain(); 40 32 41 33 static bool registerTrans(); 42 protected:43 bool local ;44 void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs);45 34 46 35 protected: 47 C ReductionAlgorithm* reduction_;36 CDomain* domainSrc_ ; 48 37 49 38 private:
Note: See TracChangeset
for help on using the changeset viewer.