32Foam::label Foam::interpolationLookUpTable<Type>::index
34 const List<scalar>& indices,
43 for (
int j = i + 1; j < dim_.size(); j++)
52 max(label((indices[i] - min_[i])/delta_[i]), 0),
59 label iLastdim = dim_.size() - 1;
64 label((indices[iLastdim] - min_[iLastdim])/delta_[iLastdim]),
76Foam::label Foam::interpolationLookUpTable<Type>::index
87 label((indice - min_[i])/delta_[i]),
98bool Foam::interpolationLookUpTable<Type>::checkRange
100 const scalar lookUpValue,
101 const label interfield
104 return lookUpValue >= min_[interfield] && lookUpValue <= max_[interfield];
109Foam::scalar Foam::interpolationLookUpTable<Type>::interpolate
113 const scalar lookUpValue,
115 const label interfield
120 List<scalarField>::operator[](interfield).
operator[](hi)
121 != List<scalarField>::operator[](interfield).
operator[](lo)
126 List<scalarField>::operator[](ofield).
operator[](lo)
128 List<scalarField>::operator[](ofield).
operator[](hi)
129 - List<scalarField>::operator[](ofield).
operator[](lo)
133 - List<scalarField>::operator[](interfield).
operator[](lo)
136 List<scalarField>::operator[](interfield).
operator[](hi)
137 - List<scalarField>::operator[](interfield).
operator[](lo)
144 return List<scalarField>::operator[](ofield).operator[](lo);
150void Foam::interpolationLookUpTable<Type>::dimensionTable()
152 min_.setSize(entries_.size());
153 dim_.setSize(entries_.size());
154 delta_.setSize(entries_.size());
155 max_.setSize(entries_.size());
156 entryIndices_.setSize(entries_.size());
157 outputIndices_.setSize(output_.size());
163 dim_[i] = entries_[i].template get<label>(
"N");
164 max_[i] = entries_[i].template get<scalar>(
"max");
165 min_[i] = entries_[i].template get<scalar>(
"min");
166 delta_[i] = (max_[i] - min_[i])/dim_[i];
167 tableDim *= dim_[i] + 1;
168 fieldIndices_.insert(entries_[i].
template get<word>(
"name"), index);
169 entryIndices_[i] = index;
175 fieldIndices_.insert(output_[i].
template get<word>(
"name"), index);
176 outputIndices_[i] = index;
182 internal.
setSize(entries_.size() + output_.size());
184 interpOutput_.setSize(entries_.size() + output_.size());
194void Foam::interpolationLookUpTable<Type>::readTable
196 const word& instance,
197 const objectRegistry& obr
212 control.readEntry(
"fields", entries_);
213 control.readEntry(
"output", output_);
214 control.readEntry(
"values", *
this);
220 if (this->
size() == 0)
234 fileName_(
"fileNameIsUndefined")
242 const word& instance,
258 readTable(instance, obr);
269 fileName_(interpTable.fileName_),
270 entryIndices_(interpTable.entryIndices_),
271 outputIndices_(interpTable.outputIndices_),
272 dim_(interpTable.dim_),
273 min_(interpTable.min_),
274 delta_(interpTable.delta_),
275 max_(interpTable.max_),
278 interpOutput_(interpTable.interpOutput_)
289 fileName_(
dict.template get<
fileName>(
"file").expand()),
308void Foam::interpolationLookUpTable<Type>::check()
const
313 for (
int j = 1; j < dim_.size(); j++)
318 for (label i = 1; i < dim_[0]; i++)
321 const scalar currValue =
325 if (currValue <= prevValue)
328 <<
"out-of-order value: " << currValue
331 prevValue = currValue;
341 const word& instance,
357 control.writeHeader(
os);
362 if (this->size() == 0)
377 const label
n = this->size();
403 const label
n = this->size();
418 <<
"index (" << i <<
") overflow" <<
nl
429 return fieldIndices_.contains(fieldName);
437 const label lo = index(retvals);
439 return interpOutput_;
444void Foam::interpolationLookUpTable<Type>::findHi
453 label ofield = outputIndices_[j];
458 if (checkRange(retvals, entryIndices_[i]))
462 label hi =
Foam::min(lo + dim, (*
this)[0].size() - 1);
464 tmp +=
interpolate(lo, hi, retvals, ofield, entryIndices_[i])
467 interpOutput_[entryIndices_[i]] = retvals;
471 interpOutput_[outputIndices_[j]] =
tmp;
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
bool writeHeader(Ostream &os) const
Write header with current type().
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void setSize(label n)
Alias for resize().
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
bool get(const label i) const
T & operator[](const label i)
Return element of UList.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A class for handling file names.
A list of lists. Interpolates based on the first dimension. The values must be positive and monotonic...
bool contains(const word &fieldName) const
Return true if the field exists in the table.
const scalarField & operator[](const label) const
Return an element of constant List<scalar, Type>.
const List< scalar > & lookUp(const scalar)
Return the output list given a single input scalar.
interpolationLookUpTable()
Construct null.
void write(Ostream &, const fileName &, const word &instance, const objectRegistry &) const
Write lookup table to filename.
Registry of regIOobjects.
Lookup type of boundary radiation properties.
A class for managing temporary objects.
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
const wordList internal
Standard volume internal field types (scalar, vector, tensor, etc).
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< scalar > scalarList
List of scalar.
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.