mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add missing Hash function for List/UList (issue #966)
- there were previously no hashing mechanisms for lists so they would fall back to the definition for primitives and hash the memory location of the allocated List object. - provide a UList::Hash<> sub-class for inheritance, and also a global specialization for UList<T>, List<T> such that the hash value for List<List<T>> cascades properly. - provide similar function in triFace to ensure that it remains similar in behaviour to face. - added SymmHash to Pair, for use when order is unimportant. STYLE: use string::hash() more consistently - no particular reason to use Hash<word>() which forwards to string::hash() anyhow
This commit is contained in:
@ -26,9 +26,8 @@ License
|
||||
#include "cuttingPlane.H"
|
||||
#include "fvMesh.H"
|
||||
#include "volFields.H"
|
||||
#include "linePointRef.H"
|
||||
#include "meshTools.H"
|
||||
#include "EdgeMap.H"
|
||||
#include "edgeHashes.H"
|
||||
#include "HashOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
@ -80,29 +79,8 @@ namespace Foam
|
||||
}
|
||||
|
||||
|
||||
//- Hash specialization for labelList. Hash incrementally.
|
||||
template<>
|
||||
inline unsigned Hash<labelList>::operator()
|
||||
(
|
||||
const labelList& list,
|
||||
unsigned seed
|
||||
) const
|
||||
{
|
||||
return Hasher(list.cdata(), list.size()*sizeof(label), seed);
|
||||
}
|
||||
|
||||
//- Hash specialization for labelList
|
||||
template<>
|
||||
inline unsigned Hash<labelList>::operator()
|
||||
(
|
||||
const labelList& list
|
||||
) const
|
||||
{
|
||||
return Hash<labelList>()(list, 0);
|
||||
}
|
||||
|
||||
//- For hashing face point labels, which are pre-sorted.
|
||||
typedef HashSet<labelList, Hash<labelList>> labelListHashSet;
|
||||
typedef HashSet<labelList, labelList::Hash<>> labelListHashSet;
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
@ -354,6 +332,7 @@ void Foam::cuttingPlane::walkCellCuts
|
||||
{
|
||||
edge e(f.faceEdge(fp));
|
||||
|
||||
// Action #1: detect edge intersection and orient edge
|
||||
if (!intersectEdgeOrient(sides, e))
|
||||
{
|
||||
continue;
|
||||
@ -388,6 +367,7 @@ void Foam::cuttingPlane::walkCellCuts
|
||||
const point& p0 = points[e[0]];
|
||||
const point& p1 = points[e[1]];
|
||||
|
||||
// Action #2: edge cut alpha
|
||||
const scalar alpha =
|
||||
this->lineIntersect(linePointRef(p0, p1));
|
||||
|
||||
@ -540,6 +520,7 @@ void Foam::cuttingPlane::walkCellCuts
|
||||
|
||||
face f(localFaceLoop);
|
||||
|
||||
// Action #3: orient face
|
||||
// Orient face to point in the same direction as the plane normal
|
||||
if ((f.areaNormal(dynCutPoints) & this->normal()) < 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user