ENH: Refactored TimeFunction1 - now possible using Function1 directly

This commit is contained in:
Andrew Heather
2021-10-13 21:30:46 +01:00
committed by Mark Olesen
parent b9b011f5ea
commit f29eb55cee
9 changed files with 27 additions and 6 deletions

View File

@ -224,7 +224,7 @@ Foam::Function1Types::CSV<Type>::CSV
{ {
read(); read();
TableBase<Type>::check(); TableBase<Type>::initialise();
} }

View File

@ -56,6 +56,11 @@ void Foam::Function1Types::Polynomial<Type>::checkCoefficients()
<< "Polynomial " << this->name() << " cannot be integrated" << "Polynomial " << this->name() << " cannot be integrated"
<< endl; << endl;
} }
if (this->isTime())
{
convertTimeBase(this->time());
}
} }

View File

@ -50,6 +50,11 @@ Foam::Function1Types::Sine<Type>::Sine
{ {
frequency_ = Function1<scalar>::New("frequency", dict); frequency_ = Function1<scalar>::New("frequency", dict);
} }
if (this->isTime())
{
convertTimeBase(this->time());
}
} }

View File

@ -85,7 +85,7 @@ Foam::Function1Types::Table<Type>::Table
dict.readEntry("values", this->table_); dict.readEntry("values", this->table_);
} }
TableBase<Type>::check(); TableBase<Type>::initialise();
} }

View File

@ -107,7 +107,7 @@ Foam::Function1Types::TableBase<Type>::TableBase(const TableBase<Type>& tbl)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type> template<class Type>
void Foam::Function1Types::TableBase<Type>::check() const void Foam::Function1Types::TableBase<Type>::initialise()
{ {
if (!table_.size()) if (!table_.size())
{ {
@ -134,6 +134,11 @@ void Foam::Function1Types::TableBase<Type>::check() const
prevValue = currValue; prevValue = currValue;
++i; ++i;
} }
if (this->isTime())
{
convertTimeBase(this->time());
}
} }

View File

@ -119,7 +119,7 @@ public:
// Member Functions // Member Functions
//- Check the table for size and consistency //- Check the table for size and consistency
void check() const; void initialise();
//- Check minimum table bounds //- Check minimum table bounds
bool checkMinBounds(const scalar x, scalar& xDash) const; bool checkMinBounds(const scalar x, scalar& xDash) const;

View File

@ -57,7 +57,7 @@ Foam::Function1Types::TableFile<Type>::TableFile
is >> this->table_; is >> this->table_;
TableBase<Type>::check(); TableBase<Type>::initialise();
} }

View File

@ -34,6 +34,11 @@ void Foam::Function1Types::ramp::read(const dictionary& coeffs)
{ {
start_ = coeffs.getOrDefault<scalar>("start", 0); start_ = coeffs.getOrDefault<scalar>("start", 0);
coeffs.readEntry("duration", duration_); coeffs.readEntry("duration", duration_);
if (isTime())
{
convertTimeBase(time());
}
} }

View File

@ -42,7 +42,8 @@ Foam::TimeFunction1<Type>::TimeFunction1
name_(entryName), name_(entryName),
entry_(Function1<Type>::New(entryName, dict, &runTime)) entry_(Function1<Type>::New(entryName, dict, &runTime))
{ {
entry_->convertTimeBase(runTime); // Time conversion now handled by Function1 directly
// entry_->convertTimeBase(runTime);
} }