39 fileName fName(fileName_);
44 reader_()(fName, *
this);
49 <<
"table read from " << fName <<
" is empty" <<
nl
65 fileName_(
"fileNameIsUndefined"),
125 bounding_(tbl.bounding_),
126 fileName_(tbl.fileName_),
127 reader_(tbl.reader_.clone())
141 for (
const auto& item : list)
143 const scalar& currValue = item.first();
146 if (i && currValue <= prevValue)
149 <<
"out-of-order value: "
150 << currValue <<
" at index " << i <<
nl
153 prevValue = currValue;
162 os.writeEntry(
"file", fileName_);
176 const label
n = list.size();
184 const scalar minLimit = list.first().first();
185 const scalar maxLimit = list.last().first();
187 if (lookupValue < minLimit)
191 case bounds::repeatableBounding::ERROR:
194 <<
"value (" << lookupValue <<
") less than lower "
195 <<
"bound (" << minLimit <<
")\n"
199 case bounds::repeatableBounding::WARN:
202 <<
"value (" << lookupValue <<
") less than lower "
203 <<
"bound (" << minLimit <<
")\n"
204 <<
" Zero rate of change." <<
endl;
210 case bounds::repeatableBounding::CLAMP:
215 case bounds::repeatableBounding::REPEAT:
218 scalar span = maxLimit-minLimit;
219 lookupValue = fmod(lookupValue - minLimit, span) + minLimit;
224 else if (lookupValue >= maxLimit)
228 case bounds::repeatableBounding::ERROR:
231 <<
"value (" << lookupValue <<
") greater than upper "
232 <<
"bound (" << maxLimit <<
")\n"
236 case bounds::repeatableBounding::WARN:
239 <<
"value (" << lookupValue <<
") greater than upper "
240 <<
"bound (" << maxLimit <<
")\n"
241 <<
" Zero rate of change." <<
endl;
247 case bounds::repeatableBounding::CLAMP:
252 case bounds::repeatableBounding::REPEAT:
255 scalar span = maxLimit-minLimit;
256 lookupValue = fmod(lookupValue - minLimit, span) + minLimit;
266 for (label i = 0; i <
n; ++i)
268 if (lookupValue >= list[i].first())
294 (list[hi].second() - list[lo].second())
295 / (list[hi].first() + minLimit - list[lo].first())
303 (list[hi].second() - list[lo].second())
304 / (list[hi].first() - list[lo].first())
317 const label
n = list.size();
325 <<
"Cannot interpolate from zero-sized table" <<
nl
330 return list.first().second();
333 const scalar minLimit = list.first().first();
334 const scalar maxLimit = list.last().first();
336 if (lookupValue < minLimit)
340 case bounds::repeatableBounding::ERROR:
343 <<
"value (" << lookupValue <<
") less than lower "
344 <<
"bound (" << minLimit <<
")\n"
348 case bounds::repeatableBounding::WARN:
351 <<
"value (" << lookupValue <<
") less than lower "
352 <<
"bound (" << minLimit <<
")\n"
353 <<
" Continuing with the first entry" <<
endl;
356 return list.first().second();
359 case bounds::repeatableBounding::CLAMP:
361 return list.first().second();
364 case bounds::repeatableBounding::REPEAT:
367 const scalar span = maxLimit-minLimit;
368 lookupValue = fmod(lookupValue - minLimit, span) + minLimit;
373 else if (lookupValue >= maxLimit)
377 case bounds::repeatableBounding::ERROR:
380 <<
"value (" << lookupValue <<
") greater than upper "
381 <<
"bound (" << maxLimit <<
")\n"
385 case bounds::repeatableBounding::WARN:
388 <<
"value (" << lookupValue <<
") greater than upper "
389 <<
"bound (" << maxLimit <<
")\n"
390 <<
" Continuing with the last entry" <<
endl;
393 return list.last().second();
396 case bounds::repeatableBounding::CLAMP:
398 return list.last().second();
401 case bounds::repeatableBounding::REPEAT:
404 const scalar span = maxLimit-minLimit;
405 lookupValue = fmod(lookupValue - minLimit, span) + minLimit;
416 for (label i = 0; i <
n; ++i)
418 if (lookupValue >= list[i].first())
431 return list[hi].second();
445 + (list[hi].second() - list[lo].second())
446 * (lookupValue / minLimit)
455 + (list[hi].second() - list[lo].second())
456 * (lookupValue - list[lo].first())
457 / (list[hi].first() - list[lo].first())
468 return interpolateValue(*
this, lookupValue, bounding_);
480 auto&
fld = tfld.ref();
484 fld[i] = interpolateValue(vals[i]);
505 bounding_ = rhs.bounding_;
506 fileName_ = rhs.fileName_;
507 reader_.reset(rhs.reader_.clone());
516 const label
n = list.size();
526 <<
"Cannot interpolate from zero-sized table" <<
nl
535 case bounds::repeatableBounding::ERROR:
538 <<
"index (" << idx <<
") underflow" <<
nl
542 case bounds::repeatableBounding::WARN:
545 <<
"index (" << idx <<
") underflow" <<
nl
546 <<
" Continuing with the first entry" <<
nl;
552 case bounds::repeatableBounding::CLAMP:
557 case bounds::repeatableBounding::REPEAT:
571 case bounds::repeatableBounding::ERROR:
574 <<
"index (" << idx <<
") overflow" <<
nl
578 case bounds::repeatableBounding::WARN:
581 <<
"index (" << idx <<
") overflow" <<
nl
582 <<
" Continuing with the last entry" <<
nl;
588 case bounds::repeatableBounding::CLAMP:
593 case bounds::repeatableBounding::REPEAT:
611 return interpolateValue(*
this, lookupValue, bounding_);