diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H index 0784f12e17..8ee8078d89 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H +++ b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H @@ -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> New ( const word& entryName, - const dictionary& dict + const dictionary& dict, + const word& redirectType = word::null ); diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1New.C b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1New.C index 24adbadf99..bb537720c2 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1New.C +++ b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1New.C @@ -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 Foam::autoPtr> Foam::Function1::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("type")); + const word Function1Type + ( + redirectType.empty() + ? coeffsDict.get("type") + : coeffsDict.lookupOrDefault("type", redirectType) + ); auto cstrIter = dictionaryConstructorTablePtr_->cfind(Function1Type); @@ -57,24 +63,37 @@ Foam::autoPtr> Foam::Function1::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> - ( - new Function1Types::Constant(entryName, is) - ); + Istream& is = finder.ref().stream(); + + token firstToken(is); + + if (!firstToken.isWord()) + { + is.putBack(firstToken); + return autoPtr> + ( + new Function1Types::Constant(entryName, is) + ); + } + else + { + Function1Type = firstToken.wordToken(); + } } else { - Function1Type = firstToken.wordToken(); + Function1Type = redirectType; } + auto cstrIter = dictionaryConstructorTablePtr_->cfind(Function1Type); if (!cstrIter.found()) diff --git a/src/meshTools/PatchFunction1/ConstantField/ConstantField.C b/src/meshTools/PatchFunction1/ConstantField/ConstantField.C index ee0a20229d..2755e472c3 100644 --- a/src/meshTools/PatchFunction1/ConstantField/ConstantField.C +++ b/src/meshTools/PatchFunction1/ConstantField/ConstantField.C @@ -127,6 +127,7 @@ template Foam::PatchFunction1Types::ConstantField::ConstantField ( const polyPatch& pp, + const word& type, const word& entryName, const dictionary& dict, const bool faceValues diff --git a/src/meshTools/PatchFunction1/ConstantField/ConstantField.H b/src/meshTools/PatchFunction1/ConstantField/ConstantField.H index c9eeea67f8..307a49c4ac 100644 --- a/src/meshTools/PatchFunction1/ConstantField/ConstantField.H +++ b/src/meshTools/PatchFunction1/ConstantField/ConstantField.H @@ -100,6 +100,7 @@ public: ConstantField ( const polyPatch& pp, + const word& type, const word& entryName, const dictionary& dict, const bool faceValues = true diff --git a/src/meshTools/PatchFunction1/MappedFile/MappedFile.C b/src/meshTools/PatchFunction1/MappedFile/MappedFile.C index a13da99ab1..6a283a329e 100644 --- a/src/meshTools/PatchFunction1/MappedFile/MappedFile.C +++ b/src/meshTools/PatchFunction1/MappedFile/MappedFile.C @@ -33,6 +33,7 @@ template Foam::PatchFunction1Types::MappedFile::MappedFile ( const polyPatch& pp, + const word& type, const word& entryName, const dictionary& dict, const bool faceValues diff --git a/src/meshTools/PatchFunction1/MappedFile/MappedFile.H b/src/meshTools/PatchFunction1/MappedFile/MappedFile.H index 89840c2a63..60bdb325b5 100644 --- a/src/meshTools/PatchFunction1/MappedFile/MappedFile.H +++ b/src/meshTools/PatchFunction1/MappedFile/MappedFile.H @@ -122,6 +122,7 @@ public: MappedFile ( const polyPatch& pp, + const word& type, const word& entryName, const dictionary& dict, const bool faceValues = true diff --git a/src/meshTools/PatchFunction1/PatchFunction1.H b/src/meshTools/PatchFunction1/PatchFunction1.H index a1cfaa7901..e6713a3023 100644 --- a/src/meshTools/PatchFunction1/PatchFunction1.H +++ b/src/meshTools/PatchFunction1/PatchFunction1.H @@ -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) ); diff --git a/src/meshTools/PatchFunction1/PatchFunction1New.C b/src/meshTools/PatchFunction1/PatchFunction1New.C index a77f23b1c2..ce379527eb 100644 --- a/src/meshTools/PatchFunction1/PatchFunction1New.C +++ b/src/meshTools/PatchFunction1/PatchFunction1New.C @@ -55,7 +55,7 @@ Foam::autoPtr> Foam::PatchFunction1::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::New ( pp, entryName, - value, + value, // Supply value dict, faceValues ) @@ -92,6 +92,7 @@ Foam::autoPtr> Foam::PatchFunction1::New new PatchFunction1Types::ConstantField ( pp, + PatchFunction1Types::ConstantField::typeName, entryName, dict ) @@ -114,6 +115,7 @@ Foam::autoPtr> Foam::PatchFunction1::New return cstrIter() ( pp, + modelType, entryName, dict.found(entryName + "Coeffs") ? dict.subDict(entryName + "Coeffs") diff --git a/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.C b/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.C index fa7161f35c..cbeebbc831 100644 --- a/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.C +++ b/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.C @@ -32,13 +32,22 @@ template Foam::PatchFunction1Types::UniformValueField::UniformValueField ( const polyPatch& pp, + const word& type, const word& entryName, const dictionary& dict, const bool faceValues ) : PatchFunction1(pp, entryName, dict, faceValues), - uniformValuePtr_(Function1::New(entryName, dict)) + uniformValuePtr_ + ( + Function1::New + ( + entryName, + dict, + type + ) + ) {} diff --git a/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.H b/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.H index 4b021d61d9..683ff0c560 100644 --- a/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.H +++ b/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.H @@ -80,19 +80,11 @@ public: // Constructors -// //- Construct from components -// UniformValueField -// ( -// const polyPatch& pp, -// const word& entryName, -// const Field& 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