postProcessing: Replaced 'foamCalc' and the 'postCalc' utilities
with the more general and flexible 'postProcess' utility and '-postProcess' solver option
Rationale
---------
Both the 'postProcess' utility and '-postProcess' solver option use the
same extensive set of functionObjects available for data-processing
during the run avoiding the substantial code duplication necessary for
the 'foamCalc' and 'postCalc' utilities and simplifying maintenance.
Additionally consistency is guaranteed between solver data processing
and post-processing.
The functionObjects have been substantially re-written and generalized
to simplify development and encourage contribution.
Configuration
-------------
An extensive set of simple functionObject configuration files are
provided in
OpenFOAM-dev/etc/caseDicts/postProcessing
and more will be added in the future. These can either be copied into
'<case>/system' directory and included into the 'controlDict.functions'
sub-dictionary or included directly from 'etc/caseDicts/postProcessing'
using the '#includeEtc' directive or the new and more convenient
'#includeFunc' directive which searches the
'<etc>/caseDicts/postProcessing' directories for the selected
functionObject, e.g.
functions
{
#includeFunc Q
#includeFunc Lambda2
}
'#includeFunc' first searches the '<case>/system' directory in case
there is a local configuration.
Description of #includeFunc
---------------------------
Specify a functionObject dictionary file to include, expects the
functionObject name to follow (without quotes).
Search for functionObject dictionary file in
user/group/shipped directories.
The search scheme allows for version-specific and
version-independent files using the following hierarchy:
- \b user settings:
- ~/.OpenFOAM/\<VERSION\>/caseDicts/postProcessing
- ~/.OpenFOAM/caseDicts/postProcessing
- \b group (site) settings (when $WM_PROJECT_SITE is set):
- $WM_PROJECT_SITE/\<VERSION\>/caseDicts/postProcessing
- $WM_PROJECT_SITE/caseDicts/postProcessing
- \b group (site) settings (when $WM_PROJECT_SITE is not set):
- $WM_PROJECT_INST_DIR/site/\<VERSION\>/caseDicts/postProcessing
- $WM_PROJECT_INST_DIR/site/caseDicts/postProcessing
- \b other (shipped) settings:
- $WM_PROJECT_DIR/etc/caseDicts/postProcessing
An example of the \c \#includeFunc directive:
\verbatim
#includeFunc <funcName>
\endverbatim
postProcess
-----------
The 'postProcess' utility and '-postProcess' solver option provide the
same set of controls to execute functionObjects after the run either by
reading a specified set of fields to process in the case of
'postProcess' or by reading all fields and models required to start the
run in the case of '-postProcess' for each selected time:
postProcess -help
Usage: postProcess [OPTIONS]
options:
-case <dir> specify alternate case directory, default is the cwd
-constant include the 'constant/' dir in the times list
-dict <file> read control dictionary from specified location
-field <name> specify the name of the field to be processed, e.g. U
-fields <list> specify a list of fields to be processed, e.g. '(U T p)' -
regular expressions not currently supported
-func <name> specify the name of the functionObject to execute, e.g. Q
-funcs <list> specify the names of the functionObjects to execute, e.g.
'(Q div(U))'
-latestTime select the latest time
-newTimes select the new times
-noFunctionObjects
do not execute functionObjects
-noZero exclude the '0/' dir from the times list, has precedence
over the -withZero option
-parallel run in parallel
-region <name> specify alternative mesh region
-roots <(dir1 .. dirN)>
slave root directories for distributed running
-time <ranges> comma-separated time ranges - eg, ':10,20,40:70,1000:'
-srcDoc display source code in browser
-doc display application documentation in browser
-help print the usage
pimpleFoam -postProcess -help
Usage: pimpleFoam [OPTIONS]
options:
-case <dir> specify alternate case directory, default is the cwd
-constant include the 'constant/' dir in the times list
-dict <file> read control dictionary from specified location
-field <name> specify the name of the field to be processed, e.g. U
-fields <list> specify a list of fields to be processed, e.g. '(U T p)' -
regular expressions not currently supported
-func <name> specify the name of the functionObject to execute, e.g. Q
-funcs <list> specify the names of the functionObjects to execute, e.g.
'(Q div(U))'
-latestTime select the latest time
-newTimes select the new times
-noFunctionObjects
do not execute functionObjects
-noZero exclude the '0/' dir from the times list, has precedence
over the -withZero option
-parallel run in parallel
-postProcess Execute functionObjects only
-region <name> specify alternative mesh region
-roots <(dir1 .. dirN)>
slave root directories for distributed running
-time <ranges> comma-separated time ranges - eg, ':10,20,40:70,1000:'
-srcDoc display source code in browser
-doc display application documentation in browser
-help print the usage
The functionObjects to execute may be specified on the command-line
using the '-func' option for a single functionObject or '-funcs' for a
list, e.g.
postProcess -func Q
postProcess -funcs '(div(U) div(phi))'
In the case of 'Q' the default field to process is 'U' which is
specified in and read from the configuration file but this may be
overridden thus:
postProcess -func 'Q(Ua)'
as is done in the example above to calculate the two forms of the divergence of
the velocity field. Additional fields which the functionObjects may depend on
can be specified using the '-field' or '-fields' options.
The 'postProcess' utility can only be used to execute functionObjects which
process fields present in the time directories. However, functionObjects which
depend on fields obtained from models, e.g. properties derived from turbulence
models can be executed using the '-postProcess' of the appropriate solver, e.g.
pisoFoam -postProcess -func PecletNo
or
sonicFoam -postProcess -func MachNo
In this case all required fields will have already been read so the '-field' or
'-fields' options are not be needed.
Henry G. Weller
CFD Direct Ltd.
This commit is contained in:
@ -76,7 +76,7 @@ wmake $targetType engine
|
||||
wmake $targetType fvOptions
|
||||
wmake $targetType regionCoupled
|
||||
|
||||
postProcessing/Allwmake $targetType $*
|
||||
functionObjects/Allwmake $targetType $*
|
||||
|
||||
wmake $targetType sixDoFRigidBodyMotion
|
||||
wmake $targetType rigidBodyDynamics
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
|
||||
@ -3,6 +3,7 @@ global/global.Cver
|
||||
/* global/constants/dimensionedConstants.C in global.Cver */
|
||||
global/argList/argList.C
|
||||
global/clock/clock.C
|
||||
global/etcFiles/etcFiles.C
|
||||
|
||||
bools = primitives/bools
|
||||
$(bools)/bool/bool.C
|
||||
@ -186,6 +187,7 @@ $(functionEntries)/codeStream/codeStream.C
|
||||
$(functionEntries)/functionEntry/functionEntry.C
|
||||
$(functionEntries)/includeEntry/includeEntry.C
|
||||
$(functionEntries)/includeEtcEntry/includeEtcEntry.C
|
||||
$(functionEntries)/includeFuncEntry/includeFuncEntry.C
|
||||
$(functionEntries)/includeIfPresentEntry/includeIfPresentEntry.C
|
||||
$(functionEntries)/inputModeEntry/inputModeEntry.C
|
||||
$(functionEntries)/removeEntry/removeEntry.C
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -24,11 +24,10 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "includeEtcEntry.H"
|
||||
#include "dictionary.H"
|
||||
#include "etcFiles.H"
|
||||
#include "IFstream.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
#include "stringOps.H"
|
||||
#include "OSspecific.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -0,0 +1,152 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "includeFuncEntry.H"
|
||||
#include "functionObjectList.H"
|
||||
#include "dictionary.H"
|
||||
#include "IFstream.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::word Foam::functionEntries::includeFuncEntry::typeName
|
||||
(
|
||||
Foam::functionEntries::includeFuncEntry::typeName_()
|
||||
);
|
||||
|
||||
// Don't lookup the debug switch here as the debug switch dictionary
|
||||
// might include includeFuncEntry
|
||||
int Foam::functionEntries::includeFuncEntry::debug(0);
|
||||
|
||||
bool Foam::functionEntries::includeFuncEntry::report(false);
|
||||
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionEntries
|
||||
{
|
||||
addToMemberFunctionSelectionTable
|
||||
(
|
||||
functionEntry,
|
||||
includeFuncEntry,
|
||||
execute,
|
||||
dictionaryIstream
|
||||
);
|
||||
|
||||
addToMemberFunctionSelectionTable
|
||||
(
|
||||
functionEntry,
|
||||
includeFuncEntry,
|
||||
execute,
|
||||
primitiveEntryIstream
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileName Foam::functionEntries::includeFuncEntry::funcPath
|
||||
(
|
||||
const word& fName,
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
// Search the system and etc directories for the file and return the path
|
||||
return functionObjectList::findDict(fName);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionEntries::includeFuncEntry::execute
|
||||
(
|
||||
dictionary& parentDict,
|
||||
Istream& is
|
||||
)
|
||||
{
|
||||
const word fName(is);
|
||||
const fileName fPath(funcPath(fName, parentDict));
|
||||
IFstream ifs(fPath);
|
||||
|
||||
if (ifs)
|
||||
{
|
||||
if (Foam::functionEntries::includeFuncEntry::report)
|
||||
{
|
||||
Info<< fPath << endl;
|
||||
}
|
||||
parentDict.read(ifs);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalIOErrorInFunction
|
||||
(
|
||||
is
|
||||
) << "Cannot open functionObject file "
|
||||
<< (ifs.name().size() ? ifs.name() : fileName(fName))
|
||||
<< " while reading dictionary " << parentDict.name()
|
||||
<< exit(FatalIOError);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionEntries::includeFuncEntry::execute
|
||||
(
|
||||
const dictionary& parentDict,
|
||||
primitiveEntry& entry,
|
||||
Istream& is
|
||||
)
|
||||
{
|
||||
const word fName(is);
|
||||
const fileName fPath(funcPath(fName, parentDict));
|
||||
IFstream ifs(fPath);
|
||||
|
||||
if (ifs)
|
||||
{
|
||||
if (Foam::functionEntries::includeFuncEntry::report)
|
||||
{
|
||||
Info<< fPath << endl;
|
||||
}
|
||||
entry.read(parentDict, ifs);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalIOErrorInFunction
|
||||
(
|
||||
is
|
||||
) << "Cannot open functionObject file "
|
||||
<< (ifs.name().size() ? ifs.name() : fileName(fName))
|
||||
<< " while reading dictionary " << parentDict.name()
|
||||
<< exit(FatalIOError);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,132 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionEntries::includeFuncEntry
|
||||
|
||||
Description
|
||||
Specify a functionObject dictionary file to include, expects the
|
||||
functionObject name to follow (without quotes).
|
||||
|
||||
Search for functionObject dictionary file in
|
||||
user/group/shipped directories.
|
||||
The search scheme allows for version-specific and
|
||||
version-independent files using the following hierarchy:
|
||||
- \b user settings:
|
||||
- ~/.OpenFOAM/\<VERSION\>/caseDicts/postProcessing
|
||||
- ~/.OpenFOAM/caseDicts/postProcessing
|
||||
- \b group (site) settings (when $WM_PROJECT_SITE is set):
|
||||
- $WM_PROJECT_SITE/\<VERSION\>/caseDicts/postProcessing
|
||||
- $WM_PROJECT_SITE/caseDicts/postProcessing
|
||||
- \b group (site) settings (when $WM_PROJECT_SITE is not set):
|
||||
- $WM_PROJECT_INST_DIR/site/\<VERSION\>/caseDicts/postProcessing
|
||||
- $WM_PROJECT_INST_DIR/site/caseDicts/postProcessing
|
||||
- \b other (shipped) settings:
|
||||
- $WM_PROJECT_DIR/etc/caseDicts/postProcessing
|
||||
|
||||
An example of the \c \#includeFunc directive:
|
||||
\verbatim
|
||||
#includeFunc <funcName>
|
||||
\endverbatim
|
||||
|
||||
See Also
|
||||
functionObjectList::findDict
|
||||
|
||||
SourceFiles
|
||||
includeFuncEntry.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef includeFuncEntry_H
|
||||
#define includeFuncEntry_H
|
||||
|
||||
#include "functionEntry.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionEntries
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class includeFuncEntry Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class includeFuncEntry
|
||||
:
|
||||
public functionEntry
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
includeFuncEntry(const includeFuncEntry&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const includeFuncEntry&);
|
||||
|
||||
//- Return the path to the functionObject dictionary path
|
||||
static fileName funcPath
|
||||
(
|
||||
const word& fName,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Static data members
|
||||
|
||||
//- Report which file is included to stdout
|
||||
static bool report;
|
||||
|
||||
|
||||
//- Runtime type information
|
||||
ClassName("includeFunc");
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Execute the functionEntry in a sub-dict context
|
||||
static bool execute(dictionary& parentDict, Istream&);
|
||||
|
||||
//- Execute the functionEntry in a primitiveEntry context
|
||||
static bool execute
|
||||
(
|
||||
const dictionary& parentDict,
|
||||
primitiveEntry&,
|
||||
Istream&
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionEntries
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -29,6 +29,7 @@ License
|
||||
#include "IFstream.H"
|
||||
#include "OFstream.H"
|
||||
#include "OSspecific.H"
|
||||
#include "etcFiles.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -28,6 +28,18 @@ License
|
||||
#include "mapPolyMesh.H"
|
||||
#include "argList.H"
|
||||
#include "timeControlFunctionObject.H"
|
||||
#include "IFstream.H"
|
||||
#include "dictionaryEntry.H"
|
||||
#include "stringOps.H"
|
||||
#include "etcFiles.H"
|
||||
|
||||
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
|
||||
|
||||
Foam::fileName Foam::functionObjectList::functionObjectDictPath
|
||||
(
|
||||
"caseDicts/postProcessing"
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
@ -59,6 +71,125 @@ Foam::functionObject* Foam::functionObjectList::remove
|
||||
}
|
||||
|
||||
|
||||
Foam::fileName Foam::functionObjectList::findDict(const word& funcName)
|
||||
{
|
||||
// First check if there is a functionObject dictionary file in the
|
||||
// case system directory
|
||||
fileName dictFile = stringOps::expand("$FOAM_CASE")/"system"/funcName;
|
||||
|
||||
if (isFile(dictFile))
|
||||
{
|
||||
return dictFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
fileNameList etcDirs(findEtcDirs(functionObjectDictPath));
|
||||
|
||||
forAll(etcDirs, i)
|
||||
{
|
||||
dictFile = search(funcName, etcDirs[i]);
|
||||
if (!dictFile.empty())
|
||||
{
|
||||
return dictFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fileName::null;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjectList::readFunctionObject
|
||||
(
|
||||
const word& funcNameArgs0,
|
||||
dictionary& functionsDict,
|
||||
HashSet<word>& selectedFields
|
||||
)
|
||||
{
|
||||
// Parse the optional functionObject arguments
|
||||
// e.g. 'Q(U)' -> funcName = Q; args = (U);
|
||||
|
||||
word funcNameArgs(funcNameArgs0);
|
||||
string::stripInvalid<word>(funcNameArgs);
|
||||
|
||||
word funcName(funcNameArgs);
|
||||
wordList args;
|
||||
|
||||
word::size_type start = 0;
|
||||
word::size_type i = 0;
|
||||
|
||||
for
|
||||
(
|
||||
word::const_iterator iter = funcNameArgs.begin();
|
||||
iter != funcNameArgs.end();
|
||||
++iter
|
||||
)
|
||||
{
|
||||
char c = *iter;
|
||||
|
||||
if (c == '(')
|
||||
{
|
||||
funcName.resize(i);
|
||||
start = i+1;
|
||||
}
|
||||
else if (c == ',')
|
||||
{
|
||||
args.append(funcNameArgs(start, i - start));
|
||||
start = i+1;
|
||||
}
|
||||
else if (c == ')')
|
||||
{
|
||||
args.append(funcNameArgs(start, i - start));
|
||||
break;
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
// Search for the functionObject dictionary
|
||||
fileName path = findDict(funcName);
|
||||
|
||||
if (path == fileName::null)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Cannot find functionObject file " << funcName << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// Read the functionObject dictionary
|
||||
IFstream fileStream(path);
|
||||
dictionary funcsDict(fileStream);
|
||||
dictionary& funcDict = funcsDict.subDict(funcName);
|
||||
|
||||
// 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
|
||||
if (args.size() == 1)
|
||||
{
|
||||
funcDict.set("field", args[0]);
|
||||
selectedFields.insert(args[0]);
|
||||
}
|
||||
else if (args.size() > 1)
|
||||
{
|
||||
funcDict.set("fields", args);
|
||||
selectedFields.insert(args);
|
||||
}
|
||||
else if (funcDict.found("field"))
|
||||
{
|
||||
selectedFields.insert(word(funcDict.lookup("field")));
|
||||
}
|
||||
else if (funcDict.found("fields"))
|
||||
{
|
||||
selectedFields.insert(wordList(funcDict.lookup("fields")));
|
||||
}
|
||||
|
||||
// Merge this functionObject dictionary into functionsDict
|
||||
dictionary funcArgsDict;
|
||||
funcArgsDict.add(funcNameArgs, funcDict);
|
||||
functionsDict.subDict("functions").merge(funcArgsDict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjectList::functionObjectList
|
||||
@ -98,35 +229,65 @@ Foam::autoPtr<Foam::functionObjectList> Foam::functionObjectList::New
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
dictionary& functionObjectsDict
|
||||
dictionary& functionsDict,
|
||||
HashSet<word>& selectedFields
|
||||
)
|
||||
{
|
||||
autoPtr<functionObjectList> functionObjectsPtr;
|
||||
autoPtr<functionObjectList> functionsPtr;
|
||||
|
||||
if (args.optionFound("dict"))
|
||||
functionsDict.add
|
||||
(
|
||||
dictionaryEntry("functions", functionsDict, dictionary::null)
|
||||
);
|
||||
|
||||
if
|
||||
(
|
||||
args.optionFound("dict")
|
||||
|| args.optionFound("func")
|
||||
|| args.optionFound("funcs")
|
||||
)
|
||||
{
|
||||
functionObjectsDict = IOdictionary
|
||||
(
|
||||
IOobject
|
||||
if (args.optionFound("dict"))
|
||||
{
|
||||
functionsDict.merge
|
||||
(
|
||||
args["dict"],
|
||||
runTime,
|
||||
IOobject::MUST_READ_IF_MODIFIED
|
||||
)
|
||||
);
|
||||
IOdictionary
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
args["dict"],
|
||||
runTime,
|
||||
IOobject::MUST_READ_IF_MODIFIED
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
functionObjectsPtr.reset
|
||||
(
|
||||
new functionObjectList(runTime, functionObjectsDict)
|
||||
);
|
||||
if (args.optionFound("func"))
|
||||
{
|
||||
readFunctionObject(args["func"], functionsDict, selectedFields);
|
||||
}
|
||||
|
||||
if (args.optionFound("funcs"))
|
||||
{
|
||||
wordList funcs(args.optionLookup("funcs")());
|
||||
|
||||
forAll(funcs, i)
|
||||
{
|
||||
readFunctionObject(funcs[i], functionsDict, selectedFields);
|
||||
}
|
||||
}
|
||||
|
||||
functionsPtr.reset(new functionObjectList(runTime, functionsDict));
|
||||
}
|
||||
else
|
||||
{
|
||||
functionObjectsPtr.reset(new functionObjectList(runTime));
|
||||
functionsPtr.reset(new functionObjectList(runTime));
|
||||
}
|
||||
functionObjectsPtr->start();
|
||||
|
||||
return functionObjectsPtr;
|
||||
functionsPtr->start();
|
||||
|
||||
return functionsPtr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -44,6 +44,7 @@ SourceFiles
|
||||
#include "functionObject.H"
|
||||
#include "SHA1Digest.H"
|
||||
#include "HashTable.H"
|
||||
#include "HashSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -90,6 +91,13 @@ 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&);
|
||||
|
||||
@ -99,13 +107,20 @@ class functionObjectList
|
||||
|
||||
public:
|
||||
|
||||
// Static data members
|
||||
|
||||
//- Default relative path to the directory structure
|
||||
// containing the functionObject dictionary files
|
||||
static fileName functionObjectDictPath;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and the execution setting
|
||||
//- Construct from Time and the execution setting.
|
||||
// The functionObject specifications are read from the controlDict
|
||||
functionObjectList
|
||||
(
|
||||
const Time&,
|
||||
const Time& runTime,
|
||||
const bool execution=true
|
||||
);
|
||||
|
||||
@ -119,13 +134,12 @@ public:
|
||||
// or not. Default: true.
|
||||
functionObjectList
|
||||
(
|
||||
const Time& t,
|
||||
const Time& runTime,
|
||||
const dictionary& parentDict,
|
||||
const bool execution=true
|
||||
);
|
||||
|
||||
//- 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
|
||||
@ -134,7 +148,8 @@ public:
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
dictionary& functionObjectsDict
|
||||
dictionary& functionObjectsDict,
|
||||
HashSet<word>& selectedFields
|
||||
);
|
||||
|
||||
|
||||
@ -159,6 +174,26 @@ public:
|
||||
//- Find the ID of a given function object by name
|
||||
label findObjectID(const word& name) const;
|
||||
|
||||
//- Search for functionObject dictionary file in
|
||||
// user/group/shipped directories.
|
||||
// The search scheme allows for version-specific and
|
||||
// version-independent files using the following hierarchy:
|
||||
// - \b user settings:
|
||||
// - ~/.OpenFOAM/\<VERSION\>/caseDicts/postProcessing
|
||||
// - ~/.OpenFOAM/caseDicts/postProcessing
|
||||
// - \b group (site) settings (when $WM_PROJECT_SITE is set):
|
||||
// - $WM_PROJECT_SITE/\<VERSION\>/caseDicts/postProcessing
|
||||
// - $WM_PROJECT_SITE/caseDicts/postProcessing
|
||||
// - \b group (site) settings (when $WM_PROJECT_SITE is not set):
|
||||
// - $WM_PROJECT_INST_DIR/site/\<VERSION\>/caseDicts/postProcessing
|
||||
// - $WM_PROJECT_INST_DIR/site/caseDicts/postProcessing
|
||||
// - \b other (shipped) settings:
|
||||
// - $WM_PROJECT_DIR/etc/caseDicts/postProcessing
|
||||
//
|
||||
// \return The path of the functionObject dictionary file if found
|
||||
// otherwise null
|
||||
static fileName findDict(const word& funcName);
|
||||
|
||||
//- Read and set the function objects if their data have changed
|
||||
bool read();
|
||||
|
||||
|
||||
@ -71,7 +71,7 @@ if (argList::postProcess(argc, argv))
|
||||
{
|
||||
Foam::timeSelector::addOptions();
|
||||
#include "addRegionOption.H"
|
||||
#include "addDictOption.H"
|
||||
#include "addFunctionObjectOptions.H"
|
||||
|
||||
#include "setRootCase.H"
|
||||
#include INCLUDE_FILE(CREATE_TIME)
|
||||
@ -84,12 +84,14 @@ if (argList::postProcess(argc, argv))
|
||||
|
||||
// Externally stored dictionary for functionObjectList
|
||||
// if not constructed from runTime
|
||||
dictionary functionObjectsDict;
|
||||
dictionary functionsDict;
|
||||
|
||||
HashSet<word> selectedFields;
|
||||
|
||||
// Construct functionObjectList
|
||||
autoPtr<functionObjectList> functionObjectsPtr
|
||||
autoPtr<functionObjectList> functionsPtr
|
||||
(
|
||||
functionObjectList::New(args, runTime, functionObjectsDict)
|
||||
functionObjectList::New(args, runTime, functionsDict, selectedFields)
|
||||
);
|
||||
|
||||
forAll(timeDirs, timeI)
|
||||
@ -101,8 +103,13 @@ if (argList::postProcess(argc, argv))
|
||||
if (mesh.readUpdate() != polyMesh::UNCHANGED)
|
||||
{
|
||||
// Update functionObjects if mesh changes
|
||||
functionObjectsPtr =
|
||||
functionObjectList::New(args, runTime, functionObjectsDict);
|
||||
functionsPtr = functionObjectList::New
|
||||
(
|
||||
args,
|
||||
runTime,
|
||||
functionsDict,
|
||||
selectedFields
|
||||
);
|
||||
}
|
||||
|
||||
FatalIOError.throwExceptions();
|
||||
@ -119,7 +126,7 @@ if (argList::postProcess(argc, argv))
|
||||
#include INCLUDE_FILE(CREATE_FIELDS_3)
|
||||
#endif
|
||||
|
||||
functionObjectsPtr->execute(true);
|
||||
functionsPtr->execute(true);
|
||||
}
|
||||
catch (IOerror& err)
|
||||
{
|
||||
|
||||
@ -47,6 +47,7 @@ namespace Foam
|
||||
|
||||
class regIOobject;
|
||||
class IOobjectList;
|
||||
class objectRegistry;
|
||||
|
||||
//- Read all fields of the specified type.
|
||||
// Returns names of fields read.
|
||||
|
||||
@ -29,7 +29,7 @@ Description
|
||||
#include "debug.H"
|
||||
#include "dictionary.H"
|
||||
#include "IFstream.H"
|
||||
#include "OSspecific.H"
|
||||
#include "etcFiles.H"
|
||||
#include "Ostream.H"
|
||||
#include "demandDrivenData.H"
|
||||
#include "simpleObjectRegistry.H"
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
|
||||
26
src/OpenFOAM/include/addFunctionObjectOptions.H
Normal file
26
src/OpenFOAM/include/addFunctionObjectOptions.H
Normal file
@ -0,0 +1,26 @@
|
||||
#include "addDictOption.H"
|
||||
Foam::argList::addOption
|
||||
(
|
||||
"field",
|
||||
"name",
|
||||
"specify the name of the field to be processed, e.g. U"
|
||||
);
|
||||
Foam::argList::addOption
|
||||
(
|
||||
"fields",
|
||||
"list",
|
||||
"specify a list of fields to be processed, e.g. '(U T p)' - "
|
||||
"regular expressions not currently supported"
|
||||
);
|
||||
Foam::argList::addOption
|
||||
(
|
||||
"func",
|
||||
"name",
|
||||
"specify the name of the functionObject to execute, e.g. Q"
|
||||
);
|
||||
Foam::argList::addOption
|
||||
(
|
||||
"funcs",
|
||||
"list",
|
||||
"specify the names of the functionObjects to execute, e.g. '(Q div(U))'"
|
||||
);
|
||||
@ -27,7 +27,7 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "cellModeller.H"
|
||||
#include "OSspecific.H"
|
||||
#include "etcFiles.H"
|
||||
#include "IFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Static data * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -26,6 +26,7 @@ License
|
||||
#include "stringOps.H"
|
||||
#include "typeInfo.H"
|
||||
#include "OSspecific.H"
|
||||
#include "etcFiles.H"
|
||||
#include "OStringStream.H"
|
||||
|
||||
|
||||
|
||||
@ -36,6 +36,7 @@ SourceFiles
|
||||
#define gaussConvectionScheme_H
|
||||
|
||||
#include "convectionScheme.H"
|
||||
#include "etcFiles.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -10,5 +10,6 @@ wmake $targetType field
|
||||
wmake $targetType forces
|
||||
wmake $targetType lagrangian
|
||||
wmake $targetType utilities
|
||||
wmake $targetType solvers
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -68,10 +68,10 @@ Foam::functionObjects::CourantNo::byRho
|
||||
|
||||
bool Foam::functionObjects::CourantNo::calc()
|
||||
{
|
||||
if (foundObject<surfaceScalarField>(phiName_))
|
||||
if (foundObject<surfaceScalarField>(fieldName_))
|
||||
{
|
||||
const surfaceScalarField& phi =
|
||||
lookupObject<surfaceScalarField>(phiName_);
|
||||
lookupObject<surfaceScalarField>(fieldName_);
|
||||
|
||||
tmp<volScalarField::Internal> Coi
|
||||
(
|
||||
@ -138,8 +138,9 @@ Foam::functionObjects::CourantNo::CourantNo
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "phi", "Co")
|
||||
fieldExpression(name, runTime, dict, "phi")
|
||||
{
|
||||
setResultName("Co", "phi");
|
||||
read(dict);
|
||||
}
|
||||
|
||||
@ -156,7 +157,6 @@ bool Foam::functionObjects::CourantNo::read(const dictionary& dict)
|
||||
{
|
||||
fieldExpression::read(dict);
|
||||
|
||||
phiName_ = dict.lookupOrDefault<word>("phi", "phi");
|
||||
rhoName_ = dict.lookupOrDefault<word>("rho", "rho");
|
||||
|
||||
return true;
|
||||
@ -83,8 +83,10 @@ Foam::functionObjects::Lambda2::Lambda2
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "U", "Lambda2")
|
||||
{}
|
||||
fieldExpression(name, runTime, dict, "U")
|
||||
{
|
||||
setResultName(typeName, "U");
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
@ -82,8 +82,10 @@ Foam::functionObjects::MachNo::MachNo
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "U", "Ma")
|
||||
{}
|
||||
fieldExpression(name, runTime, dict, "U")
|
||||
{
|
||||
setResultName("Ma", "U");
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
@ -27,7 +27,7 @@ wallBoundedStreamLine/wallBoundedStreamLineParticle.C
|
||||
wallBoundedStreamLine/wallBoundedStreamLineParticleCloud.C
|
||||
wallBoundedStreamLine/wallBoundedParticle.C
|
||||
|
||||
surfaceInterpolateFields/surfaceInterpolateFields.C
|
||||
surfaceInterpolate/surfaceInterpolate.C
|
||||
|
||||
regionSizeDistribution/regionSizeDistribution.C
|
||||
histogram/histogram.C
|
||||
@ -50,4 +50,7 @@ blendingFactor/blendingFactor.C
|
||||
pressure/pressure.C
|
||||
MachNo/MachNo.C
|
||||
|
||||
turbulenceFields/turbulenceFields.C
|
||||
yPlus/yPlus.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libfieldFunctionObjects
|
||||
@ -8,13 +8,18 @@ EXE_INC = \
|
||||
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
|
||||
-I$(LIB_SRC)/transportModels \
|
||||
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
|
||||
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude
|
||||
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
|
||||
-I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
|
||||
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude
|
||||
|
||||
LIB_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lfluidThermophysicalModels \
|
||||
-lcompressibleTransportModels \
|
||||
-lincompressibleTransportModels \
|
||||
-lturbulenceModels \
|
||||
-lcompressibleTransportModels \
|
||||
-lincompressibleTurbulenceModels \
|
||||
-lcompressibleTurbulenceModels \
|
||||
-lmeshTools \
|
||||
-lsurfMesh \
|
||||
-llagrangian \
|
||||
@ -50,7 +50,7 @@ namespace functionObjects
|
||||
|
||||
bool Foam::functionObjects::PecletNo::calc()
|
||||
{
|
||||
if (foundObject<surfaceScalarField>(phiName_))
|
||||
if (foundObject<surfaceScalarField>(fieldName_))
|
||||
{
|
||||
tmp<volScalarField> nuEff
|
||||
(
|
||||
@ -61,7 +61,7 @@ bool Foam::functionObjects::PecletNo::calc()
|
||||
);
|
||||
|
||||
const surfaceScalarField& phi =
|
||||
mesh_.lookupObject<surfaceScalarField>(phiName_);
|
||||
mesh_.lookupObject<surfaceScalarField>(fieldName_);
|
||||
|
||||
return store
|
||||
(
|
||||
@ -90,9 +90,9 @@ Foam::functionObjects::PecletNo::PecletNo
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "phi", "Pe")
|
||||
fieldExpression(name, runTime, dict, "phi")
|
||||
{
|
||||
read(dict);
|
||||
setResultName("Pe", "phi");
|
||||
}
|
||||
|
||||
|
||||
@ -102,16 +102,4 @@ Foam::functionObjects::PecletNo::~PecletNo()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::PecletNo::read(const dictionary& dict)
|
||||
{
|
||||
fieldExpression::read(dict);
|
||||
|
||||
phiName_ = dict.lookupOrDefault<word>("phi", "phi");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -60,12 +60,6 @@ class PecletNo
|
||||
:
|
||||
public fieldExpression
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of flux field, default is "phi"
|
||||
word phiName_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the Peclet number field and return true if successful
|
||||
@ -92,12 +86,6 @@ public:
|
||||
|
||||
//- Destructor
|
||||
virtual ~PecletNo();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the PecletNo data
|
||||
virtual bool read(const dictionary&);
|
||||
};
|
||||
|
||||
|
||||
@ -79,17 +79,7 @@ Foam::functionObjects::Q::Q
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "U")
|
||||
{
|
||||
if (resultName_.empty())
|
||||
{
|
||||
if (fieldName_ != "U")
|
||||
{
|
||||
resultName_ = "Q(" + fieldName_ + ')';
|
||||
}
|
||||
else
|
||||
{
|
||||
resultName_ = 'Q';
|
||||
}
|
||||
}
|
||||
setResultName(typeName, "U");
|
||||
}
|
||||
|
||||
|
||||
@ -75,8 +75,10 @@ Foam::functionObjects::enstrophy::enstrophy
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "U", "enstrophy")
|
||||
{}
|
||||
fieldExpression(name, runTime, dict, "U")
|
||||
{
|
||||
setResultName(typeName, "U");
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
@ -46,6 +46,31 @@ bool Foam::functionObjects::fieldExpression::calc()
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::fieldExpression::setResultName
|
||||
(
|
||||
const word& typeName,
|
||||
const word& defaultArg
|
||||
)
|
||||
{
|
||||
if (fieldName_.empty())
|
||||
{
|
||||
fieldName_ = defaultArg;
|
||||
}
|
||||
|
||||
if (resultName_.empty())
|
||||
{
|
||||
if (fieldName_ != defaultArg)
|
||||
{
|
||||
resultName_ = typeName + '(' + fieldName_ + ')';
|
||||
}
|
||||
else
|
||||
{
|
||||
resultName_ = typeName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldExpression::fieldExpression
|
||||
@ -73,6 +73,8 @@ protected:
|
||||
|
||||
virtual bool calc();
|
||||
|
||||
void setResultName(const word& typeName, const word& defaultArg);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -87,8 +87,10 @@ Foam::functionObjects::flowType::flowType
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "U", "flowType")
|
||||
{}
|
||||
fieldExpression(name, runTime, dict, "U")
|
||||
{
|
||||
setResultName(typeName, "U");
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,7 +25,7 @@ Class
|
||||
Foam::functionObjects::pressure
|
||||
|
||||
Group
|
||||
grpForcesFunctionObjects
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
This function object includes tools to manipulate the pressure into
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user