Changeset 2186
- Timestamp:
- 07/15/21 17:17:07 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/domain_algorithm/domain_algorithm_extract.cpp
r2006 r2186 41 41 TRY 42 42 { 43 // Reset geometrical attributes to avoid incompatible (user/domainSource) attributs 44 // attributs will be defined using domainSource and/or transformation attributs 45 domainDestination->type.reset(); 46 domainDestination->ni_glo.reset(); 47 domainDestination->nj_glo.reset(); 48 49 domainDestination->i_index.reset(); // defined using domainSource->getLocalElement() 50 domainDestination->j_index.reset(); // " 51 domainDestination->ibegin.reset(); // will be computed in domainDestination->checkDomain() (from checkAttributes()) 52 domainDestination->ni.reset(); // " 53 domainDestination->jbegin.reset(); // " 54 domainDestination->nj.reset(); // " 55 56 domainDestination->mask_1d.reset(); // defined scanning domainSource->getFullView() & domainSource->getWorkflowView() differencies 57 domainDestination->mask_2d.reset(); // in all case domainDestination->mask_1d used as reference 58 59 // domainDestination->data_* attributes will be computed in : 60 domainDestination->data_dim.reset(); // domainDestination->checkDomainData() (from checkAttributes()) 61 domainDestination->data_ni.reset(); 62 domainDestination->data_nj.reset(); 63 domainDestination->data_ibegin.reset(); 64 domainDestination->data_jbegin.reset(); 65 domainDestination->data_i_index.reset(); // domainDestination->checkCompression() (from checkAttributes()) 66 domainDestination->data_j_index.reset(); 67 68 // Next attributes will be set using domainSource->attributes 69 domainDestination->lonvalue_1d.reset(); 70 domainDestination->latvalue_1d.reset(); 71 domainDestination->lonvalue_2d.reset(); 72 domainDestination->latvalue_2d.reset(); 73 domainDestination->nvertex.reset(); 74 domainDestination->bounds_lon_1d.reset(); 75 domainDestination->bounds_lat_1d.reset(); 76 domainDestination->bounds_lon_2d.reset(); 77 domainDestination->bounds_lat_2d.reset(); 78 domainDestination->area.reset(); 79 domainDestination->radius.reset(); 80 81 43 82 extractDomain->checkValid(domainSource); 44 83 extractIBegin_ = extractDomain->ibegin.getValue(); … … 68 107 69 108 // Calculate the size of local domain 70 int ind, indLocSrc, indLocDest, iIdxSrc, jIdxSrc, destIBegin = -1, destJBegin = -1, niDest = 0, njDest = 0 , ibeginDest, jbeginDest;109 int ind, indLocSrc, indLocDest, iIdxSrc, jIdxSrc, destIBegin = -1, destJBegin = -1, niDest = 0, njDest = 0 ; 71 110 int indGloDest, indGloSrc, niGloSrc = domainSrc_->ni_glo, iSrc, jSrc; 72 111 for (int j = 0; j < domainSrc_->nj.getValue(); j++) … … 93 132 } 94 133 } 95 ibeginDest = destIBegin + domainSrc_->ibegin - extractIBegin_; 96 jbeginDest = destJBegin + domainSrc_->jbegin - extractJBegin_; 97 if (niDest==0) ibeginDest=0 ; 98 if (njDest==0) jbeginDest=0 ; 99 134 135 136 // Set attributes for this transformation 100 137 domainDest_->type = domainSrc_ -> type ; 101 domainDest_->data_dim = domainSrc_->data_dim ;102 138 domainDest_->ni_glo.setValue(extractNi_); 103 139 domainDest_->nj_glo.setValue(extractNj_); 104 domainDest_->ni.setValue(niDest);105 domainDest_->nj.setValue(njDest);106 domainDest_->ibegin.setValue(ibeginDest);107 domainDest_->jbegin.setValue(jbeginDest);108 140 domainDest_->i_index.resize(niDest*njDest); 109 141 domainDest_->j_index.resize(niDest*njDest); 110 142 111 domainDest_->data_ni.setValue(niDest); 112 domainDest_->data_nj.setValue(njDest); 113 domainDest_->data_ibegin.setValue(0); // local position 114 domainDest_->data_jbegin.setValue(0); // local position 115 domainDest_->data_i_index.resize(niDest*njDest); // local position 116 domainDest_->data_j_index.resize(niDest*njDest); // local position 117 118 //domainDest_->domainMask.resize(niDest*njDest); 119 120 if (!domainSrc_->mask_2d.isEmpty()) domainDest_->mask_2d.resize(niDest,njDest); 121 if (!domainSrc_->mask_1d.isEmpty()) domainDest_->mask_1d.resize(niDest*njDest); 122 143 // Resize lon/lat, bounds, area arrays to local domain dimensions 123 144 if (!domainSrc_->lonvalue_1d.isEmpty()) 124 145 { … … 139 160 domainDest_->latvalue_2d.resize(niDest,njDest); 140 161 } 141 142 162 if (domainSrc_->hasBounds) 143 163 { … … 154 174 } 155 175 if (domainSrc_->hasArea) domainDest_->area.resize(niDest,njDest); 176 177 // Set attributes required to define domainDestination->localElement_ and associated views, full and workflow) 178 CArray<size_t,1> sourceGlobalIdx = domainSource->getLocalElement()->getGlobalIndex(); 179 int indexSize = sourceGlobalIdx.numElements(); 180 domainDest_->mask_1d.resize(niDest*njDest); 181 CArray<int,1> sourceWorkflowIdx = domainSource->getLocalView(CElementView::WORKFLOW)->getIndex(); 182 CArray<int,1> sourceFullIdx = domainSource->getLocalView(CElementView::FULL )->getIndex(); 156 183 157 for (int iDest = 0; iDest < niDest; iDest++) 158 { 159 iSrc = iDest + destIBegin; 160 for (int jDest = 0; jDest < njDest; jDest++) 161 { 162 jSrc = jDest + destJBegin; 163 ind = jSrc * domainSrc_->ni + iSrc; 164 iIdxSrc = domainSrc_->i_index(ind); 165 jIdxSrc = domainSrc_->j_index(ind); 166 indLocDest = jDest*niDest + iDest; 167 indGloDest = (jDest + jbeginDest)*extractNi_ + (iDest + ibeginDest); 168 indLocSrc = (jDest+destJBegin)*domainSrc_->ni + (iDest+destIBegin); 169 indGloSrc = (jIdxSrc )* niGloSrc + iIdxSrc; 170 domainDest_->i_index(indLocDest) = iDest + ibeginDest; // i_index contains global positions 171 domainDest_->j_index(indLocDest) = jDest + jbeginDest; // i_index contains global positions 172 domainDest_->data_i_index(indLocDest) = (domainSrc_->data_dim == 1) ? indLocDest : iDest; // data_i_index contains local positions 173 domainDest_->data_j_index(indLocDest) = (domainSrc_->data_dim == 1) ? 0 :jDest; // data_i_index contains local positions 174 //domainDest_->domainMask(indLocDest) = domainSrc_->domainMask(indLocSrc); 175 176 if (!domainSrc_->mask_2d.isEmpty()) 177 domainDest_->mask_2d(iDest,jDest) = domainSrc_->mask_2d(iSrc,jSrc); 178 179 if (!domainSrc_->mask_1d.isEmpty()) 180 domainDest_->mask_1d(indLocDest) = domainSrc_->mask_1d(indLocSrc); 181 182 if (domainSrc_->hasArea) 183 domainDest_->area(iDest,jDest) = domainSrc_->area(iSrc,jSrc); 184 185 186 if (domainSrc_->hasBounds) 187 { 188 if (!domainSrc_->bounds_lon_2d.isEmpty()) 189 { 190 for (int n = 0; n < domainSrc_->nvertex; ++n) 191 { 192 domainDest_->bounds_lon_2d(n,iDest,jDest) = domainSrc_->bounds_lon_2d(n,iSrc,jSrc); 193 domainDest_->bounds_lat_2d(n,iDest,jDest) = domainSrc_->bounds_lat_2d(n,iSrc,jSrc); 194 } 195 } 196 else if (!domainSrc_->bounds_lon_1d.isEmpty()) 197 { 198 for (int n = 0; n < domainSrc_->nvertex; ++n) 199 { 200 domainDest_->bounds_lon_1d(n,iDest) = domainSrc_->bounds_lon_1d(n,iSrc); 201 domainDest_->bounds_lat_1d(n,iDest) = domainSrc_->bounds_lat_1d(n,iSrc); 202 } 203 } 204 } 205 206 if (domainSrc_->hasLonLat) 184 int countDest(0); // increment of the position in destination domain 185 int countMasked(0); // countMasked will store the offset index between full and workflow views 186 for (int countSrc = 0; countSrc < indexSize ; ++countSrc) { 187 int iIdxSrc = sourceGlobalIdx(countSrc)%domainSource->ni_glo; 188 int jIdxSrc = sourceGlobalIdx(countSrc)/domainSource->ni_glo; 189 // check that point countSrc concerned by extract 190 if ( (iIdxSrc >= extractIBegin_) && (iIdxSrc <= extractIEnd_) 191 && (jIdxSrc >= extractJBegin_) && (jIdxSrc <= extractJEnd_) ) 192 { 193 // if concerned, convert source the global indexation in the extracted frame 194 domainDest_->i_index(countDest) = iIdxSrc-extractIBegin_; 195 domainDest_->j_index(countDest) = jIdxSrc-extractJBegin_; 196 transformationMapping_[extractNi_*(jIdxSrc-extractJBegin_)+iIdxSrc-extractIBegin_]=sourceGlobalIdx(countSrc); 197 if ( sourceFullIdx(countSrc)==sourceWorkflowIdx(countSrc-countMasked) ) 198 { 199 domainDest_->mask_1d(countDest) = 1; 200 } 201 else { 202 domainDest_->mask_1d(countDest) = 0; 203 // if point masked, manage offset between full and worfklow views of domainSource 204 countMasked++; 205 } 206 207 int iIdxDestLocal = countDest%niDest; 208 int jIdxDestLocal = countDest/niDest; 209 int iIdxSrcLocal = countSrc%domainSource->ni; 210 int jIdxSrcLocal = countSrc/domainSource->ni; 211 212 // area 213 if (!domainSrc_->area.isEmpty()) 214 { 215 domainDest_->area(iIdxDestLocal,jIdxDestLocal) = domainSrc_->area(iIdxSrcLocal,jIdxSrcLocal); 216 } 217 218 // bounds 219 if (!domainDest_->bounds_lon_1d.isEmpty()) 220 { 221 for (int n = 0; n < domainSrc_->nvertex; ++n) 222 { 223 domainDest_->bounds_lon_1d(n, countDest) = domainSrc_->bounds_lon_1d(n,countSrc); 224 domainDest_->bounds_lat_1d(n, countDest) = domainSrc_->bounds_lat_1d(n,countSrc); 225 } 226 } 227 else if (!domainDest_->bounds_lon_2d.isEmpty()) 228 { 229 for (int n = 0; n < domainSrc_->nvertex; ++n) 230 { 231 domainDest_->bounds_lon_2d(n, iIdxDestLocal, jIdxDestLocal) = domainSrc_->bounds_lon_2d(n, iIdxSrcLocal, jIdxSrcLocal); 232 domainDest_->bounds_lat_2d(n, iIdxDestLocal, jIdxDestLocal) = domainSrc_->bounds_lat_2d(n, iIdxSrcLocal, jIdxSrcLocal); 233 } 234 } 235 236 // lon/lat 237 if (!domainDest_->lonvalue_1d.isEmpty()) 207 238 { 208 239 if (domainDest_->type == CDomain::type_attr::rectilinear) 209 240 { 210 domainDest_->latvalue_1d(jDest) = domainSrc_->latvalue_1d(jSrc); 211 } 212 else if (domainDest_->type == CDomain::type_attr::curvilinear) 213 { 214 domainDest_->lonvalue_2d(iDest,jDest) = domainSrc_->lonvalue_2d(iSrc,jSrc); 215 domainDest_->latvalue_2d(iDest,jDest) = domainSrc_->latvalue_2d(iSrc,jSrc); 216 } 217 } 218 219 transformationMapping_[indGloDest]=indGloSrc; 220 221 } 222 if (domainSrc_->hasLonLat) 223 { 224 if (domainDest_->type == CDomain::type_attr::unstructured) 225 { 226 domainDest_->lonvalue_1d(iDest) = domainSrc_->lonvalue_1d(iSrc); 227 domainDest_->latvalue_1d(iDest) = domainSrc_->latvalue_1d(iSrc); 228 } 229 else if (domainDest_->type == CDomain::type_attr::rectilinear) 230 { 231 domainDest_->lonvalue_1d(iDest) = domainSrc_->lonvalue_1d(iSrc); 232 } 233 } 241 // i : scan nbr of points in src 242 domainDest_->lonvalue_1d(iIdxDestLocal) = domainSrc_->lonvalue_1d(iIdxSrcLocal); 243 domainDest_->latvalue_1d(jIdxDestLocal) = domainSrc_->latvalue_1d(jIdxSrcLocal); 244 } 245 else if (domainDest_->type == CDomain::type_attr::unstructured) 246 { 247 domainDest_->lonvalue_1d(countDest) = domainSrc_->lonvalue_1d(countSrc); 248 domainDest_->latvalue_1d(countDest) = domainSrc_->latvalue_1d(countSrc); 249 } 250 } 251 else if (!domainDest_->lonvalue_2d.isEmpty()) 252 { 253 if (domainDest_->type == CDomain::type_attr::curvilinear) 254 { 255 domainDest_->lonvalue_2d(iIdxDestLocal, jIdxDestLocal) = domainSrc_->lonvalue_2d(iIdxSrcLocal,jIdxSrcLocal); 256 domainDest_->latvalue_2d(iIdxDestLocal, jIdxDestLocal) = domainSrc_->latvalue_2d(iIdxSrcLocal,jIdxSrcLocal); 257 } 258 } 259 260 // if point i has been identified as extracted, increment position in destination domain for the next point 261 countDest++; 262 } 263 else 264 if ( sourceFullIdx(countSrc)!=sourceWorkflowIdx(countSrc-countMasked) ) 265 { 266 // manage offset between full and worfklow views of domainSource even if point i is not concerned 267 countMasked++; 268 } 269 234 270 } 235 271
Note: See TracChangeset
for help on using the changeset viewer.