Merge branch 'feature-primitiveMesh' into 'develop'

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

See merge request Development/OpenFOAM-plus!189
This commit is contained in:
Andrew Heather
2018-02-07 13:56:34 +00:00
5 changed files with 25 additions and 34 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,27 +71,22 @@ 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) for (const label facei : cFaces)
{ {
const labelList& f = fcs[cFaces[i]]; set.insert(fcs[facei]);
forAll(f, fp)
{
labelSet_.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) for (const label pointi : set)
{ {
storage.append(iter.key()); storage.append(pointi);
} }
return storage; return storage;
@ -100,10 +96,8 @@ 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,28 +642,22 @@ const Foam::labelList& Foam::primitiveMesh::cellEdges
{ {
const labelList& cFaces = cells()[celli]; const labelList& cFaces = cells()[celli];
labelSet_.clear(); set.clear();
forAll(cFaces, i) for (const label facei : cFaces)
{ {
const labelList& fe = faceEdges(cFaces[i]); set.insert(faceEdges(facei));
forAll(fe, feI)
{
labelSet_.insert(fe[feI]);
}
} }
storage.clear(); storage.clear();
if (set.size() > storage.capacity())
if (labelSet_.size() > storage.capacity())
{ {
storage.setCapacity(labelSet_.size()); storage.setCapacity(set.size());
} }
forAllConstIter(labelHashSet, labelSet_, iter) for (const label edgei : set)
{ {
storage.append(iter.key()); storage.append(edgei);
} }
return storage; return storage;
@ -672,7 +667,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)
@ -729,10 +730,8 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
label nNonAnchorBoundary = 0; label nNonAnchorBoundary = 0;
label nonBoundaryAnchor = -1; label nonBoundaryAnchor = -1;
forAll(cPoints, i) for (const label pointi : cPoints)
{ {
label pointi = cPoints[i];
if (pointLevel[pointi] <= cellLevel[celli]) if (pointLevel[pointi] <= cellLevel[celli])
{ {
// Anchor point // Anchor point