functionObjectList::findDict: Added support for region-specific functionObject specification

e.g.

postProcess -func sample -region bottomWater

will now search for the system/bottomWater/sample dictionary before searching
for system/sample so that the fields and type of sampling can optionally be
specified differently for the particular region.

Resolves feature request https://bugs.openfoam.org/view.php?id=2807
This commit is contained in:
Henry Weller
2018-01-11 12:19:13 +00:00
parent 07f86eabc4
commit a5a034a1d2
2 changed files with 69 additions and 8 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -28,7 +28,6 @@ License
#include "mapPolyMesh.H"
#include "argList.H"
#include "timeControlFunctionObject.H"
//#include "IFstream.H"
#include "dictionaryEntry.H"
#include "stringOps.H"
#include "Tuple2.H"
@ -120,11 +119,18 @@ void Foam::functionObjectList::list()
}
Foam::fileName Foam::functionObjectList::findDict(const word& funcName)
Foam::fileName Foam::functionObjectList::findRegionDict
(
const word& funcName,
const word& region
)
{
// First check if there is a functionObject dictionary file in the
// case system directory
fileName dictFile = stringOps::expand("$FOAM_CASE")/"system"/funcName;
fileName dictFile
(
stringOps::expand("$FOAM_CASE")/"system"/region/funcName
);
if (isFile(dictFile))
{
@ -148,6 +154,32 @@ Foam::fileName Foam::functionObjectList::findDict(const word& funcName)
}
Foam::fileName Foam::functionObjectList::findDict
(
const word& funcName,
const word& region
)
{
if (region == word::null)
{
return findRegionDict(funcName);
}
else
{
fileName dictFile(findRegionDict(funcName, region));
if (dictFile != fileName::null)
{
return dictFile;
}
else
{
return findRegionDict(funcName);
}
}
}
bool Foam::functionObjectList::readFunctionObject
(
const string& funcNameArgs,
@ -239,7 +271,7 @@ bool Foam::functionObjectList::readFunctionObject
}
// Search for the functionObject dictionary
fileName path = findDict(funcName);
fileName path = findDict(funcName, region);
if (path == fileName::null)
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -188,7 +188,32 @@ public:
// - $WM_PROJECT_DIR/etc/caseDicts/postProcessing
static void list();
//- Search for functionObject dictionary file in
//- Search for functionObject dictionary file for given region
// and the 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 findRegionDict
(
const word& funcPath,
const word& region = word::null
);
//- Search for functionObject dictionary file for given region
// and if not present also search the case directory as well as the
// user/group/shipped directories.
// The search scheme allows for version-specific and
// version-independent files using the following hierarchy:
@ -206,7 +231,11 @@ public:
//
// \return The path of the functionObject dictionary file if found
// otherwise null
static fileName findDict(const word& funcName);
static fileName findDict
(
const word& funcName,
const word& region = word::null
);
//- Read the specified functionObject configuration dictionary parsing
// the optional arguments included in the name 'funcNameArgs0',