- Timestamp:
- 03/21/22 15:27:07 (2 years ago)
- Location:
- XIOS/dev/dev_ym/XIOS_COUPLING/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/weight_transform_connector.cpp
r2267 r2313 5 5 6 6 CWeightTransformConnector::CWeightTransformConnector(shared_ptr<CLocalView> srcView, shared_ptr<CLocalView> dstView, unordered_map<int, std::vector<int>>& indexMap, 7 unordered_map<int, std::vector<double>>& weightMap) : srcView_(srcView), dstView_(dstView) 7 unordered_map<int, std::vector<double>>& weightMap, bool detectMissingValue, bool renormalize) : 8 srcView_(srcView), dstView_(dstView), detectMissingValue_(detectMissingValue), renormalize_(renormalize) 8 9 { 9 10 computeConnector(indexMap, weightMap) ; -
XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/weight_transform_connector.hpp
r2267 r2313 23 23 int srcSize_ ; 24 24 int dstSize_ ; 25 bool detectMissingValue_ ; 26 bool renormalize_ ; 25 27 26 28 void computeConnector(unordered_map<int, std::vector<int>>& indexMap, unordered_map<int, std::vector<double>>& weightMap) ; … … 29 31 30 32 CWeightTransformConnector(shared_ptr<CLocalView> srcView, shared_ptr<CLocalView> dstView, unordered_map<int, std::vector<int>>& indexMap, 31 unordered_map<int, std::vector<double>>& weightMap ) ;33 unordered_map<int, std::vector<double>>& weightMap, bool detectMissingValue, bool renormalize) ; 32 34 33 35 void transfer(int repeat, int sizeT, const CArray<double,1>& dataIn, CArray<double,1>& dataOut) … … 36 38 int srcSlice = srcSize_*sizeT ; 37 39 dataOut.resize(repeat* dstSlice) ; 38 d ataOut=0 ; // what to do about missing value => next step ?39 40 double defaultValue = std::numeric_limits<double>::quiet_NaN(); 41 dataOut = defaultValue ; // what to do about missing value => next step ? 40 42 const double* input = dataIn.dataFirst() ; 41 43 double* output = dataOut.dataFirst() ; 44 vector<bool> isFirst(dstSlice) ; 45 size_t pos ; 46 47 if (renormalize_) 48 { 49 double inVal ; 50 vector<double> renormalizeFactor(repeat*dstSlice,1) ; 51 double* renorm = renormalizeFactor.data() ; 52 for(int r=0;r<repeat;r++, input+=srcSlice, output+=dstSlice, renorm+=dstSlice) 53 { 54 const double* in = input; 55 double* out = output ; 56 double* ren = renorm ; 57 isFirst.assign(dstSlice,true) ; 58 pos=0 ; 59 int k=0 ; 60 for(int i=0; i<dstSize_; i++, out+=sizeT, pos+=sizeT, ren+=sizeT) 61 for(int j=0 ; j<nWeights_[i] ; j++,k++) 62 for(int l=0; l<sizeT; l++) 63 { 64 inVal=in[connector_[k]*sizeT+l] ; 65 if (!std::isnan(inVal)) 66 { 67 if (isFirst[pos+l]) { out[l] = inVal*weights_[k] ; isFirst[pos+l]=false ;} 68 else out[l] += inVal*weights_[k] ; 69 } 70 else ren[l] -= weights_[k] ; 71 } 72 for(int i=0; i<dstSlice; i++) output[i] /= renorm[i] ; 73 } 74 } 75 else if (detectMissingValue_) 76 { 77 double inVal ; 78 for(int r=0;r<repeat;r++, input+=srcSlice, output+=dstSlice) 79 { 80 const double* in = input; 81 double* out = output ; 82 isFirst.assign(dstSlice,true) ; 83 pos=0 ; 84 int k=0 ; 85 for(int i=0; i<dstSize_; i++, out+=sizeT, pos+=sizeT) 86 for(int j=0 ; j<nWeights_[i] ; j++,k++) 87 for(int l=0; l<sizeT; l++) 88 { 89 inVal=in[connector_[k]*sizeT+l] ; 90 if (!std::isnan(inVal)) 91 { 92 if (isFirst[pos+l]) { out[l] = inVal*weights_[k] ; isFirst[pos+l]=false ;} 93 else out[l] += inVal*weights_[k] ; 94 } 95 } 96 } 42 97 43 for(int r=0;r<repeat;r++, input+=srcSlice, output+=dstSlice) 98 } 99 else 44 100 { 45 const double* in = input; 46 double* out = output ; 47 int k=0 ; 48 for(int i=0; i<dstSize_; i++, out+=sizeT) 49 for(int j=0 ; j<nWeights_[i] ; j++,k++) 50 for(int l=0; l<sizeT; l++) out[l] += in[connector_[k]*sizeT+l]*weights_[k] ; 101 for(int r=0;r<repeat;r++, input+=srcSlice, output+=dstSlice) 102 { 103 const double* in = input; 104 double* out = output ; 105 isFirst.assign(dstSlice,true) ; 106 pos=0 ; 107 int k=0 ; 108 for(int i=0; i<dstSize_; i++, out+=sizeT, pos+=sizeT) 109 for(int j=0 ; j<nWeights_[i] ; j++,k++) 110 for(int l=0; l<sizeT; l++) 111 if (isFirst[pos+l]) { out[l] = in[connector_[k]*sizeT+l]*weights_[k] ; isFirst[pos+l]=false ;} 112 else out[l] += in[connector_[k]*sizeT+l]*weights_[k] ; 113 } 51 114 } 52 115 } -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/algorithm_transformation_weight.cpp
r2267 r2313 6 6 7 7 8 void CAlgorithmTransformationWeight::computeAlgorithm(shared_ptr<CLocalView> srcView, shared_ptr<CLocalView> dstView )8 void CAlgorithmTransformationWeight::computeAlgorithm(shared_ptr<CLocalView> srcView, shared_ptr<CLocalView> dstView, bool detectMissingValue, bool renormalize) 9 9 { 10 10 this->computeRecvElement(srcView, dstView) ; 11 weightTransformConnector_ = make_shared<CWeightTransformConnector>(recvElement_->getView(CElementView::FULL), dstView, transformationMapping_, transformationWeight_ ) ;11 weightTransformConnector_ = make_shared<CWeightTransformConnector>(recvElement_->getView(CElementView::FULL), dstView, transformationMapping_, transformationWeight_, detectMissingValue, renormalize) ; 12 12 } 13 13 -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/algorithm_transformation_weight.hpp
r2267 r2313 15 15 public: 16 16 17 CAlgorithmTransformationWeight(bool isSource) : CGenericAlgorithmTransformation(isSource) {} 17 CAlgorithmTransformationWeight(bool isSource) : CGenericAlgorithmTransformation(isSource) {} 18 18 19 virtual ~CAlgorithmTransformationWeight() {}; 19 20 virtual void apply(int dimBefore, int dimAfter, const CArray<double,1>& dataIn, CArray<double,1>& dataOut); 20 21 virtual void computeRecvElement(shared_ptr<CLocalView> srcView, shared_ptr<CLocalView> dstView); 21 22 protected: 22 virtual void computeAlgorithm(shared_ptr<CLocalView> srcView, shared_ptr<CLocalView> dstView ) ;23 virtual void computeAlgorithm(shared_ptr<CLocalView> srcView, shared_ptr<CLocalView> dstView, bool detectMissingValue, bool renormalize) ; 23 24 24 25 //! Map between global index of destination element and source element -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_interpolate.cpp
r2270 r2313 68 68 std::vector<CArray<double,1>* > dataAuxInputs ; 69 69 computeRemap(dataAuxInputs) ; 70 this->computeAlgorithm(axisSource->getLocalView(CElementView::WORKFLOW), axisDestination->getLocalView(CElementView::WORKFLOW) ) ;70 this->computeAlgorithm(axisSource->getLocalView(CElementView::WORKFLOW), axisDestination->getLocalView(CElementView::WORKFLOW), false, false) ; 71 71 } 72 72 CATCH -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/domain_algorithm/domain_algorithm_interpolate.cpp
r2270 r2313 102 102 else computeRemap(); 103 103 104 this->computeAlgorithm(domainSource->getLocalView(CElementView::WORKFLOW), domainDestination->getLocalView(CElementView::WORKFLOW) ) ;104 this->computeAlgorithm(domainSource->getLocalView(CElementView::WORKFLOW), domainDestination->getLocalView(CElementView::WORKFLOW), detectMissingValue, renormalize) ; 105 105 106 106 }
Note: See TracChangeset
for help on using the changeset viewer.