- Timestamp:
- 11/10/21 11:47:59 (3 years ago)
- Location:
- XIOS/dev/dev_ym/XIOS_COUPLING/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/extract_domain_to_axis.cpp
r2116 r2255 48 48 << "Axis destination " << axisDst->getId()); 49 49 50 int axis_n_glo = axisDst->n_glo;51 50 int domain_ni_glo = domainSrc->ni_glo; 52 51 int domain_nj_glo = domainSrc->nj_glo; … … 67 66 { 68 67 case direction_attr::jDir: 69 if (axis_n_glo != domain_nj_glo)70 ERROR("CExtractDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)",71 << "Extract domain along j, axis destination should have n_glo equal to nj_glo of domain source"72 << "Domain source " <<domainSrc->getId() << " has nj_glo " << domain_nj_glo << std::endl73 << "Axis destination " << axisDst->getId() << " has n_glo " << axis_n_glo);74 68 if ((position < 0) || (position >= domain_ni_glo)) 75 69 ERROR("CExtractDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", … … 81 75 82 76 case direction_attr::iDir: 83 if (axis_n_glo != domain_ni_glo)84 ERROR("CExtractDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)",85 << "Extract domain along i, axis destination should have n_glo equal to ni_glo of domain source"86 << "Domain source " <<domainSrc->getId() << " has ni_glo " << domain_ni_glo << std::endl87 << "Axis destination " << axisDst->getId() << " has n_glo " << axis_n_glo);88 77 if ((position < 0) || (position >= domain_nj_glo)) 89 78 ERROR("CExtractDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_extract.cpp
r1998 r2255 44 44 TRY 45 45 { 46 axisDestination->axis_type.reset(); 47 axisDestination->n_glo.reset(); 48 axisDestination->index.reset(); 49 axisDestination->n.reset(); 50 axisDestination->begin.reset(); 51 52 axisDestination->mask.reset(); 53 axisDestination->data_index.reset(); 54 axisDestination->data_n.reset(); 55 axisDestination->data_begin.reset(); 56 57 axisDestination->value.reset(); 58 axisDestination->label.reset(); 59 axisDestination->bounds.reset(); 60 46 61 extractAxis->checkValid(axisSource); 47 62 extractBegin_ = extractAxis->begin.getValue(); … … 68 83 } 69 84 } 70 beginDestGlo = beginDestLoc + axisSrc_->begin - extractBegin_;85 71 86 axisDest_->n_glo.setValue(extractN_); 72 axisDest_->n.setValue(nDest);73 axisDest_->begin.setValue(beginDestGlo);74 87 axisDest_->index.resize(nDest); 88 if (nDest==0) 89 { 90 axisDest_->n.setValue( 0 ); 91 axisDest_->begin.setValue( 0 ); 92 } 75 93 76 axisDest_->data_n.setValue(nDest);77 axisDest_->data_begin.setValue(0);78 axisDest_->data_index.resize(nDest);79 80 axisDest_->mask.resize(nDest);81 94 if (axisSrc_->hasValue) axisDest_->value.resize(nDest); 82 95 if (axisSrc_->hasLabel) axisDest_->label.resize(nDest); … … 85 98 auto& transMap = this->transformationMapping_; 86 99 87 for (int iDest = 0; iDest < nDest; iDest++) 100 // Set attributes required to define domainDestination->localElement_ and associated views, full and workflow) 101 CArray<size_t,1> sourceGlobalIdx = axisSource->getLocalElement()->getGlobalIndex(); 102 int indexSize = sourceGlobalIdx.numElements(); 103 104 CArray<int,1> sourceWorkflowIdx = axisSource->getLocalView(CElementView::WORKFLOW)->getIndex(); 105 int srcWorkflowSize = sourceWorkflowIdx.numElements(); 106 axisDest_->data_index.resize(nDest); 107 axisDest_->data_index = -1; 108 109 int idxMin = INT_MAX; 110 for (int countSrc = 0; countSrc < indexSize ; ++countSrc) 88 111 { 89 iSrc = iDest + beginDestLoc; 90 axisDest_->index(iDest) = iDest + beginDestGlo; 91 axisDest_->data_index(iDest) = axisSrc_->data_index(iSrc) - beginDestLoc; 92 axisDest_->mask(iDest) = axisSrc_->mask(iSrc); 93 94 if (axisSrc_->hasValue) 95 axisDest_->value(iDest) = axisSrc_->value(iSrc); 96 if (axisSrc_->hasLabel) 97 axisDest_->label(iDest) = axisSrc_->label(iSrc); 98 if (axisSrc_->hasBounds) 99 { 100 axisDest_->bounds(0,iDest) = axisSrc_->bounds(0,iSrc); 101 axisDest_->bounds(1,iDest) = axisSrc_->bounds(1,iSrc); 102 } 103 indGloDest = axisDest_->index(iDest); 104 indGloSrc = axisSrc_->index(iSrc); 105 106 transMap[indGloDest]=indGloSrc; 107 112 if ( sourceGlobalIdx(countSrc) < idxMin ) 113 idxMin = sourceGlobalIdx(countSrc); 108 114 } 109 115 116 int countDest(0); // increment of the position in destination domain 117 for (int countSrc = 0; countSrc < indexSize ; ++countSrc) 118 { 119 int idxSrc = sourceGlobalIdx(countSrc); 120 if ( (idxSrc >= extractBegin_) && (idxSrc <= extractEnd_) ) 121 { 122 axisDest_->index(countDest) = idxSrc-extractBegin_; 123 124 // ------------------ define transformation only if in the WF ------------------ 125 int iIdxSrc2 = (countSrc+idxMin)%axisSource->n_glo; 126 int convert_locally_global_idx = (iIdxSrc2-idxMin) ; 127 bool concerned_by_WF(false); 128 for ( int i = 0 ; i<sourceWorkflowIdx.numElements() ; ++i ) 129 { 130 if (sourceWorkflowIdx(i)==convert_locally_global_idx) 131 { 132 concerned_by_WF = true; 133 break; 134 } 135 } 136 137 if (concerned_by_WF) 138 { 139 transformationMapping_[idxSrc-extractBegin_]=sourceGlobalIdx(countSrc); 140 axisDest_->data_index( countDest ) = countDest; 141 } 142 // ----------------------------------------------------------------------------- 143 144 if (axisSrc_->hasValue) 145 { 146 axisDest_->value(countDest) = axisSrc_->value(countSrc); 147 } 148 if (axisSrc_->hasLabel) 149 { 150 axisDest_->label(countDest) = axisSrc_->label(countSrc); 151 } 152 if (axisSrc_->hasBounds) 153 { 154 axisDest_->bounds(0,countDest) = axisSrc_->bounds(0,countSrc); 155 axisDest_->bounds(1,countDest) = axisSrc_->bounds(1,countSrc); 156 } 157 158 // if point i has been identified as extracted, increment position in destination domain for the next point 159 countDest++; 160 } 161 } 162 110 163 axisDestination->checkAttributes() ; 111 164 -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_extract_domain.cpp
r2117 r2255 51 51 TRY 52 52 { 53 axisDestination->checkAttributes() ; 53 axisDestination->axis_type.reset(); 54 axisDestination->n_glo.reset(); 55 axisDestination->index.reset(); 56 axisDestination->n.reset(); 57 axisDestination->begin.reset(); 58 59 axisDestination->mask.reset(); 60 axisDestination->data_index.reset(); 61 axisDestination->data_n.reset(); 62 axisDestination->data_begin.reset(); 63 64 axisDestination->value.reset(); 65 axisDestination->label.reset(); 66 axisDestination->bounds.reset(); 67 54 68 algo->checkValid(axisDestination, domainSource); 55 69 StdString op = "extract"; 56 70 71 int nglo,nloc; 57 72 switch (algo->direction) 58 73 { 59 74 case CExtractDomainToAxis::direction_attr::jDir: 60 75 dir_ = jDir; 76 nglo = domainSource->nj_glo.getValue(); 77 nloc = domainSource->nj.getValue(); 61 78 break; 62 79 case CExtractDomainToAxis::direction_attr::iDir: 63 80 dir_ = iDir; 81 nglo = domainSource->ni_glo.getValue(); 82 nloc = domainSource->ni.getValue(); 64 83 break; 65 84 default: 66 85 break; 86 } 87 88 axisDestination->n_glo.setValue( nglo ); 89 axisDestination->index.resize( nloc ); 90 axisDestination->data_index.resize( nloc ); 91 axisDestination->data_index = -1; 92 93 if ( axisDestination->index.isEmpty() ) 94 { 95 axisDestination->n.setValue( 0 ); 96 axisDestination->begin.setValue( 0 ); 67 97 } 68 98 … … 70 100 71 101 auto& transMap = this->transformationMapping_; 102 103 CArray<size_t,1> sourceGlobalIdx = domainSource->getLocalElement()->getGlobalIndex(); 104 int indexSize = sourceGlobalIdx.numElements(); 72 105 73 CArray<int,1>& axisDstIndex = axisDest_->index; 74 int ni_glo = domainSrc_->ni_glo, nj_glo = domainSrc_->nj_glo; 106 CArray<int,1> sourceWorkflowIdx = domainSource->getLocalView(CElementView::WORKFLOW)->getIndex(); 107 int srcWorkflowSize = sourceWorkflowIdx.numElements(); 108 109 int iIdxSrcMin = INT_MAX; 110 int jIdxSrcMin = INT_MAX; 111 int IdxMin = INT_MAX; 112 for (int countSrc = 0; countSrc < indexSize ; ++countSrc) 113 { 114 if ( sourceGlobalIdx(countSrc)%domainSource->ni_glo < iIdxSrcMin ) 115 iIdxSrcMin = sourceGlobalIdx(countSrc)%domainSource->ni_glo; 116 if ( sourceGlobalIdx(countSrc)/domainSource->ni_glo < jIdxSrcMin ) 117 jIdxSrcMin = sourceGlobalIdx(countSrc)/domainSource->ni_glo; 118 if ( sourceGlobalIdx(countSrc) < IdxMin ) 119 IdxMin = sourceGlobalIdx(countSrc); 120 } 121 75 122 if (jDir == dir_) 76 123 { 77 int nbAxisIdx = axisDstIndex.numElements();78 for (int idxAxis = 0; idxAxis < nbAxisIdx; ++idxAxis)124 int countDest(0); 125 for (int countSrc = 0; countSrc < indexSize ; ++countSrc) 79 126 { 80 int globalAxisIdx = axisDstIndex(idxAxis); 81 transMap[globalAxisIdx] = globalAxisIdx * ni_glo + pos_; 127 if ( sourceGlobalIdx(countSrc)%domainSource->ni_glo == pos_ ) 128 { 129 axisDest_->index(countDest) = sourceGlobalIdx(countSrc)/domainSource->ni_glo; 130 int iIdxSrc2 = (countSrc+IdxMin)%domainSource->ni_glo; 131 int jIdxSrc2 = (countSrc+IdxMin)/domainSource->ni_glo; 132 int convert_locally_global_idx = (jIdxSrc2-jIdxSrcMin)*domainSource->ni + (iIdxSrc2-iIdxSrcMin) ; 133 bool concerned_by_WF(false); 134 for ( int i = 0 ; i<sourceWorkflowIdx.numElements() ; ++i ) 135 { 136 if (sourceWorkflowIdx(i)==convert_locally_global_idx) 137 { 138 concerned_by_WF = true; 139 break; 140 } 141 } 142 if (concerned_by_WF) 143 { 144 axisDest_->data_index(countDest) = countDest; 145 transMap[axisDest_->index(countDest)] = sourceGlobalIdx(countSrc); 146 } 147 countDest++; 148 } 82 149 } 83 150 } 84 151 else if (iDir == dir_) 85 152 { 86 int nbAxisIdx = axisDstIndex.numElements();87 for (int idxAxis = 0; idxAxis < nbAxisIdx; ++idxAxis)153 int countDest(0); 154 for (int countSrc = 0; countSrc < indexSize ; ++countSrc) 88 155 { 89 int globalAxisIdx = axisDstIndex(idxAxis); 90 transMap[globalAxisIdx] = globalAxisIdx + ni_glo * pos_; 156 if ( sourceGlobalIdx(countSrc)/domainSource->ni_glo == pos_ ) 157 { 158 axisDest_->index(countDest) = sourceGlobalIdx(countSrc)%domainSource->ni_glo; 159 int iIdxSrc2 = (countSrc+IdxMin)%domainSource->ni_glo; 160 int jIdxSrc2 = (countSrc+IdxMin)/domainSource->ni_glo; 161 int convert_locally_global_idx = (jIdxSrc2-jIdxSrcMin)*domainSource->ni + (iIdxSrc2-iIdxSrcMin) ; 162 bool concerned_by_WF(false); 163 for ( int i = 0 ; i<sourceWorkflowIdx.numElements() ; ++i ) 164 { 165 if (sourceWorkflowIdx(i)==convert_locally_global_idx) 166 { 167 concerned_by_WF = true; 168 break; 169 } 170 } 171 if (concerned_by_WF) 172 { 173 axisDest_->data_index(countDest) = countDest; 174 transMap[axisDest_->index(countDest)] = sourceGlobalIdx(countSrc); 175 } 176 countDest++; 177 } 91 178 } 92 179 }
Note: See TracChangeset
for help on using the changeset viewer.