functionObjects: 'valueOutput' -> 'writeFields'
This commit is contained in:
parent
55782e2868
commit
0f4df0150a
@ -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;
|
||||
|
@ -212,7 +212,7 @@ public:
|
||||
// 'requiredFields'
|
||||
static bool readFunctionObject
|
||||
(
|
||||
const word& funcNameArgs0,
|
||||
const string& funcNameArgs0,
|
||||
dictionary& functionsDict,
|
||||
HashSet<word>& requiredFields
|
||||
);
|
||||
|
@ -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 |
|
||||
|
@ -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>
|
||||
(
|
||||
|
@ -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;
|
||||
|
@ -515,7 +515,7 @@ void Foam::functionObjects::fieldValues::faceSource::initialise
|
||||
|
||||
Info<< nl << endl;
|
||||
|
||||
if (valueOutput_)
|
||||
if (writeFields_)
|
||||
{
|
||||
const word surfaceFormat(dict.lookup("surfaceFormat"));
|
||||
|
||||
|
@ -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 |
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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_;
|
||||
}
|
||||
|
||||
|
||||
|
@ -38,7 +38,7 @@ functions
|
||||
writeControl timeStep;
|
||||
writeInterval 1;
|
||||
log true;
|
||||
valueOutput true;
|
||||
writeFields true;
|
||||
source faceZone;
|
||||
sourceName f0;
|
||||
operation areaAverage;
|
||||
|
@ -59,7 +59,7 @@ functions
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
writeControl writeTime;
|
||||
log yes;
|
||||
valueOutput no;
|
||||
writeFields no;
|
||||
source patch;
|
||||
sourceName outlet;
|
||||
operation weightedAverage;
|
||||
|
@ -54,7 +54,7 @@ functions
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
writeControl writeTime;
|
||||
log yes;
|
||||
valueOutput no;
|
||||
writeFields no;
|
||||
source patch;
|
||||
sourceName outlet;
|
||||
operation weightedAverage;
|
||||
|
@ -55,7 +55,7 @@ functions
|
||||
enabled yes;
|
||||
writeControl writeTime;
|
||||
log yes;
|
||||
valueOutput no;
|
||||
writeFields no;
|
||||
source patch;
|
||||
sourceName outlet;
|
||||
operation weightedAverage;
|
||||
|
@ -60,7 +60,7 @@ functions
|
||||
writeControl timeStep;
|
||||
log true;
|
||||
// Output field values as well
|
||||
valueOutput false;
|
||||
writeFields false;
|
||||
source patch;
|
||||
sourceName inlet;
|
||||
operation sum;
|
||||
|
@ -73,7 +73,7 @@ functions
|
||||
writeInterval 1;
|
||||
log yes;
|
||||
writeTotalArea no;
|
||||
valueOutput no;
|
||||
writeFields no;
|
||||
source faceZone;
|
||||
sourceName f0;
|
||||
operation areaAverage;
|
||||
|
@ -73,7 +73,7 @@ functions
|
||||
writeInterval 1;
|
||||
log yes;
|
||||
writeTotalArea no;
|
||||
valueOutput no;
|
||||
writeFields no;
|
||||
source faceZone;
|
||||
sourceName f0;
|
||||
operation areaAverage;
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user