Function1: Corrections to Scale integration and Table default bounds handling
This commit is contained in:
@ -37,9 +37,13 @@ void Foam::Function1Types::Scale<Type>::read(const dictionary& coeffs)
|
||||
: autoPtr<Function1<scalar>>(new Constant<scalar>("xScale", 1));
|
||||
value_ = Function1<Type>::New("value", coeffs);
|
||||
|
||||
integrable_ =
|
||||
integrableScale_ =
|
||||
isA<Constant<scalar>>(xScale_())
|
||||
&& isA<Constant<scalar>>(scale_());
|
||||
|
||||
integrableValue_ =
|
||||
isA<Constant<scalar>>(xScale_())
|
||||
&& isA<Constant<Type>>(value_());
|
||||
}
|
||||
|
||||
|
||||
@ -65,7 +69,8 @@ Foam::Function1Types::Scale<Type>::Scale(const Scale<Type>& se)
|
||||
scale_(se.scale_, false),
|
||||
xScale_(se.xScale_, false),
|
||||
value_(se.value_, false),
|
||||
integrable_(se.integrable_)
|
||||
integrableScale_(se.integrableScale_),
|
||||
integrableValue_(se.integrableValue_)
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -149,7 +149,10 @@ class Scale
|
||||
autoPtr<Function1<Type>> value_;
|
||||
|
||||
//- Is this function integrable?
|
||||
bool integrable_;
|
||||
bool integrableScale_;
|
||||
|
||||
//- Is this function integrable?
|
||||
bool integrableValue_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
@ -42,16 +42,25 @@ inline Type Foam::Function1Types::Scale<Type>::integrate
|
||||
const scalar x2
|
||||
) const
|
||||
{
|
||||
if (!integrable_)
|
||||
if (integrableScale_)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Integration is not defined for " << type() << " functions "
|
||||
<< "unless all scaling is constant"
|
||||
<< exit(FatalError);
|
||||
const scalar sx = xScale_->value(NaN);
|
||||
return scale_->value(NaN)*value_->integrate(sx*x1, sx*x2)/sx;
|
||||
}
|
||||
|
||||
const scalar sx = xScale_->value(NaN);
|
||||
return scale_->value(NaN)/sx*value_->integrate(sx*x1, sx*x2);
|
||||
if (integrableValue_)
|
||||
{
|
||||
const scalar sx = xScale_->value(NaN);
|
||||
return scale_->integrate(sx*x1, sx*x2)/sx*value_->value(NaN);
|
||||
}
|
||||
|
||||
FatalErrorInFunction
|
||||
<< "Integration is not defined for " << type() << " functions "
|
||||
<< "unless x-scaling is constant and either scaling is constant or "
|
||||
<< "the value is constant"
|
||||
<< exit(FatalError);
|
||||
|
||||
return Zero;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -144,7 +144,7 @@ Foam::Function1Types::TableBase<Type>::TableBase
|
||||
(
|
||||
dict.found("outOfBounds")
|
||||
? tableBase::boundsHandlingNames_.read(dict.lookup("outOfBounds"))
|
||||
: tableBase::boundsHandling::warn
|
||||
: tableBase::boundsHandling::clamp
|
||||
),
|
||||
interpolationScheme_
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user