Commit 9ce984d1 authored by Mark Olesen's avatar Mark Olesen
Browse files

added edge/triFace to the hashing tests

parent 7544164d
......@@ -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)
)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -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<edge>() << endl << endl;
edgeList lst(is);
forAll(lst, i)
{
unsigned hash1 = Hash<edge>()(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<triFace>() << endl << endl;
triFaceList lst(is);
forAll(lst, i)
{
// direct value
unsigned hash1 = Hash<triFace>()(lst[i]);
unsigned hash2 = FixedList<label, 3>::Hash<>()(lst[i]);
Info<< hex << hash1 << " (as FixedList: " << hash2
<< "): " << dec << lst[i] << endl;
}
}
else
{
Info<< "unknown type: " << listType << endl;
}
}
return 0;
......
......@@ -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<label, FixedList<label, 2>, FixedList<label, 2>::Hash<> >
labelPairLookup;
typedef HashTable
<
label,
FixedList<label, 2>,
FixedList<label, 2>::Hash<>
> labelPairLookup;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment