DimensionedFunction1: Function1 with dimensions
This can be used identically to a standard Function1. In addition, it
also permits specification of the dimensions. This allows the dimensions
to be checked. It also permits unit conversions. For example:
<name>
{
type table;
// Dimensions
xDimensions [CAD]; // Optional. Argument dimensions/units.
// Here, this specifies coordinates are in
// crank angle degrees (available if using
// engine time).
dimensions [mm]; // Optional. Value dimensions/units.
// Here, values are in mm.
// Tablulated data
values
(
(0 0)
(60 12) // <-- i.e., 12 mm at 60 degrees
(180 20)
(240 8)
(360 0)
);
outOfBounds repeat;
}
This replaces TimeFunction1, as it allows per-function control over
whether the function is considered to be one of real-time or user-time.
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -31,32 +31,13 @@ template<class Type>
|
||||
Foam::Function1s::Polynomial<Type>::Polynomial
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict
|
||||
const List<Tuple2<Type, Type>>& coeffs
|
||||
)
|
||||
:
|
||||
FieldFunction1<Type, Polynomial<Type>>(name),
|
||||
coeffs_(),
|
||||
canIntegrate_(true)
|
||||
coeffs_(coeffs),
|
||||
integrable_(true)
|
||||
{
|
||||
if (!dict.found(name))
|
||||
{
|
||||
dict.lookup("coeffs") >> coeffs_;
|
||||
}
|
||||
else
|
||||
{
|
||||
Istream& is(dict.lookup(name));
|
||||
word entryType(is);
|
||||
|
||||
if (is.eof())
|
||||
{
|
||||
dict.lookup("coeffs") >> coeffs_;
|
||||
}
|
||||
else
|
||||
{
|
||||
is >> coeffs_;
|
||||
}
|
||||
}
|
||||
|
||||
if (!coeffs_.size())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
@ -68,14 +49,14 @@ Foam::Function1s::Polynomial<Type>::Polynomial
|
||||
{
|
||||
if (mag(coeffs_[i].second() + pTraits<Type>::one) < rootVSmall)
|
||||
{
|
||||
canIntegrate_ = false;
|
||||
integrable_ = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
if (!canIntegrate_)
|
||||
if (!integrable_)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Polynomial " << this->name_ << " cannot be integrald"
|
||||
@ -89,39 +70,22 @@ template<class Type>
|
||||
Foam::Function1s::Polynomial<Type>::Polynomial
|
||||
(
|
||||
const word& name,
|
||||
const List<Tuple2<Type, Type>>& coeffs
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
FieldFunction1<Type, Polynomial<Type>>(name),
|
||||
coeffs_(coeffs),
|
||||
canIntegrate_(true)
|
||||
{
|
||||
if (!coeffs_.size())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Polynomial coefficients for entry " << this->name_
|
||||
<< " are invalid (empty)" << nl << exit(FatalError);
|
||||
}
|
||||
Polynomial<Type>(name, dict.lookup("coeffs"))
|
||||
{}
|
||||
|
||||
forAll(coeffs_, i)
|
||||
{
|
||||
if (mag(coeffs_[i].second() + 1) < rootVSmall)
|
||||
{
|
||||
canIntegrate_ = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
if (!canIntegrate_)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Polynomial " << this->name_ << " cannot be integrald"
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
template<class Type>
|
||||
Foam::Function1s::Polynomial<Type>::Polynomial
|
||||
(
|
||||
const word& name,
|
||||
Istream& is
|
||||
)
|
||||
:
|
||||
Polynomial<Type>(name, List<Tuple2<Type, Type>>(is))
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
@ -129,7 +93,7 @@ Foam::Function1s::Polynomial<Type>::Polynomial(const Polynomial& poly)
|
||||
:
|
||||
FieldFunction1<Type, Polynomial<Type>>(poly),
|
||||
coeffs_(poly.coeffs_),
|
||||
canIntegrate_(poly.canIntegrate_)
|
||||
integrable_(poly.integrable_)
|
||||
{}
|
||||
|
||||
|
||||
@ -168,7 +132,7 @@ Type Foam::Function1s::Polynomial<Type>::integral
|
||||
{
|
||||
Type intx(Zero);
|
||||
|
||||
if (canIntegrate_)
|
||||
if (integrable_)
|
||||
{
|
||||
forAll(coeffs_, i)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user