diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C index a4d5340230b25d553ecbefd8ffb079047f9c795d..d32926d4ffd4fc85403793a8bfc49b770d51d93c 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C @@ -31,6 +31,7 @@ License #include "IFstream.H" #include "dictionaryEntry.H" #include "stringOps.H" +#include "Tuple2.H" #include "etcFiles.H" /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */ @@ -132,21 +133,27 @@ Foam::fileName Foam::functionObjectList::findDict(const word& funcName) bool Foam::functionObjectList::readFunctionObject ( - const word& funcNameArgs0, + const string& funcNameArgs, dictionary& functionsDict, HashSet<word>& requiredFields ) { - // Parse the optional functionObject arguments - // e.g. 'Q(U)' -> funcName = Q; args = (U); + // Parse the optional functionObject arguments: + // 'Q(U)' -> funcName = Q; args = (U); field = U + // + // Supports named arguments: + // 'patchAverage(patch=inlet, p)' -> funcName = patchAverage; + // args = (patch=inlet, p); field = p - word funcNameArgs(funcNameArgs0); - string::stripInvalid<word>(funcNameArgs); + word funcName; - word funcName(funcNameArgs); int argLevel = 0; wordList args; + List<Tuple2<word, string>> namedArgs; + bool namedArg = false; + word argName; + word::size_type start = 0; word::size_type i = 0; @@ -163,27 +170,51 @@ bool Foam::functionObjectList::readFunctionObject { if (argLevel == 0) { - funcName.resize(i); + funcName = funcNameArgs(start, i - start); start = i+1; } ++argLevel; } - else if (c == ',') + else if (c == ',' || c == ')') { if (argLevel == 1) { - args.append(funcNameArgs(start, i - start)); + if (namedArg) + { + namedArgs.append + ( + Tuple2<word, string> + ( + argName, + funcNameArgs(start, i - start) + ) + ); + namedArg = false; + } + else + { + args.append + ( + string::validate<word>(funcNameArgs(start, i - start)) + ); + } start = i+1; } - } - else if (c == ')') - { - if (argLevel == 1) + + if (c == ')') { - args.append(funcNameArgs(start, i - start)); - break; + if (argLevel == 1) + { + break; + } + --argLevel; } - --argLevel; + } + else if (c == '=') + { + argName = string::validate<word>(funcNameArgs(start, i - start)); + start = i+1; + namedArg = true; } ++i; @@ -204,12 +235,13 @@ bool Foam::functionObjectList::readFunctionObject dictionary funcsDict(fileStream); dictionary& funcDict = funcsDict.subDict(funcName); - // Insert the 'field' or 'fields' entry corresponding to the optional + // Insert the 'field' and/or 'fields' entry corresponding to the optional // arguments or read the 'field' or 'fields' entry and add the required // fields to requiredFields if (args.size() == 1) { funcDict.set("field", args[0]); + funcDict.set("fields", args); requiredFields.insert(args[0]); } else if (args.size() > 1) @@ -226,9 +258,19 @@ bool Foam::functionObjectList::readFunctionObject requiredFields.insert(wordList(funcDict.lookup("fields"))); } + // Insert named arguments + forAll(namedArgs, i) + { + IStringStream entryStream + ( + namedArgs[i].first() + ' ' + namedArgs[i].second() + ';' + ); + funcDict.set(entry::New(entryStream).ptr()); + } + // Merge this functionObject dictionary into functionsDict dictionary funcArgsDict; - funcArgsDict.add(funcNameArgs, funcDict); + funcArgsDict.add(string::validate<word>(funcNameArgs), funcDict); functionsDict.merge(funcArgsDict); return true; diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H index 10406c1038b50528cc4f7808b0fa4f4438dfa4b9..0337cd47d71e0bc64e45d30da68a8d84f3e0c6d6 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H @@ -212,7 +212,7 @@ public: // 'requiredFields' static bool readFunctionObject ( - const word& funcNameArgs0, + const string& funcNameArgs0, dictionary& functionsDict, HashSet<word>& requiredFields ); diff --git a/src/functionObjects/field/fieldValues/cellSource/cellSource.H b/src/functionObjects/field/fieldValues/cellSource/cellSource.H index 5644582aaaa3e61832d10e643fe987c8565bd5af..79c52a1c5074f8c5d7c91f1e6443c4d481e327a7 100644 --- a/src/functionObjects/field/fieldValues/cellSource/cellSource.H +++ b/src/functionObjects/field/fieldValues/cellSource/cellSource.H @@ -42,7 +42,7 @@ Description libs ("libfieldFunctionObjects.so"); ... log true; - valueOutput true; + writeFields true; source cellZone; sourceName c0; operation volAverage; @@ -60,7 +60,7 @@ Description Property | Description | Required | Default value type | Type name: cellSource | yes | log | Write data to standard output | no | no - valueOutput | Write the raw output values | yes | + writeFields | Write the raw output values | yes | writeVolume | Write the volume of the cellSource | no | source | cell source: see below | yes | sourceName | name of cell source if required | no | diff --git a/src/functionObjects/field/fieldValues/cellSource/cellSourceTemplates.C b/src/functionObjects/field/fieldValues/cellSource/cellSourceTemplates.C index 3e753d037f18d8bfc18777506c31f3e766ecf11c..c525504c873809c8e81177186cb7415ea26ee099 100644 --- a/src/functionObjects/field/fieldValues/cellSource/cellSourceTemplates.C +++ b/src/functionObjects/field/fieldValues/cellSource/cellSourceTemplates.C @@ -185,7 +185,7 @@ bool Foam::functionObjects::fieldValues::cellSource::writeValues // Add to result dictionary, over-writing any previous entry resultDict_.add(fieldName, result, true); - if (valueOutput_) + if (writeFields_) { IOField<Type> ( diff --git a/src/functionObjects/field/fieldValues/controlDict b/src/functionObjects/field/fieldValues/controlDict index 5cc34689618303bf0826d65e1a985316d8c963fc..7b2581c19b785322632e8358c1d7fd9b42fd9974 100644 --- a/src/functionObjects/field/fieldValues/controlDict +++ b/src/functionObjects/field/fieldValues/controlDict @@ -58,7 +58,7 @@ functions log true; // Output field values as well - valueOutput true; + writeFields true; // Type of source: patch/faceZone/sampledSurface source patch; @@ -95,7 +95,7 @@ functions enabled true; writeControl writeTime; log true; - valueOutput true; + writeFields true; source faceZone; sourceName f0; operation sum; @@ -113,7 +113,7 @@ functions enabled true; writeControl writeTime; log true; - valueOutput true; + writeFields true; source cellZone; sourceName c0; operation volAverage; diff --git a/src/functionObjects/field/fieldValues/faceSource/faceSource.C b/src/functionObjects/field/fieldValues/faceSource/faceSource.C index 4859c8074b8f9d366a5d23d497a058d8452b9988..fcc3aff3e0ddaff2222bd0198c87812d0eefdc86 100644 --- a/src/functionObjects/field/fieldValues/faceSource/faceSource.C +++ b/src/functionObjects/field/fieldValues/faceSource/faceSource.C @@ -515,7 +515,7 @@ void Foam::functionObjects::fieldValues::faceSource::initialise Info<< nl << endl; - if (valueOutput_) + if (writeFields_) { const word surfaceFormat(dict.lookup("surfaceFormat")); diff --git a/src/functionObjects/field/fieldValues/faceSource/faceSource.H b/src/functionObjects/field/fieldValues/faceSource/faceSource.H index 7a9a6d639311ca5608ffe70bd1357494efe268ee..6a8884ce16e19d9c197e5ac36b67b728d2e8c0a1 100644 --- a/src/functionObjects/field/fieldValues/faceSource/faceSource.H +++ b/src/functionObjects/field/fieldValues/faceSource/faceSource.H @@ -45,7 +45,7 @@ Description libs ("libfieldFunctionObjects.so"); ... log yes; - valueOutput true; + writeFields true; surfaceFormat none; source faceZone; sourceName f0; @@ -65,7 +65,7 @@ Description Property | Description | Required | Default value type | type name: faceSource | yes | log | write data to standard output | no | no - valueOutput | write the output values | yes | + writeFields | write the output values | yes | writeArea | Write the area of the faceSource | no | surfaceFormat | output value format | no | source | face source: see below | yes | diff --git a/src/functionObjects/field/fieldValues/fieldValue/fieldValue.C b/src/functionObjects/field/fieldValues/fieldValue/fieldValue.C index 9dda1941260bd2833b9ccdaded5d29df1a12cd01..9bb22503c8097a85059842a72697b475b408fa14 100644 --- a/src/functionObjects/field/fieldValues/fieldValue/fieldValue.C +++ b/src/functionObjects/field/fieldValues/fieldValue/fieldValue.C @@ -90,17 +90,8 @@ bool Foam::functionObjects::fieldValue::read(const dictionary& dict) dict_ = dict; writeFiles::read(dict); - if (dict.found("field")) - { - fields_.setSize(1); - dict.lookup("field") >> fields_[0]; - } - else if (dict.found("fields")) - { - dict.lookup("fields") >> fields_; - } - - dict.lookup("valueOutput") >> valueOutput_; + dict.lookup("fields") >> fields_; + dict.lookup("writeFields") >> writeFields_; return true; } diff --git a/src/functionObjects/field/fieldValues/fieldValue/fieldValue.H b/src/functionObjects/field/fieldValues/fieldValue/fieldValue.H index 450f0179da389f2387c048411007767d2513b896..3ec92b8581382a20e7b3bd6017e68e468a8fe03b 100644 --- a/src/functionObjects/field/fieldValues/fieldValue/fieldValue.H +++ b/src/functionObjects/field/fieldValues/fieldValue/fieldValue.H @@ -76,7 +76,7 @@ protected: wordList fields_; //- Output field values flag - Switch valueOutput_; + Switch writeFields_; //- Results dictionary for external access of results dictionary resultDict_; @@ -160,7 +160,7 @@ public: inline const wordList& fields() const; //- Return the output field values flag - inline const Switch& valueOutput() const; + inline const Switch& writeFields() const; //- Helper function to return the reference to the mesh inline const fvMesh& mesh() const; diff --git a/src/functionObjects/field/fieldValues/fieldValue/fieldValueI.H b/src/functionObjects/field/fieldValues/fieldValue/fieldValueI.H index a5e4c4711514da5e33013b2be2c708c579291ddc..3375af1b44887bc37cae204cd47f0788a14e9584 100644 --- a/src/functionObjects/field/fieldValues/fieldValue/fieldValueI.H +++ b/src/functionObjects/field/fieldValues/fieldValue/fieldValueI.H @@ -47,9 +47,9 @@ inline const Foam::wordList& Foam::functionObjects::fieldValue::fields() const inline const Foam::Switch& -Foam::functionObjects::fieldValue::valueOutput() const +Foam::functionObjects::fieldValue::writeFields() const { - return valueOutput_; + return writeFields_; } diff --git a/src/functionObjects/field/readFields/postProcessingDict b/src/functionObjects/field/readFields/postProcessingDict index 3ed3fe8e984a4725a6da589235ae559dadbe2681..3d385ccc885b1d30bf7d604e81add4bc565c61e4 100644 --- a/src/functionObjects/field/readFields/postProcessingDict +++ b/src/functionObjects/field/readFields/postProcessingDict @@ -38,7 +38,7 @@ functions writeControl timeStep; writeInterval 1; log true; - valueOutput true; + writeFields true; source faceZone; sourceName f0; operation areaAverage; diff --git a/tutorials/lagrangian/reactingParcelFoam/verticalChannel/system/controlDict b/tutorials/lagrangian/reactingParcelFoam/verticalChannel/system/controlDict index 935559ccc1552d31b088aad0f497e239f2fd577b..1cc662f91669c6447622b22b34538b734220343b 100644 --- a/tutorials/lagrangian/reactingParcelFoam/verticalChannel/system/controlDict +++ b/tutorials/lagrangian/reactingParcelFoam/verticalChannel/system/controlDict @@ -59,7 +59,7 @@ functions libs ("libfieldFunctionObjects.so"); writeControl writeTime; log yes; - valueOutput no; + writeFields no; source patch; sourceName outlet; operation weightedAverage; diff --git a/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/system/controlDict b/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/system/controlDict index 5dc1e71c2d853535c7013d3eba474a0df99b5a4c..978cf432fef475e544c3b3ae291b61c5a9eaee94 100644 --- a/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/system/controlDict +++ b/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/system/controlDict @@ -54,7 +54,7 @@ functions libs ("libfieldFunctionObjects.so"); writeControl writeTime; log yes; - valueOutput no; + writeFields no; source patch; sourceName outlet; operation weightedAverage; diff --git a/tutorials/lagrangian/simpleReactingParcelFoam/verticalChannel/system/controlDict b/tutorials/lagrangian/simpleReactingParcelFoam/verticalChannel/system/controlDict index 9b6fa3b8441fade2c5c31837ddce572618fc3e72..afdcf0bb5e7e653560b42118270b8fd049e37577 100644 --- a/tutorials/lagrangian/simpleReactingParcelFoam/verticalChannel/system/controlDict +++ b/tutorials/lagrangian/simpleReactingParcelFoam/verticalChannel/system/controlDict @@ -55,7 +55,7 @@ functions enabled yes; writeControl writeTime; log yes; - valueOutput no; + writeFields no; source patch; sourceName outlet; operation weightedAverage; diff --git a/tutorials/multiphase/interFoam/ras/waterChannel/system/controlDict b/tutorials/multiphase/interFoam/ras/waterChannel/system/controlDict index e9292a96afb25eaa561c5078918d7491e53d6601..392c64a789f55b37b93b84f2d3eb2d74e40fc90b 100644 --- a/tutorials/multiphase/interFoam/ras/waterChannel/system/controlDict +++ b/tutorials/multiphase/interFoam/ras/waterChannel/system/controlDict @@ -60,7 +60,7 @@ functions writeControl timeStep; log true; // Output field values as well - valueOutput false; + writeFields false; source patch; sourceName inlet; operation sum; diff --git a/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/system/controlDict b/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/system/controlDict index 9846717057100beebc2c4e2b3d8d0efdf6c7bc39..a3c78e04d2556d6fef43267c9a47039294b0a262 100644 --- a/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/system/controlDict +++ b/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/system/controlDict @@ -73,7 +73,7 @@ functions writeInterval 1; log yes; writeTotalArea no; - valueOutput no; + writeFields no; source faceZone; sourceName f0; operation areaAverage; diff --git a/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/system/controlDict b/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/system/controlDict index 53157df907de6186f58460dbbebbbb6d17a16178..43e066aeb69c4738f4ae41e77a9d7df7c5603a6b 100644 --- a/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/system/controlDict +++ b/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/system/controlDict @@ -73,7 +73,7 @@ functions writeInterval 1; log yes; writeTotalArea no; - valueOutput no; + writeFields no; source faceZone; sourceName f0; operation areaAverage; diff --git a/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/bubbleColumnEvaporating/system/continuityFunctions b/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/bubbleColumnEvaporating/system/continuityFunctions index fa05777fbba63e5d843c94cc8e6823bef3f2b726..7bb51bac239fce0c15e37cb70afcdc9f3c9e73fb 100644 --- a/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/bubbleColumnEvaporating/system/continuityFunctions +++ b/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/bubbleColumnEvaporating/system/continuityFunctions @@ -17,7 +17,7 @@ inletMassFlowRate alphaRhoPhi.liquid ); - valueOutput false; + writeFields false; log true; surfaceFormat null; @@ -40,7 +40,7 @@ outletMassFlowRate alphaRhoPhi.liquid ); - valueOutput false; + writeFields false; log true; surfaceFormat null;