From 0f4df0150a8dc8f682a90d903efaf8176e440a21 Mon Sep 17 00:00:00 2001 From: Henry Weller <http://cfd.direct> Date: Sat, 11 Jun 2016 15:25:00 +0100 Subject: [PATCH] functionObjects: 'valueOutput' -> 'writeFields' --- .../functionObjectList/functionObjectList.C | 78 ++++++++++++++----- .../functionObjectList/functionObjectList.H | 2 +- .../field/fieldValues/cellSource/cellSource.H | 4 +- .../cellSource/cellSourceTemplates.C | 2 +- .../field/fieldValues/controlDict | 6 +- .../field/fieldValues/faceSource/faceSource.C | 2 +- .../field/fieldValues/faceSource/faceSource.H | 4 +- .../field/fieldValues/fieldValue/fieldValue.C | 13 +--- .../field/fieldValues/fieldValue/fieldValue.H | 4 +- .../fieldValues/fieldValue/fieldValueI.H | 4 +- .../field/readFields/postProcessingDict | 2 +- .../verticalChannel/system/controlDict | 2 +- .../verticalChannelLTS/system/controlDict | 2 +- .../verticalChannel/system/controlDict | 2 +- .../ras/waterChannel/system/controlDict | 2 +- .../oscillatingBox/system/controlDict | 2 +- .../oscillatingBox/system/controlDict | 2 +- .../system/continuityFunctions | 4 +- 18 files changed, 85 insertions(+), 52 deletions(-) diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C index a4d5340230b..d32926d4ffd 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 10406c1038b..0337cd47d71 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 5644582aaaa..79c52a1c507 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 3e753d037f1..c525504c873 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 5cc34689618..7b2581c19b7 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 4859c8074b8..fcc3aff3e0d 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 7a9a6d63931..6a8884ce16e 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 9dda1941260..9bb22503c80 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 450f0179da3..3ec92b85813 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 a5e4c471151..3375af1b448 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 3ed3fe8e984..3d385ccc885 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 935559ccc15..1cc662f9166 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 5dc1e71c2d8..978cf432fef 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 9b6fa3b8441..afdcf0bb5e7 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 e9292a96afb..392c64a789f 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 98467170571..a3c78e04d25 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 53157df907d..43e066aeb69 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 fa05777fbba..7bb51bac239 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; -- GitLab