Commit 0b464392 authored by Henry Weller's avatar Henry Weller
Browse files

Rename DataEntry -> Function1

Function1 is an abstract base-class of run-time selectable unary
functions which may be composed of other Function1's allowing the user
to specify complex functions of a single scalar variable, e.g. time.
The implementations need not be a simple or continuous functions;
interpolated tables and polynomials are also supported.  In fact form of
mapping between a single scalar input and a single primitive type output
is supportable.

The primary application of Function1 is in time-varying boundary
conditions, it also used for other functions of time, e.g. injected mass
is spray simulations but is not limited to functions of time.
parent e0ae7fc0
Test-Function1.C
EXE = $(FOAM_USER_APPBIN)/Test-Function1
......@@ -22,15 +22,15 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
testDataEntry
Test-Function1
Description
Tests DataEntry
Tests Function1
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "DataEntry.H"
#include "Function1.H"
#include "IOdictionary.H"
#include "linearInterpolationWeights.H"
#include "splineInterpolationWeights.H"
......@@ -54,8 +54,8 @@ int main(int argc, char *argv[])
//values[0] = 0.0;
//values[1] = 1.0;
//linearInterpolationWeights interpolator
splineInterpolationWeights interpolator
linearInterpolationWeights interpolator
//splineInterpolationWeights interpolator
(
samples
);
......@@ -98,11 +98,11 @@ int main(int argc, char *argv[])
return 1;
}
IOdictionary dataEntryProperties
IOdictionary function1Properties
(
IOobject
(
"dataEntryProperties",
"function1Properties",
runTime.constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
......@@ -110,19 +110,19 @@ int main(int argc, char *argv[])
)
);
autoPtr<DataEntry<scalar>> dataEntry
autoPtr<Function1<scalar>> function1
(
DataEntry<scalar>::New
Function1<scalar>::New
(
"dataEntry",
dataEntryProperties
"function1",
function1Properties
)
);
scalar x0 = readScalar(dataEntryProperties.lookup("x0"));
scalar x1 = readScalar(dataEntryProperties.lookup("x1"));
scalar x0 = readScalar(function1Properties.lookup("x0"));
scalar x1 = readScalar(function1Properties.lookup("x1"));
Info<< "Data entry type: " << dataEntry().type() << nl << endl;
Info<< "Data entry type: " << function1().type() << nl << endl;
Info<< "Inputs" << nl
<< " x0 = " << x0 << nl
......@@ -130,12 +130,12 @@ int main(int argc, char *argv[])
<< endl;
Info<< "Interpolation" << nl
<< " f(x0) = " << dataEntry().value(x0) << nl
<< " f(x1) = " << dataEntry().value(x1) << nl
<< " f(x0) = " << function1().value(x0) << nl
<< " f(x1) = " << function1().value(x1) << nl
<< endl;
Info<< "Integration" << nl
<< " int(f(x)) lim(x0->x1) = " << dataEntry().integrate(x0, x1) << nl
<< " int(f(x)) lim(x0->x1) = " << function1().integrate(x0, x1) << nl
<< endl;
return 0;
......
......@@ -11,7 +11,7 @@ FoamFile
format ascii;
class dictionary;
location "constant";
object dataEntryProperties;
object function1Properties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -19,7 +19,7 @@ x0 0.5;
x1 1;
dataEntry table ((0 0)(10 1));
function1 table ((0 0)(10 1));
// ************************************************************************* //
Test-DataEntry.C
EXE = $(FOAM_USER_APPBIN)/Test-DataEntry
......@@ -135,7 +135,7 @@ int main(int argc, char *argv[])
#include "createFields.H"
Info<< "Reading data file" << endl;
DataEntryTypes::CSV<scalar> pData("pressure", dict, "Data");
Function1Types::CSV<scalar> pData("pressure", dict, "Data");
// time history data
const scalarField t(pData.x());
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -76,7 +76,7 @@ CONSTRUCT
scalarData_(readScalar(dict.lookup("scalarData"))),
data_(pTraits<TYPE>(dict.lookup("data"))),
fieldData_("fieldData", dict, p.size()),
timeVsData_(DataEntry<TYPE>::New("timeVsData", dict)),
timeVsData_(Function1<TYPE>::New("timeVsData", dict)),
wordData_(dict.lookupOrDefault<word>("wordName", "wordDefault")),
labelData_(-1),
boolData_(false)
......@@ -203,7 +203,10 @@ void Foam::CLASS::updateCoeffs()
);
const scalarField& phip =
this->patch().template lookupPatchField<surfaceScalarField, scalar>("phi");
this->patch().template lookupPatchField<surfaceScalarField, scalar>
(
"phi"
);
this->valueFraction() = 1.0 - pos(phip);
PARENT::updateCoeffs();
......
......@@ -80,7 +80,7 @@ SourceFiles
#define CONSTRUCT_H
#include "BASEFvPatchFields.H"
#include "DataEntry.H"
#include "Function1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -110,7 +110,7 @@ class CONSTRUCT
FIELD fieldData_;
//- Type specified as a function of time for time-varying BCs
autoPtr<DataEntry<TYPE>> timeVsData_;
autoPtr<Function1<TYPE>> timeVsData_;
//- Word entry, e.g. pName_ for name of the pressure field on database
word wordData_;
......
......@@ -123,7 +123,7 @@ DebugSwitches
DICGaussSeidel 0;
DILU 0;
DILUGaussSeidel 0;
DataEntry 0;
Function1 0;
DeardorffDiffStress 0;
DispersionModel 0;
DispersionRASModel 0;
......
......@@ -72,7 +72,7 @@ primitives/septernion/septernion.C
primitives/triad/triad.C
/* functions, data entries */
primitives/functions/DataEntry/makeDataEntries.C
primitives/functions/Function1/makeDataEntries.C
primitives/functions/Polynomial/polynomialFunction.C
primitives/subModelBase/subModelBase.C
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -50,7 +50,7 @@ uniformFixedValuePointPatchField
)
:
fixedValuePointPatchField<Type>(p, iF, dict, false),
uniformValue_(DataEntry<Type>::New("uniformValue", dict))
uniformValue_(Function1<Type>::New("uniformValue", dict))
{
if (dict.found("value"))
{
......
......@@ -36,7 +36,7 @@ Description
}
\endverbatim
The uniformValue entry is a DataEntry type, able to describe time
The uniformValue entry is a Function1 type, able to describe time
varying functions. The example above gives the usage for supplying a
constant value.
......@@ -49,7 +49,7 @@ SourceFiles
#define uniformFixedValuePointPatchField_H
#include "fixedValuePointPatchField.H"
#include "DataEntry.H"
#include "Function1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -67,7 +67,7 @@ class uniformFixedValuePointPatchField
{
// Private data
autoPtr<DataEntry<Type>> uniformValue_;
autoPtr<Function1<Type>> uniformValue_;
public:
......@@ -150,7 +150,7 @@ public:
// Access
//- Return the fluctuation scale
const DataEntry<Type>& uniformValue() const
const Function1<Type>& uniformValue() const
{
return uniformValue_;
}
......
......@@ -30,7 +30,7 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<>
Foam::label Foam::DataEntryTypes::CSV<Foam::label>::readValue
Foam::label Foam::Function1Types::CSV<Foam::label>::readValue
(
const List<string>& splitted
)
......@@ -48,7 +48,7 @@ Foam::label Foam::DataEntryTypes::CSV<Foam::label>::readValue
template<>
Foam::scalar Foam::DataEntryTypes::CSV<Foam::scalar>::readValue
Foam::scalar Foam::Function1Types::CSV<Foam::scalar>::readValue
(
const List<string>& splitted
)
......@@ -66,7 +66,7 @@ Foam::scalar Foam::DataEntryTypes::CSV<Foam::scalar>::readValue
template<class Type>
Type Foam::DataEntryTypes::CSV<Type>::readValue(const List<string>& splitted)
Type Foam::Function1Types::CSV<Type>::readValue(const List<string>& splitted)
{
Type result;
......@@ -89,7 +89,7 @@ Type Foam::DataEntryTypes::CSV<Type>::readValue(const List<string>& splitted)
template<class Type>
void Foam::DataEntryTypes::CSV<Type>::read()
void Foam::Function1Types::CSV<Type>::read()
{
fileName expandedFile(fName_);
IFstream is(expandedFile.expand());
......@@ -200,7 +200,7 @@ void Foam::DataEntryTypes::CSV<Type>::read()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::DataEntryTypes::CSV<Type>::CSV
Foam::Function1Types::CSV<Type>::CSV
(
const word& entryName,
const dictionary& dict,
......@@ -231,7 +231,7 @@ Foam::DataEntryTypes::CSV<Type>::CSV
template<class Type>
Foam::DataEntryTypes::CSV<Type>::CSV(const CSV<Type>& tbl)
Foam::Function1Types::CSV<Type>::CSV(const CSV<Type>& tbl)
:
TableBase<Type>(tbl),
nHeaderLine_(tbl.nHeaderLine_),
......@@ -246,14 +246,14 @@ Foam::DataEntryTypes::CSV<Type>::CSV(const CSV<Type>& tbl)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::DataEntryTypes::CSV<Type>::~CSV()
Foam::Function1Types::CSV<Type>::~CSV()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
const Foam::fileName& Foam::DataEntryTypes::CSV<Type>::fName() const
const Foam::fileName& Foam::Function1Types::CSV<Type>::fName() const
{
return fName_;
}
......
......@@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::DataEntryTypes::CSV
Foam::Function1Types::CSV
Description
Templated CSV container data entry. Reference column is always a scalar,
......@@ -51,7 +51,7 @@ SourceFiles
#ifndef CSV_H
#define CSV_H
#include "DataEntry.H"
#include "Function1.H"
#include "TableBase.H"
#include "Tuple2.H"
#include "labelList.H"
......@@ -63,15 +63,15 @@ namespace Foam
{
// Forward declaration of friend functions and operators
namespace DataEntryTypes
namespace Function1Types
{
template<class Type> class CSV;
};
template<class Type>
Ostream& operator<<(Ostream&, const DataEntryTypes::CSV<Type>&);
Ostream& operator<<(Ostream&, const Function1Types::CSV<Type>&);
namespace DataEntryTypes
namespace Function1Types
{
/*---------------------------------------------------------------------------*\
......@@ -139,9 +139,9 @@ public:
CSV(const CSV<Type>& tbl);
//- Construct and return a clone
virtual tmp<DataEntry<Type>> clone() const
virtual tmp<Function1<Type>> clone() const
{
return tmp<DataEntry<Type>>(new CSV<Type>(*this));
return tmp<Function1<Type>>(new CSV<Type>(*this));
}
......@@ -180,7 +180,7 @@ Foam::scalar CSV<scalar>::readValue(const List<string>& splitted);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace DataEntryTypes
} // End namespace Function1Types
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -23,7 +23,7 @@ License
\*---------------------------------------------------------------------------*/
#include "DataEntry.H"
#include "Function1.H"
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
......@@ -31,10 +31,10 @@ template<class Type>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const DataEntryTypes::CSV<Type>& tbl
const Function1Types::CSV<Type>& tbl
)
{
os << static_cast<const DataEntry<Type>& >(tbl)
os << static_cast<const Function1<Type>& >(tbl)
<< token::SPACE << tbl.nHeaderLine_
<< token::SPACE << tbl.timeColumn_
<< token::SPACE << tbl.componentColumns_
......@@ -50,9 +50,9 @@ Foam::Ostream& Foam::operator<<
template<class Type>
void Foam::DataEntryTypes::CSV<Type>::writeData(Ostream& os) const
void Foam::Function1Types::CSV<Type>::writeData(Ostream& os) const
{
DataEntry<Type>::writeData(os);
Function1<Type>::writeData(os);
os << token::END_STATEMENT << nl;
os << indent << word(this->name() + "Coeffs") << nl;
os << indent << token::BEGIN_BLOCK << incrIndent << nl;
......
......@@ -28,13 +28,13 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::DataEntryTypes::Constant<Type>::Constant
Foam::Function1Types::Constant<Type>::Constant
(
const word& entryName,
const dictionary& dict
)
:
DataEntry<Type>(entryName),
Function1<Type>(entryName),
value_(pTraits<Type>::zero)
{
Istream& is(dict.lookup(entryName));
......@@ -44,21 +44,21 @@ Foam::DataEntryTypes::Constant<Type>::Constant
template<class Type>
Foam::DataEntryTypes::Constant<Type>::Constant
Foam::Function1Types::Constant<Type>::Constant
(
const word& entryName,
Istream& is
)
:
DataEntry<Type>(entryName),
Function1<Type>(entryName),
value_(pTraits<Type>(is))
{}
template<class Type>
Foam::DataEntryTypes::Constant<Type>::Constant(const Constant<Type>& cnst)
Foam::Function1Types::Constant<Type>::Constant(const Constant<Type>& cnst)
:
DataEntry<Type>(cnst),
Function1<Type>(cnst),
value_(cnst.value_)
{}
......@@ -66,21 +66,21 @@ Foam::DataEntryTypes::Constant<Type>::Constant(const Constant<Type>& cnst)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::DataEntryTypes::Constant<Type>::~Constant()
Foam::Function1Types::Constant<Type>::~Constant()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Type Foam::DataEntryTypes::Constant<Type>::value(const scalar x) const
Type Foam::Function1Types::Constant<Type>::value(const scalar x) const
{
return value_;
}
template<class Type>
Type Foam::DataEntryTypes::Constant<Type>::integrate
Type Foam::Function1Types::Constant<Type>::integrate
(
const scalar x1,
const scalar x2
......
......@@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::DataEntryTypes::Constant
Foam::Function1Types::Constant
Description
Templated basic entry that holds a constant value.
......@@ -40,7 +40,7 @@ SourceFiles
#ifndef Constant_H
#define Constant_H
#include "DataEntry.H"
#include "Function1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -48,15 +48,15 @@ namespace Foam
{
// Forward declaration of friend functions and operators
namespace DataEntryTypes
namespace Function1Types
{
template<class Type> class Constant;
};
template<class Type>
Ostream& operator<<(Ostream&, const DataEntryTypes::Constant<Type>&);
Ostream& operator<<(Ostream&, const Function1Types::Constant<Type>&);
namespace DataEntryTypes
namespace Function1Types
{
/*---------------------------------------------------------------------------*\
......@@ -66,7 +66,7 @@ namespace DataEntryTypes
template<class Type>
class Constant
:
public DataEntry<Type>
public Function1<Type>
{
// Private data
......@@ -92,7 +92,7 @@ public:
Constant(const word& entryName, const dictionary& dict);
//- Construct from entry name and Istream
// Reads the constant value without the DataEntry type
// Reads the constant value without the Function1 type
// for backward compatibility
Constant(const word& entryName, Istream& is);
......@@ -100,9 +100,9 @@ public:
Constant(const Constant<Type>& cnst);
//- Construct and return a clone
virtual tmp<DataEntry<Type>> clone() const
virtual tmp<Function1<Type>> clone() const
{
return tmp<DataEntry<Type>>(new Constant<Type>(*this));
return tmp<Function1<Type>>(new Constant<Type>(*this));
}
......@@ -135,14 +135,14 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace DataEntryTypes
} // End namespace Function1Types
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "Constant.C"
# include "DataEntryNew.C"
# include "Function1New.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -31,10 +31,10 @@ template<class Type>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const DataEntryTypes::Constant<Type>& cnst
const Function1Types::Constant<Type>& cnst
)
{
os << static_cast<const DataEntry<Type>& >(cnst)
os << static_cast<const Function1<Type>& >(cnst)
<< token::SPACE << cnst.value_;
// Check state of Ostream
......@@ -48,9 +48,9 @@ Foam::Ostream& Foam::operator<<
template<class Type>
void Foam::DataEntryTypes::Constant<Type>::writeData(Ostream& os) const
void Foam::Function1Types::Constant<Type>::writeData(Ostream& os) const
{
DataEntry<Type>::writeData(os);
Function1<Type>::writeData(os);
os << token::SPACE << value_ << token::END_STATEMENT << nl;
}
......
......@@ -23,13 +23,13 @@ License
\*---------------------------------------------------------------------------*/
#include "DataEntry.H"
#include "Function1.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::DataEntry<Type>::DataEntry(const word& entryName)
Foam::Function1<Type>::Function1(const word& entryName)
:
refCount(),
name_(entryName)
......@@ -37,7 +37,7 @@ Foam::DataEntry<Type>::DataEntry(const word& entryName)
template<class Type>
Foam::DataEntry<Type>::DataEntry(const DataEntry<Type>& de)
Foam::Function1<Type>::Function1(const Function1<Type>& de)
:
refCount(),
name_(de.name_)
......@@ -47,28 +47,28 @@ Foam::DataEntry<Type>::DataEntry(const DataEntry<Type>& de)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //