From 66df3369dcd58559049f6aa45a739993a5ab4a89 Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Thu, 17 May 2018 09:04:00 +0100 Subject: [PATCH 01/28] BUG: ConeInjection - corrected number of parcels injected for multiple injector positions --- .../InjectionModel/ConeInjection/ConeInjection.C | 8 ++++---- .../hotBoxes/constant/reactingCloud1Properties | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjection/ConeInjection.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjection/ConeInjection.C index 6651a9573f..7daf1cab7d 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjection/ConeInjection.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjection/ConeInjection.C @@ -198,12 +198,12 @@ Foam::label Foam::ConeInjection::parcelsToInject { const scalar targetVolume = flowRateProfile_.integrate(0, time1); + const scalar volumeFraction = targetVolume/this->volumeTotal_; + const label targetParcels = - parcelsPerInjector_*targetVolume/this->volumeTotal_; + ceil(positionAxis_.size()*parcelsPerInjector_*volumeFraction); - const label nToInject = targetParcels - nInjected_; - - return positionAxis_.size()*nToInject; + return targetParcels - nInjected_; } else { diff --git a/tutorials/lagrangian/reactingParcelFoam/hotBoxes/constant/reactingCloud1Properties b/tutorials/lagrangian/reactingParcelFoam/hotBoxes/constant/reactingCloud1Properties index 593d1c3cc3..0e2ce3631a 100644 --- a/tutorials/lagrangian/reactingParcelFoam/hotBoxes/constant/reactingCloud1Properties +++ b/tutorials/lagrangian/reactingParcelFoam/hotBoxes/constant/reactingCloud1Properties @@ -85,7 +85,6 @@ subModels massTotal 10; parcelsPerInjector 20000; - parcelsPerSecond 500; parcelBasisType mass; flowRateProfile constant 0.1; Umag constant 3.0; From 85ecb009d753d9a8d8e8ae5b6b82c3291bfd5250 Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Fri, 18 May 2018 09:57:12 +0100 Subject: [PATCH 02/28] TUT: Updated input value --- .../hotBoxes/constant/reactingCloud1Properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/lagrangian/reactingParcelFoam/hotBoxes/constant/reactingCloud1Properties b/tutorials/lagrangian/reactingParcelFoam/hotBoxes/constant/reactingCloud1Properties index 0e2ce3631a..07dd23e052 100644 --- a/tutorials/lagrangian/reactingParcelFoam/hotBoxes/constant/reactingCloud1Properties +++ b/tutorials/lagrangian/reactingParcelFoam/hotBoxes/constant/reactingCloud1Properties @@ -86,7 +86,7 @@ subModels massTotal 10; parcelsPerInjector 20000; parcelBasisType mass; - flowRateProfile constant 0.1; + flowRateProfile constant 1; Umag constant 3.0; thetaInner constant 0; thetaOuter constant 45; From ffe8048e04b8115607faf4b207a82cd0562ba6fa Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Tue, 29 May 2018 15:10:19 +0100 Subject: [PATCH 03/28] BUG: COxidationIntrinicRate - corrected eta. See #842 --- .../COxidationIntrinsicRate/COxidationIntrinsicRate.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lagrangian/coalCombustion/submodels/surfaceReactionModel/COxidationIntrinsicRate/COxidationIntrinsicRate.C b/src/lagrangian/coalCombustion/submodels/surfaceReactionModel/COxidationIntrinsicRate/COxidationIntrinsicRate.C index 1a260dac90..77435d66b4 100644 --- a/src/lagrangian/coalCombustion/submodels/surfaceReactionModel/COxidationIntrinsicRate/COxidationIntrinsicRate.C +++ b/src/lagrangian/coalCombustion/submodels/surfaceReactionModel/COxidationIntrinsicRate/COxidationIntrinsicRate.C @@ -180,7 +180,7 @@ Foam::scalar Foam::COxidationIntrinsicRate::calculate max(0.5*d*sqrt(Sb_*rhop*Ag_*ki*ppO2/(De*rhoO2)), ROOTVSMALL); // Effectiveness factor [] - const scalar eta = max(3.0*sqr(phi)*(phi/tanh(phi) - 1.0), 0.0); + const scalar eta = max(3.0/sqr(phi)*(phi/tanh(phi) - 1.0), 0.0); // Chemical rate [kmol/m2/s] const scalar R = eta*d/6.0*rhop*Ag_*ki; From e747024c34df5baf217d21e19ea4e0713cb48b6c Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Tue, 29 May 2018 15:28:44 +0100 Subject: [PATCH 04/28] BUG: Corrected header documentation - see #831 --- ...idityTemperatureCoupledMixedFvPatchScalarField.H | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.H b/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.H index 3c0de53027..dee4aa5fdf 100644 --- a/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.H +++ b/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.H @@ -32,7 +32,7 @@ Description This boundary condition can operate in four modes: - \c constantMass: thermal inertia only - - requires \c rho, \c thickness and \cp + - requires \c rho, \c thickness and \c p - \c condensation: condensation only - when the wall temperature (Tw) is below the dew temperature (Tdew) condesation takes place and the resulting condensed mass is stored @@ -60,21 +60,26 @@ Description The mass transfer correlation used is: - \f[ h_m = D_{ab} \frac{Sc}{L} \f] + \f[ h_m = D_{ab} \frac{Sh}{L} \f] where: \vartable D_{ab} | mass vapour difussivity L | characteristic length - Sc | Schmidt number + Sh | Sherwood number \endvartable - The Schmidt number is calculated using: + The Sherwood number is calculated using: \f{eqnarray*}{ 0.664 Re^\frac{1}{2} Sc^\frac{1}{3} & Re < 5.0E+05 \\ 0.037 Re^\frac{4}{5} Sc^\frac{1}{3} & Re > 5.0E+05 \f} + where: + \vartable + Re | Reynolds number + Sc | Schmidt number + \endvartable NOTE: - The correlation used to calculate Tdew is for water vapour. From fe21322939c164867be32161b0867ea16310f1c2 Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Wed, 30 May 2018 14:05:53 +0100 Subject: [PATCH 05/28] BUG: Corrected ConeNozzleInjection injected posisions in parallel operation. See #840 --- .../InjectionModel/ConeNozzleInjection/ConeNozzleInjection.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeNozzleInjection/ConeNozzleInjection.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeNozzleInjection/ConeNozzleInjection.C index 6ac062ee57..36a638c3b6 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeNozzleInjection/ConeNozzleInjection.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeNozzleInjection/ConeNozzleInjection.C @@ -186,7 +186,7 @@ Foam::ConeNozzleInjection::ConeNozzleInjection while(magTangent < SMALL) { - vector v = rndGen.sample01(); + vector v = rndGen.globalSample01(); tangent = v - (v & direction_)*direction_; magTangent = mag(tangent); @@ -323,7 +323,7 @@ void Foam::ConeNozzleInjection::setPositionAndCell { Random& rndGen = this->owner().rndGen(); - scalar beta = mathematical::twoPi*rndGen.sample01(); + scalar beta = mathematical::twoPi*rndGen.globalSample01(); normal_ = tanVec1_*cos(beta) + tanVec2_*sin(beta); switch (injectionMethod_) From eeb725715d5a5794a15f328d20773f1326eea66f Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 29 May 2018 10:26:22 +0100 Subject: [PATCH 06/28] BUG: decomposeParDict: ignores mesh region. Fixes #848. --- src/parallel/decompose/decompose/decompositionModel.C | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/parallel/decompose/decompose/decompositionModel.C b/src/parallel/decompose/decompose/decompositionModel.C index 8f156c64b5..b2c948c919 100644 --- a/src/parallel/decompose/decompose/decompositionModel.C +++ b/src/parallel/decompose/decompose/decompositionModel.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -58,7 +58,7 @@ Foam::decompositionModel::decompositionModel "decomposeParDict", mesh.time().system(), mesh.local(), - mesh.db(), + mesh.thisDb(), IOobject::MUST_READ, IOobject::NO_WRITE, false, //io.registerObject(), @@ -92,7 +92,7 @@ Foam::decompositionModel::decompositionModel "decomposeParDict", mesh.time().system(), mesh.local(), - mesh.db(), + mesh.thisDb(), (dict.size() ? IOobject::NO_READ : IOobject::MUST_READ), IOobject::NO_WRITE, false, //io.registerObject(), From a6f524b1df93413d96d9c9ca9380acfec841408a Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 1 Jun 2018 11:36:43 +0200 Subject: [PATCH 07/28] STYLE: -diff-etc instead of -diffEtc in foamDictionary --- .../foamDictionary/foamDictionary.C | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C b/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C index c8d972fd51..b15a09c15a 100644 --- a/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C +++ b/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C @@ -50,7 +50,7 @@ Usage Write differences with respect to the specified dictionary (or sub entry if -entry specified) - - \par -diffEtc \ + - \par -diff-etc \ Write differences with respect to the specified dictionary (or sub entry if -entry specified) @@ -94,13 +94,13 @@ Usage - Write the differences with respect to a template dictionary: \verbatim - foamDictionary 0/U -diffEtc templates/closedVolume/0/U + foamDictionary 0/U -diff-etc templates/closedVolume/0/U \endverbatim - Write the differences in boundaryField with respect to a template dictionary: \verbatim - foamDictionary 0/U -diffEtc templates/closedVolume/0/U \ + foamDictionary 0/U -diff-etc templates/closedVolume/0/U \ -entry boundaryField \endverbatim @@ -217,11 +217,9 @@ const dictionary& lookupScopedDict if (!eptr || !eptr->isDict()) { FatalIOErrorInFunction(dict) - << "keyword " << subDictName - << " is undefined in dictionary " - << dict.name() << " or is not a dictionary" - << endl - << "Valid keywords are " << dict.keys() + << "'" << subDictName << "' not found in dictionary " + << dict.name() << " or is not a dictionary" << nl + << "Known entries are " << dict.keys() << exit(FatalIOError); } @@ -300,10 +298,12 @@ int main(int argc, char *argv[]) ); argList::addOption ( - "diffEtc", + "diff-etc", "dict", "As per -diff, but locate the file as per foamEtcFile" ); + argList::addOptionCompat("diff-etc", {"diffEtc", 1712}); + argList::addBoolOption ( "includes", @@ -371,10 +371,10 @@ int main(int argc, char *argv[]) } - // Has "diff" or "diffEtc" + // Has "diff" or "diff-etc" bool optDiff = false; - // Reference dictionary for -diff / -diffEtc + // Reference dictionary for -diff / -diff-etc dictionary diffDict; { fileName diffFileName; @@ -392,7 +392,7 @@ int main(int argc, char *argv[]) diffDict.read(diffFile, true); optDiff = true; } - else if (args.readIfPresent("diffEtc", diffFileName)) + else if (args.readIfPresent("diff-etc", diffFileName)) { fileName foundName = findEtcFile(diffFileName); if (foundName.empty()) From 511b35629d245fbdafda6b72382a5add331e221b Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 1 Jun 2018 11:55:57 +0200 Subject: [PATCH 08/28] ENH: improve infrastructure for detecting excess tokens (issue #762) - Always used for optional dictionary entries, since these are individual values, and not meant to be embedded in a larger stream of tokens. Methods: - lookupOrDefault, lookupOrAddDefault, lookupOrDefaultCompat - readIfPresent, readIfPresentCompat - Handling mandatory dictionary entries is slightly more complex, since these may be part of larger stream of tokens, and are often used in a constructor context. For example, word modelType(dict.lookup("type")); Or they are used without a definite context. For example, dict.lookup("format") >> outputFormat; Newly introduced methods for mandatory dictionary entries: - get, getCompat - read, readCompat In a constructor or assignment context: word modelType(dict.get("type")); outputFormat = dict.lookup("format"); without copy/move (similar to readIfPresent): dict.read("format", outputFormat); --- .../DictionaryBase/DictionaryBase.C | 4 +- src/OpenFOAM/db/dictionary/dictionary.C | 91 +++++--- src/OpenFOAM/db/dictionary/dictionary.H | 99 +++++++-- src/OpenFOAM/db/dictionary/dictionaryCompat.C | 19 +- src/OpenFOAM/db/dictionary/dictionarySearch.C | 70 +++--- .../db/dictionary/dictionaryTemplates.C | 204 +++++++++--------- src/OpenFOAM/db/error/IOerror.C | 10 +- .../functions/Function1/ramp/ramp.C | 2 +- 8 files changed, 279 insertions(+), 220 deletions(-) diff --git a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C index 2f95d40f71..0661cbf8d9 100644 --- a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C +++ b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C @@ -138,7 +138,7 @@ const T* Foam::DictionaryBase::lookup(const word& keyword) const if (iter == hashedTs_.end()) { FatalErrorInFunction - << keyword << " is undefined" + << "'" << keyword << "' not found" << exit(FatalError); } @@ -154,7 +154,7 @@ T* Foam::DictionaryBase::lookup(const word& keyword) if (iter == hashedTs_.end()) { FatalErrorInFunction - << keyword << " is undefined" + << "'" << keyword << "' not found" << exit(FatalError); } diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C index 6223da9e0f..f2adc1b598 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.C +++ b/src/OpenFOAM/db/dictionary/dictionary.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) 2015-2017 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -24,6 +24,8 @@ License \*---------------------------------------------------------------------------*/ #include "dictionary.H" +#include "error.H" +#include "JobInfo.H" #include "primitiveEntry.H" #include "dictionaryEntry.H" #include "regExp.H" @@ -48,7 +50,6 @@ bool Foam::dictionary::writeOptionalEntries void Foam::dictionary::excessTokens ( - OSstream& msg, const word& keyword, const ITstream& is ) const @@ -60,12 +61,44 @@ void Foam::dictionary::excessTokens return; } - msg << "entry '" << keyword << "' has " - << nExcess << " excess tokens, near line: " << is.lineNumber() << nl - << "dictionary: " << name() << nl - << "stream: "; - is.writeList(msg, 0); - msg << nl; + // Similar to SafeFatalIOError + + if (JobInfo::constructed) + { + OSstream& err = + FatalIOError + ( + "", // functionName + "", // sourceFileName + 0, // sourceFileLineNumber + this->name(), // ioFileName + is.lineNumber() // ioStartLineNumber + ); + + err << "'" << keyword << "' has " + << nExcess << " excess tokens in stream" << nl << nl + << " "; + is.writeList(err, 0); + + err << exit(FatalIOError); + } + else + { + std::cerr + << nl + << "--> FOAM FATAL IO ERROR:" << nl; + + std::cerr + << "'" << keyword << "' has " + << nExcess << " excess tokens in stream" << nl << nl; + + std::cerr + << "file: " << this->name() + << " at line " << is.lineNumber() << '.' << nl + << std::endl; + + ::exit(1); + } } @@ -296,10 +329,8 @@ const Foam::entry& Foam::dictionary::lookupEntry if (!finder.found()) { - FatalIOErrorInFunction - ( - *this - ) << "keyword " << keyword << " is undefined in dictionary " + FatalIOErrorInFunction(*this) + << "'" << keyword << "' not found in dictionary " << name() << exit(FatalIOError); } @@ -422,10 +453,8 @@ const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const if (!finder.found()) { - FatalIOErrorInFunction - ( - *this - ) << "keyword " << keyword << " is undefined in dictionary " + FatalIOErrorInFunction(*this) + << "'" << keyword << "' not found in dictionary " << name() << exit(FatalIOError); } @@ -441,10 +470,8 @@ Foam::dictionary& Foam::dictionary::subDict(const word& keyword) if (!finder.found()) { - FatalIOErrorInFunction - ( - *this - ) << "keyword " << keyword << " is undefined in dictionary " + FatalIOErrorInFunction(*this) + << "'" << keyword << "' not found in dictionary " << name() << exit(FatalIOError); } @@ -470,20 +497,18 @@ Foam::dictionary Foam::dictionary::subOrEmptyDict if (mustRead) { - FatalIOErrorInFunction - ( - *this - ) << "keyword " << keyword - << " is not a sub-dictionary in dictionary " + FatalIOErrorInFunction(*this) + << "'" << keyword + << "' is not a sub-dictionary in dictionary " << name() << exit(FatalIOError); } if (finder.found()) { - IOWarningInFunction((*this)) - << "keyword " << keyword - << " found but not a sub-dictionary in dictionary " + IOWarningInFunction(*this) + << "'" << keyword + << "' found but not a sub-dictionary in dictionary " << name() << endl; } @@ -506,9 +531,9 @@ const Foam::dictionary& Foam::dictionary::optionalSubDict if (finder.found()) { - IOWarningInFunction((*this)) - << "keyword " << keyword - << " found but not a sub-dictionary in dictionary " + IOWarningInFunction(*this) + << "'" << keyword + << "' found but not a sub-dictionary in dictionary " << name() << endl; } @@ -597,7 +622,7 @@ Foam::entry* Foam::dictionary::add(entry* entryPtr, bool mergeEntry) } - IOWarningInFunction((*this)) + IOWarningInFunction(*this) << "problem replacing entry "<< entryPtr->keyword() << " in dictionary " << name() << endl; @@ -626,7 +651,7 @@ Foam::entry* Foam::dictionary::add(entry* entryPtr, bool mergeEntry) } - IOWarningInFunction((*this)) + IOWarningInFunction(*this) << "attempt to add entry " << entryPtr->keyword() << " which already exists in dictionary " << name() << endl; diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H index e5e6641b4d..2a8f95ec25 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.H +++ b/src/OpenFOAM/db/dictionary/dictionary.H @@ -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. @@ -143,18 +143,18 @@ public: return name_; } - //- Return the dictionary name + //- Return the dictionary name for modification (use with caution). fileName& name() { return name_; } //- Return the local dictionary name (final part of scoped name) - const word dictName() const + word dictName() const { - const word scopedName = name_.name(); - const auto i = scopedName.rfind('.'); + word scopedName(name_.name()); + const auto i = scopedName.rfind('.'); if (i == std::string::npos) { return scopedName; @@ -383,13 +383,8 @@ private: ) const; - //- Add report of excess tokens to the messageStream - void excessTokens - ( - OSstream& msg, - const word& keyword, - const ITstream& is - ) const; + //- Emit FatalIOError if excess tokens exist + void excessTokens(const word& keyword, const ITstream& is) const; public: @@ -505,7 +500,7 @@ public: ) const; //- Find and return an entry pointer for manipulation if present, - // or return a nullptr. + //- or return a nullptr. // // \param recursive search parent dictionaries // \param patternMatch use regular expressions @@ -516,7 +511,7 @@ public: bool patternMatch ); - //- Find and return an entry if present otherwise error. + //- Find and return an entry if present, otherwise FatalIOError. // // \param recursive search parent dictionaries // \param patternMatch use regular expressions @@ -528,7 +523,7 @@ public: ) const; //- Find and return a T. - //- FatalError if not found, or if there are excess tokens. + //- FatalIOError if not found, or if there are excess tokens. // Default search: non-recursive with patterns. // // \param recursive search parent dictionaries @@ -554,13 +549,13 @@ public: ) const; //- Find and return a T. - //- FatalError if not found, or if there are excess tokens. + //- FatalIOError if not found, or if there are excess tokens. // Default search: non-recursive with patterns. // // \param recursive search parent dictionaries // \param patternMatch use regular expressions // - // \note same as get() + // \deprecated - same as the get() method template T lookupType ( @@ -570,7 +565,7 @@ public: ) const; //- Find and return a T, or return the given default value - //- FatalError if it is found and there are excess tokens. + //- FatalIOError if it is found and there are excess tokens. // Default search: non-recursive with patterns. // // \param recursive search parent dictionaries @@ -586,7 +581,7 @@ public: //- Find and return a T, or return the given default value //- and add it to dictionary. - //- FatalError if it is found and there are excess tokens. + //- FatalIOError if it is found and there are excess tokens. // Default search: non-recursive with patterns. // // \param recursive search parent dictionaries @@ -600,8 +595,26 @@ public: bool patternMatch = true ); + //- Find entry and assign to T val. + //- FatalIOError if it is found and there are excess tokens. + // Default search: non-recursive with patterns. + // + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions + // + // \return true if the entry was found. + template + bool read + ( + const word& keyword, + T& val, + bool recursive = false, + bool patternMatch = true, + bool mandatory = true + ) const; + //- Find an entry if present, and assign to T val. - //- FatalError if it is found and there are excess tokens. + //- FatalIOError if it is found and there are excess tokens. // Default search: non-recursive with patterns. // // \param val the value to read @@ -662,7 +675,7 @@ public: dictionary& subDict(const word& keyword); //- Find and return a sub-dictionary as a copy, otherwise return - // an empty dictionary. + //- an empty dictionary. // Warn if the entry exists but is not a sub-dictionary. // // Search type: non-recursive with patterns. @@ -984,7 +997,7 @@ public: bool patternMatch ) const; - //- Find and return an entry if present otherwise error, + //- Find and return an entry if present, otherwise FatalIOError, //- using any compatibility names if needed. // // \param compat list of old compatibility keywords and the last @@ -999,6 +1012,24 @@ public: bool patternMatch ) const; + //- Find and return a T + //- using any compatibility names if needed. + //- FatalIOError if not found, or if there are excess tokens. + // Default search: non-recursive with patterns. + // + // \param compat list of old compatibility keywords and the last + // OpenFOAM version for which they were used. + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions + template + T getCompat + ( + const word& keyword, + std::initializer_list> compat, + bool recursive = false, + bool patternMatch = true + ) const; + //- Find and return an entry data stream, //- using any compatibility names if needed. // Default search: non-recursive with patterns. @@ -1033,8 +1064,32 @@ public: bool patternMatch = true ) const; + //- Find entry and assign to T val + //- using any compatibility names if needed. + //- FatalIOError if there are excess tokens. + // Default search: non-recursive with patterns. + // + // \param compat list of old compatibility keywords and the last + // OpenFOAM version for which they were used. + // \param val the value to read + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions + // + // \return true if the entry was found. + template + bool readCompat + ( + const word& keyword, + std::initializer_list> compat, + T& val, + bool recursive = false, + bool patternMatch = true, + bool mandatory = true + ) const; + //- Find an entry if present, and assign to T val //- using any compatibility names if needed. + //- FatalIOError if it is found and there are excess tokens. // Default search: non-recursive with patterns. // // \param compat list of old compatibility keywords and the last diff --git a/src/OpenFOAM/db/dictionary/dictionaryCompat.C b/src/OpenFOAM/db/dictionary/dictionaryCompat.C index 46567b6126..ab8e500014 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryCompat.C +++ b/src/OpenFOAM/db/dictionary/dictionaryCompat.C @@ -52,7 +52,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchCompat bool patternMatch ) const { - const_searcher finder(csearch(keyword, recursive,patternMatch)); + const_searcher finder(csearch(keyword, recursive, patternMatch)); if (finder.found()) { @@ -61,7 +61,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchCompat for (const std::pair& iter : compat) { - finder = csearch(word::validate(iter.first), recursive,patternMatch); + finder = csearch(word::validate(iter.first), recursive, patternMatch); if (finder.found()) { @@ -95,7 +95,7 @@ bool Foam::dictionary::foundCompat bool patternMatch ) const { - return csearchCompat(keyword, compat, recursive,patternMatch).found(); + return csearchCompat(keyword, compat, recursive, patternMatch).found(); } @@ -107,7 +107,7 @@ const Foam::entry* Foam::dictionary::lookupEntryPtrCompat bool patternMatch ) const { - return csearchCompat(keyword, compat, recursive,patternMatch).ptr(); + return csearchCompat(keyword, compat, recursive, patternMatch).ptr(); } @@ -120,14 +120,12 @@ const Foam::entry& Foam::dictionary::lookupEntryCompat ) const { const const_searcher - finder(csearchCompat(keyword, compat, recursive,patternMatch)); + finder(csearchCompat(keyword, compat, recursive, patternMatch)); if (!finder.found()) { - FatalIOErrorInFunction - ( - *this - ) << "keyword " << keyword << " is undefined in dictionary " + FatalIOErrorInFunction(*this) + << "'" << keyword << "' not found in dictionary " << name() << exit(FatalIOError); } @@ -144,7 +142,8 @@ Foam::ITstream& Foam::dictionary::lookupCompat bool patternMatch ) const { - return lookupEntryCompat(keyword, compat, recursive,patternMatch).stream(); + return + lookupEntryCompat(keyword, compat, recursive, patternMatch).stream(); } diff --git a/src/OpenFOAM/db/dictionary/dictionarySearch.C b/src/OpenFOAM/db/dictionary/dictionarySearch.C index cea0844cdf..34bdd4bca9 100644 --- a/src/OpenFOAM/db/dictionary/dictionarySearch.C +++ b/src/OpenFOAM/db/dictionary/dictionarySearch.C @@ -27,18 +27,17 @@ License #include "dictionaryEntry.H" #include "stringOps.H" -/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */ +// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // -namespace Foam +namespace { - // file-scope - //- Walk lists of patterns and regexps for an exact match - // or regular expression match + // Walk lists of patterns and regexps for an exact match + // or a regular expression match template static bool findInPatterns ( const bool patternMatch, - const word& keyword, + const Foam::word& keyword, WcIterator& wcIter, ReIterator& reIter ) @@ -61,7 +60,8 @@ namespace Foam return false; } -} + +} // End anonymous namespace // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -73,7 +73,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchDotScoped bool patternMatch ) const { - std::string::size_type scopePos = keyword.find('.'); + auto scopePos = keyword.find('.'); if (scopePos == string::npos) { @@ -101,10 +101,8 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchDotScoped } else { - FatalIOErrorInFunction - ( - *this - ) << "No parent of current dictionary when searching for " + FatalIOErrorInFunction(*this) + << "No parent of current dictionary when searching for " << keyword.substr(1) << exit(FatalIOError); @@ -210,10 +208,8 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchSlashScoped } else { - FatalIOErrorInFunction - ( - *dictPtr - ) << "No parent of current dictionary when searching for " + FatalIOErrorInFunction(*dictPtr) + << "No parent of current dictionary when searching for " << keyword << " at " << cmpt << exit(FatalIOError); break; @@ -424,10 +420,8 @@ const Foam::dictionary* Foam::dictionary::cfindScopedDictPtr } else { - FatalIOErrorInFunction - ( - *dictPtr - ) << "No parent for dictionary while searching " + FatalIOErrorInFunction(*dictPtr) + << "No parent for dictionary while searching " << path << exit(FatalIOError); @@ -451,10 +445,8 @@ const Foam::dictionary* Foam::dictionary::cfindScopedDictPtr } else { - FatalIOErrorInFunction - ( - *dictPtr - ) << "Found entry '" << cmpt + FatalIOErrorInFunction(*dictPtr) + << "Found entry '" << cmpt << "' but not a dictionary, while searching scoped" << nl << " " << path @@ -533,10 +525,8 @@ Foam::dictionary* Foam::dictionary::makeScopedDictPtr(const fileName& dictPath) } else { - FatalIOErrorInFunction - ( - *dictPtr - ) << "No parent for dictionary while searching " + FatalIOErrorInFunction(*dictPtr) + << "No parent for dictionary while searching " << path << exit(FatalIOError); @@ -561,10 +551,8 @@ Foam::dictionary* Foam::dictionary::makeScopedDictPtr(const fileName& dictPath) } else { - FatalIOErrorInFunction - ( - *dictPtr - ) << "Cannot create sub-dictionary entry '" << cmptName + FatalIOErrorInFunction(*dictPtr) + << "Cannot create sub-dictionary entry '" << cmptName << "' - a non-dictionary entry is in the way" << nl << "Encountered in scope" << nl << " " << path @@ -621,10 +609,8 @@ bool Foam::dictionary::remove(const word& keyword) return true; } - else - { - return false; - } + + return false; } @@ -651,10 +637,8 @@ bool Foam::dictionary::changeKeyword if (iter()->keyword().isPattern()) { - FatalIOErrorInFunction - ( - *this - ) << "Old keyword "<< oldKeyword + FatalIOErrorInFunction(*this) + << "Old keyword "<< oldKeyword << " is a pattern." << "Pattern replacement not yet implemented." << exit(FatalIOError); @@ -688,10 +672,8 @@ bool Foam::dictionary::changeKeyword } else { - IOWarningInFunction - ( - *this - ) << "cannot rename keyword "<< oldKeyword + IOWarningInFunction(*this) + << "cannot rename keyword "<< oldKeyword << " to existing keyword " << newKeyword << " in dictionary " << name() << endl; return false; diff --git a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C index e2a5ab621d..dc13b26d14 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C +++ b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C @@ -57,31 +57,63 @@ T Foam::dictionary::get bool patternMatch ) const { - const const_searcher finder(csearch(keyword, recursive, patternMatch)); - - if (!finder.found()) - { - FatalIOErrorInFunction(*this) - << "keyword " << keyword << " is undefined in dictionary " - << name() - << exit(FatalIOError); - } - T val; - ITstream& is = finder.ptr()->stream(); - is >> val; - - if (!is.eof()) - { - auto err = FatalIOErrorInFunction(*this); - excessTokens(err, keyword, is); - err << exit(FatalIOError); - } - + read(keyword, val, recursive, patternMatch); return val; } +template +T Foam::dictionary::getCompat +( + const word& keyword, + std::initializer_list> compat, + bool recursive, + bool patternMatch +) const +{ + T val; + readCompat(keyword, compat, val, recursive, patternMatch); + return val; +} + + +template +bool Foam::dictionary::readCompat +( + const word& keyword, + std::initializer_list> compat, + T& val, + bool recursive, + bool patternMatch, + bool mandatory +) const +{ + const const_searcher + finder(csearchCompat(keyword, compat, recursive, patternMatch)); + + if (finder.found()) + { + ITstream& is = finder.ptr()->stream(); + is >> val; + + excessTokens(keyword, is); + + return true; + } + else if (mandatory) + { + FatalIOErrorInFunction(*this) + << "'" << keyword << "' not found in dictionary " + << name() + << exit(FatalIOError); + } + + return false; +} + + +// older name template T Foam::dictionary::lookupType ( @@ -112,21 +144,15 @@ T Foam::dictionary::lookupOrDefault ITstream& is = finder.ptr()->stream(); is >> val; - if (!is.eof()) - { - auto err = FatalIOErrorInFunction(*this); - excessTokens(err, keyword, is); - err << exit(FatalIOError); - } + excessTokens(keyword, is); return val; } - - if (writeOptionalEntries) + else if (writeOptionalEntries) { IOInfoInFunction(*this) - << "Optional entry '" << keyword << "' is not present," - << " returning the default value '" << deflt << "'" + << "Optional entry '" << keyword << "' not found," + << " using default value '" << deflt << "'" << endl; } @@ -152,21 +178,15 @@ T Foam::dictionary::lookupOrAddDefault ITstream& is = finder.ptr()->stream(); is >> val; - if (!is.eof()) - { - auto err = FatalIOErrorInFunction(*this); - excessTokens(err, keyword, is); - err << exit(FatalIOError); - } + excessTokens(keyword, is); return val; } - - if (writeOptionalEntries) + else if (writeOptionalEntries) { IOInfoInFunction(*this) - << "Optional entry '" << keyword << "' is not present," - << " adding and returning the default value '" << deflt << "'" + << "Optional entry '" << keyword << "' not found," + << " adding default value '" << deflt << "'" << endl; } @@ -175,6 +195,39 @@ T Foam::dictionary::lookupOrAddDefault } +template +bool Foam::dictionary::read +( + const word& keyword, + T& val, + bool recursive, + bool patternMatch, + bool mandatory +) const +{ + const const_searcher finder(csearch(keyword, recursive, patternMatch)); + + if (finder.found()) + { + ITstream& is = finder.ptr()->stream(); + is >> val; + + excessTokens(keyword, is); + + return true; + } + else if (mandatory) + { + FatalIOErrorInFunction(*this) + << "'" << keyword << "' not found in dictionary " + << name() + << exit(FatalIOError); + } + + return false; +} + + template bool Foam::dictionary::readIfPresent ( @@ -184,32 +237,8 @@ bool Foam::dictionary::readIfPresent bool patternMatch ) const { - const const_searcher finder(csearch(keyword, recursive, patternMatch)); - - if (finder.found()) - { - ITstream& is = finder.ptr()->stream(); - is >> val; - - if (!is.eof()) - { - auto err = FatalIOErrorInFunction(*this); - excessTokens(err, keyword, is); - err << exit(FatalIOError); - } - - return true; - } - - if (writeOptionalEntries) - { - IOInfoInFunction(*this) - << "Optional entry '" << keyword << "' is not present," - << " the default value '" << val << "' will be used." - << endl; - } - - return false; + // Read is non-mandatory + return read(keyword, val, recursive, patternMatch, false); } @@ -233,21 +262,15 @@ T Foam::dictionary::lookupOrDefaultCompat ITstream& is = finder.ptr()->stream(); is >> val; - if (!is.eof()) - { - auto err = FatalIOErrorInFunction(*this); - excessTokens(err, keyword, is); - err << exit(FatalIOError); - } + excessTokens(keyword, is); return val; } - - if (writeOptionalEntries) + else if (writeOptionalEntries) { IOInfoInFunction(*this) - << "Optional entry '" << keyword << "' is not present," - << " returning the default value '" << deflt << "'" + << "Optional entry '" << keyword << "' not found," + << " using default value '" << deflt << "'" << endl; } @@ -265,33 +288,8 @@ bool Foam::dictionary::readIfPresentCompat bool patternMatch ) const { - const const_searcher - finder(csearchCompat(keyword, compat, recursive, patternMatch)); - - if (finder.found()) - { - ITstream& is = finder.ptr()->stream(); - is >> val; - - if (!is.eof()) - { - auto err = FatalIOErrorInFunction(*this); - excessTokens(err, keyword, is); - err << exit(FatalIOError); - } - - return true; - } - - if (writeOptionalEntries) - { - IOInfoInFunction(*this) - << "Optional entry '" << keyword << "' is not present," - << " the default value '" << val << "' will be used." - << endl; - } - - return false; + // Read is non-mandatory + return readCompat(keyword, compat, recursive, patternMatch, false); } diff --git a/src/OpenFOAM/db/error/IOerror.C b/src/OpenFOAM/db/error/IOerror.C index d200c578ab..9b6eea93c9 100644 --- a/src/OpenFOAM/db/error/IOerror.C +++ b/src/OpenFOAM/db/error/IOerror.C @@ -139,15 +139,15 @@ void Foam::IOerror::SafeFatalIOError else { std::cerr - << std::endl - << "--> FOAM FATAL IO ERROR:" << std::endl + << nl + << "--> FOAM FATAL IO ERROR:" << nl << msg - << std::endl + << nl << "file: " << ioStream.name() << " at line " << ioStream.lineNumber() << '.' - << std::endl << std::endl + << nl << nl << " From function " << functionName - << std::endl + << nl << " in file " << sourceFileName << " at line " << sourceFileLineNumber << '.' << std::endl; diff --git a/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C b/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C index 773a072f2e..1f39dafa3e 100644 --- a/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C +++ b/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C @@ -30,7 +30,7 @@ License void Foam::Function1Types::ramp::read(const dictionary& coeffs) { start_ = coeffs.lookupOrDefault("start", 0); - duration_ = coeffs.lookupType("duration"); + duration_ = coeffs.get("duration"); } From d571e5231ba5f06a6e3e5e54c34b8a3f27c5b342 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 1 Jun 2018 13:31:12 +0200 Subject: [PATCH 09/28] ENH: detect excess tokens for "libs" entry (issue #762) - this addresses issue #843 --- .../dlLibraryTable/dlLibraryTable.C | 146 ++++++++---------- .../dlLibraryTable/dlLibraryTable.H | 30 ++-- .../dlLibraryTable/dlLibraryTableTemplates.C | 51 +++--- 3 files changed, 102 insertions(+), 125 deletions(-) diff --git a/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C b/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C index 641a051a41..2c64282612 100644 --- a/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C +++ b/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.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 | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -79,104 +79,92 @@ Foam::dlLibraryTable::~dlLibraryTable() bool Foam::dlLibraryTable::open ( - const fileName& functionLibName, + const fileName& libName, const bool verbose ) { - if (functionLibName.size()) - { - void* functionLibPtr = dlOpen - ( - fileName(functionLibName).expand(), - verbose - ); - - if (debug) - { - InfoInFunction - << "Opened " << functionLibName - << " resulting in handle " << uintptr_t(functionLibPtr) << endl; - } - - if (!functionLibPtr) - { - if (verbose) - { - WarningInFunction - << "could not load " << functionLibName - << endl; - } - - return false; - } - else - { - libPtrs_.append(functionLibPtr); - libNames_.append(functionLibName); - return true; - } - } - else + if (libName.empty()) { return false; } + + void* ptr = dlOpen(fileName(libName).expand(), verbose); + + if (debug) + { + InfoInFunction + << "Opened " << libName + << " resulting in handle " << uintptr_t(ptr) << endl; + } + + if (ptr) + { + libPtrs_.append(ptr); + libNames_.append(libName); + return true; + } + + if (verbose) + { + WarningInFunction + << "could not load " << libName + << endl; + } + + return false; } bool Foam::dlLibraryTable::close ( - const fileName& functionLibName, + const fileName& libName, const bool verbose ) { label index = -1; forAllReverse(libNames_, i) { - if (libNames_[i] == functionLibName) + if (libName == libNames_[i]) { index = i; break; } } - if (index != -1) + if (index == -1) { - if (debug) - { - InfoInFunction - << "Closing " << functionLibName - << " with handle " << uintptr_t(libPtrs_[index]) << endl; - } - - bool ok = dlClose(libPtrs_[index]); - - libPtrs_[index] = nullptr; - libNames_[index] = fileName::null; - - if (!ok) - { - if (verbose) - { - WarningInFunction - << "could not close " << functionLibName - << endl; - } - - return false; - } - - return true; + return false; } - return false; + + if (debug) + { + InfoInFunction + << "Closing " << libName + << " with handle " << uintptr_t(libPtrs_[index]) << endl; + } + + const bool ok = dlClose(libPtrs_[index]); + + libPtrs_[index] = nullptr; + libNames_[index].clear(); + + if (!ok && verbose) + { + WarningInFunction + << "could not close " << libName + << endl; + } + + return ok; } -void* Foam::dlLibraryTable::findLibrary(const fileName& functionLibName) +void* Foam::dlLibraryTable::findLibrary(const fileName& libName) { label index = -1; forAllReverse(libNames_, i) { - if (libNames_[i] == functionLibName) + if (libName == libNames_[i]) { index = i; break; @@ -187,6 +175,7 @@ void* Foam::dlLibraryTable::findLibrary(const fileName& functionLibName) { return libPtrs_[index]; } + return nullptr; } @@ -197,23 +186,20 @@ bool Foam::dlLibraryTable::open const word& libsEntry ) { - if (dict.found(libsEntry)) + fileNameList libNames; + dict.readIfPresent(libsEntry, libNames); + + label nOpen = 0; + + for (const fileName& libName : libNames) { - fileNameList libNames(dict.lookup(libsEntry)); - - bool allOpened = !libNames.empty(); - - forAll(libNames, i) + if (dlLibraryTable::open(libName)) { - allOpened = dlLibraryTable::open(libNames[i]) && allOpened; + ++nOpen; } + } - return allOpened; - } - else - { - return false; - } + return nOpen && nOpen == libNames.size(); } diff --git a/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.H b/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.H index b40c4c4953..04f51fd5ad 100644 --- a/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.H +++ b/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.H @@ -49,13 +49,15 @@ namespace Foam class dlLibraryTable { - // Private Member Functions + // Private data DynamicList libPtrs_; DynamicList libNames_; + // Private Member Functions + //- No copy construct dlLibraryTable(const dlLibraryTable&) = delete; @@ -73,9 +75,9 @@ public: //- Construct null dlLibraryTable(); - //- Construct from dictionary and name of 'libs' entry giving - // the libraries to load - dlLibraryTable(const dictionary&, const word&); + //- Open all libraries listed in the 'libsEntry' entry in the + //- given dictionary. + dlLibraryTable(const dictionary& dict, const word& libsEntry); //- Destructor @@ -85,25 +87,25 @@ public: // Member Functions //- Open the named library, optionally with warnings if problems occur - bool open(const fileName& name, const bool verbose = true); + bool open(const fileName& libName, const bool verbose = true); //- Close the named library, optionally with warnings if problems occur - bool close(const fileName& name, const bool verbose = true); + bool close(const fileName& libName, const bool verbose = true); //- Find the handle of the named library - void* findLibrary(const fileName& name); + void* findLibrary(const fileName& libName); - //- Open all the libraries listed in the 'libsEntry' entry in the - // given dictionary if present - bool open(const dictionary&, const word& libsEntry); + //- Open all libraries listed in the 'libsEntry' entry in the + //- given dictionary. + bool open(const dictionary& dict, const word& libsEntry); - //- Open all the libraries listed in the 'libsEntry' entry in the - // given dictionary if present and check the additions - // to the given constructor table + //- Open all libraries listed in the 'libsEntry' entry in the + //- given dictionary and check the additions + //- to the given constructor table template bool open ( - const dictionary&, + const dictionary& dict, const word& libsEntry, const TablePtr& tablePtr ); diff --git a/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTableTemplates.C b/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTableTemplates.C index 62796ab062..08491cb03a 100644 --- a/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTableTemplates.C +++ b/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTableTemplates.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -37,47 +37,36 @@ bool Foam::dlLibraryTable::open const TablePtr& tablePtr ) { - if (dict.found(libsEntry)) + fileNameList libNames; + dict.readIfPresent(libsEntry, libNames); + + label nOpen = 0; + + for (const fileName& libName : libNames) { - fileNameList libNames(dict.lookup(libsEntry)); + const label nEntries = (tablePtr ? tablePtr->size() : 0); - bool allOpened = (libNames.size() > 0); - - forAll(libNames, i) + if (dlLibraryTable::open(libName)) { - const fileName& libName = libNames[i]; + ++nOpen; - label nEntries = 0; - - if (tablePtr) - { - nEntries = tablePtr->size(); - } - - bool opened = dlLibraryTable::open(libName); - allOpened = opened && allOpened; - - if (!opened) - { - WarningInFunction - << "Could not open library " << libName - << endl << endl; - } - else if (debug && (!tablePtr || tablePtr->size() <= nEntries)) + if (debug && (!tablePtr || tablePtr->size() <= nEntries)) { WarningInFunction << "library " << libName << " did not introduce any new entries" - << endl << endl; + << nl << endl; } } + else + { + WarningInFunction + << "Could not open library " << libName + << nl << endl; + } + } - return allOpened; - } - else - { - return false; - } + return nOpen && nOpen == libNames.size(); } From 8058184b0cce02e5493054f4bc91948e5db59f64 Mon Sep 17 00:00:00 2001 From: Alexey Matveichev Date: Fri, 1 Jun 2018 14:10:17 +0200 Subject: [PATCH 10/28] COMP: resolve 'point' ambiguity in foamyQuadMesh - CGAL Triangulation_2.h (version 4.12) defines a point function, which interferes with the Foam::point typedef. --- .../mesh/generation/foamyMesh/foamyQuadMesh/CV2D.C | 4 ++-- .../mesh/generation/foamyMesh/foamyQuadMesh/CV2D.H | 6 +++--- .../mesh/generation/foamyMesh/foamyQuadMesh/CV2DI.H | 6 +++--- .../mesh/generation/foamyMesh/foamyQuadMesh/CV2DIO.C | 4 ++-- .../foamyQuadMesh/insertBoundaryConformPointPairs.C | 2 +- .../foamyMesh/foamyQuadMesh/insertFeaturePoints.C | 4 ++-- .../foamyQuadMesh/insertSurfaceNearestPointPairs.C | 5 +++-- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/CV2D.C b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/CV2D.C index 8e4543a07d..697f90eb98 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/CV2D.C +++ b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/CV2D.C @@ -150,7 +150,7 @@ Foam::CV2D::CV2D ), z_ ( - point + Foam::point ( cvMeshDict.subDict("surfaceConformation").lookup("locationInMesh") ).z() @@ -260,7 +260,7 @@ void Foam::CV2D::insertGrid() { for (int j=0; j(p); } @@ -140,7 +140,7 @@ inline const Foam::point2DField Foam::CV2D::toPoint2D(const pointField& p) const inline Foam::point Foam::CV2D::toPoint3D(const point2D& p) const { - return point(p.x(), p.y(), z_); + return Foam::point(p.x(), p.y(), z_); } @@ -175,7 +175,7 @@ inline Foam::CV2D::PointFromPoint2D Foam::CV2D::toPoint(const point2D& p) const inline Foam::point Foam::CV2D::toPoint3D(const Point& P) const { - return point(CGAL::to_double(P.x()), CGAL::to_double(P.y()), z_); + return Foam::point(CGAL::to_double(P.x()), CGAL::to_double(P.y()), z_); } diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/CV2DIO.C b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/CV2DIO.C index d370880aee..b8e8518eb5 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/CV2DIO.C +++ b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/CV2DIO.C @@ -210,8 +210,8 @@ void Foam::CV2D::extractPatches || (vB->internalOrBoundaryPoint() && !vA->internalOrBoundaryPoint()) ) { - point ptA = toPoint3D(vA->point()); - point ptB = toPoint3D(vB->point()); + Foam::point ptA = toPoint3D(vA->point()); + Foam::point ptB = toPoint3D(vB->point()); label patchIndex = qSurf_.findPatch(ptA, ptB); diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/insertBoundaryConformPointPairs.C b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/insertBoundaryConformPointPairs.C index 0f69268500..3017c72a9e 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/insertBoundaryConformPointPairs.C +++ b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/insertBoundaryConformPointPairs.C @@ -295,7 +295,7 @@ void Foam::CV2D::markNearBoundaryPoints() { if (vit->internalPoint()) { - point vert(toPoint3D(vit->point())); + Foam::point vert(toPoint3D(vit->point())); pointIndexHit pHit; label hitSurface = -1; diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/insertFeaturePoints.C b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/insertFeaturePoints.C index 1cf848eec4..c746d95dc6 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/insertFeaturePoints.C +++ b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/insertFeaturePoints.C @@ -109,8 +109,8 @@ void Foam::CV2D::insertFeaturePoints() { const edge& e = feMesh.edges()[edgeI]; - const point& ep0 = points[e.start()]; - const point& ep1 = points[e.end()]; + const Foam::point& ep0 = points[e.start()]; + const Foam::point& ep1 = points[e.end()]; const linePointRef line(ep0, ep1); diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/insertSurfaceNearestPointPairs.C b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/insertSurfaceNearestPointPairs.C index 7578920f82..6cec128d71 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/insertSurfaceNearestPointPairs.C +++ b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/insertSurfaceNearestPointPairs.C @@ -39,7 +39,7 @@ bool Foam::CV2D::dualCellSurfaceIntersection { if (!is_infinite(ec)) { - point e0 = toPoint3D(circumcenter(ec->first)); + Foam::point e0 = toPoint3D(circumcenter(ec->first)); // If edge end is outside bounding box then edge cuts boundary if (!qSurf_.globalBounds().contains(e0)) @@ -47,7 +47,8 @@ bool Foam::CV2D::dualCellSurfaceIntersection return true; } - point e1 = toPoint3D(circumcenter(ec->first->neighbor(ec->second))); + Foam::point e1 = + toPoint3D(circumcenter(ec->first->neighbor(ec->second))); // If other edge end is outside bounding box then edge cuts boundary if (!qSurf_.globalBounds().contains(e1)) From 35d682a4fb541532c59facb8032d642d512a9181 Mon Sep 17 00:00:00 2001 From: Alexey Matveichev Date: Fri, 1 Jun 2018 14:17:41 +0200 Subject: [PATCH 11/28] COMP: make the scotch librt dependency conditional --- src/parallel/decompose/ptscotchDecomp/Make/options | 7 ++++++- src/parallel/decompose/scotchDecomp/Make/options | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/parallel/decompose/ptscotchDecomp/Make/options b/src/parallel/decompose/ptscotchDecomp/Make/options index 733441c3fc..4d8690985a 100644 --- a/src/parallel/decompose/ptscotchDecomp/Make/options +++ b/src/parallel/decompose/ptscotchDecomp/Make/options @@ -16,4 +16,9 @@ LIB_LIBS = \ -L$(FOAM_EXT_LIBBIN) \ -L$(FOAM_EXT_LIBBIN)/$(FOAM_MPI) \ -lptscotch -lptscotcherrexit \ - -lscotch -lrt + -lscotch + +/* May require librt, but scotch does not declare the dependency */ +ifeq ("$(SO)","so") + LIB_LIBS += -lrt +endif diff --git a/src/parallel/decompose/scotchDecomp/Make/options b/src/parallel/decompose/scotchDecomp/Make/options index d2165b174d..6846910c04 100644 --- a/src/parallel/decompose/scotchDecomp/Make/options +++ b/src/parallel/decompose/scotchDecomp/Make/options @@ -12,4 +12,9 @@ EXE_INC = \ LIB_LIBS = \ -L$(SCOTCH_LIB_DIR) \ - -lscotch -lscotcherrexit -lrt + -lscotch -lscotcherrexit + +/* May require librt, but scotch does not declare the dependency */ +ifeq ("$(SO)","so") + LIB_LIBS += -lrt +endif From cdb6d5a604256d399bc39225f38e4d9078b7d460 Mon Sep 17 00:00:00 2001 From: Alexey Matveichev Date: Fri, 1 Jun 2018 14:35:43 +0200 Subject: [PATCH 12/28] CONFIG: remove Darwin GCC wmake rules (partly broken, poorly tested) --- wmake/rules/darwin64Gcc/c | 16 ---------------- wmake/rules/darwin64Gcc/c++ | 17 ----------------- wmake/rules/darwin64Gcc/c++Debug | 2 -- wmake/rules/darwin64Gcc/c++Opt | 4 ---- wmake/rules/darwin64Gcc/c++Prof | 2 -- wmake/rules/darwin64Gcc/cDebug | 2 -- wmake/rules/darwin64Gcc/cOpt | 2 -- wmake/rules/darwin64Gcc/cProf | 2 -- wmake/rules/darwin64Gcc/general | 9 --------- 9 files changed, 56 deletions(-) delete mode 100644 wmake/rules/darwin64Gcc/c delete mode 100644 wmake/rules/darwin64Gcc/c++ delete mode 100644 wmake/rules/darwin64Gcc/c++Debug delete mode 100644 wmake/rules/darwin64Gcc/c++Opt delete mode 100644 wmake/rules/darwin64Gcc/c++Prof delete mode 100644 wmake/rules/darwin64Gcc/cDebug delete mode 100644 wmake/rules/darwin64Gcc/cOpt delete mode 100644 wmake/rules/darwin64Gcc/cProf delete mode 100644 wmake/rules/darwin64Gcc/general diff --git a/wmake/rules/darwin64Gcc/c b/wmake/rules/darwin64Gcc/c deleted file mode 100644 index 50539d091f..0000000000 --- a/wmake/rules/darwin64Gcc/c +++ /dev/null @@ -1,16 +0,0 @@ -SUFFIXES += .c - -cc = gcc -m64 -Ddarwin - -cWARN = -Wall - -include $(DEFAULT_RULES)/c$(WM_COMPILE_OPTION) - -cFLAGS = $(GFLAGS) $(cWARN) $(cOPT) $(cDBUG) $(LIB_HEADER_DIRS) -fPIC - -ctoo = $(WM_SCHEDULER) $(cc) $(cFLAGS) -c $< -o $@ - -LINK_LIBS = $(cDBUG) - -LINKLIBSO = $(cc) -Wl,-dylib,-undefined,dynamic_lookup -LINKEXE = $(cc) -Wl,-execute,-undefined,dynamic_lookup diff --git a/wmake/rules/darwin64Gcc/c++ b/wmake/rules/darwin64Gcc/c++ deleted file mode 100644 index 59d505f1af..0000000000 --- a/wmake/rules/darwin64Gcc/c++ +++ /dev/null @@ -1,17 +0,0 @@ -include $(GENERAL_RULES)/Gcc/c++ - -CC = g++ -std=c++11 -m64 -Ddarwin - -include $(DEFAULT_RULES)/c++$(WM_COMPILE_OPTION) - -c++FLAGS = $(GFLAGS) $(c++WARN) $(c++OPT) $(c++DBUG) $(ptFLAGS) $(LIB_HEADER_DIRS) -fPIC - -Ctoo = $(WM_SCHEDULER) $(CC) $(c++FLAGS) -c $< -o $@ -cxxtoo = $(Ctoo) -cctoo = $(Ctoo) -cpptoo = $(Ctoo) - -LINK_LIBS = $(c++DBUG) - -LINKLIBSO = $(CC) $(c++FLAGS) -Wl,-dylib,-undefined,dynamic_lookup -LINKEXE = $(CC) $(c++FLAGS) -Wl,-execute,-undefined,dynamic_lookup diff --git a/wmake/rules/darwin64Gcc/c++Debug b/wmake/rules/darwin64Gcc/c++Debug deleted file mode 100644 index 08680a0e4a..0000000000 --- a/wmake/rules/darwin64Gcc/c++Debug +++ /dev/null @@ -1,2 +0,0 @@ -c++DBUG = -ggdb3 -DFULLDEBUG -c++OPT = -O0 -fdefault-inline diff --git a/wmake/rules/darwin64Gcc/c++Opt b/wmake/rules/darwin64Gcc/c++Opt deleted file mode 100644 index 599e6aba61..0000000000 --- a/wmake/rules/darwin64Gcc/c++Opt +++ /dev/null @@ -1,4 +0,0 @@ -c++DBUG = -c++OPT = -O3 - -ROUNDING_MATH = -frounding-math diff --git a/wmake/rules/darwin64Gcc/c++Prof b/wmake/rules/darwin64Gcc/c++Prof deleted file mode 100644 index 3bda4dad55..0000000000 --- a/wmake/rules/darwin64Gcc/c++Prof +++ /dev/null @@ -1,2 +0,0 @@ -c++DBUG = -pg -c++OPT = -O2 diff --git a/wmake/rules/darwin64Gcc/cDebug b/wmake/rules/darwin64Gcc/cDebug deleted file mode 100644 index 72b638f458..0000000000 --- a/wmake/rules/darwin64Gcc/cDebug +++ /dev/null @@ -1,2 +0,0 @@ -cDBUG = -ggdb -DFULLDEBUG -cOPT = -O1 -fdefault-inline -finline-functions diff --git a/wmake/rules/darwin64Gcc/cOpt b/wmake/rules/darwin64Gcc/cOpt deleted file mode 100644 index 17318709f1..0000000000 --- a/wmake/rules/darwin64Gcc/cOpt +++ /dev/null @@ -1,2 +0,0 @@ -cDBUG = -cOPT = -O3 diff --git a/wmake/rules/darwin64Gcc/cProf b/wmake/rules/darwin64Gcc/cProf deleted file mode 100644 index ca3ac9bf5f..0000000000 --- a/wmake/rules/darwin64Gcc/cProf +++ /dev/null @@ -1,2 +0,0 @@ -cDBUG = -pg -cOPT = -O2 diff --git a/wmake/rules/darwin64Gcc/general b/wmake/rules/darwin64Gcc/general deleted file mode 100644 index 2457a3c5b6..0000000000 --- a/wmake/rules/darwin64Gcc/general +++ /dev/null @@ -1,9 +0,0 @@ -CPP = cpp -traditional-cpp $(GFLAGS) -Ddarwin - -PROJECT_LIBS = -l$(WM_PROJECT) -ldl - -include $(GENERAL_RULES)/standard -include $(GENERAL_RULES)/Gcc/openmp - -include $(DEFAULT_RULES)/c -include $(DEFAULT_RULES)/c++ From 0f60cc9263ac5b0fdaf46fd3396ce09828066153 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 1 Jun 2018 14:59:35 +0200 Subject: [PATCH 13/28] STYLE: remove bad edit in comment --- .../pointPatchFields/pointPatchField/pointPatchField.H | 2 +- .../pointPatchFields/pointPatchField/pointPatchFieldNew.C | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H index 2029249ed3..1e0ab21849 100644 --- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H @@ -35,7 +35,7 @@ Description SourceFiles pointPatchField.C - newPointPatchField.C + pointPatchFieldNew.C \*---------------------------------------------------------------------------*/ diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldNew.C b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldNew.C index a3ce7e0d8a..5e88a183dc 100644 --- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldNew.C +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldNew.C @@ -6,20 +6,20 @@ \\/ M anipulation | ------------------------------------------------------------------------------- License - This file is part of2011 OpenFOAM. + This file is part of OpenFOAM. - 2011 OpenFOAM is free software: you can redistribute it and/or modify it + OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - 2011 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with2011 OpenFOAM. If not, see . + along with OpenFOAM. If not, see . \*---------------------------------------------------------------------------*/ From 84b109219a4a6de196ff5dde54d3c054584506fe Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 1 Jun 2018 20:51:48 +0200 Subject: [PATCH 14/28] STYLE: reduced usage of Switch - Since 'bool' and 'Switch' use the _identical_ input mechanism (ie, both accept true/false, on/off, yes/no, none, 1/0), the main reason to prefer one or the other is the output. The output for Switch is as text (eg, "true"), whereas for bool it is label (0 or 1). If the output is required for a dictionary, Switch may be appropriate. If the output is not required, or is only used for Pstream exchange, bool can be more appropriate. --- .../solvers/combustion/PDRFoam/PDRFoam.C | 1 - .../combustion/PDRFoam/PDRFoamAutoRefine.C | 1 - .../dragModels/PDRDragModel/PDRDragModel.C | 6 +- .../dragModels/PDRDragModel/PDRDragModel.H | 2 +- .../dragModels/PDRDragModel/PDRDragModelNew.C | 4 +- .../PDRModels/dragModels/basic/basic.C | 4 +- .../combustion/chemFoam/createControls.H | 5 +- .../combustion/chemFoam/readControls.H | 4 +- .../rhoPorousSimpleFoam/createZones.H | 2 +- .../readGravitationalAcceleration.H | 6 +- .../porousSimpleFoam/createPorousZones.H | 2 +- .../ThermalPhaseChangePhaseSystem.C | 4 +- .../ThermalPhaseChangePhaseSystem.H | 3 +- .../solidDisplacementFoam/createControl.H | 2 +- .../solidDisplacementFoam/createControls.H | 2 +- .../readMechanicalProperties.H | 4 +- .../readSolidDisplacementFoamControls.H | 4 +- .../readThermalProperties.H | 3 +- .../solidDisplacementFoam.C | 1 - .../tractionDisplacementFvPatchVectorField.C | 8 +- .../solidEquilibriumDisplacementFoam.C | 1 - ...DisplacementCorrectionFvPatchVectorField.C | 4 +- .../mesh/advanced/selectCells/edgeStats.C | 4 +- .../snappyRefineMesh/snappyRefineMesh.C | 4 +- .../extrude/extrudeMesh/extrudeMesh.C | 6 +- .../extrudeToRegionMesh/extrudeToRegionMesh.C | 6 +- .../automatic/automatic.C | 17 +- .../automatic/automatic.H | 18 +- .../cvControls/cvControls.C | 165 +++++++----------- .../initialPointsMethod/initialPointsMethod.C | 9 +- .../initialPointsMethod/initialPointsMethod.H | 5 +- .../foamyMesh/foamyQuadMesh/foamyQuadMesh.C | 2 +- .../generation/snappyHexMesh/snappyHexMesh.C | 28 ++- .../createBaffles/createBaffles.C | 20 +-- .../faceSelection/faceSelection.H | 3 +- .../manipulation/createPatch/createPatch.C | 3 +- .../surface/surfaceSubset/surfaceSubset.C | 9 +- .../dynamicRefineFvMesh/dynamicRefineFvMesh.C | 2 +- .../dynamicRefineFvMesh/dynamicRefineFvMesh.H | 3 +- src/dynamicMesh/attachDetach/attachDetach.C | 2 +- .../layerAdditionRemoval.C | 9 +- .../layerAdditionRemoval.H | 2 +- .../meshCut/directions/directions.C | 3 +- .../multiDirRefinement/multiDirRefinement.C | 10 +- src/dynamicMesh/setUpdater/setUpdater.C | 2 +- .../slidingInterface/slidingInterface.C | 2 +- .../finiteArea/faSchemes/faSchemes.C | 4 +- .../finiteVolume/fvSchemes/fvSchemes.C | 4 +- .../basic/InteractionLists/InteractionLists.C | 2 +- .../basic/InteractionLists/InteractionLists.H | 4 +- .../PairCollision/PairCollision.C | 9 +- .../MultiInteraction/MultiInteraction.C | 2 +- .../MultiInteraction/MultiInteraction.H | 2 +- .../mdTools/createAutoCorrelationFunctions.H | 6 +- .../pairPotential/basic/pairPotential.C | 2 +- .../pairPotential/basic/pairPotentialI.H | 1 + .../ORourkeCollision/ORourkeCollision.C | 5 +- .../ORourkeCollision/ORourkeCollision.H | 4 +- .../offsetSurface/offsetSurface.H | 3 +- .../regionModel/regionModel/regionModel.C | 4 +- .../structuredRenumber/structuredRenumber.C | 4 +- .../structuredRenumber/structuredRenumber.H | 9 +- .../distanceSurface/sampledDistanceSurface.H | 2 +- .../isoSurface/sampledIsoSurface.H | 6 +- .../isoSurface/sampledIsoSurfaceCell.H | 4 +- .../sampledCuttingPlane/sampledCuttingPlane.H | 4 +- .../surface/distanceSurface/distanceSurface.C | 4 +- .../surface/distanceSurface/distanceSurface.H | 4 +- src/sampling/surface/isoSurface/isoSurface.H | 2 +- .../chemkinReader/chemkinReader.H | 3 +- .../liquidProperties/liquidProperties.C | 43 +++-- .../solidProperties/solidPropertiesNew.C | 2 +- 72 files changed, 227 insertions(+), 319 deletions(-) diff --git a/applications/solvers/combustion/PDRFoam/PDRFoam.C b/applications/solvers/combustion/PDRFoam/PDRFoam.C index 5f4cac3e6e..d57da07df9 100644 --- a/applications/solvers/combustion/PDRFoam/PDRFoam.C +++ b/applications/solvers/combustion/PDRFoam/PDRFoam.C @@ -78,7 +78,6 @@ Description #include "XiModel.H" #include "PDRDragModel.H" #include "ignition.H" -#include "Switch.H" #include "bound.H" #include "pimpleControl.H" #include "fvOptions.H" diff --git a/applications/solvers/combustion/PDRFoam/PDRFoamAutoRefine.C b/applications/solvers/combustion/PDRFoam/PDRFoamAutoRefine.C index 60618232e0..48a9aaf5c8 100644 --- a/applications/solvers/combustion/PDRFoam/PDRFoamAutoRefine.C +++ b/applications/solvers/combustion/PDRFoam/PDRFoamAutoRefine.C @@ -63,7 +63,6 @@ Description #include "XiModel.H" #include "PDRDragModel.H" #include "ignition.H" -#include "Switch.H" #include "bound.H" #include "dynamicRefineFvMesh.H" #include "pimpleControl.H" diff --git a/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModel.C b/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModel.C index 2b2cd7c4fd..175c5f4f1c 100644 --- a/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModel.C +++ b/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModel.C @@ -58,14 +58,14 @@ Foam::PDRDragModel::PDRDragModel ( PDRProperties.subDict ( - word(PDRProperties.lookup("PDRDragModel")) + "Coeffs" + PDRProperties.get("PDRDragModel") + "Coeffs" ) ), turbulence_(turbulence), rho_(rho), U_(U), phi_(phi), - on_(PDRDragModelCoeffs_.lookup("drag")) + on_(PDRDragModelCoeffs_.get("drag")) {} @@ -81,7 +81,7 @@ bool Foam::PDRDragModel::read(const dictionary& PDRProperties) { PDRDragModelCoeffs_ = PDRProperties.optionalSubDict(type() + "Coeffs"); - PDRDragModelCoeffs_.lookup("drag") >> on_; + PDRDragModelCoeffs_.read("drag", on_); return true; } diff --git a/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModel.H b/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModel.H index 66c1abb44a..c4a52f3f02 100644 --- a/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModel.H +++ b/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModel.H @@ -67,7 +67,7 @@ protected: const volVectorField& U_; const surfaceScalarField& phi_; - Switch on_; + bool on_; private: diff --git a/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModelNew.C b/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModelNew.C index 25a4a2098e..0069477bac 100644 --- a/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModelNew.C +++ b/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModelNew.C @@ -36,9 +36,9 @@ Foam::autoPtr Foam::PDRDragModel::New const surfaceScalarField& phi ) { - const word modelType(PDRProperties.lookup("PDRDragModel")); + const word modelType(PDRProperties.get("PDRDragModel")); - Info<< "Selecting flame-wrinkling model " << modelType << endl; + Info<< "Selecting drag model " << modelType << endl; auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); diff --git a/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/basic/basic.C b/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/basic/basic.C index 5f3e6f1bc5..821380fe04 100644 --- a/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/basic/basic.C +++ b/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/basic/basic.C @@ -165,8 +165,8 @@ bool Foam::PDRDragModels::basic::read(const dictionary& PDRProperties) { PDRDragModel::read(PDRProperties); - PDRDragModelCoeffs_.lookup("Csu") >> Csu.value(); - PDRDragModelCoeffs_.lookup("Csk") >> Csk.value(); + PDRDragModelCoeffs_.read("Csu", Csu.value()); + PDRDragModelCoeffs_.read("Csk", Csk.value()); return true; } diff --git a/applications/solvers/combustion/chemFoam/createControls.H b/applications/solvers/combustion/chemFoam/createControls.H index 6aeb2fff15..f06814dc2b 100644 --- a/applications/solvers/combustion/chemFoam/createControls.H +++ b/applications/solvers/combustion/chemFoam/createControls.H @@ -1,2 +1,3 @@ -Switch adjustTimeStep(runTime.controlDict().lookup("adjustTimeStep")); -scalar maxDeltaT(readScalar(runTime.controlDict().lookup("maxDeltaT"))); +bool adjustTimeStep(runTime.controlDict().get("adjustTimeStep")); + +scalar maxDeltaT(runTime.controlDict().get("maxDeltaT")); diff --git a/applications/solvers/combustion/chemFoam/readControls.H b/applications/solvers/combustion/chemFoam/readControls.H index c56206df1a..09937a19a6 100644 --- a/applications/solvers/combustion/chemFoam/readControls.H +++ b/applications/solvers/combustion/chemFoam/readControls.H @@ -1,3 +1,3 @@ -runTime.controlDict().lookup("adjustTimeStep") >> adjustTimeStep; +runTime.controlDict().read("adjustTimeStep", adjustTimeStep); -maxDeltaT = readScalar(runTime.controlDict().lookup("maxDeltaT")); +runTime.controlDict().read("maxDeltaT", maxDeltaT); diff --git a/applications/solvers/compressible/rhoSimpleFoam/rhoPorousSimpleFoam/createZones.H b/applications/solvers/compressible/rhoSimpleFoam/rhoPorousSimpleFoam/createZones.H index fe3d118608..7435c6d555 100644 --- a/applications/solvers/compressible/rhoSimpleFoam/rhoPorousSimpleFoam/createZones.H +++ b/applications/solvers/compressible/rhoSimpleFoam/rhoPorousSimpleFoam/createZones.H @@ -1,5 +1,5 @@ IOporosityModelList pZones(mesh); - Switch pressureImplicitPorosity(false); + bool pressureImplicitPorosity(false); // nUCorrectors used for pressureImplicitPorosity int nUCorr = 0; diff --git a/applications/solvers/incompressible/shallowWaterFoam/readGravitationalAcceleration.H b/applications/solvers/incompressible/shallowWaterFoam/readGravitationalAcceleration.H index d8a8bf8d06..b960a2f640 100644 --- a/applications/solvers/incompressible/shallowWaterFoam/readGravitationalAcceleration.H +++ b/applications/solvers/incompressible/shallowWaterFoam/readGravitationalAcceleration.H @@ -13,9 +13,11 @@ IOdictionary gravitationalProperties ); const dimensionedVector g(gravitationalProperties.lookup("g")); -const Switch rotating(gravitationalProperties.lookup("rotating")); +const bool rotating(gravitationalProperties.get("rotating")); const dimensionedVector Omega = +( rotating ? gravitationalProperties.lookup("Omega") - : dimensionedVector("Omega", -dimTime, vector(0,0,0)); + : dimensionedVector("Omega", -dimTime, vector(0,0,0)) +); const dimensionedScalar magg = mag(g); const dimensionedVector gHat = g/magg; diff --git a/applications/solvers/incompressible/simpleFoam/porousSimpleFoam/createPorousZones.H b/applications/solvers/incompressible/simpleFoam/porousSimpleFoam/createPorousZones.H index 5c6dbea19c..f67c6d7890 100644 --- a/applications/solvers/incompressible/simpleFoam/porousSimpleFoam/createPorousZones.H +++ b/applications/solvers/incompressible/simpleFoam/porousSimpleFoam/createPorousZones.H @@ -1,5 +1,5 @@ IOporosityModelList pZones(mesh); - Switch pressureImplicitPorosity(false); + bool pressureImplicitPorosity(false); // nUCorrectors used for pressureImplicitPorosity int nUCorr = 0; diff --git a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/PhaseSystems/ThermalPhaseChangePhaseSystem/ThermalPhaseChangePhaseSystem.C b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/PhaseSystems/ThermalPhaseChangePhaseSystem/ThermalPhaseChangePhaseSystem.C index d63ca7d058..0a2377b2f3 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/PhaseSystems/ThermalPhaseChangePhaseSystem/ThermalPhaseChangePhaseSystem.C +++ b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/PhaseSystems/ThermalPhaseChangePhaseSystem/ThermalPhaseChangePhaseSystem.C @@ -39,7 +39,7 @@ ThermalPhaseChangePhaseSystem HeatAndMassTransferPhaseSystem(mesh), volatile_(this->lookup("volatile")), saturationModel_(saturationModel::New(this->subDict("saturationModel"))), - massTransfer_(this->lookup("massTransfer")) + massTransfer_(this->template get("massTransfer")) { forAllConstIters(this->phasePairs_, phasePairIter) @@ -357,7 +357,7 @@ void Foam::ThermalPhaseChangePhaseSystem::correctThermo() volScalarField iDmdtNew(iDmdt); - if (massTransfer_ ) + if (massTransfer_) { volScalarField H1 ( diff --git a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/PhaseSystems/ThermalPhaseChangePhaseSystem/ThermalPhaseChangePhaseSystem.H b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/PhaseSystems/ThermalPhaseChangePhaseSystem/ThermalPhaseChangePhaseSystem.H index 611666eddc..7ce10e6c7a 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/PhaseSystems/ThermalPhaseChangePhaseSystem/ThermalPhaseChangePhaseSystem.H +++ b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/PhaseSystems/ThermalPhaseChangePhaseSystem/ThermalPhaseChangePhaseSystem.H @@ -43,7 +43,6 @@ SourceFiles #include "HeatAndMassTransferPhaseSystem.H" #include "saturationModel.H" -#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -71,7 +70,7 @@ protected: autoPtr saturationModel_; // Mass transfer enabled - Switch massTransfer_; + bool massTransfer_; //- Interfacial Mass transfer rate HashPtrTable diff --git a/applications/solvers/stressAnalysis/solidDisplacementFoam/createControl.H b/applications/solvers/stressAnalysis/solidDisplacementFoam/createControl.H index edd35297d5..40e35f8c05 100644 --- a/applications/solvers/stressAnalysis/solidDisplacementFoam/createControl.H +++ b/applications/solvers/stressAnalysis/solidDisplacementFoam/createControl.H @@ -1,3 +1,3 @@ const dictionary& stressControl = mesh.solutionDict().subDict("stressAnalysis"); -Switch compactNormalStress(stressControl.lookup("compactNormalStress")); +bool compactNormalStress(stressControl.get("compactNormalStress")); diff --git a/applications/solvers/stressAnalysis/solidDisplacementFoam/createControls.H b/applications/solvers/stressAnalysis/solidDisplacementFoam/createControls.H index dec25226f1..b35e04e26e 100644 --- a/applications/solvers/stressAnalysis/solidDisplacementFoam/createControls.H +++ b/applications/solvers/stressAnalysis/solidDisplacementFoam/createControls.H @@ -2,4 +2,4 @@ int nCorr = stressControl.lookupOrDefault("nCorrectors", 1); -scalar convergenceTolerance(readScalar(stressControl.lookup("D"))); +scalar convergenceTolerance(stressControl.get("D")); diff --git a/applications/solvers/stressAnalysis/solidDisplacementFoam/readMechanicalProperties.H b/applications/solvers/stressAnalysis/solidDisplacementFoam/readMechanicalProperties.H index a912d80e07..a592de04e9 100644 --- a/applications/solvers/stressAnalysis/solidDisplacementFoam/readMechanicalProperties.H +++ b/applications/solvers/stressAnalysis/solidDisplacementFoam/readMechanicalProperties.H @@ -184,9 +184,7 @@ volScalarField lambda(nu*E/((1.0 + nu)*(1.0 - 2.0*nu))); volScalarField threeK(E/(1.0 - 2.0*nu)); - Switch planeStress(mechanicalProperties.lookup("planeStress")); - - if (planeStress) + if (mechanicalProperties.get("planeStress")) { Info<< "Plane Stress\n" << endl; diff --git a/applications/solvers/stressAnalysis/solidDisplacementFoam/readSolidDisplacementFoamControls.H b/applications/solvers/stressAnalysis/solidDisplacementFoam/readSolidDisplacementFoamControls.H index 5ffe09b9e8..78beb0e717 100644 --- a/applications/solvers/stressAnalysis/solidDisplacementFoam/readSolidDisplacementFoamControls.H +++ b/applications/solvers/stressAnalysis/solidDisplacementFoam/readSolidDisplacementFoamControls.H @@ -1,3 +1,3 @@ nCorr = stressControl.lookupOrDefault("nCorrectors", 1); -convergenceTolerance = readScalar(stressControl.lookup("D")); -stressControl.lookup("compactNormalStress") >> compactNormalStress; +convergenceTolerance = stressControl.get("D"); +compactNormalStress = stressControl.get("compactNormalStress"); diff --git a/applications/solvers/stressAnalysis/solidDisplacementFoam/readThermalProperties.H b/applications/solvers/stressAnalysis/solidDisplacementFoam/readThermalProperties.H index ef7a53028c..3c889fc1c8 100644 --- a/applications/solvers/stressAnalysis/solidDisplacementFoam/readThermalProperties.H +++ b/applications/solvers/stressAnalysis/solidDisplacementFoam/readThermalProperties.H @@ -12,7 +12,7 @@ IOdictionary thermalProperties ) ); -Switch thermalStress(thermalProperties.lookup("thermalStress")); +bool thermalStress(thermalProperties.get("thermalStress")); volScalarField threeKalpha ( @@ -46,7 +46,6 @@ volScalarField DT if (thermalStress) { - autoPtr CPtr; IOobject CIO diff --git a/applications/solvers/stressAnalysis/solidDisplacementFoam/solidDisplacementFoam.C b/applications/solvers/stressAnalysis/solidDisplacementFoam/solidDisplacementFoam.C index d02e420ecb..15a1309c92 100644 --- a/applications/solvers/stressAnalysis/solidDisplacementFoam/solidDisplacementFoam.C +++ b/applications/solvers/stressAnalysis/solidDisplacementFoam/solidDisplacementFoam.C @@ -39,7 +39,6 @@ Description \*---------------------------------------------------------------------------*/ #include "fvCFD.H" -#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/solvers/stressAnalysis/solidDisplacementFoam/tractionDisplacement/tractionDisplacementFvPatchVectorField.C b/applications/solvers/stressAnalysis/solidDisplacementFoam/tractionDisplacement/tractionDisplacementFvPatchVectorField.C index 49d62b804e..d4ba300459 100644 --- a/applications/solvers/stressAnalysis/solidDisplacementFoam/tractionDisplacement/tractionDisplacementFvPatchVectorField.C +++ b/applications/solvers/stressAnalysis/solidDisplacementFoam/tractionDisplacement/tractionDisplacementFvPatchVectorField.C @@ -164,9 +164,7 @@ void tractionDisplacementFvPatchVectorField::updateCoeffs() scalarField lambda(nu*E/((1.0 + nu)*(1.0 - 2.0*nu))); scalarField threeK(E/(1.0 - 2.0*nu)); - Switch planeStress(mechanicalProperties.lookup("planeStress")); - - if (planeStress) + if (mechanicalProperties.get("planeStress")) { lambda = nu*E/((1.0 + nu)*(1.0 - nu)); threeK = E/(1.0 - nu); @@ -185,9 +183,7 @@ void tractionDisplacementFvPatchVectorField::updateCoeffs() + twoMuLambda*fvPatchField::snGrad() - (n & sigmaD) )/twoMuLambda; - Switch thermalStress(thermalProperties.lookup("thermalStress")); - - if (thermalStress) + if (thermalProperties.get("thermalStress")) { const fvPatchField& threeKalpha= patch().lookupPatchField("threeKalpha"); diff --git a/applications/solvers/stressAnalysis/solidEquilibriumDisplacementFoam/solidEquilibriumDisplacementFoam.C b/applications/solvers/stressAnalysis/solidEquilibriumDisplacementFoam/solidEquilibriumDisplacementFoam.C index ce297ac89e..83bd903480 100644 --- a/applications/solvers/stressAnalysis/solidEquilibriumDisplacementFoam/solidEquilibriumDisplacementFoam.C +++ b/applications/solvers/stressAnalysis/solidEquilibriumDisplacementFoam/solidEquilibriumDisplacementFoam.C @@ -39,7 +39,6 @@ Description \*---------------------------------------------------------------------------*/ #include "fvCFD.H" -#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/solvers/stressAnalysis/solidEquilibriumDisplacementFoam/tractionDisplacementCorrection/tractionDisplacementCorrectionFvPatchVectorField.C b/applications/solvers/stressAnalysis/solidEquilibriumDisplacementFoam/tractionDisplacementCorrection/tractionDisplacementCorrectionFvPatchVectorField.C index 33c1e8a8c6..2b90cacfdf 100644 --- a/applications/solvers/stressAnalysis/solidEquilibriumDisplacementFoam/tractionDisplacementCorrection/tractionDisplacementCorrectionFvPatchVectorField.C +++ b/applications/solvers/stressAnalysis/solidEquilibriumDisplacementFoam/tractionDisplacementCorrection/tractionDisplacementCorrectionFvPatchVectorField.C @@ -163,9 +163,7 @@ void tractionDisplacementCorrectionFvPatchVectorField::updateCoeffs() scalarField mu(E/(2.0*(1.0 + nu))); scalarField lambda(nu*E/((1.0 + nu)*(1.0 - 2.0*nu))); - Switch planeStress(mechanicalProperties.lookup("planeStress")); - - if (planeStress) + if (mechanicalProperties.get("planeStress")) { lambda = nu*E/((1.0 + nu)*(1.0 - nu)); } diff --git a/applications/utilities/mesh/advanced/selectCells/edgeStats.C b/applications/utilities/mesh/advanced/selectCells/edgeStats.C index 8d2fada35d..c7d7f9aab7 100644 --- a/applications/utilities/mesh/advanced/selectCells/edgeStats.C +++ b/applications/utilities/mesh/advanced/selectCells/edgeStats.C @@ -89,9 +89,7 @@ Foam::edgeStats::edgeStats(const polyMesh& mesh) IOdictionary motionProperties(motionObj); - Switch twoDMotion(motionProperties.lookup("twoDMotion")); - - if (twoDMotion) + if (motionProperties.get("twoDMotion")) { Info<< "Correcting for 2D motion" << endl << endl; diff --git a/applications/utilities/mesh/advanced/snappyRefineMesh/snappyRefineMesh.C b/applications/utilities/mesh/advanced/snappyRefineMesh/snappyRefineMesh.C index 2f268c447a..6cf0973059 100644 --- a/applications/utilities/mesh/advanced/snappyRefineMesh/snappyRefineMesh.C +++ b/applications/utilities/mesh/advanced/snappyRefineMesh/snappyRefineMesh.C @@ -658,9 +658,7 @@ int main(int argc, char *argv[]) IOdictionary motionProperties(motionObj); - Switch twoDMotion(motionProperties.lookup("twoDMotion")); - - if (twoDMotion) + if (motionProperties.get("twoDMotion")) { Info<< "Correcting for 2D motion" << endl << endl; correct2DPtr = new twoDPointCorrector(mesh); diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C index 34d5f2b5c6..a5dfafe0ae 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C @@ -297,7 +297,7 @@ int main(int argc, char *argv[]) autoPtr model(extrudeModel::New(dict)); // Whether to flip normals - const Switch flipNormals(dict.lookup("flipNormals")); + const bool flipNormals(dict.get("flipNormals")); // What to extrude const ExtrudeMode mode = ExtrudeModeNames.lookup @@ -983,8 +983,7 @@ int main(int argc, char *argv[]) // Merging front and back patch faces // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Switch mergeFaces(dict.lookup("mergeFaces")); - if (mergeFaces) + if (dict.get("mergeFaces")) { if (mode == MESH) { @@ -1009,7 +1008,6 @@ int main(int argc, char *argv[]) } - polyTopoChanger stitcher(mesh); stitcher.setSize(1); diff --git a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C index 3251cc203a..1bf2ee3138 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C @@ -1536,8 +1536,8 @@ int main(int argc, char *argv[]) mappedPatchBase::sampleMode sampleMode = mappedPatchBase::sampleModeNames_[dict.lookup("sampleMode")]; - const Switch oneD(dict.lookup("oneD")); - Switch oneDNonManifoldEdges(false); + const bool oneD(dict.get("oneD")); + bool oneDNonManifoldEdges(false); word oneDPatchType(emptyPolyPatch::typeName); if (oneD) { @@ -1545,7 +1545,7 @@ int main(int argc, char *argv[]) dict.lookup("oneDPolyPatchType") >> oneDPatchType; } - const Switch adaptMesh(dict.lookup("adaptMesh")); + const bool adaptMesh(dict.get("adaptMesh")); if (hasZones) { diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.C index 302bd61b55..b3b09022b3 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.C @@ -97,7 +97,7 @@ Foam::automatic::automatic ( const dictionary& cellSizeCalcTypeDict, const triSurfaceMesh& surface, - const scalar& defaultCellSize + const scalar defaultCellSize ) : cellSizeCalculationType @@ -109,12 +109,15 @@ Foam::automatic::automatic ), coeffsDict_(cellSizeCalcTypeDict.optionalSubDict(typeName + "Coeffs")), surfaceName_(surface.searchableSurface::name()), - readCurvature_(Switch(coeffsDict_.lookup("curvature"))), - curvatureFile_(coeffsDict_.lookup("curvatureFile")), - readFeatureProximity_(Switch(coeffsDict_.lookup("featureProximity"))), - featureProximityFile_(coeffsDict_.lookup("featureProximityFile")), - readInternalCloseness_(Switch(coeffsDict_.lookup("internalCloseness"))), - internalClosenessFile_(coeffsDict_.lookup("internalClosenessFile")), + + readCurvature_(coeffsDict_.get("curvature")), + readFeatureProximity_(coeffsDict_.get("featureProximity")), + readInternalCloseness_(coeffsDict_.get("internalCloseness")), + + curvatureFile_(coeffsDict_.get("curvatureFile")), + featureProximityFile_(coeffsDict_.get("featureProximityFile")), + internalClosenessFile_(coeffsDict_.get("internalClosenessFile")), + curvatureCellSizeCoeff_ ( readScalar(coeffsDict_.lookup("curvatureCellSizeCoeff")) diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.H b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.H index 07f4e9442d..11cf52ff86 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.H +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.H @@ -37,7 +37,6 @@ SourceFiles #include "cellSizeCalculationType.H" #include "triSurfaceFields.H" #include "PrimitivePatchInterpolation.H" -#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -54,9 +53,6 @@ class automatic : public cellSizeCalculationType { - -private: - // Private data //- Dictionary of coefficients for automatic cell sizing @@ -65,13 +61,12 @@ private: //- Name of the surface. Used to write the cell size field const fileName surfaceName_; - const Switch readCurvature_; + const bool readCurvature_; + const bool readFeatureProximity_; + const bool readInternalCloseness_; + const word curvatureFile_; - - const Switch readFeatureProximity_; const word featureProximityFile_; - - const Switch readInternalCloseness_; const word internalClosenessFile_; //- The curvature values are multiplied by the inverse of this value to @@ -100,13 +95,12 @@ public: ( const dictionary& cellSizeCalcTypeDict, const triSurfaceMesh& surface, - const scalar& defaultCellSize + const scalar defaultCellSize ); //- Destructor - virtual ~automatic() - {} + virtual ~automatic() = default; // Member Functions diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cvControls/cvControls.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cvControls/cvControls.C index 3274c0ad0a..58db69d92e 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cvControls/cvControls.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cvControls/cvControls.C @@ -42,43 +42,30 @@ Foam::cvControls::cvControls foamyHexMeshDict_.subDict("surfaceConformation") ); - pointPairDistanceCoeff_ = readScalar - ( - surfDict.lookup("pointPairDistanceCoeff") - ); + pointPairDistanceCoeff_ = + surfDict.get("pointPairDistanceCoeff"); - mixedFeaturePointPPDistanceCoeff_ = readScalar - ( - surfDict.lookup("mixedFeaturePointPPDistanceCoeff") - ); + mixedFeaturePointPPDistanceCoeff_ = + surfDict.get("mixedFeaturePointPPDistanceCoeff"); - featurePointExclusionDistanceCoeff_ = readScalar - ( - surfDict.lookup("featurePointExclusionDistanceCoeff") - ); + featurePointExclusionDistanceCoeff_ = + surfDict.get("featurePointExclusionDistanceCoeff"); - featureEdgeExclusionDistanceCoeff_ = readScalar - ( - surfDict.lookup("featureEdgeExclusionDistanceCoeff") - ); + featureEdgeExclusionDistanceCoeff_ = + surfDict.get("featureEdgeExclusionDistanceCoeff"); + surfaceSearchDistanceCoeff_ = + surfDict.get("surfaceSearchDistanceCoeff"); - surfaceSearchDistanceCoeff_ = readScalar - ( - surfDict.lookup("surfaceSearchDistanceCoeff") - ); + maxSurfaceProtrusionCoeff_ = + surfDict.get("maxSurfaceProtrusionCoeff"); - maxSurfaceProtrusionCoeff_ = readScalar - ( - surfDict.lookup("maxSurfaceProtrusionCoeff") - ); - - maxQuadAngle_ = readScalar(surfDict.lookup("maxQuadAngle")); + maxQuadAngle_ = surfDict.get("maxQuadAngle"); surfaceConformationRebuildFrequency_ = max ( 1, - readLabel(surfDict.lookup("surfaceConformationRebuildFrequency")) + surfDict.get