From 435b894d2c55c224b61ac4eac1e943e14adfe9c7 Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Wed, 4 Dec 2019 11:31:35 +0000 Subject: [PATCH] functionObjectList: Search for functions in multi-region cases in a more logical order When operating on multi-region cases, function files are now searched for in the following order: - First the $FOAM_CASE/system/ directory is searched - Second the $FOAM_CASE/system directory is searched - Finally a search is done through the preconfigured functions in $WM_PROJECT_DIR/etc Previously, in a multi-region case, preconfigured objects were considered before those in the case's (non-region) system directory. This was considered counter-intuitive. Functions residing in the system directory should always take precedence, whether they are in the region subdirectory or not. --- .../functionObjectList/functionObjectList.C | 69 +++++++++---------- .../functionObjectList/functionObjectList.H | 25 ------- 2 files changed, 31 insertions(+), 63 deletions(-) diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C index 3f14dd4580..e2201667d5 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C @@ -119,30 +119,49 @@ void Foam::functionObjectList::list() } -Foam::fileName Foam::functionObjectList::findRegionDict +Foam::fileName Foam::functionObjectList::findDict ( 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"/region/funcName - ); + // region system directory + { + const fileName dictFile + ( + stringOps::expand("$FOAM_CASE")/"system"/region/funcName + ); - if (isFile(dictFile)) - { - return dictFile; + if (isFile(dictFile)) + { + return dictFile; + } } - else + + // Next, if the region is specified, check if there is a functionObject + // dictionary file in the global system directory + if (region != word::null) { - fileNameList etcDirs(findEtcDirs(functionObjectDictPath)); + const fileName dictFile + ( + stringOps::expand("$FOAM_CASE")/"system"/funcName + ); + + if (isFile(dictFile)) + { + return dictFile; + } + } + + // Finally, check etc directories + { + const fileNameList etcDirs(findEtcDirs(functionObjectDictPath)); forAll(etcDirs, i) { - dictFile = search(funcName, etcDirs[i]); + const fileName dictFile(search(funcName, etcDirs[i])); + if (!dictFile.empty()) { return dictFile; @@ -154,32 +173,6 @@ Foam::fileName Foam::functionObjectList::findRegionDict } -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); - } - } -} - - void Foam::functionObjectList::checkUnsetEntries ( const string& funcCall, diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H index 152f639d30..fa48aabf01 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H @@ -194,31 +194,6 @@ public: // - $WM_PROJECT_DIR/etc/caseDicts/postProcessing static void list(); - //- 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/\/etc/caseDicts/postProcessing - // - $WM_PROJECT_SITE/etc/caseDicts/postProcessing - // - \b group (site) settings (when $WM_PROJECT_SITE is not set): - // - $WM_PROJECT_INST_DIR/site/\/etc/ - // caseDicts/postProcessing - // - $WM_PROJECT_INST_DIR/site/etc/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.