diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H index 5fa33c85ef..5907ba2a2b 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H +++ b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H @@ -131,6 +131,10 @@ public: //- Raw, low-level getline into a string function. inline ISstream& getLine(string&); + //- Get multiple lines using the '\' continuation character + // into a string + inline ISstream& getMultiLines(string&); + //- Raw, low-level putback character function. inline ISstream& putback(const char&); diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/ISstreamI.H b/src/OpenFOAM/db/IOstreams/Sstreams/ISstreamI.H index da9261ab33..3a3edac61d 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/ISstreamI.H +++ b/src/OpenFOAM/db/IOstreams/Sstreams/ISstreamI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -80,6 +80,32 @@ inline Foam::ISstream& Foam::ISstream::getLine(string& s) setState(is_.rdstate()); lineNumber_++; + while (s.back() == '\\') + { + string contLine; + getline(is_, contLine); + setState(is_.rdstate()); + lineNumber_++; + s.pop_back(); + s += contLine; + } + + return *this; +} + + +inline Foam::ISstream& Foam::ISstream::getMultiLines(string& s) +{ + getLine(s); + + while (s.back() == '\\') + { + s.pop_back(); + string contLine; + getLine(contLine); + s += contLine; + } + return *this; } diff --git a/src/OpenFOAM/db/dictionary/entry/entryIO.C b/src/OpenFOAM/db/dictionary/entry/entryIO.C index 7719098759..640ee9aace 100644 --- a/src/OpenFOAM/db/dictionary/entry/entryIO.C +++ b/src/OpenFOAM/db/dictionary/entry/entryIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -153,7 +153,6 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is) { if (keyword[0] == '#') // ... Function entry { - word functionName = keyword(1, keyword.size()-1); if (disableFunctionEntries) { return parentDict.add @@ -169,6 +168,7 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is) } else { + const word functionName = keyword(1, keyword.size() - 1); return functionEntry::execute(functionName, parentDict, is); } } diff --git a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C index de12d049b0..e3b6685a83 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -49,12 +49,12 @@ namespace Foam // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -Foam::token Foam::functionEntry::readLine(const word& key, Istream& is) +Foam::string Foam::functionEntry::readLine(const word& key, Istream& is) { string s; dynamic_cast(is).getLine(s); - return token(string(key+s), is.lineNumber()); + return key + s; } @@ -69,8 +69,8 @@ Foam::functionEntry::functionEntry : primitiveEntry ( - word(key+dict.name()+Foam::name(is.lineNumber())), - readLine(key, is) + word(key + dict.name() + Foam::name(is.lineNumber())), + readLine(key, is).c_str() ) {} diff --git a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H index ac6b9b9ffa..1dc4d3e97c 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H @@ -68,7 +68,7 @@ class functionEntry // Private Member Functions //- Read line as string token - static token readLine(const word& key, Istream& is); + static string readLine(const word& key, Istream& is); public: diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeFuncEntry/includeFuncEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/includeFuncEntry/includeFuncEntry.C index 17ab1822af..06e6a364c0 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeFuncEntry/includeFuncEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeFuncEntry/includeFuncEntry.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,6 +25,7 @@ License #include "includeFuncEntry.H" #include "functionObjectList.H" +#include "stringOps.H" #include "addToMemberFunctionSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -54,7 +55,10 @@ bool Foam::functionEntries::includeFuncEntry::execute Istream& is ) { - const word fNameArgs(is); + // Read line containing the function name and all the arguments + string fNameArgs; + dynamic_cast(is).getMultiLines(fNameArgs); + HashSet selectedFields; return functionObjectList::readFunctionObject diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C index 23730772e5..b15ac79ee4 100644 --- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C +++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C @@ -232,7 +232,7 @@ Foam::primitiveEntry::primitiveEntry(const keyType& key, Istream& is) void Foam::primitiveEntry::write(Ostream& os, const bool contentsOnly) const { - if (!contentsOnly) + if (!contentsOnly && keyword().size() && keyword()[0] != '#') { os.writeKeyword(keyword()); } diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C index d67d0b3a0e..35aa10bb16 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -270,6 +270,9 @@ bool Foam::functionObjectList::readFunctionObject ++i; } + // Strip whitespace from the function name + string::stripInvalid(funcName); + // Search for the functionObject dictionary fileName path = findDict(funcName, region); @@ -285,7 +288,12 @@ bool Foam::functionObjectList::readFunctionObject autoPtr fileStreamPtr(fileHandler().NewIFstream(path)); ISstream& fileStream = fileStreamPtr(); + // Delay processing the functionEntries + // until after the function argument entries have been added + entry::disableFunctionEntries = true; dictionary funcsDict(fileStream); + entry::disableFunctionEntries = false; + dictionary* funcDictPtr = &funcsDict; if (funcsDict.found(funcName) && funcsDict.isDict(funcName)) @@ -338,6 +346,15 @@ bool Foam::functionObjectList::readFunctionObject const word funcNameArgsWord = string::validate(funcNameArgs); dictionary funcArgsDict; funcArgsDict.add(funcNameArgsWord, funcDict); + + // Re-parse the funcDict to execute the functionEntries + // now that the function argument entries have been added + { + OStringStream os; + funcArgsDict.write(os); + funcArgsDict = dictionary(IStringStream(os.str())()); + } + functionsDict.merge(funcArgsDict); functionsDict.subDict(funcNameArgsWord).name() = funcDict.name();