mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
includeFuncEntry: Added support for function arguments compatible with the '-func' post-processing option
e.g.
functions
{
#includeFunc mag(U)
}
executes 'mag' on the field 'U' writing the field 'mag(U)'.
The equivalent post-processing command is
postProcess -func 'mag(U)'
This commit is contained in:
@ -99,11 +99,11 @@ Foam::fileName Foam::functionObjectList::findDict(const word& funcName)
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjectList::readFunctionObject
|
||||
bool Foam::functionObjectList::readFunctionObject
|
||||
(
|
||||
const word& funcNameArgs0,
|
||||
dictionary& functionsDict,
|
||||
HashSet<word>& selectedFields
|
||||
HashSet<word>& requiredFields
|
||||
)
|
||||
{
|
||||
// Parse the optional functionObject arguments
|
||||
@ -153,7 +153,7 @@ void Foam::functionObjectList::readFunctionObject
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Cannot find functionObject file " << funcName << endl;
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read the functionObject dictionary
|
||||
@ -163,30 +163,32 @@ void Foam::functionObjectList::readFunctionObject
|
||||
|
||||
// Insert the 'field' or 'fields' entry corresponding to the optional
|
||||
// arguments or read the 'field' or 'fields' entry and add the required
|
||||
// fields to selectedFields
|
||||
// fields to requiredFields
|
||||
if (args.size() == 1)
|
||||
{
|
||||
funcDict.set("field", args[0]);
|
||||
selectedFields.insert(args[0]);
|
||||
requiredFields.insert(args[0]);
|
||||
}
|
||||
else if (args.size() > 1)
|
||||
{
|
||||
funcDict.set("fields", args);
|
||||
selectedFields.insert(args);
|
||||
requiredFields.insert(args);
|
||||
}
|
||||
else if (funcDict.found("field"))
|
||||
{
|
||||
selectedFields.insert(word(funcDict.lookup("field")));
|
||||
requiredFields.insert(word(funcDict.lookup("field")));
|
||||
}
|
||||
else if (funcDict.found("fields"))
|
||||
{
|
||||
selectedFields.insert(wordList(funcDict.lookup("fields")));
|
||||
requiredFields.insert(wordList(funcDict.lookup("fields")));
|
||||
}
|
||||
|
||||
// Merge this functionObject dictionary into functionsDict
|
||||
dictionary funcArgsDict;
|
||||
funcArgsDict.add(funcNameArgs, funcDict);
|
||||
functionsDict.subDict("functions").merge(funcArgsDict);
|
||||
functionsDict.merge(funcArgsDict);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -229,17 +231,19 @@ Foam::autoPtr<Foam::functionObjectList> Foam::functionObjectList::New
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
dictionary& functionsDict,
|
||||
HashSet<word>& selectedFields
|
||||
dictionary& controlDict,
|
||||
HashSet<word>& requiredFields
|
||||
)
|
||||
{
|
||||
autoPtr<functionObjectList> functionsPtr;
|
||||
|
||||
functionsDict.add
|
||||
controlDict.add
|
||||
(
|
||||
dictionaryEntry("functions", functionsDict, dictionary::null)
|
||||
dictionaryEntry("functions", controlDict, dictionary::null)
|
||||
);
|
||||
|
||||
dictionary& functionsDict = controlDict.subDict("functions");
|
||||
|
||||
if
|
||||
(
|
||||
args.optionFound("dict")
|
||||
@ -249,7 +253,7 @@ Foam::autoPtr<Foam::functionObjectList> Foam::functionObjectList::New
|
||||
{
|
||||
if (args.optionFound("dict"))
|
||||
{
|
||||
functionsDict.merge
|
||||
controlDict.merge
|
||||
(
|
||||
IOdictionary
|
||||
(
|
||||
@ -265,7 +269,7 @@ Foam::autoPtr<Foam::functionObjectList> Foam::functionObjectList::New
|
||||
|
||||
if (args.optionFound("func"))
|
||||
{
|
||||
readFunctionObject(args["func"], functionsDict, selectedFields);
|
||||
readFunctionObject(args["func"], functionsDict, requiredFields);
|
||||
}
|
||||
|
||||
if (args.optionFound("funcs"))
|
||||
@ -274,11 +278,11 @@ Foam::autoPtr<Foam::functionObjectList> Foam::functionObjectList::New
|
||||
|
||||
forAll(funcs, i)
|
||||
{
|
||||
readFunctionObject(funcs[i], functionsDict, selectedFields);
|
||||
readFunctionObject(funcs[i], functionsDict, requiredFields);
|
||||
}
|
||||
}
|
||||
|
||||
functionsPtr.reset(new functionObjectList(runTime, functionsDict));
|
||||
functionsPtr.reset(new functionObjectList(runTime, controlDict));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -91,13 +91,6 @@ class functionObjectList
|
||||
// Returns a NULL pointer (and index -1) if it didn't exist.
|
||||
functionObject* remove(const word&, label& oldIndex);
|
||||
|
||||
static void readFunctionObject
|
||||
(
|
||||
const word& funcNameArgs0,
|
||||
dictionary& functionsDict,
|
||||
HashSet<word>& selectedFields
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
functionObjectList(const functionObjectList&);
|
||||
|
||||
@ -142,14 +135,14 @@ public:
|
||||
//- Construct and return a functionObjectList for an application.
|
||||
// If the "dict" argument is specified the functionObjectList is
|
||||
// constructed from that dictionary which is returned as
|
||||
// functionObjectsDict otherwise the functionObjectList is constructed
|
||||
// controlDict otherwise the functionObjectList is constructed
|
||||
// from the "functions" sub-dictionary of "system/controlDict"
|
||||
static autoPtr<functionObjectList> New
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
dictionary& functionObjectsDict,
|
||||
HashSet<word>& selectedFields
|
||||
dictionary& controlDict,
|
||||
HashSet<word>& requiredFields
|
||||
);
|
||||
|
||||
|
||||
@ -194,6 +187,19 @@ public:
|
||||
// otherwise null
|
||||
static fileName findDict(const word& funcName);
|
||||
|
||||
//- Read the specified functionObject configuration dictionary parsing
|
||||
// the optional arguments included in the name 'funcNameArgs0',
|
||||
// inserting 'field' or 'fields' entries as required and merging the
|
||||
// resulting functionObject dictionary into 'functionsDict'. Any
|
||||
// fields required to execute the functionObject are added to
|
||||
// 'requiredFields'
|
||||
static bool readFunctionObject
|
||||
(
|
||||
const word& funcNameArgs0,
|
||||
dictionary& functionsDict,
|
||||
HashSet<word>& requiredFields
|
||||
);
|
||||
|
||||
//- Read and set the function objects if their data have changed
|
||||
bool read();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user