From a5a034a1d2129ea3fd40912907b5908e9ba79b5b Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Thu, 11 Jan 2018 12:19:13 +0000 Subject: [PATCH] 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 --- .../functionObjectList/functionObjectList.C | 42 ++++++++++++++++--- .../functionObjectList/functionObjectList.H | 35 ++++++++++++++-- 2 files changed, 69 insertions(+), 8 deletions(-) diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C index bbd576fd3..57f06fcdd 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C @@ -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) { diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H index 405e61336..dc0bf94ad 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H @@ -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/\/caseDicts/postProcessing + // - ~/.OpenFOAM/caseDicts/postProcessing + // - \b group (site) settings (when $WM_PROJECT_SITE is set): + // - $WM_PROJECT_SITE/\/caseDicts/postProcessing + // - $WM_PROJECT_SITE/caseDicts/postProcessing + // - \b group (site) settings (when $WM_PROJECT_SITE is not set): + // - $WM_PROJECT_INST_DIR/site/\/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',