/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see .
\*---------------------------------------------------------------------------*/
#include "interpolationLookUpTable.H"
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
Foam::label
Foam::radiationModels::absorptionEmissionModels::interpolationLookUpTable::index
(
const List& indices,
const bool lastDim
) const
{
label totalIndex = 0;
forAll(dim_, i)
{
label dim = 1;
for (int j = i + 1; j < dim_.size(); j++)
{
dim *= dim_[j] + 1;
}
totalIndex +=
dim
*Foam::min
(
Foam::max(label((indices[i] - min_[i])/delta_[i]), 0),
dim_[i]
);
}
if (lastDim)
{
label iLastdim = dim_.size() - 1;
totalIndex += Foam::min
(
Foam::max
(
label((indices[iLastdim] - min_[iLastdim])/delta_[iLastdim]),
0
),
dim_[iLastdim]
);
}
return totalIndex;
}
Foam::label
Foam::radiationModels::absorptionEmissionModels::interpolationLookUpTable::index
(
const scalar indice
) const
{
label i = 0;
label totalIndex =
Foam::min
(
Foam::max
(
label((indice - min_[i])/delta_[i]),
0
),
dim_[i]
);
return totalIndex;
}
bool
Foam::radiationModels::absorptionEmissionModels::interpolationLookUpTable::
checkRange
(
const scalar lookUpValue,
const label interfield
) const
{
return lookUpValue >= min_[interfield] && lookUpValue <= max_[interfield];
}
Foam::scalar
Foam::radiationModels::absorptionEmissionModels::interpolationLookUpTable::
interpolate
(
const label lo,
const label hi,
const scalar lookUpValue,
const label ofield,
const label interfield
) const
{
if
(
List::operator[](interfield).operator[](hi)
!= List::operator[](interfield).operator[](lo)
)
{
scalar output
(
List::operator[](ofield).operator[](lo)
+ (
List::operator[](ofield).operator[](hi)
- List::operator[](ofield).operator[](lo)
)
*(
lookUpValue
- List::operator[](interfield).operator[](lo)
)
/(
List::operator[](interfield).operator[](hi)
- List::operator[](interfield).operator[](lo)
)
);
return output;
}
else
{
return List::operator[](ofield).operator[](lo);
}
}
void
Foam::radiationModels::absorptionEmissionModels::interpolationLookUpTable::
dimensionTable()
{
dim_.setSize(entries_.size());
min_.setSize(entries_.size());
delta_.setSize(entries_.size());
max_.setSize(entries_.size());
entryIndices_.setSize(entries_.size());
outputIndices_.setSize(output_.size());
label index = 0;
label tableDim = 1;
forAll(entries_,i)
{
dim_[i] = entries_[i].template lookup