diff --git a/applications/test/Hashing/hashingTests b/applications/test/Hashing/hashingTests index 7c549ffa0f..162854bbef 100644 --- a/applications/test/Hashing/hashingTests +++ b/applications/test/Hashing/hashingTests @@ -36,5 +36,24 @@ labelListList (0 1 100 1000) ) +// edges are hashed commutatively +edgeList +( + (0 1) + (1 0) + (45 100) + (100 45) + (128 1000) + (1000 128) +) + +// triFaces are also hashed commutatively (via multiply/add) +triFaceList +( + (10 20 30) + (30 20 10) + (20 10 30) +) + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/test/Hashing/testHashing.C b/applications/test/Hashing/testHashing.C index 00af2b962c..24a198a74f 100644 --- a/applications/test/Hashing/testHashing.C +++ b/applications/test/Hashing/testHashing.C @@ -36,6 +36,8 @@ Description #include "stringList.H" #include "labelList.H" #include "labelPair.H" +#include "edgeList.H" +#include "triFaceList.H" #include "Hash.H" @@ -117,6 +119,44 @@ int main(int argc, char *argv[]) } } + else if (listType == "edgeList") + { + Info<<"contiguous = " << contiguous() << endl << endl; + + edgeList lst(is); + + forAll(lst, i) + { + unsigned hash1 = Hash()(lst[i]); + + // as FixedList + unsigned hash2 = labelPair::Hash<>()(lst[i]); + + Info<< hex << hash1 << " (as FixedList: " << hash2 + << "): " << dec << lst[i] << endl; + } + } + else if (listType == "triFaceList") + { + Info<<"contiguous = " << contiguous() << endl << endl; + + triFaceList lst(is); + + forAll(lst, i) + { + // direct value + unsigned hash1 = Hash()(lst[i]); + unsigned hash2 = FixedList::Hash<>()(lst[i]); + + Info<< hex << hash1 << " (as FixedList: " << hash2 + << "): " << dec << lst[i] << endl; + } + } + else + { + Info<< "unknown type: " << listType << endl; + } + } return 0; diff --git a/src/triSurface/tools/labelPair/labelPairLookup.H b/src/triSurface/tools/labelPair/labelPairLookup.H index 566c2c1870..dc9d56834d 100644 --- a/src/triSurface/tools/labelPair/labelPairLookup.H +++ b/src/triSurface/tools/labelPair/labelPairLookup.H @@ -26,26 +26,31 @@ Typedef Foam::labelPairLookup Description - Hash for two labels to other label. Used for e.g. for face1, face2 to - shared edge. + A HashTable for two labels to another label. + Used for e.g. for face1, face2 to shared edge. - Note: do NOT use edge! Our two faces are non commutative, first face is - from surface1, second face is from surface2. +Note + The hash table is based on a FixedList and not edge, since an edge + hashes commutatively! \*---------------------------------------------------------------------------*/ #ifndef labelPairLookup_H #define labelPairLookup_H +#include "FixedList.H" #include "HashTable.H" -#include "edge.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - typedef HashTable, FixedList::Hash<> > - labelPairLookup; + typedef HashTable + < + label, + FixedList, + FixedList::Hash<> + > labelPairLookup; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //