BUG: incorrect HashTable / HashSet instances
- Eg instead of using labelHashSet, used HashSet<label> which uses the string::hash for hashing. Other places inadvertently using the string::hash instead of Hash<label> for hashing. STYLE: use Map<..> instead of HashTable<.., label, Hash<label>> - reduces clutter
This commit is contained in:
parent
806b668418
commit
09a6e94073
@ -56,7 +56,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
setA = { "kjhk", "kjhk2", "abced" };
|
setA = { "kjhk", "kjhk2", "abced" };
|
||||||
|
|
||||||
HashTable<label, word> tableA
|
HashTable<label> tableA
|
||||||
{
|
{
|
||||||
{ "value1", 1 },
|
{ "value1", 1 },
|
||||||
{ "value2", 2 },
|
{ "value2", 2 },
|
||||||
|
@ -853,7 +853,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
labelList own(boundaryFaces.size(), -1);
|
labelList own(boundaryFaces.size(), -1);
|
||||||
labelList nei(boundaryFaces.size(), -1);
|
labelList nei(boundaryFaces.size(), -1);
|
||||||
HashTable<label, label> faceToCell[2];
|
Map<label> faceToCell[2];
|
||||||
|
|
||||||
{
|
{
|
||||||
HashTable<label, face, Hash<face>> faceToFaceID(boundaryFaces.size());
|
HashTable<label, face, Hash<face>> faceToFaceID(boundaryFaces.size());
|
||||||
|
@ -54,13 +54,6 @@ Foam::PrintTable<KeyType, DataType>::PrintTable
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class KeyType, class DataType>
|
|
||||||
Foam::PrintTable<KeyType, DataType>::~PrintTable()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class KeyType, class DataType>
|
template<class KeyType, class DataType>
|
||||||
@ -71,7 +64,7 @@ void Foam::PrintTable<KeyType, DataType>::print
|
|||||||
const bool printAverage
|
const bool printAverage
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
HashTable<HashTable<DataType, label>, KeyType> combinedTable;
|
HashTable<Map<DataType>, KeyType> combinedTable;
|
||||||
|
|
||||||
List<HashTableData> procData(Pstream::nProcs(), HashTableData());
|
List<HashTableData> procData(Pstream::nProcs(), HashTableData());
|
||||||
|
|
||||||
@ -90,36 +83,25 @@ void Foam::PrintTable<KeyType, DataType>::print
|
|||||||
{
|
{
|
||||||
const HashTableData& procIData = procData[proci];
|
const HashTableData& procIData = procData[proci];
|
||||||
|
|
||||||
for
|
forAllConstIters(procIData, iter)
|
||||||
(
|
|
||||||
typename HashTableData::const_iterator iter = procIData.begin();
|
|
||||||
iter != procIData.end();
|
|
||||||
++iter
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (!combinedTable.found(iter.key()))
|
if (!combinedTable.found(iter.key()))
|
||||||
{
|
{
|
||||||
combinedTable.insert
|
combinedTable.insert
|
||||||
(
|
(
|
||||||
iter.key(),
|
iter.key(),
|
||||||
HashTable<DataType, label>()
|
Map<DataType>()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
HashTable<DataType, label>& key = combinedTable[iter.key()];
|
Map<DataType>& key = combinedTable[iter.key()];
|
||||||
|
|
||||||
key.insert(proci, iter());
|
key.insert(proci, iter.object());
|
||||||
|
|
||||||
for
|
forAllConstIters(key, dataIter)
|
||||||
(
|
|
||||||
typename HashTable<DataType, label>
|
|
||||||
::const_iterator dataIter = key.begin();
|
|
||||||
dataIter != key.end();
|
|
||||||
++dataIter
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
std::ostringstream buf;
|
std::ostringstream buf;
|
||||||
buf << dataIter();
|
buf << dataIter.object();
|
||||||
|
|
||||||
largestDataLength = max
|
largestDataLength = max
|
||||||
(
|
(
|
||||||
@ -172,7 +154,7 @@ void Foam::PrintTable<KeyType, DataType>::print
|
|||||||
|
|
||||||
forAll(sortedTable, keyI)
|
forAll(sortedTable, keyI)
|
||||||
{
|
{
|
||||||
const HashTable<DataType, label>& procDataList
|
const Map<DataType>& procDataList
|
||||||
= combinedTable[sortedTable[keyI]];
|
= combinedTable[sortedTable[keyI]];
|
||||||
|
|
||||||
os.width(largestKeyLength);
|
os.width(largestKeyLength);
|
||||||
|
@ -101,7 +101,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
~PrintTable();
|
~PrintTable() = default;
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
@ -33,18 +33,12 @@ Foam::pointFeatureEdgesTypes::pointFeatureEdgesTypes
|
|||||||
const label pointLabel
|
const label pointLabel
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
HashTable<label, extendedFeatureEdgeMesh::edgeStatus>(),
|
HashTable<label, extendedFeatureEdgeMesh::edgeStatus, Hash<label>>(),
|
||||||
feMesh_(feMesh),
|
feMesh_(feMesh),
|
||||||
pointLabel_(pointLabel)
|
pointLabel_(pointLabel)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::pointFeatureEdgesTypes::~pointFeatureEdgesTypes()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::List<Foam::extendedFeatureEdgeMesh::edgeStatus>
|
Foam::List<Foam::extendedFeatureEdgeMesh::edgeStatus>
|
||||||
@ -79,18 +73,12 @@ Foam::Ostream& Foam::operator<<
|
|||||||
{
|
{
|
||||||
os << "Point = " << p.pointLabel_ << endl;
|
os << "Point = " << p.pointLabel_ << endl;
|
||||||
|
|
||||||
for
|
forAllConstIters(p, iter)
|
||||||
(
|
|
||||||
HashTable<label, extendedFeatureEdgeMesh::edgeStatus>
|
|
||||||
::const_iterator iter = p.cbegin();
|
|
||||||
iter != p.cend();
|
|
||||||
++iter
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
os << " "
|
os << " "
|
||||||
<< extendedFeatureEdgeMesh::edgeStatusNames_[iter.key()]
|
<< extendedFeatureEdgeMesh::edgeStatusNames_[iter.key()]
|
||||||
<< " = "
|
<< " = "
|
||||||
<< iter()
|
<< iter.object()
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ Ostream& operator<<(Ostream&, const pointFeatureEdgesTypes&);
|
|||||||
//- Hold the types of feature edges attached to the point.
|
//- Hold the types of feature edges attached to the point.
|
||||||
class pointFeatureEdgesTypes
|
class pointFeatureEdgesTypes
|
||||||
:
|
:
|
||||||
public HashTable<label, extendedFeatureEdgeMesh::edgeStatus>
|
public HashTable<label, extendedFeatureEdgeMesh::edgeStatus, Hash<label>>
|
||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
~pointFeatureEdgesTypes();
|
~pointFeatureEdgesTypes() = default;
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
@ -38,7 +38,7 @@ Note
|
|||||||
The HashSet iterator dereferences to the key, so the following
|
The HashSet iterator dereferences to the key, so the following
|
||||||
range-for works as expected:
|
range-for works as expected:
|
||||||
\code
|
\code
|
||||||
HashSet<label> someLabels{10, 20, 30, 40, ...};
|
labelHashSet someLabels{10, 20, 30, 40, ...};
|
||||||
for (const label i : someLabels)
|
for (const label i : someLabels)
|
||||||
{
|
{
|
||||||
Info<< "val:" << i << nl;
|
Info<< "val:" << i << nl;
|
||||||
@ -55,7 +55,7 @@ Typedef
|
|||||||
Foam::labelHashSet
|
Foam::labelHashSet
|
||||||
|
|
||||||
Description
|
Description
|
||||||
A HashSet with label keys.
|
A HashSet with label keys and label hasher.
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -415,7 +415,7 @@ HashSet<Key,Hash> operator^
|
|||||||
//- A HashSet with word keys.
|
//- A HashSet with word keys.
|
||||||
typedef HashSet<> wordHashSet;
|
typedef HashSet<> wordHashSet;
|
||||||
|
|
||||||
//- A HashSet with label keys.
|
//- A HashSet with label keys and label hasher.
|
||||||
typedef HashSet<label, Hash<label>> labelHashSet;
|
typedef HashSet<label, Hash<label>> labelHashSet;
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -25,7 +25,7 @@ License
|
|||||||
|
|
||||||
#include "FIREMeshWriter.H"
|
#include "FIREMeshWriter.H"
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
#include "HashTable.H"
|
#include "Map.H"
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
#include "processorPolyPatch.H"
|
#include "processorPolyPatch.H"
|
||||||
|
|
||||||
@ -117,8 +117,8 @@ bool Foam::fileFormats::FIREMeshWriter::writeSelections(OSstream& os) const
|
|||||||
|
|
||||||
// remap name between patches and cell-zones conflicts!
|
// remap name between patches and cell-zones conflicts!
|
||||||
|
|
||||||
HashTable<word, label> patchNames;
|
Map<word> patchNames;
|
||||||
HashTable<word, label> zoneNames;
|
Map<word> zoneNames;
|
||||||
|
|
||||||
wordHashSet usedPatchNames;
|
wordHashSet usedPatchNames;
|
||||||
wordHashSet usedZoneNames;
|
wordHashSet usedZoneNames;
|
||||||
@ -245,12 +245,6 @@ Foam::fileFormats::FIREMeshWriter::FIREMeshWriter
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::fileFormats::FIREMeshWriter::~FIREMeshWriter()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::fileFormats::FIREMeshWriter::write(const fileName& meshName) const
|
bool Foam::fileFormats::FIREMeshWriter::write(const fileName& meshName) const
|
||||||
|
@ -103,7 +103,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~FIREMeshWriter();
|
virtual ~FIREMeshWriter() = default;
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
@ -59,12 +59,6 @@ Foam::vtk::vtuSizing::vtuSizing()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::vtk::vtuSizing::~vtuSizing()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::vtk::vtuSizing::reset
|
void Foam::vtk::vtuSizing::reset
|
||||||
@ -83,7 +77,7 @@ void Foam::vtk::vtuSizing::reset
|
|||||||
const cellShapeList& shapes = mesh.cellShapes();
|
const cellShapeList& shapes = mesh.cellShapes();
|
||||||
|
|
||||||
// Unique vertex labels per polyhedral
|
// Unique vertex labels per polyhedral
|
||||||
HashSet<label> hashUniqId(2*256);
|
labelHashSet hashUniqId(2*256);
|
||||||
|
|
||||||
decompose_ = decompose;
|
decompose_ = decompose;
|
||||||
nCells_ = mesh.nCells();
|
nCells_ = mesh.nCells();
|
||||||
|
@ -203,7 +203,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
~vtuSizing();
|
~vtuSizing() = default;
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
@ -224,7 +224,7 @@ void Foam::vtk::vtuSizing::populateArrays
|
|||||||
const labelList& owner = mesh.faceOwner();
|
const labelList& owner = mesh.faceOwner();
|
||||||
|
|
||||||
// Unique vertex labels per polyhedral
|
// Unique vertex labels per polyhedral
|
||||||
HashSet<label> hashUniqId(2*256);
|
labelHashSet hashUniqId(2*256);
|
||||||
|
|
||||||
// Index into vertLabels, faceLabels for normal cells
|
// Index into vertLabels, faceLabels for normal cells
|
||||||
label nVertLabels = 0;
|
label nVertLabels = 0;
|
||||||
|
@ -146,7 +146,7 @@ bool Foam::functionObjects::particleDistribution::write()
|
|||||||
// Tag field present - generate distribution per tag
|
// Tag field present - generate distribution per tag
|
||||||
const IOField<label>& tag =
|
const IOField<label>& tag =
|
||||||
cloudObr.lookupObject<IOField<label>>(tagFieldName_);
|
cloudObr.lookupObject<IOField<label>>(tagFieldName_);
|
||||||
const HashSet<label> tagMap(tag);
|
const labelHashSet tagMap(tag);
|
||||||
const label tagMax = tagMap.size();
|
const label tagMax = tagMap.size();
|
||||||
|
|
||||||
List<DynamicList<label>> tagAddr(tagMax);
|
List<DynamicList<label>> tagAddr(tagMax);
|
||||||
|
@ -451,8 +451,8 @@ void Foam::triSurfaceTools::getMergedEdges
|
|||||||
const triSurface& surf,
|
const triSurface& surf,
|
||||||
const label edgeI,
|
const label edgeI,
|
||||||
const labelHashSet& collapsedFaces,
|
const labelHashSet& collapsedFaces,
|
||||||
HashTable<label, label, Hash<label>>& edgeToEdge,
|
Map<label>& edgeToEdge,
|
||||||
HashTable<label, label, Hash<label>>& edgeToFace
|
Map<label>& edgeToFace
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const edge& e = surf.edges()[edgeI];
|
const edge& e = surf.edges()[edgeI];
|
||||||
@ -534,8 +534,8 @@ Foam::scalar Foam::triSurfaceTools::edgeCosAngle
|
|||||||
const label v1,
|
const label v1,
|
||||||
const point& pt,
|
const point& pt,
|
||||||
const labelHashSet& collapsedFaces,
|
const labelHashSet& collapsedFaces,
|
||||||
const HashTable<label, label, Hash<label>>& edgeToEdge,
|
const Map<label>& edgeToEdge,
|
||||||
const HashTable<label, label, Hash<label>>& edgeToFace,
|
const Map<label>& edgeToFace,
|
||||||
const label facei,
|
const label facei,
|
||||||
const label edgeI
|
const label edgeI
|
||||||
)
|
)
|
||||||
@ -630,8 +630,8 @@ Foam::scalar Foam::triSurfaceTools::collapseMinCosAngle
|
|||||||
const label v1,
|
const label v1,
|
||||||
const point& pt,
|
const point& pt,
|
||||||
const labelHashSet& collapsedFaces,
|
const labelHashSet& collapsedFaces,
|
||||||
const HashTable<label, label, Hash<label>>& edgeToEdge,
|
const Map<label>& edgeToEdge,
|
||||||
const HashTable<label, label, Hash<label>>& edgeToFace
|
const Map<label>& edgeToFace
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const labelList& v1Faces = surf.pointFaces()[v1];
|
const labelList& v1Faces = surf.pointFaces()[v1];
|
||||||
@ -684,8 +684,8 @@ bool Foam::triSurfaceTools::collapseCreatesFold
|
|||||||
const label v1,
|
const label v1,
|
||||||
const point& pt,
|
const point& pt,
|
||||||
const labelHashSet& collapsedFaces,
|
const labelHashSet& collapsedFaces,
|
||||||
const HashTable<label, label, Hash<label>>& edgeToEdge,
|
const Map<label>& edgeToEdge,
|
||||||
const HashTable<label, label, Hash<label>>& edgeToFace,
|
const Map<label>& edgeToFace,
|
||||||
const scalar minCos
|
const scalar minCos
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -749,7 +749,7 @@ bool Foam::triSurfaceTools::collapseCreatesFold
|
|||||||
// // neighbours actually contains the
|
// // neighbours actually contains the
|
||||||
// // edge with which triangle connects to collapsedFaces.
|
// // edge with which triangle connects to collapsedFaces.
|
||||||
//
|
//
|
||||||
// HashTable<label, label, Hash<label>> neighbours;
|
// Map<label> neighbours;
|
||||||
//
|
//
|
||||||
// labelList collapsed = collapsedFaces.toc();
|
// labelList collapsed = collapsedFaces.toc();
|
||||||
//
|
//
|
||||||
|
@ -54,6 +54,7 @@ SourceFiles
|
|||||||
#include "triadFieldFwd.H"
|
#include "triadFieldFwd.H"
|
||||||
#include "DynamicList.H"
|
#include "DynamicList.H"
|
||||||
#include "HashSet.H"
|
#include "HashSet.H"
|
||||||
|
#include "Map.H"
|
||||||
#include "FixedList.H"
|
#include "FixedList.H"
|
||||||
#include "Pair.H"
|
#include "Pair.H"
|
||||||
#include "vector2D.H"
|
#include "vector2D.H"
|
||||||
@ -159,8 +160,8 @@ class triSurfaceTools
|
|||||||
const triSurface& surf,
|
const triSurface& surf,
|
||||||
const label edgeI,
|
const label edgeI,
|
||||||
const labelHashSet& collapsedFaces,
|
const labelHashSet& collapsedFaces,
|
||||||
HashTable<label, label, Hash<label>>& edgeToEdge,
|
Map<label>& edgeToEdge,
|
||||||
HashTable<label, label, Hash<label>>& edgeToFace
|
Map<label>& edgeToFace
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Calculates (cos of) angle across edgeI of facei,
|
//- Calculates (cos of) angle across edgeI of facei,
|
||||||
@ -172,8 +173,8 @@ class triSurfaceTools
|
|||||||
const label v1,
|
const label v1,
|
||||||
const point& pt,
|
const point& pt,
|
||||||
const labelHashSet& collapsedFaces,
|
const labelHashSet& collapsedFaces,
|
||||||
const HashTable<label, label, Hash<label>>& edgeToEdge,
|
const Map<label>& edgeToEdge,
|
||||||
const HashTable<label, label, Hash<label>>& edgeToFace,
|
const Map<label>& edgeToFace,
|
||||||
const label facei,
|
const label facei,
|
||||||
const label edgeI
|
const label edgeI
|
||||||
);
|
);
|
||||||
@ -188,8 +189,8 @@ class triSurfaceTools
|
|||||||
const label v1,
|
const label v1,
|
||||||
const point& pt,
|
const point& pt,
|
||||||
const labelHashSet& collapsedFaces,
|
const labelHashSet& collapsedFaces,
|
||||||
const HashTable<label, label, Hash<label>>& edgeToEdge,
|
const Map<label>& edgeToEdge,
|
||||||
const HashTable<label, label, Hash<label>>& edgeToFace
|
const Map<label>& edgeToFace
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Like collapseMinCosAngle but return true for value < minCos
|
//- Like collapseMinCosAngle but return true for value < minCos
|
||||||
@ -199,8 +200,8 @@ class triSurfaceTools
|
|||||||
const label v1,
|
const label v1,
|
||||||
const point& pt,
|
const point& pt,
|
||||||
const labelHashSet& collapsedFaces,
|
const labelHashSet& collapsedFaces,
|
||||||
const HashTable<label, label, Hash<label>>& edgeToEdge,
|
const Map<label>& edgeToEdge,
|
||||||
const HashTable<label, label, Hash<label>>& edgeToFace,
|
const Map<label>& edgeToFace,
|
||||||
const scalar minCos
|
const scalar minCos
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -210,7 +211,7 @@ class triSurfaceTools
|
|||||||
//(
|
//(
|
||||||
// const triSurface& surf,
|
// const triSurface& surf,
|
||||||
// const label edgeI,
|
// const label edgeI,
|
||||||
// const HashTable<bool, label, Hash<label>>& collapsedFaces
|
// const Map<bool>& collapsedFaces
|
||||||
//);
|
//);
|
||||||
|
|
||||||
// Tracking
|
// Tracking
|
||||||
|
Loading…
Reference in New Issue
Block a user