BUG: primitiveMesh: cellPoints, cellEdges inconsistent API. Fixes #703.

This commit is contained in:
mattijs
2018-01-15 14:10:09 +00:00
parent ad82072d0f
commit effe4ce217
5 changed files with 20 additions and 14 deletions

View File

@ -822,6 +822,7 @@ public:
const labelList& cellPoints const labelList& cellPoints
( (
const label celli, const label celli,
labelHashSet&,
DynamicList<label>& DynamicList<label>&
) const; ) const;
@ -876,6 +877,7 @@ public:
const labelList& cellEdges const labelList& cellEdges
( (
const label celli, const label celli,
labelHashSet&,
DynamicList<label>& DynamicList<label>&
) const; ) const;

View File

@ -58,6 +58,7 @@ const Foam::labelListList& Foam::primitiveMesh::cellPoints() const
const Foam::labelList& Foam::primitiveMesh::cellPoints const Foam::labelList& Foam::primitiveMesh::cellPoints
( (
const label celli, const label celli,
labelHashSet& set,
DynamicList<label>& storage DynamicList<label>& storage
) const ) const
{ {
@ -70,7 +71,7 @@ const Foam::labelList& Foam::primitiveMesh::cellPoints
const faceList& fcs = faces(); const faceList& fcs = faces();
const labelList& cFaces = cells()[celli]; const labelList& cFaces = cells()[celli];
labelSet_.clear(); set.clear();
forAll(cFaces, i) forAll(cFaces, i)
{ {
@ -78,17 +79,17 @@ const Foam::labelList& Foam::primitiveMesh::cellPoints
forAll(f, fp) forAll(f, fp)
{ {
labelSet_.insert(f[fp]); set.insert(f[fp]);
} }
} }
storage.clear(); storage.clear();
if (labelSet_.size() > storage.capacity()) if (set.size() > storage.capacity())
{ {
storage.setCapacity(labelSet_.size()); storage.setCapacity(set.size());
} }
forAllConstIter(labelHashSet, labelSet_, iter) forAllConstIter(labelHashSet, set, iter)
{ {
storage.append(iter.key()); storage.append(iter.key());
} }
@ -100,7 +101,7 @@ const Foam::labelList& Foam::primitiveMesh::cellPoints
const Foam::labelList& Foam::primitiveMesh::cellPoints(const label celli) const const Foam::labelList& Foam::primitiveMesh::cellPoints(const label celli) const
{ {
return cellPoints(celli, labels_); return cellPoints(celli, labelSet_, labels_);
} }

View File

@ -630,6 +630,7 @@ const Foam::labelList& Foam::primitiveMesh::faceEdges(const label facei) const
const Foam::labelList& Foam::primitiveMesh::cellEdges const Foam::labelList& Foam::primitiveMesh::cellEdges
( (
const label celli, const label celli,
labelHashSet& set,
DynamicList<label>& storage DynamicList<label>& storage
) const ) const
{ {
@ -641,7 +642,7 @@ const Foam::labelList& Foam::primitiveMesh::cellEdges
{ {
const labelList& cFaces = cells()[celli]; const labelList& cFaces = cells()[celli];
labelSet_.clear(); set.clear();
forAll(cFaces, i) forAll(cFaces, i)
{ {
@ -649,18 +650,18 @@ const Foam::labelList& Foam::primitiveMesh::cellEdges
forAll(fe, feI) forAll(fe, feI)
{ {
labelSet_.insert(fe[feI]); set.insert(fe[feI]);
} }
} }
storage.clear(); storage.clear();
if (labelSet_.size() > storage.capacity()) if (set.size() > storage.capacity())
{ {
storage.setCapacity(labelSet_.size()); storage.setCapacity(set.size());
} }
forAllConstIter(labelHashSet, labelSet_, iter) forAllConstIter(labelHashSet, set, iter)
{ {
storage.append(iter.key()); storage.append(iter.key());
} }
@ -672,7 +673,7 @@ const Foam::labelList& Foam::primitiveMesh::cellEdges
const Foam::labelList& Foam::primitiveMesh::cellEdges(const label celli) const const Foam::labelList& Foam::primitiveMesh::cellEdges(const label celli) const
{ {
return cellEdges(celli, labels_); return cellEdges(celli, labelSet_, labels_);
} }

View File

@ -305,6 +305,7 @@ Foam::labelListList Foam::combineFaces::getMergeSets
// Lists of faces that can be merged. // Lists of faces that can be merged.
DynamicList<labelList> allFaceSets(boundaryCells.size() / 10); DynamicList<labelList> allFaceSets(boundaryCells.size() / 10);
// Storage for on-the-fly cell-edge addressing. // Storage for on-the-fly cell-edge addressing.
labelHashSet set;
DynamicList<label> storage; DynamicList<label> storage;
// On all cells regionise the faces // On all cells regionise the faces
@ -314,7 +315,7 @@ Foam::labelListList Foam::combineFaces::getMergeSets
const cell& cFaces = mesh_.cells()[celli]; const cell& cFaces = mesh_.cells()[celli];
const labelList& cEdges = mesh_.cellEdges(celli, storage); const labelList& cEdges = mesh_.cellEdges(celli, set, storage);
// Region per face // Region per face
Map<label> faceRegion(cFaces.size()); Map<label> faceRegion(cFaces.size());

View File

@ -718,10 +718,11 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
// On-the-fly addressing storage. // On-the-fly addressing storage.
DynamicList<label> dynFEdges; DynamicList<label> dynFEdges;
DynamicList<label> dynCPoints; DynamicList<label> dynCPoints;
labelHashSet pSet;
forAll(cellLevel, celli) forAll(cellLevel, celli)
{ {
const labelList& cPoints = mesh_.cellPoints(celli, dynCPoints); const labelList& cPoints = mesh_.cellPoints(celli, pSet, dynCPoints);
// Get number of anchor points (pointLevel <= cellLevel) // Get number of anchor points (pointLevel <= cellLevel)