Potential bugs in integratedNonUniformTable and nonUniformTable
Summary
-
nonUniformTable::index(...)
will return a negative index if the input temperature is lower thanTrange_.min()
, which will then cause the simulation to crash when used in thejumpTable_
-
The piece-wise integrals of f and fByT seem to be computed wrongly in the constructor of
integratedNonUniformTable
. Since theintfdT
andintfByTdT
functions already add the integral up until the previous point, these shouldn't be added again in the constructor, right?
Environment information
- OpenFOAM version : develop branch
- Compiler : gcc-9.3.0
Possible fixes
- In
nonUniformTable::index
, use maybe
if (T >= Trange_.min() && T <= Trange_.max())
{
nd = (T - Trange_.min())/deltaT_;
}
else if (T > Trange_.max())
{
nd = (Trange_.max() - Trange_.min())/deltaT_;
}
else if (T < Trange_.min())
{
nd = 0;
}
instead of
if (T > Trange_.min() || T < Trange_.max())
{
nd = (T - Trange_.min())/deltaT_;
}
else if (T > Trange_.max())
{
nd = (Trange_.max() - Trange_.min())/deltaT_;
}
lines 40-47 of nonUniformTableThermophysicalFunctionI.H.
As the code stands, if T < Trange_.min
, the first branch will give a negative nd
value.
for (label i = 1; i < intf_.size(); ++i)
{
// Maybe use these ...
intf_[i] = intfdT(0, values()[i].first());
intfByT_[i] = intfByTdT(0, values()[i].first());
// ... instead of these
//intf_[i] = intf_[i-1] + intfdT(0, values()[i].first());
//intfByT_[i] = intfByT_[i-1] + intfByTdT(0, values()[i].first());
}
lines 69-70 of integratedNonUniformTable.C.
since intf_[i-1]
and intfByT_[i-1]
are already added in the intfdT
and intfByTdT
functions.