Commit 633e4c9c authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: Use edgeHashes.H and labelPairHashes.H

- avoids some duplicate code.
parent 799490a3
......@@ -25,7 +25,7 @@ License
#include "DelaunayMesh.H"
#include "polyMesh.H"
#include "labelPair.H"
#include "labelPairHashes.H"
#include "PrintTable.H"
#include "pointIOField.H"
#include "scalarIOField.H"
......
......@@ -37,9 +37,7 @@ SourceFiles
#ifndef DelaunayMesh_H
#define DelaunayMesh_H
#include "Pair.H"
#include "HashSet.H"
#include "FixedList.H"
#include "labelPairHashes.H"
#include "boundBox.H"
#include "indexedVertex.H"
#include "CGALTriangulation3Ddefs.H"
......@@ -77,20 +75,6 @@ public:
typedef typename Triangulation::Finite_facets_iterator
Finite_facets_iterator;
typedef HashSet
<
Pair<label>,
FixedList<label, 2>::Hash<>
> labelPairHashSet;
typedef HashTable
<
label,
labelPair,
FixedList<label, 2>::Hash<>
> labelTolabelPairHashTable;
private:
// Private data
......@@ -263,7 +247,7 @@ public:
autoPtr<polyMesh> createMesh
(
const fileName& name,
labelTolabelPairHashTable& vertexMap,
labelPairLookup& vertexMap,
labelList& cellMap,
const bool writeDelaunayData = true
) const;
......
......@@ -337,7 +337,7 @@ Foam::autoPtr<Foam::polyMesh>
Foam::DelaunayMesh<Triangulation>::createMesh
(
const fileName& name,
labelTolabelPairHashTable& vertexMap,
labelPairLookup& vertexMap,
labelList& cellMap,
const bool writeDelaunayData
) const
......
......@@ -31,9 +31,6 @@ License
#include "indexedVertexEnum.H"
#include "IOmanip.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
template<class Triangulation>
......@@ -541,8 +538,7 @@ Foam::label Foam::DistributedDelaunayMesh<Triangulation>::referVertices
{
for
(
typename labelPairHashSet::const_iterator iter
= pointsNotInserted.begin();
labelPairHashSet::const_iterator iter = pointsNotInserted.begin();
iter != pointsNotInserted.end();
++iter
)
......@@ -863,7 +859,7 @@ void Foam::DistributedDelaunayMesh<Triangulation>::sync(const boundBox& bb)
template<class Triangulation>
template<class PointIterator>
typename Foam::DistributedDelaunayMesh<Triangulation>::labelPairHashSet
Foam::labelPairHashSet
Foam::DistributedDelaunayMesh<Triangulation>::rangeInsertReferredWithInfo
(
PointIterator begin,
......
......@@ -71,10 +71,6 @@ public:
typedef typename Triangulation::All_cells_iterator
All_cells_iterator;
typedef typename DelaunayMesh<Triangulation>::labelPairHashSet
labelPairHashSet;
private:
autoPtr<List<boundBox>> allBackgroundMeshBounds_;
......@@ -193,12 +189,6 @@ public:
bool printErrors = true
);
// distributeField();
// Queries
};
......
......@@ -635,7 +635,7 @@ void Foam::cellShapeControlMesh::write() const
}
}
DelaunayMesh<CellSizeDelaunay>::labelTolabelPairHashTable vertexMap;
labelPairLookup vertexMap;
labelList cellMap;
autoPtr<polyMesh> meshPtr = DelaunayMesh<CellSizeDelaunay>::createMesh
......
......@@ -105,7 +105,7 @@ public:
typedef Delaunay::Facet Facet;
typedef Delaunay::Point Point;
typedef List<DynamicList<Pair<labelPair>>> labelPairPairDynListList;
typedef List<DynamicList<labelPairPair>> labelPairPairDynListList;
typedef Tuple2<pointIndexHit, label> pointIndexHitAndFeature;
typedef List<pointIndexHitAndFeature> pointIndexHitAndFeatureList;
......@@ -706,7 +706,7 @@ private:
(
labelList& owner,
labelList& neighbour,
const HashSet<labelPair, labelPair::Hash<>>& deferredCollapseFaces
const labelPairHashSet& deferredCollapseFaces
) const;
//- Check whether the cell sizes are fine enough. Creates a polyMesh.
......
......@@ -673,7 +673,7 @@ void Foam::conformalVoronoiMesh::deferredCollapseFaceSet
(
labelList& owner,
labelList& neighbour,
const HashSet<labelPair, labelPair::Hash<>>& deferredCollapseFaces
const labelPairHashSet& deferredCollapseFaces
) const
{
DynamicList<label> faceLabels;
......@@ -2131,14 +2131,14 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
// Use this processor's vertex index as the master
// for sorting
DynamicList<Pair<labelPair>>& sortingIndex =
DynamicList<labelPairPair>& sortingIndex =
procPatchSortingIndex[patchIndex];
if (vB->internalOrBoundaryPoint() && vB->referred())
{
sortingIndex.append
(
Pair<labelPair>
labelPairPair
(
labelPair(vA->index(), vA->procIndex()),
labelPair(vB->index(), vB->procIndex())
......@@ -2149,7 +2149,7 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
{
sortingIndex.append
(
Pair<labelPair>
labelPairPair
(
labelPair(vB->index(), vB->procIndex()),
labelPair(vA->index(), vA->procIndex())
......@@ -2162,14 +2162,14 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
// Use the other processor's vertex index as the
// master for sorting
DynamicList<Pair<labelPair>>& sortingIndex =
DynamicList<labelPairPair>& sortingIndex =
procPatchSortingIndex[patchIndex];
if (vA->internalOrBoundaryPoint() && vA->referred())
{
sortingIndex.append
(
Pair<labelPair>
labelPairPair
(
labelPair(vA->index(), vA->procIndex()),
labelPair(vB->index(), vB->procIndex())
......@@ -2180,7 +2180,7 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
{
sortingIndex.append
(
Pair<labelPair>
labelPairPair
(
labelPair(vB->index(), vB->procIndex()),
labelPair(vA->index(), vA->procIndex())
......@@ -2463,7 +2463,7 @@ void Foam::conformalVoronoiMesh::sortProcPatches
faceList& faces = patchFaces[patchi];
labelList& owner = patchOwners[patchi];
DynamicList<label>& slaves = patchPointPairSlaves[patchi];
DynamicList<Pair<labelPair>>& sortingIndices
DynamicList<labelPairPair>& sortingIndices
= patchSortingIndices[patchi];
if (!sortingIndices.empty())
......
......@@ -199,7 +199,7 @@ void Foam::conformalVoronoiMesh::writeMesh(const fileName& instance)
Info<< nl << "Writing " << "tetDualMesh" << endl;
DistributedDelaunayMesh<Delaunay>::labelTolabelPairHashTable vertexMap;
labelPairLookup vertexMap;
labelList cellMap;
autoPtr<polyMesh> tetMesh =
createMesh("tetDualMesh", vertexMap, cellMap);
......
......@@ -28,7 +28,7 @@ License
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
template<class Triangulation>
inline Foam::Pair<Foam::labelPair>
inline Foam::labelPairPair
Foam::pointPairs<Triangulation>::orderPointPair
(
const labelPair& vA,
......@@ -38,8 +38,8 @@ Foam::pointPairs<Triangulation>::orderPointPair
return
(
(vA < vB)
? Pair<labelPair>(vA, vB)
: Pair<labelPair>(vB, vA)
? labelPairPair(vA, vB)
: labelPairPair(vB, vA)
);
}
......@@ -85,7 +85,7 @@ inline bool Foam::pointPairs<Triangulation>::insertPointPair
template<class Triangulation>
Foam::pointPairs<Triangulation>::pointPairs(const Triangulation& triangulation)
:
ptPairTable(),
StorageContainer(),
triangulation_(triangulation)
{}
......@@ -181,7 +181,7 @@ void Foam::pointPairs<Triangulation>::reIndex(const Map<label>& oldToNewIndices)
forAllConstIter(pointPairs, *this, iter)
{
Pair<labelPair> e = iter.key();
labelPairPair e = iter.key();
labelPair& start = e.first();
labelPair& end = e.second();
......
......@@ -39,20 +39,13 @@ Description
#ifndef pointPairs_H
#define pointPairs_H
#include "labelPair.H"
#include "HashSet.H"
#include "labelPairHashes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef HashSet
<
Pair<labelPair>,
FixedList<labelPair, 2>::Hash<>
> ptPairTable;
/*---------------------------------------------------------------------------*\
Class pointPairs Declaration
\*---------------------------------------------------------------------------*/
......@@ -60,11 +53,12 @@ typedef HashSet
template<class Triangulation>
class pointPairs
:
public ptPairTable
public HashSet<labelPairPair, labelPairPair::Hash<>>
{
// Private typedefs
typedef typename Triangulation::Vertex_handle Vertex_handle;
typedef HashSet<labelPairPair, labelPairPair::Hash<>> StorageContainer;
typedef typename Triangulation::Vertex_handle Vertex_handle;
// Private data
......@@ -74,7 +68,7 @@ class pointPairs
// Private Member Functions
inline Pair<labelPair> orderPointPair
inline labelPairPair orderPointPair
(
const labelPair& vA,
const labelPair& vB
......
......@@ -45,7 +45,7 @@ Description
#include "timeSelector.H"
#include "OFstream.H"
#include "passiveParticleCloud.H"
#include "labelPairHashes.H"
#include "SortableList.H"
#include "IOobjectList.H"
#include "PtrList.H"
......@@ -133,8 +133,6 @@ int main(int argc, char *argv[])
fileName vtkPath(runTime.path()/"VTK");
mkDir(vtkPath);
typedef HashTable<label, labelPair, labelPair::Hash<>> trackTableType;
forAll(timeDirs, timeI)
{
runTime.setTime(timeDirs[timeI], timeI);
......@@ -168,13 +166,14 @@ int main(int argc, char *argv[])
label nTracks = 0;
{
trackTableType trackTable;
labelPairLookup trackTable;
forAll(particles, i)
{
const label origProc = particles[i].origProc();
const label origId = particles[i].origId();
const trackTableType::const_iterator& iter =
labelPairLookup::const_iterator iter =
trackTable.find(labelPair(origProc, origId));
if (iter == trackTable.end())
......
......@@ -25,8 +25,7 @@ License
#include "cyclicGAMGInterface.H"
#include "addToRunTimeSelectionTable.H"
#include "labelPair.H"
#include "HashTable.H"
#include "labelPairHashes.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -96,10 +95,7 @@ Foam::cyclicGAMGInterface::cyclicGAMGInterface
);
// From coarse cell pair to coarse face
HashTable<label, labelPair, labelPair::Hash<>> cellsToCoarseFace
(
2*localRestrictAddressing.size()
);
labelPairLookup cellsToCoarseFace(2*localRestrictAddressing.size());
forAll(localRestrictAddressing, ffi)
{
......@@ -126,8 +122,7 @@ Foam::cyclicGAMGInterface::cyclicGAMGInterface
);
}
HashTable<label, labelPair, labelPair::Hash<>>::const_iterator fnd =
cellsToCoarseFace.find(cellPair);
labelPairLookup::const_iterator fnd = cellsToCoarseFace.find(cellPair);
if (fnd == cellsToCoarseFace.end())
{
......
......@@ -25,8 +25,7 @@ License
#include "processorGAMGInterface.H"
#include "addToRunTimeSelectionTable.H"
#include "HashTable.H"
#include "labelPair.H"
#include "labelPairHashes.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -84,10 +83,7 @@ Foam::processorGAMGInterface::processorGAMGInterface
);
// From coarse cell pair to coarse face
HashTable<label, labelPair, labelPair::Hash<>> cellsToCoarseFace
(
2*localRestrictAddressing.size()
);
labelPairLookup cellsToCoarseFace(2*localRestrictAddressing.size());
forAll(localRestrictAddressing, ffi)
{
......@@ -114,8 +110,7 @@ Foam::processorGAMGInterface::processorGAMGInterface
);
}
HashTable<label, labelPair, labelPair::Hash<>>::const_iterator fnd =
cellsToCoarseFace.find(cellPair);
labelPairLookup::const_iterator fnd = cellsToCoarseFace.find(cellPair);
if (fnd == cellsToCoarseFace.end())
{
......
......@@ -25,7 +25,7 @@ License
#include "mapDistributeBase.H"
#include "commSchedule.H"
#include "HashSet.H"
#include "labelPairHashes.H"
#include "globalIndex.H"
#include "ListOps.H"
......@@ -50,7 +50,7 @@ Foam::List<Foam::labelPair> Foam::mapDistributeBase::schedule
List<labelPair> allComms;
{
HashSet<labelPair, labelPair::Hash<>> commsSet(Pstream::nProcs());
labelPairHashSet commsSet(Pstream::nProcs());
// Find what communication is required
forAll(subMap, proci)
......
......@@ -25,8 +25,7 @@ License
#include "checkFireEdges.H"
#include "polyMesh.H"
#include "edge.H"
#include "HashSet.H"
#include "edgeHashes.H"
#include "ListOps.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -69,7 +68,6 @@ Foam::label Foam::checkFireEdges
{
label nFailedEdges = 0;
const bool fullCheck = true;
typedef HashSet<edge, Hash<edge>> edgeHashSet;
Info<< "Checking edges according to AVL/FIRE on-the-fly methodology..."
<< endl;
......
......@@ -40,6 +40,7 @@ License
#include "syncTools.H"
#include "CompactListList.H"
#include "fvMeshTools.H"
#include "labelPairHashes.H"
#include "ListOps.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -982,7 +983,7 @@ void Foam::fvMeshDistribute::findCouples
{
// Store domain neighbour as map so we can easily look for pair
// with same face+proc.
HashTable<label, labelPair, labelPair::Hash<>> map(domainFace.size());
labelPairLookup map(domainFace.size());
forAll(domainProc, bFacei)
{
......@@ -1009,8 +1010,7 @@ void Foam::fvMeshDistribute::findCouples
{
labelPair myData(sourceFace[bFacei], sourceProc[bFacei]);
HashTable<label, labelPair, labelPair::Hash<>>::const_iterator
iter = map.find(myData);
labelPairLookup::const_iterator iter = map.find(myData);
if (iter != map.end())
{
......
......@@ -36,6 +36,7 @@ License
#include "faceSet.H"
#include "cellSet.H"
#include "pointSet.H"
#include "labelPairHashes.H"
#include "OFstream.H"
#include "Time.H"
#include "FaceCellWave.H"
......@@ -4625,10 +4626,9 @@ void Foam::hexRef8::checkMesh() const
if (pp.coupled())
{
// Check how many faces between owner and neighbour. Should
// be only one.
HashTable<label, labelPair, labelPair::Hash<>>
cellToFace(2*pp.size());
// Check how many faces between owner and neighbour.
// Should be only one.
labelPairLookup cellToFace(2*pp.size());
label facei = pp.start();
......
......@@ -128,7 +128,7 @@ void Foam::ParticleTracks<CloudType>::postFace
<< "Cloud storage not allocated" << abort(FatalError);
}
hitTableType::iterator iter =
labelPairLookup::iterator iter =
faceHitCounter_.find(labelPair(p.origProc(), p.origId()));
label localI = -1;
......
......@@ -39,6 +39,7 @@ SourceFiles
#define ParticleTracks_H
#include "CloudFunctionObject.H"
#include "labelPairHashes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -61,9 +62,6 @@ class ParticleTracks
//- Convenience typedef for parcel type
typedef typename CloudType::parcelType parcelType;
//- Convenience typedef for hash hit-table
typedef HashTable<label, labelPair, typename labelPair::Hash<>>
hitTableType;
//- Number of face-hit intervals between storing parcel data
label trackInterval_;
......@@ -75,7 +73,7 @@ class ParticleTracks
Switch resetOnWrite_;
//- Table of number of times a particle has hit a face
hitTableType faceHitCounter_;
labelPairLookup faceHitCounter_;
//- Pointer to the cloud storage
autoPtr<Cloud<parcelType>> cloudPtr_;
......@@ -135,8 +133,8 @@ public:
//- Return const access to the reset on write flag
inline const Switch& resetOnWrite() const;
//- Rerurn the table of number of times a particle has hit a face
inline const hitTableType& faceHitCounter() const;
//- Return the table of number of times a particle has hit a face
inline const labelPairLookup& faceHitCounter() const;
//- Return const access to the cloud
inline const Cloud<parcelType>& cloud() const;
......
Markdown is supported
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