diff --git a/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/multiphaseMixtureThermo.H b/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/multiphaseMixtureThermo.H index 368df01043..5172f537f2 100644 --- a/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/multiphaseMixtureThermo.H +++ b/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/multiphaseMixtureThermo.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -59,24 +59,23 @@ class multiphaseMixtureThermo { public: + //- Symmetric pair of interface names class interfacePair : public Pair { public: - struct hash - { - label operator()(const interfacePair& key) const - { - return word::hash()(key.first()) + word::hash()(key.second()); - } - }; + // Always use symmetric hashing + using hasher = Pair::symmHasher; + + // Always use symmetric hashing (alias) + using hash = Pair::symmHasher; // Constructors - interfacePair() {} // = default + interfacePair() = default; interfacePair(const word& alpha1Name, const word& alpha2Name) : @@ -97,11 +96,7 @@ public: const interfacePair& b ) { - return - ( - ((a.first() == b.first()) && (a.second() == b.second())) - || ((a.first() == b.second()) && (a.second() == b.first())) - ); + return (0 != Pair::compare(a, b)); } friend bool operator!= @@ -117,7 +112,7 @@ public: private: - // Private data + // Private Data //- Dictionary of phases PtrDictionary phases_; @@ -140,7 +135,7 @@ private: const dimensionedScalar deltaN_; - // Private member functions + // Private Member Functions void calcAlphas(); diff --git a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.H b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.H index b320374e06..ddaa807a93 100644 --- a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.H +++ b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -67,24 +68,23 @@ class multiphaseMixture { public: + //- Symmetric pair of interface names class interfacePair : public Pair { public: - struct hash - { - label operator()(const interfacePair& key) const - { - return word::hash()(key.first()) + word::hash()(key.second()); - } - }; + // Always use symmetric hashing + using hasher = Pair::symmHasher; + + // Always use symmetric hashing (alias) + using hash = Pair::symmHasher; // Constructors - interfacePair() {} // = default + interfacePair() = default; interfacePair(const word& alpha1Name, const word& alpha2Name) : @@ -105,11 +105,7 @@ public: const interfacePair& b ) { - return - ( - ((a.first() == b.first()) && (a.second() == b.second())) - || ((a.first() == b.second()) && (a.second() == b.first())) - ); + return (0 != Pair::compare(a, b)); } friend bool operator!= diff --git a/applications/test/FixedList/Test-FixedList.C b/applications/test/FixedList/Test-FixedList.C index 1257c97091..f75d77e3c8 100644 --- a/applications/test/FixedList/Test-FixedList.C +++ b/applications/test/FixedList/Test-FixedList.C @@ -186,14 +186,14 @@ int main(int argc, char *argv[]) FixedList list1{2, 3, 4, 5}; Info<< "list1:" << list1 - << " hash:" << FixedList::Hash<>()(list1) << nl + << " hash:" << FixedList::hasher()(list1) << nl << " hash:" << Hash>()(list1) << nl; label a[4] = {0, 1, 2, 3}; FixedList list2(a); Info<< "list2:" << list2 - << " hash:" << FixedList::Hash<>()(list2) << nl + << " hash:" << FixedList::hasher()(list2) << nl << " hash:" << Hash>()(list2) << nl; diff --git a/applications/test/HashPtrTable/Test-HashPtrTable.C b/applications/test/HashPtrTable/Test-HashPtrTable.C index db15bdde27..31dfb62200 100644 --- a/applications/test/HashPtrTable/Test-HashPtrTable.C +++ b/applications/test/HashPtrTable/Test-HashPtrTable.C @@ -127,13 +127,13 @@ int main() myTable.insert("sqrt2", autoPtr::New(1.414214)); myTable.insert("euler", autoPtr::New(0.577216)); - HashTable, word, string::hash> myTable1; + HashTable> myTable1; myTable1.set("abc", std::unique_ptr(new double(42.1))); myTable1.set("pi", std::unique_ptr(new double(3.14159))); myTable1.set("natlog", std::unique_ptr(new double(2.718282))); - HashTable, word, string::hash> myTable2; + HashTable> myTable2; myTable2.set("abc", autoPtr(new double(42.1))); myTable2.set("pi", autoPtr(new double(3.14159))); @@ -148,7 +148,7 @@ int main() { auto iter2 = myTable2.find("pi"); - Info<< nl "Got pi="; + Info<< nl << "Got pi="; if (iter2.good()) { Info<< **iter2 << nl; diff --git a/applications/test/HashSet/Test-hashSet.C b/applications/test/HashSet/Test-hashSet.C index 8e2ac0c409..c84231f91f 100644 --- a/applications/test/HashSet/Test-hashSet.C +++ b/applications/test/HashSet/Test-hashSet.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -80,6 +80,11 @@ void printMinMax(const HashSet& set) int main(int argc, char *argv[]) { + Info<< "labelHashSet hasher: " + << typeid(labelHashSet::hasher).name() << nl + << "HashSet