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 label celli,
labelHashSet&,
DynamicList<label>&
) const;
@ -876,6 +877,7 @@ public:
const labelList& cellEdges
(
const label celli,
labelHashSet&,
DynamicList<label>&
) const;

View File

@ -58,6 +58,7 @@ const Foam::labelListList& Foam::primitiveMesh::cellPoints() const
const Foam::labelList& Foam::primitiveMesh::cellPoints
(
const label celli,
labelHashSet& set,
DynamicList<label>& storage
) const
{
@ -70,27 +71,22 @@ const Foam::labelList& Foam::primitiveMesh::cellPoints
const faceList& fcs = faces();
const labelList& cFaces = cells()[celli];
labelSet_.clear();
set.clear();
forAll(cFaces, i)
for (const label facei : cFaces)
{
const labelList& f = fcs[cFaces[i]];
forAll(f, fp)
{
labelSet_.insert(f[fp]);
}
set.insert(fcs[facei]);
}
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;
@ -100,10 +96,8 @@ const Foam::labelList& Foam::primitiveMesh::cellPoints
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 label celli,
labelHashSet& set,
DynamicList<label>& storage
) const
{
@ -641,28 +642,22 @@ const Foam::labelList& Foam::primitiveMesh::cellEdges
{
const labelList& cFaces = cells()[celli];
labelSet_.clear();
set.clear();
forAll(cFaces, i)
for (const label facei : cFaces)
{
const labelList& fe = faceEdges(cFaces[i]);
forAll(fe, feI)
{
labelSet_.insert(fe[feI]);
}
set.insert(faceEdges(facei));
}
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 edgei : set)
{
storage.append(iter.key());
storage.append(edgei);
}
return storage;
@ -672,7 +667,7 @@ const Foam::labelList& Foam::primitiveMesh::cellEdges
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.
DynamicList<labelList> allFaceSets(boundaryCells.size() / 10);
// Storage for on-the-fly cell-edge addressing.
labelHashSet set;
DynamicList<label> storage;
// On all cells regionise the faces
@ -314,7 +315,7 @@ Foam::labelListList Foam::combineFaces::getMergeSets
const cell& cFaces = mesh_.cells()[celli];
const labelList& cEdges = mesh_.cellEdges(celli, storage);
const labelList& cEdges = mesh_.cellEdges(celli, set, storage);
// Region per face
Map<label> faceRegion(cFaces.size());

View File

@ -718,10 +718,11 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
// On-the-fly addressing storage.
DynamicList<label> dynFEdges;
DynamicList<label> dynCPoints;
labelHashSet pSet;
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)
@ -729,10 +730,8 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
label nNonAnchorBoundary = 0;
label nonBoundaryAnchor = -1;
forAll(cPoints, i)
for (const label pointi : cPoints)
{
label pointi = cPoints[i];
if (pointLevel[pointi] <= cellLevel[celli])
{
// Anchor point