From 5c8a1b746dfc1ce067f8b7b8f42da7d084bd75bd Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 15 Oct 2018 21:19:13 +0200 Subject: [PATCH] STYLE: use <case> instead of $FOAM_CASE expansion in more places --- .../dynamicLibrary/dynamicCode/dynamicCode.C | 2 +- .../dynamicLibrary/dynamicCode/dynamicCode.H | 6 +-- .../functionObject/functionObject.C | 2 +- .../functionObject/functionObject.H | 9 ++--- .../functionObjectList/functionObjectList.C | 38 +++++++------------ .../functionObjectList/functionObjectList.H | 2 +- src/functionObjects/utilities/abort/abort.C | 13 +++++-- src/functionObjects/utilities/abort/abort.H | 6 +-- .../noise/noiseModels/noiseModel/noiseModel.C | 21 +++++----- .../noise/noiseModels/pointNoise/pointNoise.C | 7 +++- .../noiseModels/surfaceNoise/surfaceNoise.C | 6 ++- 11 files changed, 56 insertions(+), 56 deletions(-) diff --git a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.C b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.C index 761391b6052..7404683aea7 100644 --- a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.C +++ b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.C @@ -292,7 +292,7 @@ bool Foam::dynamicCode::writeDigest(const std::string& sha1) const Foam::dynamicCode::dynamicCode(const word& codeName, const word& codeDirName) : - codeRoot_(stringOps::expand("$FOAM_CASE")/topDirName), + codeRoot_(stringOps::expand("<case>")/topDirName), libSubDir_(stringOps::expand("platforms/$WM_OPTIONS/lib")), codeName_(codeName), codeDirName_(codeDirName) diff --git a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.H b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.H index f8b7c2fcfbf..02cf92b12c4 100644 --- a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.H +++ b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.H @@ -197,7 +197,7 @@ public: } //- Root for dynamic code compilation - // Expanded from \$FOAM_CASE/dynamicCode + // Expanded from \<case\>/dynamicCode const fileName& codeRoot() const { return codeRoot_; @@ -228,12 +228,12 @@ public: #endif } - //- Path for specified code name relative to \$FOAM_CASE + //- Path for specified code name relative to \<case\> // Corresponds to topDirName/codeDirName() fileName codeRelPath() const; - //- Library path for specified code name relative to \$FOAM_CASE + //- Library path for specified code name relative to \<case\> // Corresponds to // dynamicCode/codeDirName()/libSubDir()/lib\<codeName\>.so fileName libRelPath() const; diff --git a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C index 3804a2c4af3..a3a3b42db4a 100644 --- a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C +++ b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C @@ -140,7 +140,7 @@ bool Foam::functionObject::read(const dictionary& dict) { if (!postProcess) { - log = dict.lookupOrDefault<Switch>("log", true); + log = dict.lookupOrDefault("log", true); } return true; diff --git a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H index 7d19a907cae..6cf20b4d476 100644 --- a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H +++ b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H @@ -34,8 +34,8 @@ Description \section secFunctionObjects Using function objects - FunctionObjects are selected by additional entries in the - $FOAM_CASE/system/controlDict dictionary. Each object is listed in the \c + FunctionObjects are selected by additional entries in the global case + system/controlDict dictionary. Each object is listed in the \c functions sub-dictionary, e.g. to select the \c functionObjectType functionObject the following entry would be specified: @@ -59,7 +59,7 @@ Description Where: \table - Property | Description | Required | Default value + Property | Description | Required | Default type | Type of function object | yes | libs | Libraries containing implementation | yes | region | Name of region for multi-region cases | no | @@ -120,7 +120,6 @@ SourceFiles #include "typeInfo.H" #include "autoPtr.H" -#include "Switch.H" #include "runTimeSelectionTables.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -176,7 +175,7 @@ public: static word outputPrefix; //- Switch write log to Info - Switch log; + bool log; // Declare run-time constructor selection tables diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C index 2fd7f11563d..4519ceb282a 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C @@ -98,64 +98,54 @@ Foam::functionObject* Foam::functionObjectList::remove void Foam::functionObjectList::listDir ( const fileName& dir, - wordHashSet& foMap + wordHashSet& available ) { // Search specified directory for functionObject configuration files + for (const fileName& f : fileHandler().readDir(dir)) { - fileNameList foFiles(fileHandler().readDir(dir)); - for (const fileName& f : foFiles) + if (f.ext().empty()) { - if (f.ext().empty()) - { - foMap.insert(f); - } + available.insert(f); } } // Recurse into sub-directories + for (const fileName& d : fileHandler().readDir(dir, fileName::DIRECTORY)) { - fileNameList foDirs(fileHandler().readDir(dir, fileName::DIRECTORY)); - for (const fileName& d : foDirs) - { - listDir(dir/d, foMap); - } + listDir(dir/d, available); } } void Foam::functionObjectList::list() { - wordHashSet foMap; + wordHashSet available; - fileNameList etcDirs(findEtcDirs(functionObjectDictPath)); - - for (const fileName& d : etcDirs) + for (const fileName& d : findEtcDirs(functionObjectDictPath)) { - listDir(d, foMap); + listDir(d, available); } Info<< nl << "Available configured functionObjects:" - << foMap.sortedToc() + << available.sortedToc() << nl; } 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; + // First check for functionObject dictionary file in globalCase system/ + + fileName dictFile = stringOps::expand("<system>")/funcName; if (isFile(dictFile)) { return dictFile; } - fileNameList etcDirs(findEtcDirs(functionObjectDictPath)); - - for (const fileName& d : etcDirs) + for (const fileName& d : findEtcDirs(functionObjectDictPath)) { dictFile = search(funcName, d); if (!dictFile.empty()) diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H index 5d4597ed7cc..4977098b13c 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H @@ -102,7 +102,7 @@ class functionObjectList //- Search the specified directory for functionObject //- configuration files, add to the given map and recurse - static void listDir(const fileName& dir, wordHashSet& foMap); + static void listDir(const fileName& dir, wordHashSet& available); //- No copy construct functionObjectList(const functionObjectList&) = delete; diff --git a/src/functionObjects/utilities/abort/abort.C b/src/functionObjects/utilities/abort/abort.C index 560e4411f18..02d6a69112d 100644 --- a/src/functionObjects/utilities/abort/abort.C +++ b/src/functionObjects/utilities/abort/abort.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -99,11 +99,12 @@ Foam::functionObjects::abort::abort : functionObject(name), time_(runTime), - abortFile_("$FOAM_CASE/" + name), + abortFile_(time_.globalPath()/name), action_(Time::stopAtControls::saNextWrite), triggered_(false) { - abortFile_.expand(); + abortFile_.clean(); + read(dict); // Cleanup old files from previous runs @@ -123,6 +124,12 @@ bool Foam::functionObjects::abort::read(const dictionary& dict) if (dict.readIfPresent("file", abortFile_)) { abortFile_.expand(); + + if (!abortFile_.isAbsolute()) + { + abortFile_ = time_.globalPath()/abortFile_; + abortFile_.clean(); + } } const auto oldAction = action_; diff --git a/src/functionObjects/utilities/abort/abort.H b/src/functionObjects/utilities/abort/abort.H index 10c14675577..c2c86aa5640 100644 --- a/src/functionObjects/utilities/abort/abort.H +++ b/src/functionObjects/utilities/abort/abort.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,7 +28,7 @@ Group grpUtilitiesFunctionObjects Description - Watches for presence of the named file in the $FOAM_CASE directory + Watches for presence of the named file in the case directory and aborts the calculation if it is present. The presence of the abort file is only checked on the master process. @@ -42,7 +42,7 @@ Description \table Property | Description | Required | Default value type | Type name: abort | yes | - file | The abort filename | no | $FOAM_CASE/name + file | The abort filename | no | \<case\>/name action | Abort action | no | nextWrite \endtable diff --git a/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.C b/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.C index b65541cfe51..1104fabc3ff 100644 --- a/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.C +++ b/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.C @@ -25,6 +25,7 @@ License #include "noiseModel.H" #include "functionObject.H" +#include "stringOps.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -140,17 +141,15 @@ Foam::label Foam::noiseModel::findStartTimeIndex Foam::fileName Foam::noiseModel::baseFileDir(const label dataseti) const { - fileName baseDir("$FOAM_CASE"); - word datasetName("input" + Foam::name(dataseti)); - baseDir = - baseDir.expand() - /functionObject::outputPrefix - /"noise" - /outputPrefix_ - /type() - /datasetName; - - return baseDir; + return + ( + stringOps::expand("<case>") // ie, globalPath() + / functionObject::outputPrefix + / "noise" + / outputPrefix_ + / type() + / ("input" + Foam::name(dataseti)) + ); } diff --git a/src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.C b/src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.C index c14632bc07f..c5474aee3bb 100644 --- a/src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.C +++ b/src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.C @@ -25,6 +25,7 @@ License #include "pointNoise.H" #include "noiseFFT.H" +#include "stringOps.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -240,11 +241,13 @@ void pointNoise::calculate() { fileName fName = inputFileNames_[filei]; fName.expand(); + if (!fName.isAbsolute()) { - fName = "$FOAM_CASE"/fName; - fName.expand(); + // ie, globalPath() / name + fName = stringOps::expand("<case>")/fName; } + Function1Types::CSV<scalar> data("pressure", dict_, fName); processData(filei, data); } diff --git a/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C b/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C index 5bdd27e8f51..a60902aafb2 100644 --- a/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C +++ b/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C @@ -28,6 +28,7 @@ License #include "surfaceWriter.H" #include "noiseFFT.H" #include "graph.H" +#include "stringOps.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -464,10 +465,11 @@ void surfaceNoise::calculate() if (!fName.isAbsolute()) { - fName = "$FOAM_CASE"/fName; + // ie, globalPath() / name + fName = stringOps::expand("<case>")/fName; } - initialise(fName.expand()); + initialise(fName); // Container for pressure time history data per face List<scalarField> pData; -- GitLab