Commit 64c3e484 authored by Mark Olesen's avatar Mark Olesen
Browse files

STYLE: add nBoundaryFaces() method to primitiveMesh

- nBoundaryFaces() is often used and is identical to
  (nFaces() - nInternalFaces()).

- forward the mesh nInternalFaces() and nBoundaryFaces() to
  polyBoundaryMesh as nFaces() and start() respectively,
  for use when operating on a polyBoundaryMesh.

STYLE:

- use identity() function with starting offset when creating boundary maps.

     labelList map
     (
         identity(mesh.nBoundaryFaces(), mesh.nInternalFaces())
     );

  vs.

     labelList map(mesh.nBoundaryFaces());
     forAll(map, i)
     {
         map[i] = mesh.nInternalFaces() + i;
     }
parent 3a641275
......@@ -180,7 +180,7 @@ int main(int argc, char *argv[])
const labelListList& transformedSlaves =
globalData.globalPointTransformedBoundaryFaces();
label nBnd = mesh.nFaces()-mesh.nInternalFaces();
const label nBnd = mesh.nBoundaryFaces();
pointField fc(globalPointBoundaryFacesMap.constructSize());
SubList<point>(fc, nBnd) =
......
......@@ -195,7 +195,7 @@ void testSparseData(const polyMesh& mesh, Random& rndGen)
SubList<face>
(
mesh.faces(),
mesh.nFaces()-mesh.nInternalFaces(),
mesh.nBoundaryFaces(),
mesh.nInternalFaces()
),
mesh.points()
......
......@@ -413,7 +413,7 @@ int main(int argc, char *argv[])
const SubList<face> outsideFaces
(
mesh.faces(),
mesh.nFaces() - mesh.nInternalFaces(),
mesh.nBoundaryFaces(),
mesh.nInternalFaces()
);
......
......@@ -1386,7 +1386,7 @@ int main(int argc, char *argv[])
DynamicList<polyPatch*> newPatches(nPatches);
// For every boundary face the old patch.
labelList facePatchID(pShapeMesh.nFaces()-pShapeMesh.nInternalFaces(), -1);
labelList facePatchID(pShapeMesh.nBoundaryFaces(), -1);
label cMeshFace = pShapeMesh.nInternalFaces();
label nBoundaries = 0;
......
......@@ -468,7 +468,7 @@ void Foam::backgroundMeshDecomposition::printMeshData
// // Print stats
// globalIndex globalBoundaryFaces(mesh.nFaces()-mesh.nInternalFaces());
// globalIndex globalBoundaryFaces(mesh.nBoundaryFaces());
for (label proci = 0; proci < Pstream::nProcs(); proci++)
{
......@@ -671,7 +671,7 @@ void Foam::backgroundMeshDecomposition::buildPatchAndTree()
SubList<face>
(
mesh_.faces(),
mesh_.nFaces() - mesh_.nInternalFaces(),
mesh_.nBoundaryFaces(),
mesh_.nInternalFaces()
),
mesh_.points()
......
......@@ -39,7 +39,7 @@ void Foam::conformalVoronoiMesh::calcNeighbourCellCentres
pointField& neiCc
) const
{
label nBoundaryFaces = mesh.nFaces() - mesh.nInternalFaces();
const label nBoundaryFaces = mesh.nBoundaryFaces();
if (neiCc.size() != nBoundaryFaces)
{
......@@ -319,7 +319,7 @@ void Foam::conformalVoronoiMesh::calcFaceZones
const labelList& faceOwner = mesh.faceOwner();
const labelList& faceNeighbour = mesh.faceNeighbour();
labelList neiFaceOwner(mesh.nFaces() - mesh.nInternalFaces(), label(-1));
labelList neiFaceOwner(mesh.nBoundaryFaces(), label(-1));
const polyBoundaryMesh& patches = mesh.boundaryMesh();
......@@ -421,7 +421,7 @@ void Foam::conformalVoronoiMesh::calcFaceZones
)
);
pointField neiCc(mesh.nFaces() - mesh.nInternalFaces());
pointField neiCc(mesh.nBoundaryFaces());
calcNeighbourCellCentres
(
mesh,
......@@ -498,7 +498,7 @@ void Foam::conformalVoronoiMesh::calcFaceZones
}
// labelList neiCellSurface(mesh.nFaces()-mesh.nInternalFaces());
// labelList neiCellSurface(mesh.nBoundaryFaces());
//
// forAll(patches, patchi)
// {
......
......@@ -119,7 +119,7 @@ void printMeshData(const polyMesh& mesh)
// Print stats
globalIndex globalBoundaryFaces(mesh.nFaces()-mesh.nInternalFaces());
globalIndex globalBoundaryFaces(mesh.nBoundaryFaces());
label maxProcCells = 0;
label totProcFaces = 0;
......
......@@ -314,7 +314,7 @@ void Foam::mergeAndWrite
}
boolList bndInSet(mesh.nFaces()-mesh.nInternalFaces());
boolList bndInSet(mesh.nBoundaryFaces());
forAll(pbm, patchi)
{
const polyPatch& pp = pbm[patchi];
......
......@@ -249,7 +249,7 @@ labelList findBaffles(const polyMesh& mesh, const labelList& boundaryFaces)
(
mesh,
"duplicateFaces",
(mesh.nFaces() - mesh.nInternalFaces())/256
mesh.nBoundaryFaces()/256
);
forAll(duplicates, bFacei)
......
......@@ -295,11 +295,7 @@ int main(int argc, char *argv[])
{
const polyBoundaryMesh& bm = mesh.boundaryMesh();
labelList neiStatus
(
mesh.nFaces()-mesh.nInternalFaces(),
orientedSurface::UNVISITED
);
labelList neiStatus(mesh.nBoundaryFaces(), orientedSurface::UNVISITED);
forAll(faceLabels, i)
{
......
......@@ -140,7 +140,7 @@ void simpleMarkFeatures
SubList<face>
(
mesh.faces(),
mesh.nFaces()-mesh.nInternalFaces(),
mesh.nBoundaryFaces(),
mesh.nInternalFaces()
),
mesh.points()
......@@ -238,7 +238,7 @@ void simpleMarkFeatures
// ~~~~~~~~~~~~~~~~~~~~~~~~~
// Face centres that need inclusion in the dual mesh
labelHashSet featureFaceSet(mesh.nFaces()-mesh.nInternalFaces());
labelHashSet featureFaceSet(mesh.nBoundaryFaces());
// A. boundary faces.
for (label facei = mesh.nInternalFaces(); facei < mesh.nFaces(); facei++)
{
......
......@@ -353,7 +353,7 @@ void getInterfaceSizes
// ~~~~~~~~~~~~~~
// Neighbour cellRegion.
labelList coupledRegion(mesh.nFaces()-mesh.nInternalFaces());
labelList coupledRegion(mesh.nBoundaryFaces());
forAll(coupledRegion, i)
{
......@@ -641,7 +641,7 @@ autoPtr<mapPolyMesh> createRegionMesh
// Neighbour cellRegion.
labelList coupledRegion(mesh.nFaces()-mesh.nInternalFaces());
labelList coupledRegion(mesh.nBoundaryFaces());
forAll(coupledRegion, i)
{
......@@ -1232,7 +1232,7 @@ void getZoneID
}
// Neighbour zoneID.
neiZoneID.setSize(mesh.nFaces()-mesh.nInternalFaces());
neiZoneID.setSize(mesh.nBoundaryFaces());
forAll(neiZoneID, i)
{
......@@ -1263,7 +1263,7 @@ void matchRegions
// Get current per cell zoneID
labelList zoneID(mesh.nCells(), -1);
labelList neiZoneID(mesh.nFaces()-mesh.nInternalFaces());
labelList neiZoneID(mesh.nBoundaryFaces());
getZoneID(mesh, cellZones, zoneID, neiZoneID);
// Sizes per cellzone
......@@ -1552,7 +1552,7 @@ int main(int argc, char *argv[])
// Existing zoneID
labelList zoneID(mesh.nCells(), -1);
// Neighbour zoneID.
labelList neiZoneID(mesh.nFaces()-mesh.nInternalFaces());
labelList neiZoneID(mesh.nBoundaryFaces());
getZoneID(mesh, cellZones, zoneID, neiZoneID);
......@@ -1622,7 +1622,7 @@ int main(int argc, char *argv[])
);
labelList newZoneID(mesh.nCells(), -1);
labelList newNeiZoneID(mesh.nFaces()-mesh.nInternalFaces());
labelList newNeiZoneID(mesh.nBoundaryFaces());
getZoneID(mesh, newCellZones, newZoneID, newNeiZoneID);
label unzonedCelli = newZoneID.find(-1);
......
......@@ -172,7 +172,7 @@ void printMeshData(const polyMesh& mesh)
// Print stats
globalIndex globalBoundaryFaces(mesh.nFaces()-mesh.nInternalFaces());
globalIndex globalBoundaryFaces(mesh.nBoundaryFaces());
label maxProcCells = 0;
label totProcFaces = 0;
......
......@@ -55,7 +55,7 @@ void Foam::channelIndex::walkOppositeFaces
{
const cellList& cells = mesh.cells();
const faceList& faces = mesh.faces();
label nBnd = mesh.nFaces() - mesh.nInternalFaces();
const label nBnd = mesh.nBoundaryFaces();
DynamicList<label> frontFaces(startFaces);
forAll(frontFaces, i)
......
......@@ -128,7 +128,7 @@ int main(int argc, char *argv[])
}
// Sync agglomeration across coupled patches
labelList nbrAgglom(mesh.nFaces() - mesh.nInternalFaces(), -1);
labelList nbrAgglom(mesh.nBoundaryFaces(), -1);
forAll(boundary, patchi)
{
......
......@@ -239,7 +239,7 @@ bool setFaceFieldType
const Type& value = pTraits<Type>(fieldValueStream);
// Create flat list of selected faces and their value.
Field<Type> allBoundaryValues(mesh.nFaces()-mesh.nInternalFaces());
Field<Type> allBoundaryValues(mesh.nBoundaryFaces());
forAll(field.boundaryField(), patchi)
{
SubField<Type>
......@@ -447,7 +447,7 @@ int main(int argc, char *argv[])
(
mesh,
"faceSet",
(mesh.nFaces()-mesh.nInternalFaces())/10+1
mesh.nBoundaryFaces()/10+1
);
source->applyToSet
......
......@@ -82,10 +82,7 @@ triSurface triangulate
const polyMesh& mesh = bMesh.mesh();
// Storage for surfaceMesh. Size estimate.
DynamicList<labelledTri> triangles
(
mesh.nFaces() - mesh.nInternalFaces()
);
DynamicList<labelledTri> triangles(mesh.nBoundaryFaces());
label newPatchI = 0;
label localTriFaceI = 0;
......
......@@ -1325,7 +1325,7 @@ void Foam::globalMeshData::calcGlobalPointBoundaryFaces() const
// Global indices for boundary faces
globalBoundaryFaceNumberingPtr_.reset
(
new globalIndex(mesh_.nFaces()-mesh_.nInternalFaces())
new globalIndex(mesh_.nBoundaryFaces())
);
globalIndex& globalIndices = globalBoundaryFaceNumberingPtr_();
......
......@@ -450,10 +450,7 @@ const Foam::labelList& Foam::polyBoundaryMesh::patchID() const
{
if (!patchIDPtr_.valid())
{
patchIDPtr_.reset
(
new labelList(mesh_.nFaces() - mesh_.nInternalFaces())
);
patchIDPtr_.reset(new labelList(mesh_.nBoundaryFaces()));
labelList& list = *patchIDPtr_;
const polyPatchList& patches = *this;
......@@ -613,13 +610,21 @@ Foam::wordList Foam::polyBoundaryMesh::physicalTypes() const
}
Foam::label Foam::polyBoundaryMesh::start() const
{
return mesh_.nInternalFaces();
}
Foam::label Foam::polyBoundaryMesh::nFaces() const
{
return mesh_.nBoundaryFaces();
}
Foam::labelRange Foam::polyBoundaryMesh::range() const
{
return labelRange
(
mesh_.nInternalFaces(),
mesh_.nFaces() - mesh_.nInternalFaces()
);
return labelRange(mesh_.nInternalFaces(), mesh_.nBoundaryFaces());
}
......
......@@ -153,7 +153,7 @@ public:
// polyBoundaryMesh and not parallel
const List<labelPairList>& neighbourEdges() const;
//- Return the number of non-processor patches
//- The number of patches before the first processor patch.
label nNonProcessor() const;
//- Return a list of patch names
......@@ -165,8 +165,16 @@ public:
//- Return a list of physical types
wordList physicalTypes() const;
//- Return the range used for all boundary faces
// Spans [nInternalFaces, nFaces)
//- The start label of the boundary faces in the polyMesh face list
// Same as mesh.nInternalFaces()
label start() const;
//- The number of boundary faces in the underlying mesh
// Same as mesh.nBoundaryFaces()
label nFaces() const;
//- The face range for all boundary faces
// Spans [nInternalFaces, nFaces) of the underlying mesh
labelRange range() const;
//- Return the range used for boundary faces on patchi.
......
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