postProcess: Added '-list' option to list the available configured functionObjects

This commit is contained in:
Henry Weller
2016-06-01 16:28:07 +01:00
parent bb3910ddaf
commit dc4c881f25
5 changed files with 71 additions and 4 deletions

View File

@ -129,6 +129,13 @@ int main(int argc, char *argv[])
#include "addFunctionObjectOptions.H" #include "addFunctionObjectOptions.H"
#include "setRootCase.H" #include "setRootCase.H"
if (args.optionFound("list"))
{
functionObjectList::list();
return 0;
}
#include "createTime.H" #include "createTime.H"
Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args); Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args);
#include "createNamedMesh.H" #include "createNamedMesh.H"

View File

@ -71,6 +71,37 @@ Foam::functionObject* Foam::functionObjectList::remove
} }
void Foam::functionObjectList::list()
{
HashSet<word> foMap;
fileNameList etcDirs(findEtcDirs(functionObjectDictPath));
forAll(etcDirs, ed)
{
fileNameList foDirs(readDir(etcDirs[ed], fileName::DIRECTORY));
forAll(foDirs, fd)
{
fileNameList foFiles(readDir(etcDirs[ed]/foDirs[fd]));
{
forAll(foFiles, f)
{
if (foFiles[f].ext().empty())
{
foMap.insert(foFiles[f]);
}
}
}
}
}
Info<< nl
<< "Available configured functionObjects:"
<< foMap.sortedToc()
<< nl;
}
Foam::fileName Foam::functionObjectList::findDict(const word& funcName) Foam::fileName Foam::functionObjectList::findDict(const word& funcName)
{ {
// First check if there is a functionObject dictionary file in the // First check if there is a functionObject dictionary file in the

View File

@ -167,6 +167,23 @@ public:
//- Find the ID of a given function object by name //- Find the ID of a given function object by name
label findObjectID(const word& name) const; label findObjectID(const word& name) const;
//- Print a list of functionObject configuration files 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
static void list();
//- Search for functionObject dictionary file in //- Search for functionObject dictionary file in
// user/group/shipped directories. // user/group/shipped directories.
// The search scheme allows for version-specific and // The search scheme allows for version-specific and

View File

@ -74,6 +74,13 @@ if (argList::postProcess(argc, argv))
#include "addFunctionObjectOptions.H" #include "addFunctionObjectOptions.H"
#include "setRootCase.H" #include "setRootCase.H"
if (args.optionFound("list"))
{
functionObjectList::list();
return 0;
}
#include INCLUDE_FILE(CREATE_TIME) #include INCLUDE_FILE(CREATE_TIME)
Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args); Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args);
#include INCLUDE_FILE(CREATE_MESH) #include INCLUDE_FILE(CREATE_MESH)

View File

@ -3,24 +3,29 @@ Foam::argList::addOption
( (
"field", "field",
"name", "name",
"specify the name of the field to be processed, e.g. U" "Specify the name of the field to be processed, e.g. U"
); );
Foam::argList::addOption Foam::argList::addOption
( (
"fields", "fields",
"list", "list",
"specify a list of fields to be processed, e.g. '(U T p)' - " "Specify a list of fields to be processed, e.g. '(U T p)' - "
"regular expressions not currently supported" "regular expressions not currently supported"
); );
Foam::argList::addOption Foam::argList::addOption
( (
"func", "func",
"name", "name",
"specify the name of the functionObject to execute, e.g. Q" "Specify the name of the functionObject to execute, e.g. Q"
); );
Foam::argList::addOption Foam::argList::addOption
( (
"funcs", "funcs",
"list", "list",
"specify the names of the functionObjects to execute, e.g. '(Q div(U))'" "Specify the names of the functionObjects to execute, e.g. '(Q div(U))'"
);
Foam::argList::addBoolOption
(
"list",
"List the available configured functionObjects"
); );