mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
functionObjects: 'valueOutput' -> 'writeFields'
This commit is contained in:
@ -31,6 +31,7 @@ License
|
|||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "dictionaryEntry.H"
|
#include "dictionaryEntry.H"
|
||||||
#include "stringOps.H"
|
#include "stringOps.H"
|
||||||
|
#include "Tuple2.H"
|
||||||
#include "etcFiles.H"
|
#include "etcFiles.H"
|
||||||
|
|
||||||
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
|
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
|
||||||
@ -132,21 +133,27 @@ Foam::fileName Foam::functionObjectList::findDict(const word& funcName)
|
|||||||
|
|
||||||
bool Foam::functionObjectList::readFunctionObject
|
bool Foam::functionObjectList::readFunctionObject
|
||||||
(
|
(
|
||||||
const word& funcNameArgs0,
|
const string& funcNameArgs,
|
||||||
dictionary& functionsDict,
|
dictionary& functionsDict,
|
||||||
HashSet<word>& requiredFields
|
HashSet<word>& requiredFields
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Parse the optional functionObject arguments
|
// Parse the optional functionObject arguments:
|
||||||
// e.g. 'Q(U)' -> funcName = Q; args = (U);
|
// '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);
|
word funcName;
|
||||||
string::stripInvalid<word>(funcNameArgs);
|
|
||||||
|
|
||||||
word funcName(funcNameArgs);
|
|
||||||
int argLevel = 0;
|
int argLevel = 0;
|
||||||
wordList args;
|
wordList args;
|
||||||
|
|
||||||
|
List<Tuple2<word, string>> namedArgs;
|
||||||
|
bool namedArg = false;
|
||||||
|
word argName;
|
||||||
|
|
||||||
word::size_type start = 0;
|
word::size_type start = 0;
|
||||||
word::size_type i = 0;
|
word::size_type i = 0;
|
||||||
|
|
||||||
@ -163,28 +170,52 @@ bool Foam::functionObjectList::readFunctionObject
|
|||||||
{
|
{
|
||||||
if (argLevel == 0)
|
if (argLevel == 0)
|
||||||
{
|
{
|
||||||
funcName.resize(i);
|
funcName = funcNameArgs(start, i - start);
|
||||||
start = i+1;
|
start = i+1;
|
||||||
}
|
}
|
||||||
++argLevel;
|
++argLevel;
|
||||||
}
|
}
|
||||||
else if (c == ',')
|
else if (c == ',' || c == ')')
|
||||||
{
|
{
|
||||||
if (argLevel == 1)
|
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;
|
start = i+1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (c == ')')
|
if (c == ')')
|
||||||
{
|
{
|
||||||
if (argLevel == 1)
|
if (argLevel == 1)
|
||||||
{
|
{
|
||||||
args.append(funcNameArgs(start, i - start));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
--argLevel;
|
--argLevel;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if (c == '=')
|
||||||
|
{
|
||||||
|
argName = string::validate<word>(funcNameArgs(start, i - start));
|
||||||
|
start = i+1;
|
||||||
|
namedArg = true;
|
||||||
|
}
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
@ -204,12 +235,13 @@ bool Foam::functionObjectList::readFunctionObject
|
|||||||
dictionary funcsDict(fileStream);
|
dictionary funcsDict(fileStream);
|
||||||
dictionary& funcDict = funcsDict.subDict(funcName);
|
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
|
// arguments or read the 'field' or 'fields' entry and add the required
|
||||||
// fields to requiredFields
|
// fields to requiredFields
|
||||||
if (args.size() == 1)
|
if (args.size() == 1)
|
||||||
{
|
{
|
||||||
funcDict.set("field", args[0]);
|
funcDict.set("field", args[0]);
|
||||||
|
funcDict.set("fields", args);
|
||||||
requiredFields.insert(args[0]);
|
requiredFields.insert(args[0]);
|
||||||
}
|
}
|
||||||
else if (args.size() > 1)
|
else if (args.size() > 1)
|
||||||
@ -226,9 +258,19 @@ bool Foam::functionObjectList::readFunctionObject
|
|||||||
requiredFields.insert(wordList(funcDict.lookup("fields")));
|
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
|
// Merge this functionObject dictionary into functionsDict
|
||||||
dictionary funcArgsDict;
|
dictionary funcArgsDict;
|
||||||
funcArgsDict.add(funcNameArgs, funcDict);
|
funcArgsDict.add(string::validate<word>(funcNameArgs), funcDict);
|
||||||
functionsDict.merge(funcArgsDict);
|
functionsDict.merge(funcArgsDict);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -212,7 +212,7 @@ public:
|
|||||||
// 'requiredFields'
|
// 'requiredFields'
|
||||||
static bool readFunctionObject
|
static bool readFunctionObject
|
||||||
(
|
(
|
||||||
const word& funcNameArgs0,
|
const string& funcNameArgs0,
|
||||||
dictionary& functionsDict,
|
dictionary& functionsDict,
|
||||||
HashSet<word>& requiredFields
|
HashSet<word>& requiredFields
|
||||||
);
|
);
|
||||||
|
|||||||
@ -42,7 +42,7 @@ Description
|
|||||||
libs ("libfieldFunctionObjects.so");
|
libs ("libfieldFunctionObjects.so");
|
||||||
...
|
...
|
||||||
log true;
|
log true;
|
||||||
valueOutput true;
|
writeFields true;
|
||||||
source cellZone;
|
source cellZone;
|
||||||
sourceName c0;
|
sourceName c0;
|
||||||
operation volAverage;
|
operation volAverage;
|
||||||
@ -60,7 +60,7 @@ Description
|
|||||||
Property | Description | Required | Default value
|
Property | Description | Required | Default value
|
||||||
type | Type name: cellSource | yes |
|
type | Type name: cellSource | yes |
|
||||||
log | Write data to standard output | no | no
|
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 |
|
writeVolume | Write the volume of the cellSource | no |
|
||||||
source | cell source: see below | yes |
|
source | cell source: see below | yes |
|
||||||
sourceName | name of cell source if required | no |
|
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
|
// Add to result dictionary, over-writing any previous entry
|
||||||
resultDict_.add(fieldName, result, true);
|
resultDict_.add(fieldName, result, true);
|
||||||
|
|
||||||
if (valueOutput_)
|
if (writeFields_)
|
||||||
{
|
{
|
||||||
IOField<Type>
|
IOField<Type>
|
||||||
(
|
(
|
||||||
|
|||||||
@ -58,7 +58,7 @@ functions
|
|||||||
log true;
|
log true;
|
||||||
|
|
||||||
// Output field values as well
|
// Output field values as well
|
||||||
valueOutput true;
|
writeFields true;
|
||||||
|
|
||||||
// Type of source: patch/faceZone/sampledSurface
|
// Type of source: patch/faceZone/sampledSurface
|
||||||
source patch;
|
source patch;
|
||||||
@ -95,7 +95,7 @@ functions
|
|||||||
enabled true;
|
enabled true;
|
||||||
writeControl writeTime;
|
writeControl writeTime;
|
||||||
log true;
|
log true;
|
||||||
valueOutput true;
|
writeFields true;
|
||||||
source faceZone;
|
source faceZone;
|
||||||
sourceName f0;
|
sourceName f0;
|
||||||
operation sum;
|
operation sum;
|
||||||
@ -113,7 +113,7 @@ functions
|
|||||||
enabled true;
|
enabled true;
|
||||||
writeControl writeTime;
|
writeControl writeTime;
|
||||||
log true;
|
log true;
|
||||||
valueOutput true;
|
writeFields true;
|
||||||
source cellZone;
|
source cellZone;
|
||||||
sourceName c0;
|
sourceName c0;
|
||||||
operation volAverage;
|
operation volAverage;
|
||||||
|
|||||||
@ -515,7 +515,7 @@ void Foam::functionObjects::fieldValues::faceSource::initialise
|
|||||||
|
|
||||||
Info<< nl << endl;
|
Info<< nl << endl;
|
||||||
|
|
||||||
if (valueOutput_)
|
if (writeFields_)
|
||||||
{
|
{
|
||||||
const word surfaceFormat(dict.lookup("surfaceFormat"));
|
const word surfaceFormat(dict.lookup("surfaceFormat"));
|
||||||
|
|
||||||
|
|||||||
@ -45,7 +45,7 @@ Description
|
|||||||
libs ("libfieldFunctionObjects.so");
|
libs ("libfieldFunctionObjects.so");
|
||||||
...
|
...
|
||||||
log yes;
|
log yes;
|
||||||
valueOutput true;
|
writeFields true;
|
||||||
surfaceFormat none;
|
surfaceFormat none;
|
||||||
source faceZone;
|
source faceZone;
|
||||||
sourceName f0;
|
sourceName f0;
|
||||||
@ -65,7 +65,7 @@ Description
|
|||||||
Property | Description | Required | Default value
|
Property | Description | Required | Default value
|
||||||
type | type name: faceSource | yes |
|
type | type name: faceSource | yes |
|
||||||
log | write data to standard output | no | no
|
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 |
|
writeArea | Write the area of the faceSource | no |
|
||||||
surfaceFormat | output value format | no |
|
surfaceFormat | output value format | no |
|
||||||
source | face source: see below | yes |
|
source | face source: see below | yes |
|
||||||
|
|||||||
@ -90,17 +90,8 @@ bool Foam::functionObjects::fieldValue::read(const dictionary& dict)
|
|||||||
dict_ = dict;
|
dict_ = dict;
|
||||||
writeFiles::read(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("fields") >> fields_;
|
||||||
}
|
dict.lookup("writeFields") >> writeFields_;
|
||||||
|
|
||||||
dict.lookup("valueOutput") >> valueOutput_;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,7 +76,7 @@ protected:
|
|||||||
wordList fields_;
|
wordList fields_;
|
||||||
|
|
||||||
//- Output field values flag
|
//- Output field values flag
|
||||||
Switch valueOutput_;
|
Switch writeFields_;
|
||||||
|
|
||||||
//- Results dictionary for external access of results
|
//- Results dictionary for external access of results
|
||||||
dictionary resultDict_;
|
dictionary resultDict_;
|
||||||
@ -160,7 +160,7 @@ public:
|
|||||||
inline const wordList& fields() const;
|
inline const wordList& fields() const;
|
||||||
|
|
||||||
//- Return the output field values flag
|
//- 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
|
//- Helper function to return the reference to the mesh
|
||||||
inline const fvMesh& mesh() const;
|
inline const fvMesh& mesh() const;
|
||||||
|
|||||||
@ -47,9 +47,9 @@ inline const Foam::wordList& Foam::functionObjects::fieldValue::fields() const
|
|||||||
|
|
||||||
|
|
||||||
inline const Foam::Switch&
|
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;
|
writeControl timeStep;
|
||||||
writeInterval 1;
|
writeInterval 1;
|
||||||
log true;
|
log true;
|
||||||
valueOutput true;
|
writeFields true;
|
||||||
source faceZone;
|
source faceZone;
|
||||||
sourceName f0;
|
sourceName f0;
|
||||||
operation areaAverage;
|
operation areaAverage;
|
||||||
|
|||||||
@ -59,7 +59,7 @@ functions
|
|||||||
libs ("libfieldFunctionObjects.so");
|
libs ("libfieldFunctionObjects.so");
|
||||||
writeControl writeTime;
|
writeControl writeTime;
|
||||||
log yes;
|
log yes;
|
||||||
valueOutput no;
|
writeFields no;
|
||||||
source patch;
|
source patch;
|
||||||
sourceName outlet;
|
sourceName outlet;
|
||||||
operation weightedAverage;
|
operation weightedAverage;
|
||||||
|
|||||||
@ -54,7 +54,7 @@ functions
|
|||||||
libs ("libfieldFunctionObjects.so");
|
libs ("libfieldFunctionObjects.so");
|
||||||
writeControl writeTime;
|
writeControl writeTime;
|
||||||
log yes;
|
log yes;
|
||||||
valueOutput no;
|
writeFields no;
|
||||||
source patch;
|
source patch;
|
||||||
sourceName outlet;
|
sourceName outlet;
|
||||||
operation weightedAverage;
|
operation weightedAverage;
|
||||||
|
|||||||
@ -55,7 +55,7 @@ functions
|
|||||||
enabled yes;
|
enabled yes;
|
||||||
writeControl writeTime;
|
writeControl writeTime;
|
||||||
log yes;
|
log yes;
|
||||||
valueOutput no;
|
writeFields no;
|
||||||
source patch;
|
source patch;
|
||||||
sourceName outlet;
|
sourceName outlet;
|
||||||
operation weightedAverage;
|
operation weightedAverage;
|
||||||
|
|||||||
@ -60,7 +60,7 @@ functions
|
|||||||
writeControl timeStep;
|
writeControl timeStep;
|
||||||
log true;
|
log true;
|
||||||
// Output field values as well
|
// Output field values as well
|
||||||
valueOutput false;
|
writeFields false;
|
||||||
source patch;
|
source patch;
|
||||||
sourceName inlet;
|
sourceName inlet;
|
||||||
operation sum;
|
operation sum;
|
||||||
|
|||||||
@ -73,7 +73,7 @@ functions
|
|||||||
writeInterval 1;
|
writeInterval 1;
|
||||||
log yes;
|
log yes;
|
||||||
writeTotalArea no;
|
writeTotalArea no;
|
||||||
valueOutput no;
|
writeFields no;
|
||||||
source faceZone;
|
source faceZone;
|
||||||
sourceName f0;
|
sourceName f0;
|
||||||
operation areaAverage;
|
operation areaAverage;
|
||||||
|
|||||||
@ -73,7 +73,7 @@ functions
|
|||||||
writeInterval 1;
|
writeInterval 1;
|
||||||
log yes;
|
log yes;
|
||||||
writeTotalArea no;
|
writeTotalArea no;
|
||||||
valueOutput no;
|
writeFields no;
|
||||||
source faceZone;
|
source faceZone;
|
||||||
sourceName f0;
|
sourceName f0;
|
||||||
operation areaAverage;
|
operation areaAverage;
|
||||||
|
|||||||
@ -17,7 +17,7 @@ inletMassFlowRate
|
|||||||
alphaRhoPhi.liquid
|
alphaRhoPhi.liquid
|
||||||
);
|
);
|
||||||
|
|
||||||
valueOutput false;
|
writeFields false;
|
||||||
log true;
|
log true;
|
||||||
surfaceFormat null;
|
surfaceFormat null;
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ outletMassFlowRate
|
|||||||
alphaRhoPhi.liquid
|
alphaRhoPhi.liquid
|
||||||
);
|
);
|
||||||
|
|
||||||
valueOutput false;
|
writeFields false;
|
||||||
log true;
|
log true;
|
||||||
surfaceFormat null;
|
surfaceFormat null;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user