ENH: PatchFunction1: backwards compatibility. See #1046.

This commit is contained in:
mattijs
2018-10-30 15:13:23 +00:00
parent 04a985ccb3
commit 0048b05fdf
10 changed files with 56 additions and 28 deletions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -114,7 +114,8 @@ public:
static autoPtr<Function1<Type>> New
(
const word& entryName,
const dictionary& dict
const dictionary& dict,
const word& redirectType = word::null
);

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,14 +31,20 @@ template<class Type>
Foam::autoPtr<Foam::Function1<Type>> Foam::Function1<Type>::New
(
const word& entryName,
const dictionary& dict
const dictionary& dict,
const word& redirectType
)
{
if (dict.isDict(entryName))
{
const dictionary& coeffsDict(dict.subDict(entryName));
const word Function1Type(coeffsDict.get<word>("type"));
const word Function1Type
(
redirectType.empty()
? coeffsDict.get<word>("type")
: coeffsDict.lookupOrDefault<word>("type", redirectType)
);
auto cstrIter = dictionaryConstructorTablePtr_->cfind(Function1Type);
@ -57,10 +63,17 @@ Foam::autoPtr<Foam::Function1<Type>> Foam::Function1<Type>::New
}
else
{
Istream& is = dict.lookup(entryName, keyType::REGEX);
const dictionary::const_searcher finder
(
dict.csearch(entryName, keyType::REGEX)
);
word Function1Type;
if (finder.found())
{
Istream& is = finder.ref().stream();
token firstToken(is);
word Function1Type;
if (!firstToken.isWord())
{
@ -74,6 +87,12 @@ Foam::autoPtr<Foam::Function1<Type>> Foam::Function1<Type>::New
{
Function1Type = firstToken.wordToken();
}
}
else
{
Function1Type = redirectType;
}
auto cstrIter = dictionaryConstructorTablePtr_->cfind(Function1Type);

View File

@ -127,6 +127,7 @@ template<class Type>
Foam::PatchFunction1Types::ConstantField<Type>::ConstantField
(
const polyPatch& pp,
const word& type,
const word& entryName,
const dictionary& dict,
const bool faceValues

View File

@ -100,6 +100,7 @@ public:
ConstantField
(
const polyPatch& pp,
const word& type,
const word& entryName,
const dictionary& dict,
const bool faceValues = true

View File

@ -33,6 +33,7 @@ template<class Type>
Foam::PatchFunction1Types::MappedFile<Type>::MappedFile
(
const polyPatch& pp,
const word& type,
const word& entryName,
const dictionary& dict,
const bool faceValues

View File

@ -122,6 +122,7 @@ public:
MappedFile
(
const polyPatch& pp,
const word& type,
const word& entryName,
const dictionary& dict,
const bool faceValues = true

View File

@ -115,11 +115,12 @@ public:
dictionary,
(
const polyPatch& pp,
const word& type,
const word& entryName,
const dictionary& dict,
const bool faceValues
),
(pp, entryName, dict, faceValues)
(pp, type, entryName, dict, faceValues)
);

View File

@ -55,7 +55,7 @@ Foam::autoPtr<Foam::PatchFunction1<Type>> Foam::PatchFunction1<Type>::New
<< exit(FatalIOError);
}
return cstrIter()(pp, entryName, coeffsDict, faceValues);
return cstrIter()(pp, modelType, entryName, coeffsDict, faceValues);
}
else
{
@ -75,7 +75,7 @@ Foam::autoPtr<Foam::PatchFunction1<Type>> Foam::PatchFunction1<Type>::New
(
pp,
entryName,
value,
value, // Supply value
dict,
faceValues
)
@ -92,6 +92,7 @@ Foam::autoPtr<Foam::PatchFunction1<Type>> Foam::PatchFunction1<Type>::New
new PatchFunction1Types::ConstantField<Type>
(
pp,
PatchFunction1Types::ConstantField<Type>::typeName,
entryName,
dict
)
@ -114,6 +115,7 @@ Foam::autoPtr<Foam::PatchFunction1<Type>> Foam::PatchFunction1<Type>::New
return cstrIter()
(
pp,
modelType,
entryName,
dict.found(entryName + "Coeffs")
? dict.subDict(entryName + "Coeffs")

View File

@ -32,13 +32,22 @@ template<class Type>
Foam::PatchFunction1Types::UniformValueField<Type>::UniformValueField
(
const polyPatch& pp,
const word& type,
const word& entryName,
const dictionary& dict,
const bool faceValues
)
:
PatchFunction1<Type>(pp, entryName, dict, faceValues),
uniformValuePtr_(Function1<Type>::New(entryName, dict))
uniformValuePtr_
(
Function1<Type>::New
(
entryName,
dict,
type
)
)
{}

View File

@ -80,19 +80,11 @@ public:
// Constructors
// //- Construct from components
// UniformValueField
// (
// const polyPatch& pp,
// const word& entryName,
// const Field<Type>& value,
// const bool faceValues = true
// );
//- Construct from entry name and dictionary
UniformValueField
(
const polyPatch& pp,
const word& type,
const word& entryName,
const dictionary& dict,
const bool faceValues = true