Function1: Rationalized construction to support the simpler sub-dictionary format
e.g.
ramp
{
type quadratic;
start 200;
duration 1.6;
}
but the old format is supported for backward compatibility:
ramp linear;
rampCoeffs
{
start 200;
duration 1.6;
}
This commit is contained in:
@ -133,7 +133,7 @@ int main(int argc, char *argv[])
|
|||||||
#include "createFields.H"
|
#include "createFields.H"
|
||||||
|
|
||||||
Info<< "Reading data file" << endl;
|
Info<< "Reading data file" << endl;
|
||||||
Function1Types::CSV<scalar> pData("pressure", dict, "Data");
|
Function1Types::CSV<scalar> pData("pressure", dict.subDict("pressureData"));
|
||||||
|
|
||||||
// time history data
|
// time history data
|
||||||
const scalarField t(pData.x());
|
const scalarField t(pData.x());
|
||||||
|
|||||||
@ -203,18 +203,16 @@ template<class Type>
|
|||||||
Foam::Function1Types::CSV<Type>::CSV
|
Foam::Function1Types::CSV<Type>::CSV
|
||||||
(
|
(
|
||||||
const word& entryName,
|
const word& entryName,
|
||||||
const dictionary& dict,
|
const dictionary& dict
|
||||||
const word& ext
|
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
TableBase<Type>(entryName, dict.subDict(entryName + ext)),
|
TableBase<Type>(entryName, dict),
|
||||||
coeffs_(dict.subDict(entryName + ext)),
|
nHeaderLine_(readLabel(dict.lookup("nHeaderLine"))),
|
||||||
nHeaderLine_(readLabel(coeffs_.lookup("nHeaderLine"))),
|
refColumn_(readLabel(dict.lookup("refColumn"))),
|
||||||
refColumn_(readLabel(coeffs_.lookup("refColumn"))),
|
componentColumns_(dict.lookup("componentColumns")),
|
||||||
componentColumns_(coeffs_.lookup("componentColumns")),
|
separator_(dict.lookupOrDefault<string>("separator", string(","))[0]),
|
||||||
separator_(coeffs_.lookupOrDefault<string>("separator", string(","))[0]),
|
mergeSeparators_(readBool(dict.lookup("mergeSeparators"))),
|
||||||
mergeSeparators_(readBool(coeffs_.lookup("mergeSeparators"))),
|
fName_(dict.lookup("file"))
|
||||||
fName_(coeffs_.lookup("file"))
|
|
||||||
{
|
{
|
||||||
if (componentColumns_.size() != pTraits<Type>::nComponents)
|
if (componentColumns_.size() != pTraits<Type>::nComponents)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -25,9 +25,11 @@ Class
|
|||||||
Foam::Function1Types::CSV
|
Foam::Function1Types::CSV
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Templated CSV container data entry. Reference column is always a scalar,
|
Templated CSV function.
|
||||||
e.g. time
|
|
||||||
|
|
||||||
|
Reference column is always a scalar, e.g. time.
|
||||||
|
|
||||||
|
Usage:
|
||||||
\verbatim
|
\verbatim
|
||||||
<entryName> csvFile;
|
<entryName> csvFile;
|
||||||
<entryName>Coeffs
|
<entryName>Coeffs
|
||||||
@ -75,9 +77,6 @@ class CSV
|
|||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
//- Coefficients dictionary (for convenience on reading)
|
|
||||||
dictionary coeffs_;
|
|
||||||
|
|
||||||
//- Number header lines
|
//- Number header lines
|
||||||
label nHeaderLine_;
|
label nHeaderLine_;
|
||||||
|
|
||||||
@ -121,8 +120,7 @@ public:
|
|||||||
CSV
|
CSV
|
||||||
(
|
(
|
||||||
const word& entryName,
|
const word& entryName,
|
||||||
const dictionary& dict,
|
const dictionary& dict
|
||||||
const word& ext = "Coeffs"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Copy constructor
|
//- Copy constructor
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -25,9 +25,9 @@ Class
|
|||||||
Foam::Function1Types::Constant
|
Foam::Function1Types::Constant
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Templated basic entry that holds a constant value.
|
Templated function that returns a constant value.
|
||||||
|
|
||||||
Usage - for entry \<entryName\> having the value <value>:
|
Usage - for entry \<entryName\> returning the value <value>:
|
||||||
\verbatim
|
\verbatim
|
||||||
<entryName> constant <value>
|
<entryName> constant <value>
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -195,6 +195,14 @@ public:
|
|||||||
add##SS##Type##ConstructorToTable_;
|
add##SS##Type##ConstructorToTable_;
|
||||||
|
|
||||||
|
|
||||||
|
#define makeScalarFunction1(SS) \
|
||||||
|
\
|
||||||
|
defineTypeNameAndDebug(SS, 0); \
|
||||||
|
\
|
||||||
|
Function1<scalar>::adddictionaryConstructorToTable<SS> \
|
||||||
|
add##SS##ConstructorToTable_;
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#ifdef NoRepository
|
#ifdef NoRepository
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -34,6 +34,30 @@ Foam::autoPtr<Foam::Function1<Type>> Foam::Function1<Type>::New
|
|||||||
const dictionary& dict
|
const dictionary& dict
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
if (dict.isDict(entryName))
|
||||||
|
{
|
||||||
|
const dictionary& coeffsDict(dict.subDict(entryName));
|
||||||
|
|
||||||
|
const word Function1Type(coeffsDict.lookup("type"));
|
||||||
|
|
||||||
|
typename dictionaryConstructorTable::iterator cstrIter =
|
||||||
|
dictionaryConstructorTablePtr_->find(Function1Type);
|
||||||
|
|
||||||
|
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Unknown Function1 type "
|
||||||
|
<< Function1Type << " for Function1 "
|
||||||
|
<< entryName << nl << nl
|
||||||
|
<< "Valid Function1 types are:" << nl
|
||||||
|
<< dictionaryConstructorTablePtr_->sortedToc() << nl
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cstrIter()(entryName, coeffsDict);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Istream& is(dict.lookup(entryName, false));
|
Istream& is(dict.lookup(entryName, false));
|
||||||
|
|
||||||
token firstToken(is);
|
token firstToken(is);
|
||||||
@ -66,7 +90,14 @@ Foam::autoPtr<Foam::Function1<Type>> Foam::Function1<Type>::New
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cstrIter()(entryName, dict);
|
return cstrIter()
|
||||||
|
(
|
||||||
|
entryName,
|
||||||
|
dict.found(entryName + "Coeffs")
|
||||||
|
? dict.subDict(entryName + "Coeffs")
|
||||||
|
: dict
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -43,13 +43,12 @@ template<class Type>
|
|||||||
Foam::Function1Types::Sine<Type>::Sine
|
Foam::Function1Types::Sine<Type>::Sine
|
||||||
(
|
(
|
||||||
const word& entryName,
|
const word& entryName,
|
||||||
const dictionary& dict,
|
const dictionary& dict
|
||||||
const word& ext
|
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
Function1<Type>(entryName)
|
Function1<Type>(entryName)
|
||||||
{
|
{
|
||||||
read(dict.subDict(entryName + ext));
|
read(dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -132,8 +132,7 @@ public:
|
|||||||
Sine
|
Sine
|
||||||
(
|
(
|
||||||
const word& entryName,
|
const word& entryName,
|
||||||
const dictionary& dict,
|
const dictionary& dict
|
||||||
const word& ext = "Coeffs"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Copy constructor
|
//- Copy constructor
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -43,13 +43,12 @@ template<class Type>
|
|||||||
Foam::Function1Types::Square<Type>::Square
|
Foam::Function1Types::Square<Type>::Square
|
||||||
(
|
(
|
||||||
const word& entryName,
|
const word& entryName,
|
||||||
const dictionary& dict,
|
const dictionary& dict
|
||||||
const word& ext
|
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
Function1<Type>(entryName)
|
Function1<Type>(entryName)
|
||||||
{
|
{
|
||||||
read(dict.subDict(entryName + ext));
|
read(dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -139,8 +139,7 @@ public:
|
|||||||
Square
|
Square
|
||||||
(
|
(
|
||||||
const word& entryName,
|
const word& entryName,
|
||||||
const dictionary& dict,
|
const dictionary& dict
|
||||||
const word& ext = "Coeffs"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Copy constructor
|
//- Copy constructor
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -25,10 +25,12 @@ Class
|
|||||||
Foam::Function1Types::Table
|
Foam::Function1Types::Table
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Templated table container data entry. Items are stored in a list of
|
Templated table container function.
|
||||||
Tuple2's. First column is always stored as scalar entries. Data is read
|
|
||||||
in Tuple2 form, e.g. for an entry \<entryName\> that is (scalar, vector):
|
|
||||||
|
|
||||||
|
Items are stored in a list of Tuple2's. First column is always stored as
|
||||||
|
scalar entries. Data is read in Tuple2 form.
|
||||||
|
|
||||||
|
Usage:
|
||||||
\verbatim
|
\verbatim
|
||||||
<entryName> table
|
<entryName> table
|
||||||
(
|
(
|
||||||
|
|||||||
@ -34,11 +34,10 @@ Foam::Function1Types::TableFile<Type>::TableFile
|
|||||||
const dictionary& dict
|
const dictionary& dict
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
TableBase<Type>(entryName, dict.subDict(entryName + "Coeffs")),
|
TableBase<Type>(entryName, dict),
|
||||||
fName_("none")
|
fName_("none")
|
||||||
{
|
{
|
||||||
const dictionary coeffs(dict.subDict(entryName + "Coeffs"));
|
dict.lookup("file") >> fName_;
|
||||||
coeffs.lookup("file") >> fName_;
|
|
||||||
|
|
||||||
fileName expandedFile(fName_);
|
fileName expandedFile(fName_);
|
||||||
IFstream is(expandedFile.expand());
|
IFstream is(expandedFile.expand());
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -25,8 +25,9 @@ Class
|
|||||||
Foam::Function1Types::TableFile
|
Foam::Function1Types::TableFile
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Templated table container data entry where data is read from file.
|
Templated table container function where data is read from file.
|
||||||
|
|
||||||
|
Usage:
|
||||||
\verbatim
|
\verbatim
|
||||||
<entryName> tableFile;
|
<entryName> tableFile;
|
||||||
<entryName>Coeffs
|
<entryName>Coeffs
|
||||||
@ -37,7 +38,7 @@ Description
|
|||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
Items are stored in a list of Tuple2's. First column is always stored as
|
Data is stored as a list of Tuple2's. First column is always stored as
|
||||||
scalar entries. Data is read in the form, e.g. for an entry \<entryName\>
|
scalar entries. Data is read in the form, e.g. for an entry \<entryName\>
|
||||||
that is (scalar, vector):
|
that is (scalar, vector):
|
||||||
\verbatim
|
\verbatim
|
||||||
@ -47,7 +48,6 @@ Description
|
|||||||
);
|
);
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
TableFile.C
|
TableFile.C
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -24,6 +24,8 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "Constant.H"
|
#include "Constant.H"
|
||||||
|
#include "ZeroConstant.H"
|
||||||
|
#include "OneConstant.H"
|
||||||
#include "PolynomialEntry.H"
|
#include "PolynomialEntry.H"
|
||||||
#include "Sine.H"
|
#include "Sine.H"
|
||||||
#include "Square.H"
|
#include "Square.H"
|
||||||
@ -38,6 +40,8 @@ License
|
|||||||
#define makeFunction1s(Type) \
|
#define makeFunction1s(Type) \
|
||||||
makeFunction1(Type); \
|
makeFunction1(Type); \
|
||||||
makeFunction1Type(Constant, Type); \
|
makeFunction1Type(Constant, Type); \
|
||||||
|
makeFunction1Type(ZeroConstant, Type); \
|
||||||
|
makeFunction1Type(OneConstant, Type); \
|
||||||
makeFunction1Type(Polynomial, Type); \
|
makeFunction1Type(Polynomial, Type); \
|
||||||
makeFunction1Type(Sine, Type); \
|
makeFunction1Type(Sine, Type); \
|
||||||
makeFunction1Type(Square, Type); \
|
makeFunction1Type(Square, Type); \
|
||||||
|
|||||||
Reference in New Issue
Block a user