Commit 0048b05f authored by mattijs's avatar mattijs
Browse files

ENH: PatchFunction1: backwards compatibility. See #1046.

parent 04a985cc
......@@ -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
);
......
......@@ -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,24 +63,37 @@ 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)
);
token firstToken(is);
word Function1Type;
if (!firstToken.isWord())
if (finder.found())
{
is.putBack(firstToken);
return autoPtr<Function1<Type>>
(
new Function1Types::Constant<Type>(entryName, is)
);
Istream& is = finder.ref().stream();
token firstToken(is);
if (!firstToken.isWord())
{
is.putBack(firstToken);
return autoPtr<Function1<Type>>
(
new Function1Types::Constant<Type>(entryName, is)
);
}
else
{
Function1Type = firstToken.wordToken();
}
}
else
{
Function1Type = firstToken.wordToken();
Function1Type = redirectType;
}
auto cstrIter = dictionaryConstructorTablePtr_->cfind(Function1Type);
if (!cstrIter.found())
......
......@@ -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
......
......@@ -100,6 +100,7 @@ public:
ConstantField
(
const polyPatch& pp,
const word& type,
const word& entryName,
const dictionary& dict,
const bool faceValues = true
......
......@@ -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
......
......@@ -122,6 +122,7 @@ public:
MappedFile
(
const polyPatch& pp,
const word& type,
const word& entryName,
const dictionary& dict,
const bool faceValues = true
......
......@@ -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)
);
......
......@@ -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")
......
......@@ -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
)
)
{}
......
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment