Commit 95dcb6de authored by Mark Olesen's avatar Mark Olesen
Browse files

Simplify checking of container (List/HashTable, strings) sizes

- can use 'XX.empty()' instead of 'XX.size() == 0', 'XX.size() < 1' or
  'XX.size() <= 0' or for simpler coding.
  It also has the same number of characters as '!XX.size()' and /might/ be
  more readable

- many size checking had 'XX.size() > 0', 'XX.size() != 0', or 'XX.size() >= 1'
  when a simple 'XX.size()' suffices
parent 16aaf5b5
......@@ -26,7 +26,7 @@ Application
PDRFoam
Description
Compressible premixed/partially-premixed combustion solver with turbulence
Compressible premixed/partially-premixed combustion solver with turbulence
modelling.
Combusting RANS code using the b-Xi two-equation model.
......@@ -121,7 +121,8 @@ scalar StCoNum = 0.0;
// Test : disable refinement for some cells
PackedList<1>& protectedCell =
refCast<dynamicRefineFvMesh>(mesh).protectedCell();
if (protectedCell.size() == 0)
if (protectedCell.empty())
{
protectedCell.setSize(mesh.nCells());
protectedCell = 0;
......@@ -135,7 +136,7 @@ scalar StCoNum = 0.0;
}
}
//volScalarField pIndicator("pIndicator",
//volScalarField pIndicator("pIndicator",
// p*(fvc::laplacian(p))
// / (
// magSqr(fvc::grad(p))
......
......@@ -413,7 +413,7 @@ bool limitRefinementLevel
}
}
if (addCutCells.size() > 0)
if (addCutCells.size())
{
// Add cells to cutCells.
......@@ -479,7 +479,7 @@ void doRefinement
{
const labelList& added = addedCells[oldCellI];
if (added.size() > 0)
if (added.size())
{
// Give all cells resulting from split the refinement level
// of the master.
......@@ -895,7 +895,7 @@ int main(int argc, char *argv[])
<< " Selected for refinement :" << cutCells.size() << nl
<< endl;
if (cutCells.size() == 0)
if (cutCells.empty())
{
Info<< "Stopping refining since 0 cells selected to be refined ..."
<< nl << endl;
......
......@@ -358,18 +358,21 @@ int main(int argc, char *argv[])
(
dict.lookup("facesToTriangulate")
);
bool cutBoundary =
pointsToMove.size() > 0
|| edgesToSplit.size() > 0
|| facesToTriangulate.size() > 0;
(
pointsToMove.size()
|| edgesToSplit.size()
|| facesToTriangulate.size()
);
List<Pair<point> > edgesToCollapse(dict.lookup("edgesToCollapse"));
bool collapseEdge = edgesToCollapse.size() > 0;
bool collapseEdge = edgesToCollapse.size();
List<Pair<point> > cellsToPyramidise(dict.lookup("cellsToSplit"));
bool cellsToSplit = cellsToPyramidise.size() > 0;
bool cellsToSplit = cellsToPyramidise.size();
//List<Tuple<pointField,point> >
// cellsToCreate(dict.lookup("cellsToCreate"));
......@@ -523,7 +526,7 @@ int main(int argc, char *argv[])
Info<< nl << "There was a problem in one of the inputs in the"
<< " dictionary. Not modifying mesh." << endl;
}
else if (cellToPyrCentre.size() > 0)
else if (cellToPyrCentre.size())
{
Info<< nl << "All input cells located. Modifying mesh." << endl;
......@@ -555,7 +558,7 @@ int main(int argc, char *argv[])
Info << "Writing modified mesh to time " << runTime.value() << endl;
mesh.write();
}
else if (edgeToPos.size() > 0)
else if (edgeToPos.size())
{
Info<< nl << "All input edges located. Modifying mesh." << endl;
......
......@@ -336,7 +336,7 @@ int main(int argc, char *argv[])
)
{}
if (refCells.size() > 0)
if (refCells.size())
{
Info<< "Collected " << refCells.size() << " cells that need to be"
<< " refined to get closer to overall 2:1 refinement level limit"
......
......@@ -652,7 +652,7 @@ int main(int argc, char *argv[])
// Remove cut cells from cellsToCut (Note:only relevant if -readSet)
forAll(cuts.cellLoops(), cellI)
{
if (cuts.cellLoops()[cellI].size() > 0)
if (cuts.cellLoops()[cellI].size())
{
//Info<< "Removing cut cell " << cellI << " from wishlist"
// << endl;
......
......@@ -584,7 +584,7 @@ int main(int argc, char *argv[])
forAll (rawPatches, patchI)
{
if (rawPatches[patchI].size() > 0 && cfxPatchTypes[patchI] != "BLKBDY")
if (rawPatches[patchI].size() && cfxPatchTypes[patchI] != "BLKBDY")
{
// Check if this name has been already created
label existingPatch = -1;
......
/*---------------------------------------------------------------------------*\
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
......@@ -1486,7 +1486,7 @@ int main(int argc, char *argv[])
}
defaultBoundaryFaces.shrink();
if(defaultBoundaryFaces.size() != 0)
if (defaultBoundaryFaces.size())
{
Warning << " fluent mesh has " << defaultBoundaryFaces.size()
<< " undefined boundary faces." << endl
......@@ -1695,7 +1695,7 @@ int main(int argc, char *argv[])
// soon negating the need for double output
if (writeSets)
{
if (cellGroupZoneID.size() > 1 )
if (cellGroupZoneID.size() > 1)
{
Info<< "Writing cell sets" << endl;
......
......@@ -667,7 +667,7 @@ void readCells
const labelList& zCells = zoneCells[zoneI];
if (zCells.size() > 0)
if (zCells.size())
{
Info<< " " << zoneI << '\t' << zCells.size() << endl;
}
......@@ -778,7 +778,7 @@ int main(int argc, char *argv[])
forAll(zoneCells, zoneI)
{
if (zoneCells[zoneI].size() > 0)
if (zoneCells[zoneI].size())
{
nValidCellZones++;
}
......@@ -910,7 +910,7 @@ int main(int argc, char *argv[])
const labelList& zFaces = zoneFaces[zoneI];
if (zFaces.size() > 0)
if (zFaces.size())
{
nValidFaceZones++;
......@@ -940,7 +940,7 @@ int main(int argc, char *argv[])
forAll(zoneCells, zoneI)
{
if (zoneCells[zoneI].size() > 0)
if (zoneCells[zoneI].size())
{
label physReg = zoneToPhys[zoneI];
......@@ -979,7 +979,7 @@ int main(int argc, char *argv[])
forAll(zoneFaces, zoneI)
{
if (zoneFaces[zoneI].size() > 0)
if (zoneFaces[zoneI].size())
{
label physReg = zoneToPhys[zoneI];
......@@ -1011,7 +1011,7 @@ int main(int argc, char *argv[])
}
}
if (cz.size() > 0 || fz.size() > 0)
if (cz.size() || fz.size())
{
mesh.addZones(List<pointZone*>(0), fz, cz);
}
......
......@@ -752,7 +752,7 @@ int main(int argc, char *argv[])
List<faceList> patchFaceVerts;
if (dofVertIndices.size() > 0)
if (dofVertIndices.size())
{
// Use the vertex constraints to patch. Is of course bit dodgy since
// face goes on patch if all its vertices are on a constraint.
......
......@@ -242,7 +242,7 @@ int main(int argc, char *argv[])
}
if (vertsToBoundary.size() > 0)
if (vertsToBoundary.size())
{
// Didn't find cells connected to boundary faces.
WarningIn(args.executable())
......
......@@ -229,7 +229,7 @@ void simpleMarkFeatures
if (doNotPreserveFaceZones)
{
if (faceZones.size() > 0)
if (faceZones.size())
{
WarningIn("simpleMarkFeatures(..)")
<< "Detected " << faceZones.size()
......@@ -239,7 +239,7 @@ void simpleMarkFeatures
}
else
{
if (faceZones.size() > 0)
if (faceZones.size())
{
Info<< "Detected " << faceZones.size()
<< " faceZones. Preserving these by marking their"
......
......@@ -38,10 +38,7 @@ Class
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(meshDualiser, 0);
}
defineTypeNameAndDebug(Foam::meshDualiser, 0);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
......@@ -735,7 +732,7 @@ void Foam::meshDualiser::createFacesAroundBoundaryPoint
) << "Walked from face on patch:" << patchI
<< " to face:" << faceI
<< " fc:" << mesh_.faceCentres()[faceI]
<< " on patch:" << patches.whichPatch(faceI)
<< " on patch:" << patches.whichPatch(faceI)
<< abort(FatalError);
}
......@@ -886,7 +883,7 @@ Foam::meshDualiser::meshDualiser(const polyMesh& mesh)
faceToDualPoint_(mesh_.nFaces(), -1),
edgeToDualPoint_(mesh_.nEdges(), -1)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
......@@ -1083,7 +1080,7 @@ void Foam::meshDualiser::setRefinement
{
label pointI = multiCellFeaturePoints[i];
if (pointToDualCells_[pointI].size() > 0)
if (pointToDualCells_[pointI].size())
{
FatalErrorIn
(
......@@ -1133,7 +1130,7 @@ void Foam::meshDualiser::setRefinement
// Normal points
forAll(mesh_.points(), pointI)
{
if (pointToDualCells_[pointI].size() == 0)
if (pointToDualCells_[pointI].empty())
{
pointToDualCells_[pointI].setSize(1);
pointToDualCells_[pointI][0] = meshMod.addCell
......@@ -1241,7 +1238,7 @@ void Foam::meshDualiser::setRefinement
const edge& e = mesh_.edges()[edgeI];
// We need a point on the edge if not all cells on both sides
// are the same.
// are the same.
const labelList& eCells = mesh_.edgeCells()[edgeI];
......
......@@ -136,7 +136,7 @@ void sammMesh::readCouples()
forAll (curFaces, faceI)
{
if (curFaces[faceI].size() == 0)
if (curFaces[faceI].empty())
{
zeroSizeFound++;
}
......@@ -153,7 +153,7 @@ void sammMesh::readCouples()
forAll (oldFaces, faceI)
{
if (oldFaces[faceI].size() > 0)
if (oldFaces[faceI].size())
{
curFaces[nFaces] = oldFaces[faceI];
......
......@@ -45,12 +45,11 @@ void starMesh::createCoupleMatches()
// existing points list
// Estimate the number of cells affected by couple matches
const label cellMapSize =
min
(
cellShapes_.size()/10,
couples_.size()*2
);
const label cellMapSize = min
(
cellShapes_.size()/10,
couples_.size()*2
);
// Store newly created faces for each cell
Map<SLList<face> > cellAddedFaces(cellMapSize);
......@@ -322,7 +321,7 @@ void starMesh::createCoupleMatches()
// A new point is created. Warning:
// using original edge for accuracy.
//
//
coupleFacePoints.append
(P + alpha*curMasterEdge.vec(points_));
}
......@@ -338,7 +337,7 @@ void starMesh::createCoupleMatches()
// master edge and vice versa. The problem is that
// no symmetry exists, i.e. both operations needs
// to be done separately for both master and slave
// side.
// side.
// Master side
// check if the first or second point of slave edge is
......@@ -625,11 +624,11 @@ void starMesh::createCoupleMatches()
// Eliminate all zero-length edges
face newMasterFace(labelList(tmpMasterFace.size(), labelMax));
// insert first point by hand. Careful: the first one is
// used for comparison to allow the edge collapse across
// point zero.
//
//
newMasterFace[0] = tmpMasterFace[0];
label nMaster = 0;
......@@ -823,7 +822,7 @@ void starMesh::createCoupleMatches()
// insert first point by hand. Careful: the first one is
// used for comparison to allow the edge collapse across
// point zero.
//
//
newSlaveFace[0] = tmpSlaveFace[0];
label nSlave = 0;
......@@ -1097,7 +1096,7 @@ void starMesh::createCoupleMatches()
<< "edges to consider: " << edgesToConsider << endl;
# endif
if (edgesToConsider.size() == 0)
if (edgesToConsider.empty())
{
FatalErrorIn("void starMesh::createCoupleMatches()")
<< setprecision(12)
......@@ -1420,7 +1419,7 @@ void starMesh::createCoupleMatches()
} // end of arbitrary match
}
if (couples_.size() > 0)
if (couples_.size())
{
// Loop through all cells and reset faces for removal to zero size
const labelList crfToc = cellRemovedFaces.toc();
......@@ -1442,7 +1441,7 @@ void starMesh::createCoupleMatches()
cellFaces_[curCell][curRemovedFacesIter()].setSize(0);
}
if (curRemovedFaces.size() > 0)
if (curRemovedFaces.size())
{
// reset the shape pointer to unknown
cellShapes_[curCell] = cellShape(*unknownPtr_, labelList(0));
......@@ -1468,7 +1467,7 @@ void starMesh::createCoupleMatches()
// copy original faces that have not been removed
forAll (oldFaces, faceI)
{
if (oldFaces[faceI].size() > 0)
if (oldFaces[faceI].size())
{
newFaces[nNewFaces] = oldFaces[faceI];
nNewFaces++;
......@@ -1491,7 +1490,7 @@ void starMesh::createCoupleMatches()
// reset the size of the face list
newFaces.setSize(nNewFaces);
if (curAddedFaces.size() > 0)
if (curAddedFaces.size())
{
// reset the shape pointer to unknown
cellShapes_[curCell] = cellShape(*unknownPtr_, labelList(0));
......
......@@ -264,7 +264,7 @@ starMesh::starMesh
readCouples();
if (couples_.size() > 0)
if (couples_.size())
{
createCoupleMatches();
}
......
......@@ -160,7 +160,7 @@ int main(int argc, char *argv[])
{
nodeStream.getLine(line);
}
while((line.size() > 0) && (line[0] == '#'));
while (line.size() && line[0] == '#');
IStringStream nodeLine(line);
......@@ -193,7 +193,7 @@ int main(int argc, char *argv[])
{
nodeStream.getLine(line);
if ((line.size() > 0) && (line[0] != '#'))
if (line.size() && line[0] != '#')
{
IStringStream nodeLine(line);
......@@ -237,7 +237,7 @@ int main(int argc, char *argv[])
{
eleStream.getLine(line);
}
while((line.size() > 0) && (line[0] == '#'));
while (line.size() && line[0] == '#');
IStringStream eleLine(line);
......@@ -281,7 +281,7 @@ int main(int argc, char *argv[])
{
eleStream.getLine(line);
if ((line.size() > 0) && (line[0] != '#'))
if (line.size() && line[0] != '#')
{
IStringStream eleLine(line);
......@@ -356,7 +356,7 @@ int main(int argc, char *argv[])
{
faceStream.getLine(line);
}
while((line.size() > 0) && (line[0] == '#'));
while (line.size() && line[0] == '#');
IStringStream faceLine(line);
......@@ -398,7 +398,7 @@ int main(int argc, char *argv[])
{
faceStream.getLine(line);
if ((line.size() > 0) && (line[0] != '#'))
if (line.size() && line[0] != '#')
{
IStringStream faceLine(line);
......
......@@ -118,7 +118,7 @@ Foam::label Foam::blockMesh::numZonedBlocks() const
forAll(*this, blockI)
{
if (operator[](blockI).blockDef().zoneName().size() > 0)
if (operator[](blockI).blockDef().zoneName().size())
{
num++;
}
......
......@@ -278,7 +278,7 @@ int main(int argc, char *argv[])
const labelListList& blockCells = b.cells();
const word& zoneName = b.blockDef().zoneName();
if (zoneName.size() > 0)
if (zoneName.size())
{
HashTable<label>::const_iterator iter = zoneMap.find(zoneName);
......
Info<< "Creating merge patch pairs" << nl << endl;
if (mergePatchPairs.size() > 0)
if (mergePatchPairs.size())
{
// Create and add point and face zones and mesh modifiers
List<pointZone*> pz(mergePatchPairs.size());
......
......@@ -177,7 +177,7 @@ Foam::label Foam::checkTopology
primitivePatch::surfaceTopo pTyp = pp.surfaceType();
if (pp.size() == 0)
if (pp.empty())
{
Pout<< setw(34) << "ok (empty)";
}
......@@ -232,7 +232,7 @@ Foam::label Foam::checkTopology
Pout<< endl;
}
if (points.size() > 0)
if (points.size())
{
Pout<< " <<Writing " << points.size()
<< " conflicting points to set "
......
......@@ -172,7 +172,7 @@ void filterPatches(polyMesh& mesh)
if (isA<processorPolyPatch>(pp))
{
if (pp.size() > 0)
if (pp.size())
{
allPatches.append
(
......@@ -586,7 +586,7 @@ int main(int argc, char *argv[])
// 1. Add all new patches
// ~~~~~~~~~~~~~~~~~~~~~~
if (patchSources.size() > 0)
if (patchSources.size())
{
// Old and new patches.
DynamicList<polyPatch*> allPatches(patches.size()+patchSources.size());
......
......@@ -34,10 +34,7 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(mergePolyMesh, 1);
}
defineTypeNameAndDebug(Foam::mergePolyMesh, 1);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
......@@ -142,7 +139,7 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io)
// Point zones
wordList curPointZoneNames = pointZones().names();
if (curPointZoneNames.size() > 0)
if (curPointZoneNames.size())
{
pointZoneNames_.setCapacity(2*curPointZoneNames.size());
}
......@@ -155,7 +152,7 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io)
// Face zones