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