Changeset 2328
- Timestamp:
- 05/13/22 09:49:18 (2 years ago)
- Location:
- XIOS/dev/dev_ym/XIOS_COUPLING/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_ym/XIOS_COUPLING/src/config/interpolate_axis_attribute.conf
r2122 r2328 5 5 DECLARE_ATTRIBUTE(StdString, coordinate_src) 6 6 DECLARE_ATTRIBUTE(StdString, coordinate_dst) 7 DECLARE_ATTRIBUTE(bool, extrapolate) 8 -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_interpolate_coordinate.cpp
r2282 r2328 82 82 83 83 order_ = interpAxis->order.getValue(); 84 85 if (interpAxis->extrapolate.isEmpty()) extrapolate_=true ; 86 else extrapolate_=interpAxis->extrapolate ; 87 84 88 if (!interpAxis->coordinate.isEmpty()) 85 89 { … … 287 291 for(int i=0; i < ndst;i++) 288 292 { 293 bool intrapolating( true ); 289 294 x=dstCoordinate[dstIndex[i]] ; 290 if ( x<=srcCoordinate[srcIndex[0]]) lastj=0 ; 291 else if (x>=srcCoordinate[srcIndex[nsrc-1]]) lastj=nsrc-2 ; 295 if ( x<=srcCoordinate[srcIndex[0]]) 296 { 297 lastj=0 ; 298 intrapolating = false; 299 } 300 else if (x>=srcCoordinate[srcIndex[nsrc-1]]) 301 { 302 lastj=nsrc-2 ; 303 intrapolating = false; 304 } 292 305 else 293 306 { … … 298 311 } 299 312 } 300 x0=srcCoordinate[srcIndex[lastj]] ; 301 x1=srcCoordinate[srcIndex[lastj+1]] ; 302 y0=srcValue[srcIndex[lastj]] ; 303 y1=srcValue[srcIndex[lastj+1]] ; 304 y=((x-x1)*y0-(x-x0)*y1)/(x0-x1) ; 305 dstValue[dstIndex[i]]=y ; 313 if ((!extrapolate_) && (!intrapolating)) 314 { 315 dstValue[dstIndex[i]]= std::numeric_limits<double>::quiet_NaN() ; 316 } 317 else 318 { 319 x0=srcCoordinate[srcIndex[lastj]] ; 320 x1=srcCoordinate[srcIndex[lastj+1]] ; 321 y0=srcValue[srcIndex[lastj]] ; 322 y1=srcValue[srcIndex[lastj+1]] ; 323 y=((x-x1)*y0-(x-x0)*y1)/(x0-x1) ; 324 dstValue[dstIndex[i]]=y ; 325 } 306 326 } 307 327 } … … 315 335 for(int i=0; i < ndst;i++) 316 336 { 337 bool intrapolating( true ); 317 338 x=dstCoordinate[dstIndex[i]] ; 318 if ( x<=srcCoordinate[srcIndex[0]]) lastj=0 ; 319 else if (x>=srcCoordinate[srcIndex[nsrc-1]]) lastj=nsrc-2 ; 339 if ( x<=srcCoordinate[srcIndex[0]]) 340 { 341 lastj=0 ; 342 intrapolating = false; 343 } 344 else if (x>=srcCoordinate[srcIndex[nsrc-1]]) 345 { 346 lastj=nsrc-2 ; 347 intrapolating = false; 348 } 320 349 else 321 350 { … … 333 362 if ( (x-srcCoordinate[srcIndex[lastj-1]]) > (srcCoordinate[srcIndex[lastj+2]]-x) ) cj=lastj ; 334 363 else cj=lastj+1 ; 335 } 336 x0=srcCoordinate[srcIndex[cj-1]] ; 337 x1=srcCoordinate[srcIndex[cj]] ; 338 x2=srcCoordinate[srcIndex[cj+1]] ; 339 y0=srcValue[srcIndex[cj-1]] ; 340 y1=srcValue[srcIndex[cj]] ; 341 y2=srcValue[srcIndex[cj+1]] ; 342 343 y=y0*(x-x1)*(x-x2)/((x0-x1)*(x0-x2)) + y1*(x-x0)*(x-x2)/((x1-x0)*(x1-x2)) + y2*(x-x0)*(x-x1)/((x2-x0)*(x2-x1)) ; 344 dstValue[dstIndex[i]]=y ; 364 } 365 if ((!extrapolate_) && (!intrapolating)) 366 { 367 dstValue[dstIndex[i]]= std::numeric_limits<double>::quiet_NaN() ; 368 } 369 else 370 { 371 x0=srcCoordinate[srcIndex[cj-1]] ; 372 x1=srcCoordinate[srcIndex[cj]] ; 373 x2=srcCoordinate[srcIndex[cj+1]] ; 374 y0=srcValue[srcIndex[cj-1]] ; 375 y1=srcValue[srcIndex[cj]] ; 376 y2=srcValue[srcIndex[cj+1]] ; 377 378 y=y0*(x-x1)*(x-x2)/((x0-x1)*(x0-x2)) + y1*(x-x0)*(x-x2)/((x1-x0)*(x1-x2)) + y2*(x-x0)*(x-x1)/((x2-x0)*(x2-x1)) ; 379 dstValue[dstIndex[i]]=y ; 380 } 381 345 382 } 346 383 } -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm/axis_algorithm_interpolate_coordinate.hpp
r2270 r2328 45 45 // Interpolation order 46 46 int order_; 47 bool extrapolate_ ; 47 48 StdString coordinateSrc_; // pressure src 48 49 StdString coordinateDest_; // pressure dst
Note: See TracChangeset
for help on using the changeset viewer.