From 8638d8232598b228c7988c0506f8ce8c192429fb Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 8 Nov 2021 14:06:06 +0100 Subject: [PATCH] ENH: additional dictionary controls, methods STYLE: declaration order of topoSet, resize_nocopy for sortedOrder STYLE: remove cstring dependency from SHA1 STYLE: use Ostream endEntry() --- .../PDR/pdrFields/PDRarraysCalc.C | 3 +- .../Lists/ListOps/ListOpsTemplates.C | 19 +-- .../PtrLists/PtrListOps/PtrListOpsTemplates.C | 17 +- src/OpenFOAM/db/dictionary/dictionary.C | 82 +-------- src/OpenFOAM/db/dictionary/dictionary.H | 82 ++++----- src/OpenFOAM/db/dictionary/dictionaryI.H | 156 ++++++++++++++++++ .../db/dictionary/dictionaryTemplates.C | 68 ++------ .../expressions/exprDriver/exprDriverIO.C | 2 +- .../Function1/LimitRange/LimitRange.C | 2 +- .../functions/Function1/One/OneConstant.C | 3 +- .../functions/Function1/Scale/Scale.C | 2 +- .../functions/Function1/Zero/ZeroConstant.C | 3 +- .../functions/Function1/ramp/ramp.C | 2 +- src/OpenFOAM/primitives/hashes/SHA1/SHA1.C | 2 +- src/OpenFOAM/primitives/hashes/SHA1/SHA1.H | 2 +- src/OpenFOAM/primitives/hashes/SHA1/SHA1I.H | 7 +- src/mesh/blockMesh/PDRblockMesh/PDRblock.C | 4 +- .../UniformValueField/UniformValueField.C | 3 +- .../sets/topoSetSource/topoSetSource.H | 30 ++-- 19 files changed, 261 insertions(+), 228 deletions(-) create mode 100644 src/OpenFOAM/db/dictionary/dictionaryI.H diff --git a/applications/utilities/preProcessing/PDR/pdrFields/PDRarraysCalc.C b/applications/utilities/preProcessing/PDR/pdrFields/PDRarraysCalc.C index c434e37db9..7db3730924 100644 --- a/applications/utilities/preProcessing/PDR/pdrFields/PDRarraysCalc.C +++ b/applications/utilities/preProcessing/PDR/pdrFields/PDRarraysCalc.C @@ -203,7 +203,8 @@ static inline scalar averageSurrounding template static inline Ostream& putUniform(Ostream& os, const word& key, const Type& val) { - os.writeKeyword(key) << word("uniform") << token::SPACE + os.writeKeyword(key) + << word("uniform") << token::SPACE << val << token::END_STATEMENT << nl; return os; } diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C index 11e33407a8..98209e497c 100644 --- a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C +++ b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2020 OpenCFD Ltd. + Copyright (C) 2015-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -327,7 +327,7 @@ Foam::labelList Foam::sortedOrder const UList& input ) { - labelList order(input.size()); + labelList order; sortedOrder(input, order, typename UList::less(input)); return order; } @@ -352,15 +352,8 @@ void Foam::sortedOrder const ListComparePredicate& comp ) { - const label len = input.size(); - - // List lengths must be identical - if (order.size() != len) - { - // Avoid copying elements, they are overwritten anyhow - order.clear(); - order.resize(len); - } + // List lengths must be identical. Old content is overwritten + order.resize_nocopy(input.size()); ListOps::identity(order); @@ -374,7 +367,7 @@ Foam::labelList Foam::duplicateOrder const UList& input ) { - labelList order(input.size()); + labelList order; duplicateOrder(input, order, typename UList::less(input)); return order; } @@ -427,7 +420,7 @@ Foam::labelList Foam::uniqueOrder const UList& input ) { - labelList order(input.size()); + labelList order; uniqueOrder(input, order, typename UList::less(input)); return order; } diff --git a/src/OpenFOAM/containers/PtrLists/PtrListOps/PtrListOpsTemplates.C b/src/OpenFOAM/containers/PtrLists/PtrListOps/PtrListOpsTemplates.C index 4019fa0cb2..aec159d25f 100644 --- a/src/OpenFOAM/containers/PtrLists/PtrListOps/PtrListOpsTemplates.C +++ b/src/OpenFOAM/containers/PtrLists/PtrListOps/PtrListOpsTemplates.C @@ -35,7 +35,7 @@ Foam::labelList Foam::sortedOrder const UPtrList& input ) { - labelList order(input.size()); + labelList order; sortedOrder(input, order, typename PtrListOps::less(input)); return order; } @@ -60,15 +60,8 @@ void Foam::sortedOrder const ListComparePredicate& comp ) { - const label len = input.size(); - - // List lengths must be identical - if (order.size() != len) - { - // Avoid copying elements, they are overwritten anyhow - order.clear(); - order.resize(len); - } + // List lengths must be identical. Old content is overwritten + order.resize_nocopy(input.size()); ListOps::identity(order); @@ -79,7 +72,7 @@ void Foam::sortedOrder template void Foam::sort(UPtrList& list) { - labelList order(list.size()); + labelList order; sortedOrder(list, order); list.sortOrder(order, false); // false = allow nullptr } @@ -88,7 +81,7 @@ void Foam::sort(UPtrList& list) template void Foam::sort(UPtrList& list, const Compare& comp) { - labelList order(list.size()); + labelList order; sortedOrder(list, order, comp); list.sortOrder(order, false); // false = allow nullptr } diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C index cef7f9ea24..e2555ac5a2 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.C +++ b/src/OpenFOAM/db/dictionary/dictionary.C @@ -351,46 +351,6 @@ void Foam::dictionary::raiseBadInput } -bool Foam::dictionary::found -( - const word& keyword, - enum keyType::option matchOpt -) const -{ - return csearch(keyword, matchOpt).good(); -} - - -Foam::entry* Foam::dictionary::findEntry -( - const word& keyword, - enum keyType::option matchOpt -) -{ - return search(keyword, matchOpt).ptr(); -} - - -const Foam::entry* Foam::dictionary::findEntry -( - const word& keyword, - enum keyType::option matchOpt -) const -{ - return csearch(keyword, matchOpt).ptr(); -} - - -const Foam::entry* Foam::dictionary::findScoped -( - const word& keyword, - enum keyType::option matchOpt -) const -{ - return csearchScoped(keyword, matchOpt).ptr(); -} - - const Foam::entry& Foam::dictionary::lookupEntry ( const word& keyword, @@ -485,36 +445,6 @@ bool Foam::dictionary::substituteScopedKeyword } -bool Foam::dictionary::isDict -( - const word& keyword, - enum keyType::option matchOpt -) const -{ - return csearch(keyword, matchOpt).isDict(); -} - - -Foam::dictionary* Foam::dictionary::findDict -( - const word& keyword, - enum keyType::option matchOpt -) -{ - return search(keyword, matchOpt).dictPtr(); -} - - -const Foam::dictionary* Foam::dictionary::findDict -( - const word& keyword, - enum keyType::option matchOpt -) const -{ - return csearch(keyword, matchOpt).dictPtr(); -} - - const Foam::dictionary& Foam::dictionary::subDict ( const word& keyword, @@ -1019,9 +949,9 @@ Foam::dictionary Foam::operator+ const dictionary& dict2 ) { - dictionary sum(dict1); - sum += dict2; - return sum; + dictionary result(dict1); + result += dict2; + return result; } @@ -1031,9 +961,9 @@ Foam::dictionary Foam::operator| const dictionary& dict2 ) { - dictionary sum(dict1); - sum |= dict2; - return sum; + dictionary result(dict1); + result |= dict2; + return result; } diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H index bb4d914dc2..4fff7b0e7c 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.H +++ b/src/OpenFOAM/db/dictionary/dictionary.H @@ -314,7 +314,7 @@ private: // // \param recursive search parent dictionaries // \param pattern match using regular expressions as well - static inline enum keyType::option + inline static enum keyType::option matchOpt(bool recursive, bool pattern) { return @@ -360,13 +360,14 @@ private: //- Emit IOError about bad input for the entry void raiseBadInput(const ITstream& is, const word& keyword) const; - //- Report (on stderr) that the keyword default value was used + //- Report (stderr) that the keyword default value was used. + //- or FatalIOError when writeOptionalEntries greater than 1 template void reportDefault ( const word& keyword, const T& deflt, - const bool added = false + const bool added = false // Value was added to the dictionary ) const; @@ -375,13 +376,27 @@ public: // Declare name of the class and its debug switch ClassName("dictionary"); - //- Report optional keywords and values if not present in dictionary - // For value greater than 1: fatal. - // Set/unset via an InfoSwitch or -info-switch at the command-line - static int writeOptionalEntries; + // Static Data - //- An empty dictionary, which is also the parent for all dictionaries - static const dictionary null; + //- Report optional keywords and values if not present in dictionary + // For value greater than 1: fatal. + // Set/unset via an InfoSwitch or -info-switch at the command-line + static int writeOptionalEntries; + + //- An empty dictionary, which is also the parent for all dictionaries + static const dictionary null; + + + // Static Member Functions + + //- Return the state of reporting optional (default) entries + // 0: no reporting, 1: report, 2: fatal if not set + inline static int reportOptional() noexcept; + + //- Change the state of reporting optional (default) entries + // 0: no reporting, 1: report, 2: fatal if not set + // \return old level + inline static int reportOptional(const int level) noexcept; // Constructors @@ -443,30 +458,13 @@ public: // Access //- The dictionary name - const fileName& name() const noexcept - { - return name_; - } + inline const fileName& name() const noexcept; //- The dictionary name for modification (use with caution). - fileName& name() noexcept - { - return name_; - } + inline fileName& name() noexcept; //- The local dictionary name (final part of scoped name) - word dictName() const - { - word scopedName(name_.name()); - - const auto i = scopedName.rfind('.'); - if (i == std::string::npos) - { - return scopedName; - } - - return scopedName.substr(i+1); - } + inline word dictName() const; //- The dictionary name relative to the case. // Uses argList::envRelativePath to obtain FOAM_CASE @@ -476,11 +474,11 @@ public: // not an absolute location fileName relativeName(const bool caseTag = false) const; + //- The dictionary is actually dictionary::null (root dictionary) + inline bool isNullDict() const noexcept; + //- Return the parent dictionary - const dictionary& parent() const noexcept - { - return parent_; - } + inline const dictionary& parent() const noexcept; //- Return the top of the tree const dictionary& topDict() const; @@ -505,7 +503,7 @@ public: // \param matchOpt the default search is non-recursive with patterns // // \return True if entry was found - bool found + inline bool found ( const word& keyword, enum keyType::option matchOpt = keyType::REGEX @@ -516,7 +514,7 @@ public: // \param matchOpt the search mode // // \return the entry pointer found or a nullptr. - entry* findEntry + inline entry* findEntry ( const word& keyword, enum keyType::option matchOpt = keyType::REGEX @@ -527,7 +525,7 @@ public: // \param matchOpt the default search is non-recursive with patterns // // \return the entry pointer found or a nullptr. - const entry* findEntry + inline const entry* findEntry ( const word& keyword, enum keyType::option matchOpt = keyType::REGEX @@ -541,7 +539,7 @@ public: // \param matchOpt the default search is non-recursive with patterns // // \return the entry pointer found or a nullptr. - const entry* findScoped + inline const entry* findScoped ( const word& keyword, enum keyType::option matchOpt = keyType::REGEX @@ -551,7 +549,7 @@ public: // (and a sub-dictionary) otherwise return nullptr. // // \param matchOpt the default search is non-recursive with patterns - dictionary* findDict + inline dictionary* findDict ( const word& keyword, enum keyType::option matchOpt = keyType::REGEX @@ -561,7 +559,7 @@ public: // (and a sub-dictionary) otherwise return nullptr. // // \param matchOpt the default search is non-recursive with patterns - const dictionary* findDict + inline const dictionary* findDict ( const word& keyword, enum keyType::option matchOpt = keyType::REGEX @@ -743,7 +741,7 @@ public: // \param matchOpt the default search is non-recursive with patterns // // \return true if the entry was found. - bool isDict + inline bool isDict ( const word& keyword, enum keyType::option matchOpt = keyType::REGEX @@ -1531,6 +1529,10 @@ dictionary operator|(const dictionary& dict1, const dictionary& dict2); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#include "dictionaryI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #ifdef NoRepository #include "dictionaryTemplates.C" #endif diff --git a/src/OpenFOAM/db/dictionary/dictionaryI.H b/src/OpenFOAM/db/dictionary/dictionaryI.H new file mode 100644 index 0000000000..af4e791c96 --- /dev/null +++ b/src/OpenFOAM/db/dictionary/dictionaryI.H @@ -0,0 +1,156 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + 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. + + 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 with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "dictionary.H" + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +inline int Foam::dictionary::reportOptional() noexcept +{ + return writeOptionalEntries; +} + + +inline int Foam::dictionary::reportOptional(const int level) noexcept +{ + int old(writeOptionalEntries); + writeOptionalEntries = level; + return old; +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +inline const Foam::fileName& Foam::dictionary::name() const noexcept +{ + return name_; +} + + +inline Foam::fileName& Foam::dictionary::name() noexcept +{ + return name_; +} + + +inline Foam::word Foam::dictionary::dictName() const +{ + word scopedName(name_.name()); + + const auto i = scopedName.rfind('.'); + if (i == std::string::npos) + { + return scopedName; + } + + return scopedName.substr(i+1); +} + + +inline bool Foam::dictionary::isNullDict() const noexcept +{ + return (this == &dictionary::null); +} + + +inline const Foam::dictionary& Foam::dictionary::parent() const noexcept +{ + return parent_; +} + + +inline bool Foam::dictionary::found +( + const word& keyword, + enum keyType::option matchOpt +) const +{ + return csearch(keyword, matchOpt).good(); +} + + +inline Foam::entry* Foam::dictionary::findEntry +( + const word& keyword, + enum keyType::option matchOpt +) +{ + return search(keyword, matchOpt).ptr(); +} + + +inline const Foam::entry* Foam::dictionary::findEntry +( + const word& keyword, + enum keyType::option matchOpt +) const +{ + return csearch(keyword, matchOpt).ptr(); +} + + +inline const Foam::entry* Foam::dictionary::findScoped +( + const word& keyword, + enum keyType::option matchOpt +) const +{ + return csearchScoped(keyword, matchOpt).ptr(); +} + + +inline Foam::dictionary* Foam::dictionary::findDict +( + const word& keyword, + enum keyType::option matchOpt +) +{ + return search(keyword, matchOpt).dictPtr(); +} + + +inline const Foam::dictionary* Foam::dictionary::findDict +( + const word& keyword, + enum keyType::option matchOpt +) const +{ + return csearch(keyword, matchOpt).dictPtr(); +} + + +inline bool Foam::dictionary::isDict +( + const word& keyword, + enum keyType::option matchOpt +) const +{ + return csearch(keyword, matchOpt).isDict(); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C index 042c79cd10..2c05308c38 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C +++ b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C @@ -39,6 +39,14 @@ void Foam::dictionary::reportDefault const bool added ) const { + if (writeOptionalEntries > 1) + { + FatalIOErrorInFunction(*this) + << "No optional entry: " << keyword + << " Default: " << deflt << nl + << exit(FatalIOError); + } + InfoErr << "Dictionary: " << this->relativeName().c_str() << " Entry: " << keyword; @@ -140,17 +148,7 @@ T Foam::dictionary::getOrDefault } else if (writeOptionalEntries) { - if (writeOptionalEntries > 1) - { - FatalIOErrorInFunction(*this) - << "No optional entry: " << keyword - << " Default: " << deflt << nl - << exit(FatalIOError); - } - else - { - reportDefault(keyword, deflt); - } + reportDefault(keyword, deflt); } return deflt; @@ -180,17 +178,7 @@ T Foam::dictionary::getOrAdd } else if (writeOptionalEntries) { - if (writeOptionalEntries > 1) - { - FatalIOErrorInFunction(*this) - << "No optional entry: " << keyword - << " Default: " << deflt << nl - << exit(FatalIOError); - } - else - { - reportDefault(keyword, deflt, true); - } + reportDefault(keyword, deflt, true); // Added } add(new primitiveEntry(keyword, deflt)); @@ -236,17 +224,7 @@ T Foam::dictionary::getCheckOrDefault } else if (writeOptionalEntries) { - if (writeOptionalEntries > 1) - { - FatalIOErrorInFunction(*this) - << "No optional entry: " << keyword - << " Default: " << deflt << nl - << exit(FatalIOError); - } - else - { - reportDefault(keyword, deflt); - } + reportDefault(keyword, deflt); } return deflt; @@ -291,17 +269,7 @@ T Foam::dictionary::getCheckOrAdd } else if (writeOptionalEntries) { - if (writeOptionalEntries > 1) - { - FatalIOErrorInFunction(*this) - << "No optional entry: " << keyword - << " Default: " << deflt << nl - << exit(FatalIOError); - } - else - { - reportDefault(keyword, deflt, true); - } + reportDefault(keyword, deflt, true); // Added } add(new primitiveEntry(keyword, deflt)); @@ -463,17 +431,7 @@ T Foam::dictionary::getOrDefaultCompat } else if (writeOptionalEntries) { - if (writeOptionalEntries > 1) - { - FatalIOErrorInFunction(*this) - << "No optional entry: " << keyword - << " Default: " << deflt << nl - << exit(FatalIOError); - } - else - { - reportDefault(keyword, deflt); - } + reportDefault(keyword, deflt); } return deflt; diff --git a/src/OpenFOAM/expressions/exprDriver/exprDriverIO.C b/src/OpenFOAM/expressions/exprDriver/exprDriverIO.C index bf968cd544..93960cf414 100644 --- a/src/OpenFOAM/expressions/exprDriver/exprDriverIO.C +++ b/src/OpenFOAM/expressions/exprDriver/exprDriverIO.C @@ -130,7 +130,7 @@ Foam::Ostream& Foam::expressions::exprDriver::writeVariableStrings if (keyword.size()) { - os << token::END_STATEMENT << nl; + os.endEntry(); } return os; diff --git a/src/OpenFOAM/primitives/functions/Function1/LimitRange/LimitRange.C b/src/OpenFOAM/primitives/functions/Function1/LimitRange/LimitRange.C index 8578cec6b7..0537e48fc3 100644 --- a/src/OpenFOAM/primitives/functions/Function1/LimitRange/LimitRange.C +++ b/src/OpenFOAM/primitives/functions/Function1/LimitRange/LimitRange.C @@ -76,7 +76,7 @@ template void Foam::Function1Types::LimitRange::writeData(Ostream& os) const { Function1::writeData(os); - os << token::END_STATEMENT << nl; + os.endEntry(); os.beginBlock(word(this->name() + "Coeffs")); writeEntries(os); diff --git a/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.C b/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.C index f95259c446..25acd3a7dd 100644 --- a/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.C +++ b/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.C @@ -74,8 +74,7 @@ template void Foam::Function1Types::OneConstant::writeData(Ostream& os) const { Function1::writeData(os); - - os << token::END_STATEMENT << nl; + os.endEntry(); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C b/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C index 76bb810eee..52e7fdc8d3 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C +++ b/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C @@ -74,7 +74,7 @@ template void Foam::Function1Types::Scale::writeData(Ostream& os) const { Function1::writeData(os); - os << token::END_STATEMENT << nl; + os.endEntry(); os.beginBlock(word(this->name() + "Coeffs")); writeEntries(os); diff --git a/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.C b/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.C index 591e430f62..a9261f2ce4 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.C +++ b/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.C @@ -54,8 +54,7 @@ template void Foam::Function1Types::ZeroConstant::writeData(Ostream& os) const { Function1::writeData(os); - - os << token::END_STATEMENT << nl; + os.endEntry(); } diff --git a/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C b/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C index 53fb63ccc0..4f3baec921 100644 --- a/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C +++ b/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C @@ -68,7 +68,7 @@ void Foam::Function1Types::ramp::convertTimeBase(const Time& t) void Foam::Function1Types::ramp::writeData(Ostream& os) const { Function1::writeData(os); - os << token::END_STATEMENT << nl; + os.endEntry(); os.beginBlock(word(this->name() + "Coeffs")); writeEntries(os); diff --git a/src/OpenFOAM/primitives/hashes/SHA1/SHA1.C b/src/OpenFOAM/primitives/hashes/SHA1/SHA1.C index 0573dee1cd..3f89bb4760 100644 --- a/src/OpenFOAM/primitives/hashes/SHA1/SHA1.C +++ b/src/OpenFOAM/primitives/hashes/SHA1/SHA1.C @@ -312,7 +312,7 @@ void Foam::SHA1::calcDigest(SHA1Digest& dig) const // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // -void Foam::SHA1::clear() +void Foam::SHA1::clear() noexcept { hashsumA_ = 0x67452301; hashsumB_ = 0xefcdab89; diff --git a/src/OpenFOAM/primitives/hashes/SHA1/SHA1.H b/src/OpenFOAM/primitives/hashes/SHA1/SHA1.H index 302fc517be..9d9e617a48 100644 --- a/src/OpenFOAM/primitives/hashes/SHA1/SHA1.H +++ b/src/OpenFOAM/primitives/hashes/SHA1/SHA1.H @@ -111,7 +111,7 @@ public: // Member Functions //- Reset the hashed data before appending more - void clear(); + void clear() noexcept; //- Append data for processing inline SHA1& append(const char* str); diff --git a/src/OpenFOAM/primitives/hashes/SHA1/SHA1I.H b/src/OpenFOAM/primitives/hashes/SHA1/SHA1I.H index 5f932a5577..b04b3b6161 100644 --- a/src/OpenFOAM/primitives/hashes/SHA1/SHA1I.H +++ b/src/OpenFOAM/primitives/hashes/SHA1/SHA1I.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,7 +27,6 @@ License \*---------------------------------------------------------------------------*/ #include "SHA1.H" -#include // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -64,7 +63,7 @@ inline Foam::SHA1& Foam::SHA1::append(const char* str) { if (str && *str) { - processBytes(str, strlen(str)); + processBytes(str, std::char_traits::length(str)); } return *this; } @@ -72,7 +71,7 @@ inline Foam::SHA1& Foam::SHA1::append(const char* str) inline Foam::SHA1& Foam::SHA1::append(const std::string& str) { - processBytes(str.data(), str.size()); + processBytes(str.data(), str.length()); return *this; } diff --git a/src/mesh/blockMesh/PDRblockMesh/PDRblock.C b/src/mesh/blockMesh/PDRblockMesh/PDRblock.C index 7a97637c57..9559073305 100644 --- a/src/mesh/blockMesh/PDRblockMesh/PDRblock.C +++ b/src/mesh/blockMesh/PDRblockMesh/PDRblock.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -552,7 +552,7 @@ Foam::PDRblock::PDRblock(const dictionary& dict, bool verboseOutput) edgeLimits_(0,0), verbose_(verboseOutput) { - if (&dict != &dictionary::null) + if (!dict.isNullDict()) { read(dict); } diff --git a/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.C b/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.C index 5e3069ac85..d18b079515 100644 --- a/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.C +++ b/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.C @@ -101,9 +101,8 @@ void Foam::PatchFunction1Types::UniformValueField::writeData ) const { PatchFunction1::writeData(os); - //os << token::END_STATEMENT << nl; + uniformValuePtr_->writeData(os); - //os << endl; } diff --git a/src/meshTools/sets/topoSetSource/topoSetSource.H b/src/meshTools/sets/topoSetSource/topoSetSource.H index c45c9d1b46..85f54e0c3c 100644 --- a/src/meshTools/sets/topoSetSource/topoSetSource.H +++ b/src/meshTools/sets/topoSetSource/topoSetSource.H @@ -75,16 +75,16 @@ public: enum sourceType { UNKNOWN_SOURCE = 0, //!< Placeholder - SET_SOURCE = 0x10, //!< Source based on topoSet - ZONE_SOURCE = 0x20, //!< Source based on mesh zone CELL_TYPE = 0x1, //!< Geometric type is "cell" FACE_TYPE = 0x2, //!< Geometric type is "face" POINT_TYPE = 0x4, //!< Geometric type is "point" + SET_SOURCE = 0x10, //!< A source based on topoSet CELLSET_SOURCE = (CELL_TYPE | SET_SOURCE), //!< Cells as set FACESET_SOURCE = (FACE_TYPE | SET_SOURCE), //!< Faces as set POINTSET_SOURCE = (POINT_TYPE | SET_SOURCE), //!< Points as set + ZONE_SOURCE = 0x20, //!< A source based on mesh zone CELLZONE_SOURCE = (CELL_TYPE | ZONE_SOURCE), //!< Cells as zone FACEZONE_SOURCE = (FACE_TYPE | ZONE_SOURCE), //!< Faces as zone POINTZONE_SOURCE = (POINT_TYPE | ZONE_SOURCE), //!< Points as zone @@ -100,14 +100,18 @@ public: //- Enumeration defining the valid actions enum setAction { - ADD, //!< Add elements to the set - SUBTRACT, //!< Subtract elements from the set - SUBSET, //!< Subset with elements in the set - INVERT, //!< Invert the elements in the set - CLEAR, //!< Clear the set, possibly creating it + // Fundamental actions + ADD, //!< Add elements to current set NEW, //!< Create a new set and ADD elements to it + SUBTRACT, //!< Subtract elements from current set + + // Derived/intrinsic actions + SUBSET, //!< Union of elements with current set + INVERT, //!< Invert the elements in the current set + CLEAR, //!< Clear the set, possibly creating it REMOVE, //!< Remove the set (from the file system) LIST, //!< Print contents of the set + DELETE = SUBTRACT, //!< \deprecated(2018-10) Alias for SUBTRACT }; @@ -201,31 +205,31 @@ public: static Istream& checkIs(Istream& is); //- True if a "set" source - static inline bool isSetSource(const sourceType t) + static inline bool isSetSource(const sourceType t) noexcept { return (t & SET_SOURCE); } //- True if a "zone" source - static inline bool isZoneSource(const sourceType t) + static inline bool isZoneSource(const sourceType t) noexcept { return (t & ZONE_SOURCE); } //- True if "cell" geometric type - static inline bool isCell(const sourceType t) + static inline bool isCell(const sourceType t) noexcept { return (t & CELL_TYPE); } //- True if "face" geometric type - static inline bool isFace(const sourceType t) + static inline bool isFace(const sourceType t) noexcept { return (t & FACE_TYPE); } //- True if "point" geometric type - static inline bool isPoint(const sourceType t) + static inline bool isPoint(const sourceType t) noexcept { return (t & POINT_TYPE); } @@ -362,7 +366,7 @@ public: // Member Functions - //- The source category (set/zone, cell/face/point) + //- The source category (cell/face/point combined with set/zone) virtual sourceType setType() const = 0; //- Apply specified action to the topoSet