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
This commit is contained in:
Mark Olesen
2009-01-10 20:28:06 +01:00
parent 16aaf5b54e
commit 95dcb6ded7
211 changed files with 713 additions and 832 deletions

View File

@ -121,7 +121,8 @@ scalar StCoNum = 0.0;
// Test : disable refinement for some cells // Test : disable refinement for some cells
PackedList<1>& protectedCell = PackedList<1>& protectedCell =
refCast<dynamicRefineFvMesh>(mesh).protectedCell(); refCast<dynamicRefineFvMesh>(mesh).protectedCell();
if (protectedCell.size() == 0)
if (protectedCell.empty())
{ {
protectedCell.setSize(mesh.nCells()); protectedCell.setSize(mesh.nCells());
protectedCell = 0; protectedCell = 0;

View File

@ -413,7 +413,7 @@ bool limitRefinementLevel
} }
} }
if (addCutCells.size() > 0) if (addCutCells.size())
{ {
// Add cells to cutCells. // Add cells to cutCells.
@ -479,7 +479,7 @@ void doRefinement
{ {
const labelList& added = addedCells[oldCellI]; const labelList& added = addedCells[oldCellI];
if (added.size() > 0) if (added.size())
{ {
// Give all cells resulting from split the refinement level // Give all cells resulting from split the refinement level
// of the master. // of the master.
@ -895,7 +895,7 @@ int main(int argc, char *argv[])
<< " Selected for refinement :" << cutCells.size() << nl << " Selected for refinement :" << cutCells.size() << nl
<< endl; << endl;
if (cutCells.size() == 0) if (cutCells.empty())
{ {
Info<< "Stopping refining since 0 cells selected to be refined ..." Info<< "Stopping refining since 0 cells selected to be refined ..."
<< nl << endl; << nl << endl;

View File

@ -358,18 +358,21 @@ int main(int argc, char *argv[])
( (
dict.lookup("facesToTriangulate") dict.lookup("facesToTriangulate")
); );
bool cutBoundary = bool cutBoundary =
pointsToMove.size() > 0 (
|| edgesToSplit.size() > 0 pointsToMove.size()
|| facesToTriangulate.size() > 0; || edgesToSplit.size()
|| facesToTriangulate.size()
);
List<Pair<point> > edgesToCollapse(dict.lookup("edgesToCollapse")); List<Pair<point> > edgesToCollapse(dict.lookup("edgesToCollapse"));
bool collapseEdge = edgesToCollapse.size() > 0; bool collapseEdge = edgesToCollapse.size();
List<Pair<point> > cellsToPyramidise(dict.lookup("cellsToSplit")); List<Pair<point> > cellsToPyramidise(dict.lookup("cellsToSplit"));
bool cellsToSplit = cellsToPyramidise.size() > 0; bool cellsToSplit = cellsToPyramidise.size();
//List<Tuple<pointField,point> > //List<Tuple<pointField,point> >
// cellsToCreate(dict.lookup("cellsToCreate")); // 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" Info<< nl << "There was a problem in one of the inputs in the"
<< " dictionary. Not modifying mesh." << endl; << " dictionary. Not modifying mesh." << endl;
} }
else if (cellToPyrCentre.size() > 0) else if (cellToPyrCentre.size())
{ {
Info<< nl << "All input cells located. Modifying mesh." << endl; 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; Info << "Writing modified mesh to time " << runTime.value() << endl;
mesh.write(); mesh.write();
} }
else if (edgeToPos.size() > 0) else if (edgeToPos.size())
{ {
Info<< nl << "All input edges located. Modifying mesh." << endl; Info<< nl << "All input edges located. Modifying mesh." << endl;

View File

@ -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" Info<< "Collected " << refCells.size() << " cells that need to be"
<< " refined to get closer to overall 2:1 refinement level limit" << " refined to get closer to overall 2:1 refinement level limit"

View File

@ -652,7 +652,7 @@ int main(int argc, char *argv[])
// Remove cut cells from cellsToCut (Note:only relevant if -readSet) // Remove cut cells from cellsToCut (Note:only relevant if -readSet)
forAll(cuts.cellLoops(), cellI) forAll(cuts.cellLoops(), cellI)
{ {
if (cuts.cellLoops()[cellI].size() > 0) if (cuts.cellLoops()[cellI].size())
{ {
//Info<< "Removing cut cell " << cellI << " from wishlist" //Info<< "Removing cut cell " << cellI << " from wishlist"
// << endl; // << endl;

View File

@ -584,7 +584,7 @@ int main(int argc, char *argv[])
forAll (rawPatches, patchI) 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 // Check if this name has been already created
label existingPatch = -1; label existingPatch = -1;

View File

@ -1,4 +1,4 @@
/*---------------------------------------------------------------------------*\ /*--------------------------------*- C++ -*----------------------------------*\
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
@ -1486,7 +1486,7 @@ int main(int argc, char *argv[])
} }
defaultBoundaryFaces.shrink(); defaultBoundaryFaces.shrink();
if(defaultBoundaryFaces.size() != 0) if (defaultBoundaryFaces.size())
{ {
Warning << " fluent mesh has " << defaultBoundaryFaces.size() Warning << " fluent mesh has " << defaultBoundaryFaces.size()
<< " undefined boundary faces." << endl << " undefined boundary faces." << endl
@ -1695,7 +1695,7 @@ int main(int argc, char *argv[])
// soon negating the need for double output // soon negating the need for double output
if (writeSets) if (writeSets)
{ {
if (cellGroupZoneID.size() > 1 ) if (cellGroupZoneID.size() > 1)
{ {
Info<< "Writing cell sets" << endl; Info<< "Writing cell sets" << endl;

View File

@ -667,7 +667,7 @@ void readCells
const labelList& zCells = zoneCells[zoneI]; const labelList& zCells = zoneCells[zoneI];
if (zCells.size() > 0) if (zCells.size())
{ {
Info<< " " << zoneI << '\t' << zCells.size() << endl; Info<< " " << zoneI << '\t' << zCells.size() << endl;
} }
@ -778,7 +778,7 @@ int main(int argc, char *argv[])
forAll(zoneCells, zoneI) forAll(zoneCells, zoneI)
{ {
if (zoneCells[zoneI].size() > 0) if (zoneCells[zoneI].size())
{ {
nValidCellZones++; nValidCellZones++;
} }
@ -910,7 +910,7 @@ int main(int argc, char *argv[])
const labelList& zFaces = zoneFaces[zoneI]; const labelList& zFaces = zoneFaces[zoneI];
if (zFaces.size() > 0) if (zFaces.size())
{ {
nValidFaceZones++; nValidFaceZones++;
@ -940,7 +940,7 @@ int main(int argc, char *argv[])
forAll(zoneCells, zoneI) forAll(zoneCells, zoneI)
{ {
if (zoneCells[zoneI].size() > 0) if (zoneCells[zoneI].size())
{ {
label physReg = zoneToPhys[zoneI]; label physReg = zoneToPhys[zoneI];
@ -979,7 +979,7 @@ int main(int argc, char *argv[])
forAll(zoneFaces, zoneI) forAll(zoneFaces, zoneI)
{ {
if (zoneFaces[zoneI].size() > 0) if (zoneFaces[zoneI].size())
{ {
label physReg = zoneToPhys[zoneI]; 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); mesh.addZones(List<pointZone*>(0), fz, cz);
} }

View File

@ -752,7 +752,7 @@ int main(int argc, char *argv[])
List<faceList> patchFaceVerts; List<faceList> patchFaceVerts;
if (dofVertIndices.size() > 0) if (dofVertIndices.size())
{ {
// Use the vertex constraints to patch. Is of course bit dodgy since // Use the vertex constraints to patch. Is of course bit dodgy since
// face goes on patch if all its vertices are on a constraint. // face goes on patch if all its vertices are on a constraint.

View File

@ -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. // Didn't find cells connected to boundary faces.
WarningIn(args.executable()) WarningIn(args.executable())

View File

@ -229,7 +229,7 @@ void simpleMarkFeatures
if (doNotPreserveFaceZones) if (doNotPreserveFaceZones)
{ {
if (faceZones.size() > 0) if (faceZones.size())
{ {
WarningIn("simpleMarkFeatures(..)") WarningIn("simpleMarkFeatures(..)")
<< "Detected " << faceZones.size() << "Detected " << faceZones.size()
@ -239,7 +239,7 @@ void simpleMarkFeatures
} }
else else
{ {
if (faceZones.size() > 0) if (faceZones.size())
{ {
Info<< "Detected " << faceZones.size() Info<< "Detected " << faceZones.size()
<< " faceZones. Preserving these by marking their" << " faceZones. Preserving these by marking their"

View File

@ -38,10 +38,7 @@ Class
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam defineTypeNameAndDebug(Foam::meshDualiser, 0);
{
defineTypeNameAndDebug(meshDualiser, 0);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -1083,7 +1080,7 @@ void Foam::meshDualiser::setRefinement
{ {
label pointI = multiCellFeaturePoints[i]; label pointI = multiCellFeaturePoints[i];
if (pointToDualCells_[pointI].size() > 0) if (pointToDualCells_[pointI].size())
{ {
FatalErrorIn FatalErrorIn
( (
@ -1133,7 +1130,7 @@ void Foam::meshDualiser::setRefinement
// Normal points // Normal points
forAll(mesh_.points(), pointI) forAll(mesh_.points(), pointI)
{ {
if (pointToDualCells_[pointI].size() == 0) if (pointToDualCells_[pointI].empty())
{ {
pointToDualCells_[pointI].setSize(1); pointToDualCells_[pointI].setSize(1);
pointToDualCells_[pointI][0] = meshMod.addCell pointToDualCells_[pointI][0] = meshMod.addCell

View File

@ -136,7 +136,7 @@ void sammMesh::readCouples()
forAll (curFaces, faceI) forAll (curFaces, faceI)
{ {
if (curFaces[faceI].size() == 0) if (curFaces[faceI].empty())
{ {
zeroSizeFound++; zeroSizeFound++;
} }
@ -153,7 +153,7 @@ void sammMesh::readCouples()
forAll (oldFaces, faceI) forAll (oldFaces, faceI)
{ {
if (oldFaces[faceI].size() > 0) if (oldFaces[faceI].size())
{ {
curFaces[nFaces] = oldFaces[faceI]; curFaces[nFaces] = oldFaces[faceI];

View File

@ -45,8 +45,7 @@ void starMesh::createCoupleMatches()
// existing points list // existing points list
// Estimate the number of cells affected by couple matches // Estimate the number of cells affected by couple matches
const label cellMapSize = const label cellMapSize = min
min
( (
cellShapes_.size()/10, cellShapes_.size()/10,
couples_.size()*2 couples_.size()*2
@ -1097,7 +1096,7 @@ void starMesh::createCoupleMatches()
<< "edges to consider: " << edgesToConsider << endl; << "edges to consider: " << edgesToConsider << endl;
# endif # endif
if (edgesToConsider.size() == 0) if (edgesToConsider.empty())
{ {
FatalErrorIn("void starMesh::createCoupleMatches()") FatalErrorIn("void starMesh::createCoupleMatches()")
<< setprecision(12) << setprecision(12)
@ -1420,7 +1419,7 @@ void starMesh::createCoupleMatches()
} // end of arbitrary match } // end of arbitrary match
} }
if (couples_.size() > 0) if (couples_.size())
{ {
// Loop through all cells and reset faces for removal to zero size // Loop through all cells and reset faces for removal to zero size
const labelList crfToc = cellRemovedFaces.toc(); const labelList crfToc = cellRemovedFaces.toc();
@ -1442,7 +1441,7 @@ void starMesh::createCoupleMatches()
cellFaces_[curCell][curRemovedFacesIter()].setSize(0); cellFaces_[curCell][curRemovedFacesIter()].setSize(0);
} }
if (curRemovedFaces.size() > 0) if (curRemovedFaces.size())
{ {
// reset the shape pointer to unknown // reset the shape pointer to unknown
cellShapes_[curCell] = cellShape(*unknownPtr_, labelList(0)); cellShapes_[curCell] = cellShape(*unknownPtr_, labelList(0));
@ -1468,7 +1467,7 @@ void starMesh::createCoupleMatches()
// copy original faces that have not been removed // copy original faces that have not been removed
forAll (oldFaces, faceI) forAll (oldFaces, faceI)
{ {
if (oldFaces[faceI].size() > 0) if (oldFaces[faceI].size())
{ {
newFaces[nNewFaces] = oldFaces[faceI]; newFaces[nNewFaces] = oldFaces[faceI];
nNewFaces++; nNewFaces++;
@ -1491,7 +1490,7 @@ void starMesh::createCoupleMatches()
// reset the size of the face list // reset the size of the face list
newFaces.setSize(nNewFaces); newFaces.setSize(nNewFaces);
if (curAddedFaces.size() > 0) if (curAddedFaces.size())
{ {
// reset the shape pointer to unknown // reset the shape pointer to unknown
cellShapes_[curCell] = cellShape(*unknownPtr_, labelList(0)); cellShapes_[curCell] = cellShape(*unknownPtr_, labelList(0));

View File

@ -264,7 +264,7 @@ starMesh::starMesh
readCouples(); readCouples();
if (couples_.size() > 0) if (couples_.size())
{ {
createCoupleMatches(); createCoupleMatches();
} }

View File

@ -160,7 +160,7 @@ int main(int argc, char *argv[])
{ {
nodeStream.getLine(line); nodeStream.getLine(line);
} }
while((line.size() > 0) && (line[0] == '#')); while (line.size() && line[0] == '#');
IStringStream nodeLine(line); IStringStream nodeLine(line);
@ -193,7 +193,7 @@ int main(int argc, char *argv[])
{ {
nodeStream.getLine(line); nodeStream.getLine(line);
if ((line.size() > 0) && (line[0] != '#')) if (line.size() && line[0] != '#')
{ {
IStringStream nodeLine(line); IStringStream nodeLine(line);
@ -237,7 +237,7 @@ int main(int argc, char *argv[])
{ {
eleStream.getLine(line); eleStream.getLine(line);
} }
while((line.size() > 0) && (line[0] == '#')); while (line.size() && line[0] == '#');
IStringStream eleLine(line); IStringStream eleLine(line);
@ -281,7 +281,7 @@ int main(int argc, char *argv[])
{ {
eleStream.getLine(line); eleStream.getLine(line);
if ((line.size() > 0) && (line[0] != '#')) if (line.size() && line[0] != '#')
{ {
IStringStream eleLine(line); IStringStream eleLine(line);
@ -356,7 +356,7 @@ int main(int argc, char *argv[])
{ {
faceStream.getLine(line); faceStream.getLine(line);
} }
while((line.size() > 0) && (line[0] == '#')); while (line.size() && line[0] == '#');
IStringStream faceLine(line); IStringStream faceLine(line);
@ -398,7 +398,7 @@ int main(int argc, char *argv[])
{ {
faceStream.getLine(line); faceStream.getLine(line);
if ((line.size() > 0) && (line[0] != '#')) if (line.size() && line[0] != '#')
{ {
IStringStream faceLine(line); IStringStream faceLine(line);

View File

@ -118,7 +118,7 @@ Foam::label Foam::blockMesh::numZonedBlocks() const
forAll(*this, blockI) forAll(*this, blockI)
{ {
if (operator[](blockI).blockDef().zoneName().size() > 0) if (operator[](blockI).blockDef().zoneName().size())
{ {
num++; num++;
} }

View File

@ -278,7 +278,7 @@ int main(int argc, char *argv[])
const labelListList& blockCells = b.cells(); const labelListList& blockCells = b.cells();
const word& zoneName = b.blockDef().zoneName(); const word& zoneName = b.blockDef().zoneName();
if (zoneName.size() > 0) if (zoneName.size())
{ {
HashTable<label>::const_iterator iter = zoneMap.find(zoneName); HashTable<label>::const_iterator iter = zoneMap.find(zoneName);

View File

@ -1,6 +1,6 @@
Info<< "Creating merge patch pairs" << nl << endl; Info<< "Creating merge patch pairs" << nl << endl;
if (mergePatchPairs.size() > 0) if (mergePatchPairs.size())
{ {
// Create and add point and face zones and mesh modifiers // Create and add point and face zones and mesh modifiers
List<pointZone*> pz(mergePatchPairs.size()); List<pointZone*> pz(mergePatchPairs.size());

View File

@ -177,7 +177,7 @@ Foam::label Foam::checkTopology
primitivePatch::surfaceTopo pTyp = pp.surfaceType(); primitivePatch::surfaceTopo pTyp = pp.surfaceType();
if (pp.size() == 0) if (pp.empty())
{ {
Pout<< setw(34) << "ok (empty)"; Pout<< setw(34) << "ok (empty)";
} }
@ -232,7 +232,7 @@ Foam::label Foam::checkTopology
Pout<< endl; Pout<< endl;
} }
if (points.size() > 0) if (points.size())
{ {
Pout<< " <<Writing " << points.size() Pout<< " <<Writing " << points.size()
<< " conflicting points to set " << " conflicting points to set "

View File

@ -172,7 +172,7 @@ void filterPatches(polyMesh& mesh)
if (isA<processorPolyPatch>(pp)) if (isA<processorPolyPatch>(pp))
{ {
if (pp.size() > 0) if (pp.size())
{ {
allPatches.append allPatches.append
( (
@ -586,7 +586,7 @@ int main(int argc, char *argv[])
// 1. Add all new patches // 1. Add all new patches
// ~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~
if (patchSources.size() > 0) if (patchSources.size())
{ {
// Old and new patches. // Old and new patches.
DynamicList<polyPatch*> allPatches(patches.size()+patchSources.size()); DynamicList<polyPatch*> allPatches(patches.size()+patchSources.size());

View File

@ -34,10 +34,7 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam defineTypeNameAndDebug(Foam::mergePolyMesh, 1);
{
defineTypeNameAndDebug(mergePolyMesh, 1);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -142,7 +139,7 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io)
// Point zones // Point zones
wordList curPointZoneNames = pointZones().names(); wordList curPointZoneNames = pointZones().names();
if (curPointZoneNames.size() > 0) if (curPointZoneNames.size())
{ {
pointZoneNames_.setCapacity(2*curPointZoneNames.size()); pointZoneNames_.setCapacity(2*curPointZoneNames.size());
} }
@ -155,7 +152,7 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io)
// Face zones // Face zones
wordList curFaceZoneNames = faceZones().names(); wordList curFaceZoneNames = faceZones().names();
if (curFaceZoneNames.size() > 0) if (curFaceZoneNames.size())
{ {
faceZoneNames_.setCapacity(2*curFaceZoneNames.size()); faceZoneNames_.setCapacity(2*curFaceZoneNames.size());
} }
@ -167,7 +164,7 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io)
// Cell zones // Cell zones
wordList curCellZoneNames = cellZones().names(); wordList curCellZoneNames = cellZones().names();
if (curCellZoneNames.size() > 0) if (curCellZoneNames.size())
{ {
cellZoneNames_.setCapacity(2*curCellZoneNames.size()); cellZoneNames_.setCapacity(2*curCellZoneNames.size());
} }

View File

@ -48,7 +48,7 @@ string getLine(std::ifstream& is)
{ {
std::getline(is, line); std::getline(is, line);
} }
while((line.size() > 0) && (line[0] == '#')); while (line.size() && line[0] == '#');
return line; return line;
} }

View File

@ -485,7 +485,7 @@ int main(int argc, char *argv[])
{ {
const labelList& added = oldToNew[oldCellI]; const labelList& added = oldToNew[oldCellI];
if (added.size() > 0) if (added.size())
{ {
forAll(added, i) forAll(added, i)
{ {

View File

@ -89,7 +89,7 @@ void backup
const word& toName const word& toName
) )
{ {
if (fromSet.size() > 0) if (fromSet.size())
{ {
Pout<< " Backing up " << fromName << " into " << toName << endl; Pout<< " Backing up " << fromName << " into " << toName << endl;
@ -284,7 +284,7 @@ void printAllSets(const polyMesh& mesh, Ostream& os)
polyMesh::meshSubDir/"sets" polyMesh::meshSubDir/"sets"
); );
IOobjectList cellSets(objects.lookupClass(cellSet::typeName)); IOobjectList cellSets(objects.lookupClass(cellSet::typeName));
if (cellSets.size() > 0) if (cellSets.size())
{ {
os << "cellSets:" << endl; os << "cellSets:" << endl;
forAllConstIter(IOobjectList, cellSets, iter) forAllConstIter(IOobjectList, cellSets, iter)
@ -294,7 +294,7 @@ void printAllSets(const polyMesh& mesh, Ostream& os)
} }
} }
IOobjectList faceSets(objects.lookupClass(faceSet::typeName)); IOobjectList faceSets(objects.lookupClass(faceSet::typeName));
if (faceSets.size() > 0) if (faceSets.size())
{ {
os << "faceSets:" << endl; os << "faceSets:" << endl;
forAllConstIter(IOobjectList, faceSets, iter) forAllConstIter(IOobjectList, faceSets, iter)
@ -304,7 +304,7 @@ void printAllSets(const polyMesh& mesh, Ostream& os)
} }
} }
IOobjectList pointSets(objects.lookupClass(pointSet::typeName)); IOobjectList pointSets(objects.lookupClass(pointSet::typeName));
if (pointSets.size() > 0) if (pointSets.size())
{ {
os << "pointSets:" << endl; os << "pointSets:" << endl;
forAllConstIter(IOobjectList, pointSets, iter) forAllConstIter(IOobjectList, pointSets, iter)
@ -347,7 +347,7 @@ bool doCommand
bool ok = true; bool ok = true;
// Set to work on // Set to work on
autoPtr<topoSet> currentSetPtr(NULL); autoPtr<topoSet> currentSetPtr;
word sourceType; word sourceType;
@ -383,7 +383,7 @@ bool doCommand
currentSet.resize(max(currentSet.size(), typSize)); currentSet.resize(max(currentSet.size(), typSize));
} }
if (!currentSetPtr.valid()) if (currentSetPtr.empty())
{ {
Pout<< " Cannot construct/load set " Pout<< " Cannot construct/load set "
<< topoSet::localPath(mesh, setName) << endl; << topoSet::localPath(mesh, setName) << endl;
@ -522,7 +522,7 @@ bool doCommand
Pout<< fIOErr.message().c_str() << endl; Pout<< fIOErr.message().c_str() << endl;
if (sourceType.size() != 0) if (sourceType.size())
{ {
Pout<< topoSetSource::usage(sourceType).c_str(); Pout<< topoSetSource::usage(sourceType).c_str();
} }
@ -533,7 +533,7 @@ bool doCommand
Pout<< fErr.message().c_str() << endl; Pout<< fErr.message().c_str() << endl;
if (sourceType.size() != 0) if (sourceType.size())
{ {
Pout<< topoSetSource::usage(sourceType).c_str(); Pout<< topoSetSource::usage(sourceType).c_str();
} }
@ -571,7 +571,7 @@ commandStatus parseType
IStringStream& is IStringStream& is
) )
{ {
if (setType.size() == 0) if (setType.empty())
{ {
Pout<< "Type 'help' for usage information" << endl; Pout<< "Type 'help' for usage information" << endl;
@ -689,7 +689,7 @@ commandStatus parseAction(const word& actionName)
{ {
commandStatus stat = INVALID; commandStatus stat = INVALID;
if (actionName.size() != 0) if (actionName.size())
{ {
try try
{ {
@ -792,7 +792,7 @@ int main(int argc, char *argv[])
std::getline(*fileStreamPtr, rawLine); std::getline(*fileStreamPtr, rawLine);
if (rawLine.size() > 0) if (rawLine.size())
{ {
Pout<< "Doing:" << rawLine << endl; Pout<< "Doing:" << rawLine << endl;
} }
@ -821,7 +821,7 @@ int main(int argc, char *argv[])
# endif # endif
} }
if (rawLine.size() == 0 || rawLine[0] == '#') if (rawLine.empty() || rawLine[0] == '#')
{ {
continue; continue;
} }

View File

@ -100,10 +100,10 @@ void checkPatch(const polyBoundaryMesh& bMesh, const word& name)
<< exit(FatalError); << exit(FatalError);
} }
if (bMesh[patchI].size() != 0) if (bMesh[patchI].size())
{ {
FatalErrorIn("checkPatch(const polyBoundaryMesh&, const word&)") FatalErrorIn("checkPatch(const polyBoundaryMesh&, const word&)")
<< "Patch " << name << " is present but not of zero size" << "Patch " << name << " is present but non-zero size"
<< exit(FatalError); << exit(FatalError);
} }
} }

View File

@ -878,7 +878,7 @@ void createAndWriteRegion
{ {
const polyPatch& pp = newPatches[patchI]; const polyPatch& pp = newPatches[patchI];
if (isA<processorPolyPatch>(pp) && pp.size() > 0) if (isA<processorPolyPatch>(pp) && pp.size())
{ {
oldToNew[patchI] = newI++; oldToNew[patchI] = newI++;
} }
@ -1049,7 +1049,7 @@ label findCorrespondingZone
labelList regionCells = findIndices(cellRegion, regionI); labelList regionCells = findIndices(cellRegion, regionI);
if (regionCells.size() == 0) if (regionCells.empty())
{ {
// My local portion is empty. Maps to any empty cellZone. Mark with // My local portion is empty. Maps to any empty cellZone. Mark with
// special value which can get overwritten by other processors. // special value which can get overwritten by other processors.
@ -1200,7 +1200,7 @@ int main(int argc, char *argv[])
boolList blockedFace; boolList blockedFace;
// Read from faceSet // Read from faceSet
if (blockedFacesName.size() > 0) if (blockedFacesName.size())
{ {
faceSet blockedFaceSet(mesh, blockedFacesName); faceSet blockedFaceSet(mesh, blockedFacesName);
Info<< "Read " << returnReduce(blockedFaceSet.size(), sumOp<label>()) Info<< "Read " << returnReduce(blockedFaceSet.size(), sumOp<label>())

View File

@ -82,7 +82,7 @@ void checkPatch(const polyBoundaryMesh& bMesh, const word& name)
<< exit(FatalError); << exit(FatalError);
} }
if (bMesh[patchI].size() == 0) if (bMesh[patchI].empty())
{ {
FatalErrorIn("checkPatch(const polyBoundaryMesh&, const word&)") FatalErrorIn("checkPatch(const polyBoundaryMesh&, const word&)")
<< "Patch " << name << " is present but zero size" << "Patch " << name << " is present but zero size"

View File

@ -152,7 +152,7 @@ int main(int argc, char *argv[])
); );
if (args.options().size() == 0) if (args.options().empty())
{ {
FatalErrorIn(args.executable()) FatalErrorIn(args.executable())
<< "No options supplied, please use one or more of " << "No options supplied, please use one or more of "

View File

@ -104,7 +104,7 @@ void domainDecomposition::distributeCells()
} }
} }
if (sameProcFaces.size() > 0) if (sameProcFaces.size())
{ {
Info<< "Selected " << sameProcFaces.size() Info<< "Selected " << sameProcFaces.size()
<< " faces whose owner and neighbour cell should be kept on the" << " faces whose owner and neighbour cell should be kept on the"
@ -123,7 +123,7 @@ void domainDecomposition::distributeCells()
*this *this
); );
if (sameProcFaces.size() == 0) if (sameProcFaces.empty())
{ {
cellToProc_ = decomposePtr().decompose(cellCentres()); cellToProc_ = decomposePtr().decompose(cellCentres());
} }

View File

@ -100,7 +100,7 @@ int main(int argc, char *argv[])
args args
); );
if (!timeDirs.size()) if (timeDirs.empty())
{ {
FatalErrorIn(args.executable()) FatalErrorIn(args.executable())
<< "No times selected" << "No times selected"
@ -319,7 +319,7 @@ int main(int argc, char *argv[])
} }
if (cloudObjects.size() > 0) if (cloudObjects.size())
{ {
// Pass2: reconstruct the cloud // Pass2: reconstruct the cloud
forAllConstIter(HashTable<IOobjectList>, cloudObjects, iter) forAllConstIter(HashTable<IOobjectList>, cloudObjects, iter)

View File

@ -558,7 +558,7 @@ void ensightFieldAscii
GeometricField<Type, fvPatchField, volMesh> vf(fieldObject, mesh); GeometricField<Type, fvPatchField, volMesh> vf(fieldObject, mesh);
if (!patchNames.size()) if (patchNames.empty())
{ {
if (Pstream::master()) if (Pstream::master())
{ {
@ -633,7 +633,7 @@ void ensightFieldAscii
const word& patchName = iter.key(); const word& patchName = iter.key();
const labelList& patchProcessors = iter(); const labelList& patchProcessors = iter();
if (!patchNames.size() || patchNames.found(patchName)) if (patchNames.empty() || patchNames.found(patchName))
{ {
if (patchIndices.found(patchName)) if (patchIndices.found(patchName))
{ {
@ -734,7 +734,7 @@ void ensightFieldBinary
GeometricField<Type, fvPatchField, volMesh> vf(fieldObject, mesh); GeometricField<Type, fvPatchField, volMesh> vf(fieldObject, mesh);
if (!patchNames.size()) if (patchNames.empty())
{ {
if (Pstream::master()) if (Pstream::master())
{ {
@ -805,7 +805,7 @@ void ensightFieldBinary
const word& patchName = iter.key(); const word& patchName = iter.key();
const labelList& patchProcessors = iter(); const labelList& patchProcessors = iter();
if (!patchNames.size() || patchNames.found(patchName)) if (patchNames.empty() || patchNames.found(patchName))
{ {
if (patchIndices.found(patchName)) if (patchIndices.found(patchName))
{ {

View File

@ -129,7 +129,7 @@ Foam::ensightMesh::ensightMesh
{ {
wordList patchNameList(IStringStream(args.options()["patches"])()); wordList patchNameList(IStringStream(args.options()["patches"])());
if (!patchNameList.size()) if (patchNameList.empty())
{ {
patchNameList = allPatchNames_.toc(); patchNameList = allPatchNames_.toc();
} }
@ -163,7 +163,7 @@ Foam::ensightMesh::ensightMesh
label nHexes = 0; label nHexes = 0;
label nPolys = 0; label nPolys = 0;
if (!patchNames_.size()) if (patchNames_.empty())
{ {
forAll(cellShapes, celli) forAll(cellShapes, celli)
{ {
@ -267,7 +267,7 @@ Foam::ensightMesh::ensightMesh
const word& patchName = iter.key(); const word& patchName = iter.key();
nFacePrimitives nfp; nFacePrimitives nfp;
if (!patchNames_.size() || patchNames_.found(patchName)) if (patchNames_.empty() || patchNames_.found(patchName))
{ {
if (patchIndices_.found(patchName)) if (patchIndices_.found(patchName))
{ {
@ -403,7 +403,7 @@ void Foam::ensightMesh::writePrimsBinary
numElem = cellShapes.size(); numElem = cellShapes.size();
if (cellShapes.size() > 0) if (cellShapes.size())
{ {
// All the cellShapes have the same number of elements! // All the cellShapes have the same number of elements!
int numIntElem = cellShapes.size()*cellShapes[0].size(); int numIntElem = cellShapes.size()*cellShapes[0].size();
@ -917,7 +917,7 @@ void Foam::ensightMesh::writeAscii
labelList pointOffsets(Pstream::nProcs(), 0); labelList pointOffsets(Pstream::nProcs(), 0);
if (!patchNames_.size()) if (patchNames_.empty())
{ {
label nPoints = points.size(); label nPoints = points.size();
Pstream::gather(nPoints, sumOp<label>()); Pstream::gather(nPoints, sumOp<label>());
@ -1044,7 +1044,7 @@ void Foam::ensightMesh::writeAscii
{ {
const labelList& patchProcessors = iter(); const labelList& patchProcessors = iter();
if (!patchNames_.size() || patchNames_.found(iter.key())) if (patchNames_.empty() || patchNames_.found(iter.key()))
{ {
const word& patchName = iter.key(); const word& patchName = iter.key();
const nFacePrimitives& nfp = nPatchPrims_.find(patchName)(); const nFacePrimitives& nfp = nPatchPrims_.find(patchName)();
@ -1244,7 +1244,7 @@ void Foam::ensightMesh::writeBinary
labelList pointOffsets(Pstream::nProcs(), 0); labelList pointOffsets(Pstream::nProcs(), 0);
if (!patchNames_.size()) if (patchNames_.empty())
{ {
label nPoints = points.size(); label nPoints = points.size();
Pstream::gather(nPoints, sumOp<label>()); Pstream::gather(nPoints, sumOp<label>());
@ -1373,7 +1373,7 @@ void Foam::ensightMesh::writeBinary
iCount ++; iCount ++;
const labelList& patchProcessors = iter(); const labelList& patchProcessors = iter();
if (!patchNames_.size() || patchNames_.found(iter.key())) if (patchNames_.empty() || patchNames_.found(iter.key()))
{ {
const word& patchName = iter.key(); const word& patchName = iter.key();
const nFacePrimitives& nfp = nPatchPrims_.find(patchName)(); const nFacePrimitives& nfp = nPatchPrims_.find(patchName)();

View File

@ -57,7 +57,7 @@ void writeEnsDataBinary
std::ofstream& ensightFile std::ofstream& ensightFile
) )
{ {
if (sf.size() > 0) if (sf.size())
{ {
List<float> temp(sf.size()); List<float> temp(sf.size());

View File

@ -77,9 +77,9 @@ forAllIter(HashTable<HashTable<word> >, cloudFields, cloudIter)
} }
} }
if (!cloudIter().size()) if (cloudIter().empty())
{ {
Info<< "removing cloud " << cloudName<< endl; Info<< "removing cloud " << cloudName << endl;
cloudFields.erase(cloudIter); cloudFields.erase(cloudIter);
} }
} }

View File

@ -227,7 +227,7 @@ int main(int argc, char *argv[])
# include "getFieldNames.H" # include "getFieldNames.H"
bool hasLagrangian = false; bool hasLagrangian = false;
if ((sprayScalarNames.size() > 0) || (sprayVectorNames.size() > 0)) if (sprayScalarNames.size() || sprayVectorNames.size())
{ {
hasLagrangian = true; hasLagrangian = true;
} }

View File

@ -80,7 +80,7 @@ for(label i=0; i < nTypes; i++)
wordList lagrangianScalarNames = objects.names("scalarField"); wordList lagrangianScalarNames = objects.names("scalarField");
wordList lagrangianVectorNames = objects.names("vectorField"); wordList lagrangianVectorNames = objects.names("vectorField");
if (particles.size() > 0) if (particles.size())
{ {
# include "gmvOutputLagrangian.H" # include "gmvOutputLagrangian.H"
} }

View File

@ -49,16 +49,11 @@ forAll(lagrangianScalarNames, i)
) )
); );
if (s.size() != 0) if (s.size())
{ {
gmvFile << name << nl; gmvFile << name << nl;
for for (label n = 0; n < s.size(); n++)
(
label n = 0;
n < s.size();
n++
)
{ {
gmvFile << s[n] << token::SPACE; gmvFile << s[n] << token::SPACE;
} }
@ -85,16 +80,11 @@ forAll(lagrangianVectorNames, i)
) )
); );
if (v.size() != 0) if (v.size())
{ {
gmvFile << name + "x" << nl; gmvFile << name + "x" << nl;
for for (label n = 0; n < v.size(); n++)
(
label n = 0;
n < v.size();
n++
)
{ {
gmvFile << v[n].x() << token::SPACE; gmvFile << v[n].x() << token::SPACE;
} }
@ -102,12 +92,7 @@ forAll(lagrangianVectorNames, i)
gmvFile << name + "y" << nl; gmvFile << name + "y" << nl;
for for (label n = 0; n < v.size(); n++)
(
label n = 0;
n < v.size();
n++
)
{ {
gmvFile << v[n].y() << token::SPACE; gmvFile << v[n].y() << token::SPACE;
} }
@ -115,19 +100,13 @@ forAll(lagrangianVectorNames, i)
gmvFile << name + "z" << nl; gmvFile << name + "z" << nl;
for for (label n = 0; n < v.size(); n++)
(
label n = 0;
n < v.size();
n++
)
{ {
gmvFile << v[n].z() << token::SPACE; gmvFile << v[n].z() << token::SPACE;
} }
gmvFile << nl; gmvFile << nl;
} }
} }

View File

@ -47,16 +47,11 @@ forAll(lagrangianScalarNames, i)
) )
); );
if (s.size() != 0) if (s.size())
{ {
gmvFile << name << nl; gmvFile << name << nl;
for for (label n = 0; n < s.size(); n++)
(
label n = 0;
n < s.size();
n++
)
{ {
gmvFile << s[n] << token::SPACE; gmvFile << s[n] << token::SPACE;
} }

View File

@ -339,7 +339,7 @@ int main(int argc, char *argv[])
( (
args.options().found("time") args.options().found("time")
|| args.options().found("latestTime") || args.options().found("latestTime")
|| cellSetName.size() > 0 || cellSetName.size()
|| regionName != polyMesh::defaultRegion || regionName != polyMesh::defaultRegion
) )
{ {

View File

@ -58,7 +58,7 @@ void readFields
++iter ++iter
) )
{ {
if (!selectedFields.size() || selectedFields.found(iter()->name())) if (selectedFields.empty() || selectedFields.found(iter()->name()))
{ {
fields.set fields.set
( (

View File

@ -47,7 +47,7 @@ Foam::vtkMesh::vtkMesh
subsetter_(baseMesh), subsetter_(baseMesh),
setName_(setName) setName_(setName)
{ {
if (setName.size() > 0) if (setName.size())
{ {
// Read cellSet using whole mesh // Read cellSet using whole mesh
cellSet currentSet(baseMesh_, setName_); cellSet currentSet(baseMesh_, setName_);
@ -71,7 +71,7 @@ Foam::polyMesh::readUpdateState Foam::vtkMesh::readUpdate()
topoPtr_.clear(); topoPtr_.clear();
if (setName_.size() > 0) if (setName_.size())
{ {
Info<< "Subsetting mesh based on cellSet " << setName_ << endl; Info<< "Subsetting mesh based on cellSet " << setName_ << endl;

View File

@ -105,13 +105,13 @@ public:
//- Check if running subMesh //- Check if running subMesh
bool useSubMesh() const bool useSubMesh() const
{ {
return setName_.size() > 0; return setName_.size();
} }
//- topology //- topology
const vtkTopo& topo() const const vtkTopo& topo() const
{ {
if (!topoPtr_.valid()) if (topoPtr_.empty())
{ {
topoPtr_.reset(new vtkTopo(mesh())); topoPtr_.reset(new vtkTopo(mesh()));
} }

View File

@ -154,6 +154,11 @@ class vtkPV3Foam
return size_; return size_;
} }
bool empty() const
{
return (size_ == 0);
}
void reset() void reset()
{ {
start_ = -1; start_ = -1;

View File

@ -147,14 +147,14 @@ int USERD_set_filenames
bool lagrangianNamesFound = false; bool lagrangianNamesFound = false;
label n = 0; label n = 0;
while ((!lagrangianNamesFound) && (n<Num_time_steps)) while (!lagrangianNamesFound && n < Num_time_steps)
{ {
runTime.setTime(TimeList[n+1], n+1); runTime.setTime(TimeList[n+1], n+1);
Cloud<passiveParticle> lagrangian(*meshPtr); Cloud<passiveParticle> lagrangian(*meshPtr);
n++; n++;
if (lagrangian.size()>0) if (lagrangian.size())
{ {
lagrangianNamesFound = true; lagrangianNamesFound = true;
} }

View File

@ -4,7 +4,6 @@ nVar -= Num_variables - nSprayVariables;
if (nVar >= 0) if (nVar >= 0)
{ {
word name = lagrangianScalarNames[nVar]; word name = lagrangianScalarNames[nVar];
IOField<scalar> s IOField<scalar> s
@ -20,15 +19,9 @@ if (nVar >= 0)
) )
); );
if (s.size() != 0) if (s.size())
{ {
for (label n = 0; n < s.size(); n++)
for
(
label n = 0;
n < s.size();
n++
)
{ {
var_array[n+1] = s[n]; var_array[n+1] = s[n];
} }
@ -36,7 +29,7 @@ if (nVar >= 0)
} }
else else
{ {
//Info << "getLagrangianScalar: nVar = " << nVar << endl; // Info << "getLagrangianScalar: nVar = " << nVar << endl;
return Z_UNDEF; return Z_UNDEF;
} }

View File

@ -21,16 +21,10 @@ if (nVar >= 0)
) )
); );
if (v.size() != 0) if (v.size())
{ {
for for (label n = 0; n < v.size(); n++)
(
label n = 0;
n < v.size();
n++
)
{ {
if (component == 0) if (component == 0)
{ {
var_array[n+1] = v[n].x(); var_array[n+1] = v[n].x();

View File

@ -235,7 +235,7 @@ static void createFieldNames
HashSet<word> surfScalarHash; HashSet<word> surfScalarHash;
HashSet<word> surfVectorHash; HashSet<word> surfVectorHash;
if (setName.size() == 0) if (setName.empty())
{ {
forAll(Times, timeI) forAll(Times, timeI)
{ {
@ -536,13 +536,12 @@ void user_query_file_function
fileName caseName(rootAndCase.name()); fileName caseName(rootAndCase.name());
// handle trailing '/' // handle trailing '/'
if (caseName.size() == 0) if (caseName.empty())
{ {
caseName = rootDir.name(); caseName = rootDir.name();
rootDir = rootDir.path(); rootDir = rootDir.path();
} }
Info<< "rootDir : " << rootDir << endl Info<< "rootDir : " << rootDir << endl
<< "caseName : " << caseName << endl << "caseName : " << caseName << endl
<< "setName : " << setName << endl; << "setName : " << setName << endl;

View File

@ -150,7 +150,7 @@ const Foam::fvMesh& Foam::readerDatabase::mesh() const
<< "No mesh set" << abort(FatalError); << "No mesh set" << abort(FatalError);
} }
if (setName_.size() == 0) if (setName_.empty())
{ {
return *meshPtr_; return *meshPtr_;
} }
@ -265,7 +265,7 @@ void Foam::readerDatabase::loadMesh()
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
); );
if (setName_.size() != 0) if (setName_.size())
{ {
Info<< "Subsetting mesh based on cellSet " << setName_ << endl; Info<< "Subsetting mesh based on cellSet " << setName_ << endl;
@ -294,7 +294,7 @@ Foam::polyMesh::readUpdateState Foam::readerDatabase::setTime
// Update loaded mesh // Update loaded mesh
meshChange = meshPtr_->readUpdate(); meshChange = meshPtr_->readUpdate();
if ((setName_.size() != 0) && (meshChange != polyMesh::UNCHANGED)) if (setName_.size() && meshChange != polyMesh::UNCHANGED)
{ {
Info<< "Subsetting mesh based on " << setName_ << endl; Info<< "Subsetting mesh based on " << setName_ << endl;

View File

@ -206,7 +206,7 @@ void mapLagrangian(const meshToMesh& meshToMeshInterp)
// Do closer inspection for unmapped particles // Do closer inspection for unmapped particles
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (unmappedSource.size() > 0) if (unmappedSource.size())
{ {
meshSearch targetSearcher(meshTarget, false); meshSearch targetSearcher(meshTarget, false);
@ -237,7 +237,7 @@ void mapLagrangian(const meshToMesh& meshToMeshInterp)
Info<< " after additional mesh searching found " Info<< " after additional mesh searching found "
<< targetParcels.size() << " parcels in target mesh." << endl; << targetParcels.size() << " parcels in target mesh." << endl;
if (addParticles.size() > 0) if (addParticles.size())
{ {
IOPosition<passiveParticle>(targetParcels).write(); IOPosition<passiveParticle>(targetParcels).write();

View File

@ -242,9 +242,7 @@ int main(int argc, char *argv[])
} }
} }
illegalFaces.shrink(); if (illegalFaces.size())
if (illegalFaces.size() > 0)
{ {
Pout<< "Surface has " << illegalFaces.size() Pout<< "Surface has " << illegalFaces.size()
<< " illegal triangles." << endl; << " illegal triangles." << endl;
@ -628,7 +626,7 @@ int main(int argc, char *argv[])
triSurfaceSearch querySurf(surf); triSurfaceSearch querySurf(surf);
surfaceIntersection inter(querySurf); surfaceIntersection inter(querySurf);
if ((inter.cutEdges().size() == 0) && (inter.cutPoints().size() == 0)) if (inter.cutEdges().empty() && inter.cutPoints().empty())
{ {
Pout<< "Surface is not self-intersecting" << endl; Pout<< "Surface is not self-intersecting" << endl;
} }

View File

@ -860,7 +860,7 @@ label collapseBase(triSurface& surf, const scalar minLen)
splitWeights splitWeights
); );
if (splitVerts.size() > 0) if (splitVerts.size())
{ {
// Split edge using splitVerts. All non-collapsed triangles // Split edge using splitVerts. All non-collapsed triangles
// using edge will get split. // using edge will get split.

View File

@ -49,9 +49,9 @@ void readNASEdges
edgeList& allEdges edgeList& allEdges
) )
{ {
IFstream OBJfile(inFileName); IFstream is(inFileName);
if (!OBJfile.good()) if (!is.good())
{ {
FatalErrorIn("readNASEdges") FatalErrorIn("readNASEdges")
<< "Cannot read file " << inFileName << "Cannot read file " << inFileName
@ -68,14 +68,14 @@ void readNASEdges
DynamicList<label> edgeIndices; DynamicList<label> edgeIndices;
while (OBJfile.good()) while (is.good())
{ {
string line; string line;
OBJfile.getLine(line); is.getLine(line);
if (line.size() > 0 && line[0] == '$') if (line.empty() || line[0] == '$')
{ {
// Skip comment // Skip empty and comment
continue; continue;
} }
@ -87,9 +87,9 @@ void readNASEdges
while (true) while (true)
{ {
string buf; string buf;
OBJfile.getLine(buf); is.getLine(buf);
if (buf.size() > 72 && buf[72]=='+') if (buf.size() > 72 && buf[72] == '+')
{ {
line += buf.substr(8, 64); line += buf.substr(8, 64);
} }

View File

@ -64,7 +64,7 @@ int main(int argc, char *argv[])
word patchName = pp.name(); word patchName = pp.name();
if (patchName.size() == 0) if (patchName.empty())
{ {
patchName = "patch" + Foam::name(patchI); patchName = "patch" + Foam::name(patchI);
} }

View File

@ -86,7 +86,7 @@ int main(int argc, char *argv[])
meshSubsetDict.lookup("zone") meshSubsetDict.lookup("zone")
); );
if ((markedZone.size() != 0) && (markedZone.size() != 2)) if (markedZone.size() && markedZone.size() != 2)
{ {
FatalErrorIn(args.executable()) FatalErrorIn(args.executable())
<< "zone specification should be two points, min and max of " << "zone specification should be two points, min and max of "
@ -115,7 +115,7 @@ int main(int argc, char *argv[])
// pick up faces connected to "localPoints" // pick up faces connected to "localPoints"
// //
if (markedPoints.size() > 0) if (markedPoints.size())
{ {
Info << "Found " << markedPoints.size() << " marked point(s)." << endl; Info << "Found " << markedPoints.size() << " marked point(s)." << endl;
@ -153,7 +153,7 @@ int main(int argc, char *argv[])
// pick up faces connected to "edges" // pick up faces connected to "edges"
// //
if (markedEdges.size() > 0) if (markedEdges.size())
{ {
Info << "Found " << markedEdges.size() << " marked edge(s)." << endl; Info << "Found " << markedEdges.size() << " marked edge(s)." << endl;
@ -293,7 +293,7 @@ int main(int argc, char *argv[])
// Number of additional faces picked up because of addFaceNeighbours // Number of additional faces picked up because of addFaceNeighbours
label nFaceNeighbours = 0; label nFaceNeighbours = 0;
if (markedFaces.size() > 0) if (markedFaces.size())
{ {
Info << "Found " << markedFaces.size() << " marked face(s)." << endl; Info << "Found " << markedFaces.size() << " marked face(s)." << endl;

View File

@ -63,7 +63,7 @@ int main(int argc, char *argv[])
Info<< "Writing surf to " << outFileName << " ..." << endl; Info<< "Writing surf to " << outFileName << " ..." << endl;
if (args.options().size() == 0) if (args.options().empty())
{ {
FatalErrorIn(args.executable()) FatalErrorIn(args.executable())
<< "No options supplied, please use one or more of " << "No options supplied, please use one or more of "

View File

@ -284,7 +284,7 @@ Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory)
bool Foam::mkDir(const fileName& pathName, mode_t mode) bool Foam::mkDir(const fileName& pathName, mode_t mode)
{ {
// empty names are meaningless // empty names are meaningless
if (!pathName.size()) if (pathName.empty())
{ {
return false; return false;
} }
@ -567,10 +567,10 @@ Foam::fileNameList Foam::readDir
{ {
fileName fName(list->d_name); fileName fName(list->d_name);
// ignore files begining with ., i.e. ., .. and .??* // ignore files begining with ., i.e. '.', '..' and '.*'
if (fName.size() > 0 && fName[size_t(0)] != '.') if (fName.size() && fName[0] != '.')
{ {
word fileNameExt = fName.ext(); word fExt = fName.ext();
if if
( (
@ -579,10 +579,10 @@ Foam::fileNameList Foam::readDir
( (
type == fileName::FILE type == fileName::FILE
&& fName[fName.size()-1] != '~' && fName[fName.size()-1] != '~'
&& fileNameExt != "bak" && fExt != "bak"
&& fileNameExt != "BAK" && fExt != "BAK"
&& fileNameExt != "old" && fExt != "old"
&& fileNameExt != "save" && fExt != "save"
) )
) )
{ {
@ -593,7 +593,7 @@ Foam::fileNameList Foam::readDir
dirEntries.setSize(dirEntries.size() + maxNnames); dirEntries.setSize(dirEntries.size() + maxNnames);
} }
if (filtergz && fileNameExt == "gz") if (filtergz && fExt == "gz")
{ {
dirEntries[nEntries++] = fName.lessExt(); dirEntries[nEntries++] = fName.lessExt();
} }
@ -616,17 +616,17 @@ Foam::fileNameList Foam::readDir
} }
// Copy, recursively if necessary, the source top the destination // Copy, recursively if necessary, the source to the destination
bool Foam::cp(const fileName& src, const fileName& dest) bool Foam::cp(const fileName& src, const fileName& dest)
{ {
fileName destFile(dest);
// Make sure source exists. // Make sure source exists.
if (!exists(src)) if (!exists(src))
{ {
return false; return false;
} }
fileName destFile(dest);
// Check type of source file. // Check type of source file.
if (src.type() == fileName::FILE) if (src.type() == fileName::FILE)
{ {
@ -676,7 +676,7 @@ bool Foam::cp(const fileName& src, const fileName& dest)
destFile = destFile/src.component(src.components().size() -1); destFile = destFile/src.component(src.components().size() -1);
} }
// Make sure the destination directory extists. // Make sure the destination directory exists.
if (!dir(destFile) && !mkDir(destFile)) if (!dir(destFile) && !mkDir(destFile))
{ {
return false; return false;

View File

@ -149,7 +149,7 @@ void getSymbolForRaw
const word& address const word& address
) )
{ {
if (filename.size() > 0 && filename[0] == '/') if (filename.size() && filename[0] == '/')
{ {
string fcnt = pOpen string fcnt = pOpen
( (
@ -189,7 +189,7 @@ void error::printStack(Ostream& os)
string::size_type space = line.rfind(' ') + 1; string::size_type space = line.rfind(' ') + 1;
fileName libPath = line.substr(space, line.size()-space); fileName libPath = line.substr(space, line.size()-space);
if (libPath.size() > 0 && libPath[0] == '/') if (libPath.size() && libPath[0] == '/')
{ {
string offsetString(line.substr(0, line.find('-'))); string offsetString(line.substr(0, line.find('-')));
IStringStream offsetStr(offsetString); IStringStream offsetStr(offsetString);

View File

@ -476,8 +476,8 @@ void Foam::StaticHashTable<T, Key, Hash>::operator=
} }
// could be zero-sized from a previous transfer() // keys could be empty from a previous transfer()
if (keys_.size() == 0) if (keys_.empty())
{ {
keys_.setSize(rhs.keys_.size()); keys_.setSize(rhs.keys_.size());
objects_.setSize(keys_.size()); objects_.setSize(keys_.size());

View File

@ -328,7 +328,7 @@ Foam::StaticHashTable<T, Key, Hash>::begin()
// Find first non-empty entry // Find first non-empty entry
forAll(keys_, hashIdx) forAll(keys_, hashIdx)
{ {
if (keys_[hashIdx].size() > 0) if (keys_[hashIdx].size())
{ {
return iterator(*this, hashIdx, 0); return iterator(*this, hashIdx, 0);
} }
@ -360,7 +360,7 @@ Foam::StaticHashTable<T, Key, Hash>::begin() const
// Find first non-empty entry // Find first non-empty entry
forAll(keys_, hashIdx) forAll(keys_, hashIdx)
{ {
if (keys_[hashIdx].size() > 0) if (keys_[hashIdx].size())
{ {
return const_iterator(*this, hashIdx, 0); return const_iterator(*this, hashIdx, 0);
} }

View File

@ -52,7 +52,7 @@ Foam::IOobjectList::IOobjectList
{ {
newInstance = db.time().findInstancePath(instant(instance)); newInstance = db.time().findInstancePath(instant(instance));
if (!newInstance.size()) if (newInstance.empty())
{ {
return; return;
} }
@ -181,7 +181,7 @@ Foam::wordList Foam::IOobjectList::names() const
{ {
wordList objectNames(size()); wordList objectNames(size());
label count=0; label count = 0;
for for
( (
HashPtrTable<IOobject>::const_iterator iter = begin(); HashPtrTable<IOobject>::const_iterator iter = begin();
@ -200,7 +200,7 @@ Foam::wordList Foam::IOobjectList::names(const word& ClassName) const
{ {
wordList objectNames(size()); wordList objectNames(size());
label count=0; label count = 0;
for for
( (
HashPtrTable<IOobject>::const_iterator iter = begin(); HashPtrTable<IOobject>::const_iterator iter = begin();

View File

@ -42,7 +42,7 @@ Foam::IFstreamAllocator::IFstreamAllocator(const fileName& pathname)
ifPtr_(NULL), ifPtr_(NULL),
compression_(IOstream::UNCOMPRESSED) compression_(IOstream::UNCOMPRESSED)
{ {
if (!pathname.size()) if (pathname.empty())
{ {
if (IFstream::debug) if (IFstream::debug)
{ {

View File

@ -46,7 +46,7 @@ Foam::OFstreamAllocator::OFstreamAllocator
: :
ofPtr_(NULL) ofPtr_(NULL)
{ {
if (!pathname.size()) if (pathname.empty())
{ {
if (OFstream::debug) if (OFstream::debug)
{ {

View File

@ -136,18 +136,18 @@ Foam::Ostream& Foam::OPstream::write(const char* str)
{ {
word nonWhiteChars(string::validate<word>(str)); word nonWhiteChars(string::validate<word>(str));
if (nonWhiteChars.size() == 0) if (nonWhiteChars.size() == 1)
{
return *this;
}
else if (nonWhiteChars.size() == 1)
{ {
return write(nonWhiteChars.c_str()[1]); return write(nonWhiteChars.c_str()[1]);
} }
else else if (nonWhiteChars.size())
{ {
return write(nonWhiteChars); return write(nonWhiteChars);
} }
else
{
return *this;
}
} }

View File

@ -236,7 +236,7 @@ Foam::List<Foam::instant> Foam::timeSelector::select0
{ {
instantList timeDirs = timeSelector::select(runTime.times(), args); instantList timeDirs = timeSelector::select(runTime.times(), args);
if (!timeDirs.size()) if (timeDirs.empty())
{ {
FatalErrorIn(args.executable()) FatalErrorIn(args.executable())
<< "No times selected" << "No times selected"

View File

@ -46,7 +46,7 @@ bool Foam::dictionary::findInPatterns
DLList<autoPtr<regExp> >::const_iterator& reLink DLList<autoPtr<regExp> >::const_iterator& reLink
) const ) const
{ {
if (patternEntries_.size() > 0) if (patternEntries_.size())
{ {
while (wcLink != patternEntries_.end()) while (wcLink != patternEntries_.end())
{ {
@ -76,7 +76,7 @@ bool Foam::dictionary::findInPatterns
DLList<autoPtr<regExp> >::iterator& reLink DLList<autoPtr<regExp> >::iterator& reLink
) )
{ {
if (patternEntries_.size() > 0) if (patternEntries_.size())
{ {
while (wcLink != patternEntries_.end()) while (wcLink != patternEntries_.end())
{ {
@ -240,7 +240,7 @@ bool Foam::dictionary::found(const word& keyword, bool recursive) const
} }
else else
{ {
if (patternEntries_.size() > 0) if (patternEntries_.size())
{ {
DLList<entry*>::const_iterator wcLink = patternEntries_.begin(); DLList<entry*>::const_iterator wcLink = patternEntries_.begin();
DLList<autoPtr<regExp> >::const_iterator reLink = DLList<autoPtr<regExp> >::const_iterator reLink =
@ -276,7 +276,7 @@ const Foam::entry* Foam::dictionary::lookupEntryPtr
if (iter == hashedEntries_.end()) if (iter == hashedEntries_.end())
{ {
if (patternMatch && patternEntries_.size() > 0) if (patternMatch && patternEntries_.size())
{ {
DLList<entry*>::const_iterator wcLink = DLList<entry*>::const_iterator wcLink =
patternEntries_.begin(); patternEntries_.begin();
@ -315,7 +315,7 @@ Foam::entry* Foam::dictionary::lookupEntryPtr
if (iter == hashedEntries_.end()) if (iter == hashedEntries_.end())
{ {
if (patternMatch && patternEntries_.size() > 0) if (patternMatch && patternEntries_.size())
{ {
DLList<entry*>::iterator wcLink = DLList<entry*>::iterator wcLink =
patternEntries_.begin(); patternEntries_.begin();

View File

@ -113,15 +113,19 @@ Foam::dictionary& Foam::primitiveEntry::dict()
} }
void Foam::primitiveEntry::insert(const tokenList& varTokens, const label i) void Foam::primitiveEntry::insert
(
const tokenList& varTokens,
const label posI
)
{ {
tokenList& tokens = *this; tokenList& tokens = *this;
if (!varTokens.size()) if (varTokens.empty())
{ {
label end = tokens.size() - 1; label end = tokens.size() - 1;
for(label j=i; j<end; j++) for (label j=posI; j<end; j++)
{ {
tokens[j] = tokens[j+1]; tokens[j] = tokens[j+1];
} }
@ -135,7 +139,7 @@ void Foam::primitiveEntry::insert(const tokenList& varTokens, const label i)
label end = tokens.size() - 1; label end = tokens.size() - 1;
label offset = varTokens.size() - 1; label offset = varTokens.size() - 1;
for(label j=end; j>i; j--) for (label j=end; j>posI; j--)
{ {
tokens[j] = tokens[j-offset]; tokens[j] = tokens[j-offset];
} }
@ -143,7 +147,7 @@ void Foam::primitiveEntry::insert(const tokenList& varTokens, const label i)
forAll(varTokens, j) forAll(varTokens, j)
{ {
tokens[i + j] = varTokens[j]; tokens[posI + j] = varTokens[j];
} }
} }

View File

@ -99,8 +99,8 @@ public:
//- Read the complete entry from the given stream //- Read the complete entry from the given stream
void readEntry(const dictionary&, Istream&); void readEntry(const dictionary&, Istream&);
//- Insert the given tokens at token i //- Insert the given tokens at token posI
void insert(const tokenList&, const label i); void insert(const tokenList&, const label posI);
public: public:

View File

@ -55,7 +55,7 @@ bool regIOobject::writeObject
return false; return false;
} }
if (!instance().size()) if (instance().empty())
{ {
SeriousErrorIn("regIOobject::write()") SeriousErrorIn("regIOobject::write()")
<< "instance undefined for object " << name() << "instance undefined for object " << name()

View File

@ -50,7 +50,7 @@ UNARY_FUNCTION(symmTensor, symmTensor, cof)
void inv(Field<symmTensor>& tf, const UList<symmTensor>& tf1) void inv(Field<symmTensor>& tf, const UList<symmTensor>& tf1)
{ {
if (!tf.size()) if (tf.empty())
{ {
return; return;
} }

View File

@ -49,7 +49,7 @@ UNARY_FUNCTION(tensor, tensor, cof)
void inv(Field<tensor>& tf, const UList<tensor>& tf1) void inv(Field<tensor>& tf, const UList<tensor>& tf1)
{ {
if (!tf.size()) if (tf.empty())
{ {
return; return;
} }

View File

@ -312,7 +312,7 @@ void PatchToPatchInterpolation<FromPatch, ToPatch>::calcFaceAddressing() const
if if
( (
m < directHitTol // Direct hit m < directHitTol // Direct hit
|| neighbours.size() == 0 || neighbours.empty()
) )
{ {
faceWeights.set(faceI, new scalarField(1)); faceWeights.set(faceI, new scalarField(1));

View File

@ -73,7 +73,7 @@ labelList bandCompression(const labelListList& cellCellAddressing)
// neighbours. If the neighbour in question has not been visited, // neighbours. If the neighbour in question has not been visited,
// add it to the end of the nextCell list // add it to the end of the nextCell list
while (nextCell.size() > 0) while (nextCell.size())
{ {
currentCell = nextCell.removeHead(); currentCell = nextCell.removeHead();

View File

@ -50,7 +50,7 @@ const Foam::boundBox Foam::boundBox::invertedBox
void Foam::boundBox::calculate(const pointField& points, const bool doReduce) void Foam::boundBox::calculate(const pointField& points, const bool doReduce)
{ {
if (points.size() == 0) if (points.empty())
{ {
min_ = point::zero; min_ = point::zero;
max_ = point::zero; max_ = point::zero;

View File

@ -49,7 +49,7 @@ bool Foam::matchPoints
if (origin == point(VGREAT, VGREAT, VGREAT)) if (origin == point(VGREAT, VGREAT, VGREAT))
{ {
if (pts1.size() > 0) if (pts1.size())
{ {
compareOrigin = sum(pts1)/pts1.size(); compareOrigin = sum(pts1)/pts1.size();
} }

View File

@ -44,7 +44,7 @@ bool Foam::mergePoints
if (origin == point(VGREAT, VGREAT, VGREAT)) if (origin == point(VGREAT, VGREAT, VGREAT))
{ {
if (points.size() > 0) if (points.size())
{ {
compareOrigin = sum(points)/points.size(); compareOrigin = sum(points)/points.size();
} }
@ -57,7 +57,7 @@ bool Foam::mergePoints
// Storage for merged points // Storage for merged points
newPoints.setSize(points.size()); newPoints.setSize(points.size());
if (points.size() == 0) if (points.empty())
{ {
return false; return false;
} }

View File

@ -97,7 +97,7 @@ void Foam::pointMapper::calcAddressing() const
label pointI = cfc[cfcI].index(); label pointI = cfc[cfcI].index();
if (addr[pointI].size() > 0) if (addr[pointI].size())
{ {
FatalErrorIn("void pointMapper::calcAddressing() const") FatalErrorIn("void pointMapper::calcAddressing() const")
<< "Master point " << pointI << "Master point " << pointI
@ -118,7 +118,7 @@ void Foam::pointMapper::calcAddressing() const
forAll (cm, pointI) forAll (cm, pointI)
{ {
if (cm[pointI] > -1 && addr[pointI].size() == 0) if (cm[pointI] > -1 && addr[pointI].empty())
{ {
// Mapped from a single point // Mapped from a single point
addr[pointI] = labelList(1, cm[pointI]); addr[pointI] = labelList(1, cm[pointI]);
@ -135,7 +135,7 @@ void Foam::pointMapper::calcAddressing() const
forAll (addr, pointI) forAll (addr, pointI)
{ {
if (addr[pointI].size() == 0) if (addr[pointI].empty())
{ {
// Mapped from a dummy point. Take point 0 with weight 1. // Mapped from a dummy point. Take point 0 with weight 1.
addr[pointI] = labelList(1, 0); addr[pointI] = labelList(1, 0);
@ -175,7 +175,7 @@ Foam::pointMapper::pointMapper(const pointMesh& pMesh, const mapPolyMesh& mpm)
insertedPointLabelsPtr_(NULL) insertedPointLabelsPtr_(NULL)
{ {
// Check for possibility of direct mapping // Check for possibility of direct mapping
if (mpm_.pointsFromPointsMap().size() == 0) if (mpm_.pointsFromPointsMap().empty())
{ {
direct_ = true; direct_ = true;
} }
@ -185,7 +185,7 @@ Foam::pointMapper::pointMapper(const pointMesh& pMesh, const mapPolyMesh& mpm)
} }
// Check for inserted points // Check for inserted points
if (direct_ && (mpm_.pointMap().size() == 0 || min(mpm_.pointMap()) > -1)) if (direct_ && (mpm_.pointMap().empty() || min(mpm_.pointMap()) > -1))
{ {
insertedPoints_ = false; insertedPoints_ = false;
} }

View File

@ -96,7 +96,7 @@ void Foam::cellMapper::calcAddressing() const
label cellI = cfp[cfpI].index(); label cellI = cfp[cfpI].index();
if (addr[cellI].size() > 0) if (addr[cellI].size())
{ {
FatalErrorIn("void cellMapper::calcAddressing() const") FatalErrorIn("void cellMapper::calcAddressing() const")
<< "Master cell " << cellI << "Master cell " << cellI
@ -118,7 +118,7 @@ void Foam::cellMapper::calcAddressing() const
label cellI = cfe[cfeI].index(); label cellI = cfe[cfeI].index();
if (addr[cellI].size() > 0) if (addr[cellI].size())
{ {
FatalErrorIn("void cellMapper::calcAddressing() const") FatalErrorIn("void cellMapper::calcAddressing() const")
<< "Master cell " << cellI << "Master cell " << cellI
@ -140,7 +140,7 @@ void Foam::cellMapper::calcAddressing() const
label cellI = cff[cffI].index(); label cellI = cff[cffI].index();
if (addr[cellI].size() > 0) if (addr[cellI].size())
{ {
FatalErrorIn("void cellMapper::calcAddressing() const") FatalErrorIn("void cellMapper::calcAddressing() const")
<< "Master cell " << cellI << "Master cell " << cellI
@ -162,7 +162,7 @@ void Foam::cellMapper::calcAddressing() const
label cellI = cfc[cfcI].index(); label cellI = cfc[cfcI].index();
if (addr[cellI].size() > 0) if (addr[cellI].size())
{ {
FatalErrorIn("void cellMapper::calcAddressing() const") FatalErrorIn("void cellMapper::calcAddressing() const")
<< "Master cell " << cellI << "Master cell " << cellI
@ -183,7 +183,7 @@ void Foam::cellMapper::calcAddressing() const
forAll (cm, cellI) forAll (cm, cellI)
{ {
if (cm[cellI] > -1 && addr[cellI].size() == 0) if (cm[cellI] > -1 && addr[cellI].empty())
{ {
// Mapped from a single cell // Mapped from a single cell
addr[cellI] = labelList(1, cm[cellI]); addr[cellI] = labelList(1, cm[cellI]);
@ -200,7 +200,7 @@ void Foam::cellMapper::calcAddressing() const
forAll (addr, cellI) forAll (addr, cellI)
{ {
if (addr[cellI].size() == 0) if (addr[cellI].empty())
{ {
// Mapped from a dummy cell // Mapped from a dummy cell
addr[cellI] = labelList(1, 0); addr[cellI] = labelList(1, 0);
@ -242,10 +242,10 @@ Foam::cellMapper::cellMapper(const mapPolyMesh& mpm)
// Check for possibility of direct mapping // Check for possibility of direct mapping
if if
( (
mpm_.cellsFromPointsMap().size() == 0 mpm_.cellsFromPointsMap().empty()
&& mpm_.cellsFromEdgesMap().size() == 0 && mpm_.cellsFromEdgesMap().empty()
&& mpm_.cellsFromFacesMap().size() == 0 && mpm_.cellsFromFacesMap().empty()
&& mpm_.cellsFromCellsMap().size() == 0 && mpm_.cellsFromCellsMap().empty()
) )
{ {
direct_ = true; direct_ = true;
@ -256,7 +256,7 @@ Foam::cellMapper::cellMapper(const mapPolyMesh& mpm)
} }
// Check for inserted cells // Check for inserted cells
if (direct_ && (mpm_.cellMap().size() == 0 || min(mpm_.cellMap()) > -1)) if (direct_ && (mpm_.cellMap().empty() || min(mpm_.cellMap()) > -1))
{ {
insertedCells_ = false; insertedCells_ = false;
} }

View File

@ -96,7 +96,7 @@ void Foam::faceMapper::calcAddressing() const
label faceI = ffp[ffpI].index(); label faceI = ffp[ffpI].index();
if (addr[faceI].size() > 0) if (addr[faceI].size())
{ {
FatalErrorIn("void faceMapper::calcAddressing() const") FatalErrorIn("void faceMapper::calcAddressing() const")
<< "Master face " << faceI << "Master face " << faceI
@ -118,7 +118,7 @@ void Foam::faceMapper::calcAddressing() const
label faceI = ffe[ffeI].index(); label faceI = ffe[ffeI].index();
if (addr[faceI].size() > 0) if (addr[faceI].size())
{ {
FatalErrorIn("void faceMapper::calcAddressing() const") FatalErrorIn("void faceMapper::calcAddressing() const")
<< "Master face " << faceI << "Master face " << faceI
@ -140,7 +140,7 @@ void Foam::faceMapper::calcAddressing() const
label faceI = fff[fffI].index(); label faceI = fff[fffI].index();
if (addr[faceI].size() > 0) if (addr[faceI].size())
{ {
FatalErrorIn("void faceMapper::calcAddressing() const") FatalErrorIn("void faceMapper::calcAddressing() const")
<< "Master face " << faceI << "Master face " << faceI
@ -160,7 +160,7 @@ void Foam::faceMapper::calcAddressing() const
forAll (fm, faceI) forAll (fm, faceI)
{ {
if (fm[faceI] > -1 && addr[faceI].size() == 0) if (fm[faceI] > -1 && addr[faceI].empty())
{ {
// Mapped from a single face // Mapped from a single face
addr[faceI] = labelList(1, fm[faceI]); addr[faceI] = labelList(1, fm[faceI]);
@ -178,7 +178,7 @@ void Foam::faceMapper::calcAddressing() const
forAll (addr, faceI) forAll (addr, faceI)
{ {
if (addr[faceI].size() == 0) if (addr[faceI].empty())
{ {
// Mapped from a dummy face // Mapped from a dummy face
addr[faceI] = labelList(1, 0); addr[faceI] = labelList(1, 0);
@ -220,9 +220,9 @@ Foam::faceMapper::faceMapper(const mapPolyMesh& mpm)
// Check for possibility of direct mapping // Check for possibility of direct mapping
if if
( (
mpm_.facesFromPointsMap().size() == 0 mpm_.facesFromPointsMap().empty()
&& mpm_.facesFromEdgesMap().size() == 0 && mpm_.facesFromEdgesMap().empty()
&& mpm_.facesFromFacesMap().size() == 0 && mpm_.facesFromFacesMap().empty()
) )
{ {
direct_ = true; direct_ = true;
@ -233,7 +233,7 @@ Foam::faceMapper::faceMapper(const mapPolyMesh& mpm)
} }
// Check for inserted faces // Check for inserted faces
if (direct_ && (mpm_.faceMap().size() == 0 || min(mpm_.faceMap()) > -1)) if (direct_ && (mpm_.faceMap().empty() || min(mpm_.faceMap()) > -1))
{ {
insertedFaces_ = false; insertedFaces_ = false;
} }

View File

@ -48,12 +48,12 @@ Foam::List<Foam::labelPair> Foam::mapDistribute::schedule
{ {
if (procI != Pstream::myProcNo()) if (procI != Pstream::myProcNo())
{ {
if (subMap[procI].size() > 0) if (subMap[procI].size())
{ {
// I need to send to procI // I need to send to procI
commsSet.insert(labelPair(Pstream::myProcNo(), procI)); commsSet.insert(labelPair(Pstream::myProcNo(), procI));
} }
if (constructMap[procI].size() > 0) if (constructMap[procI].size())
{ {
// I need to receive from procI // I need to receive from procI
commsSet.insert(labelPair(procI, Pstream::myProcNo())); commsSet.insert(labelPair(procI, Pstream::myProcNo()));
@ -288,7 +288,7 @@ void Foam::mapDistribute::compact(const boolList& elemIsUsed)
{ {
const labelList& map = constructMap_[domain]; const labelList& map = constructMap_[domain];
if (domain != Pstream::myProcNo() && map.size() > 0) if (domain != Pstream::myProcNo() && map.size())
{ {
boolList& subField = sendFields[domain]; boolList& subField = sendFields[domain];
subField.setSize(map.size()); subField.setSize(map.size());
@ -315,7 +315,7 @@ void Foam::mapDistribute::compact(const boolList& elemIsUsed)
{ {
const labelList& map = subMap_[domain]; const labelList& map = subMap_[domain];
if (domain != Pstream::myProcNo() && map.size() > 0) if (domain != Pstream::myProcNo() && map.size())
{ {
recvFields[domain].setSize(map.size()); recvFields[domain].setSize(map.size());
IPstream::read IPstream::read

View File

@ -50,7 +50,7 @@ void Foam::mapDistribute::distribute
{ {
const labelList& map = subMap[domain]; const labelList& map = subMap[domain];
if (domain != Pstream::myProcNo() && map.size() > 0) if (domain != Pstream::myProcNo() && map.size())
{ {
List<T> subField(map.size()); List<T> subField(map.size());
forAll(map, i) forAll(map, i)
@ -86,7 +86,7 @@ void Foam::mapDistribute::distribute
{ {
const labelList& map = constructMap[domain]; const labelList& map = constructMap[domain];
if (domain != Pstream::myProcNo() && map.size() > 0) if (domain != Pstream::myProcNo() && map.size())
{ {
IPstream fromNbr(Pstream::blocking, domain); IPstream fromNbr(Pstream::blocking, domain);
List<T> subField(fromNbr); List<T> subField(fromNbr);
@ -227,7 +227,7 @@ void Foam::mapDistribute::distribute
{ {
const labelList& map = subMap[domain]; const labelList& map = subMap[domain];
if (domain != Pstream::myProcNo() && map.size() > 0) if (domain != Pstream::myProcNo() && map.size())
{ {
List<T>& subField = sendFields[domain]; List<T>& subField = sendFields[domain];
subField.setSize(map.size()); subField.setSize(map.size());
@ -254,7 +254,7 @@ void Foam::mapDistribute::distribute
{ {
const labelList& map = constructMap[domain]; const labelList& map = constructMap[domain];
if (domain != Pstream::myProcNo() && map.size() > 0) if (domain != Pstream::myProcNo() && map.size())
{ {
recvFields[domain].setSize(map.size()); recvFields[domain].setSize(map.size());
IPstream::read IPstream::read
@ -310,7 +310,7 @@ void Foam::mapDistribute::distribute
{ {
const labelList& map = constructMap[domain]; const labelList& map = constructMap[domain];
if (domain != Pstream::myProcNo() && map.size() > 0) if (domain != Pstream::myProcNo() && map.size())
{ {
if (recvFields[domain].size() != map.size()) if (recvFields[domain].size() != map.size())
{ {
@ -372,7 +372,7 @@ void Foam::mapDistribute::distribute
{ {
const labelList& map = subMap[domain]; const labelList& map = subMap[domain];
if (domain != Pstream::myProcNo() && map.size() > 0) if (domain != Pstream::myProcNo() && map.size())
{ {
List<T> subField(map.size()); List<T> subField(map.size());
forAll(map, i) forAll(map, i)
@ -409,7 +409,7 @@ void Foam::mapDistribute::distribute
{ {
const labelList& map = constructMap[domain]; const labelList& map = constructMap[domain];
if (domain != Pstream::myProcNo() && map.size() > 0) if (domain != Pstream::myProcNo() && map.size())
{ {
IPstream fromNbr(Pstream::blocking, domain); IPstream fromNbr(Pstream::blocking, domain);
List<T> subField(fromNbr); List<T> subField(fromNbr);
@ -550,7 +550,7 @@ void Foam::mapDistribute::distribute
{ {
const labelList& map = subMap[domain]; const labelList& map = subMap[domain];
if (domain != Pstream::myProcNo() && map.size() > 0) if (domain != Pstream::myProcNo() && map.size())
{ {
List<T>& subField = sendFields[domain]; List<T>& subField = sendFields[domain];
subField.setSize(map.size()); subField.setSize(map.size());
@ -577,7 +577,7 @@ void Foam::mapDistribute::distribute
{ {
const labelList& map = constructMap[domain]; const labelList& map = constructMap[domain];
if (domain != Pstream::myProcNo() && map.size() > 0) if (domain != Pstream::myProcNo() && map.size())
{ {
recvFields[domain].setSize(map.size()); recvFields[domain].setSize(map.size());
IPstream::read IPstream::read
@ -632,7 +632,7 @@ void Foam::mapDistribute::distribute
{ {
const labelList& map = constructMap[domain]; const labelList& map = constructMap[domain];
if (domain != Pstream::myProcNo() && map.size() > 0) if (domain != Pstream::myProcNo() && map.size())
{ {
if (recvFields[domain].size() != map.size()) if (recvFields[domain].size() != map.size())
{ {

View File

@ -251,7 +251,7 @@ Foam::polyBoundaryMesh::neighbourEdges() const
} }
} }
if (pointsToEdge.size() > 0) if (pointsToEdge.size())
{ {
FatalErrorIn("polyBoundaryMesh::neighbourEdges() const") FatalErrorIn("polyBoundaryMesh::neighbourEdges() const")
<< "Not all boundary edges of patches match up." << nl << "Not all boundary edges of patches match up." << nl
@ -425,7 +425,7 @@ Foam::labelHashSet Foam::polyBoundaryMesh::patchSet
// of all patch names for matches // of all patch names for matches
labelList patchIDs = findStrings(patchNames[i], allPatchNames); labelList patchIDs = findStrings(patchNames[i], allPatchNames);
if (patchIDs.size() == 0) if (patchIDs.empty())
{ {
WarningIn("polyBoundaryMesh::patchSet(const wordList&)") WarningIn("polyBoundaryMesh::patchSet(const wordList&)")
<< "Cannot find any patch names matching " << patchNames[i] << "Cannot find any patch names matching " << patchNames[i]

View File

@ -814,7 +814,7 @@ void Foam::polyMesh::addPatches
const bool validBoundary const bool validBoundary
) )
{ {
if (boundaryMesh().size() > 0) if (boundaryMesh().size())
{ {
FatalErrorIn FatalErrorIn
( (
@ -858,12 +858,7 @@ void Foam::polyMesh::addZones
const List<cellZone*>& cz const List<cellZone*>& cz
) )
{ {
if if (pointZones().size() || faceZones().size() || cellZones().size())
(
pointZones().size() > 0
|| faceZones().size() > 0
|| cellZones().size() > 0
)
{ {
FatalErrorIn FatalErrorIn
( (

View File

@ -256,7 +256,7 @@ public:
//- Are the cyclic planes parallel //- Are the cyclic planes parallel
bool parallel() const bool parallel() const
{ {
return forwardT_.size() == 0; return forwardT_.empty();
} }
//- Return face transformation tensor //- Return face transformation tensor

View File

@ -86,7 +86,7 @@ Foam::label Foam::cyclicPolyPatch::findMaxArea
void Foam::cyclicPolyPatch::calcTransforms() void Foam::cyclicPolyPatch::calcTransforms()
{ {
if (size() > 0) if (size())
{ {
const pointField& points = this->points(); const pointField& points = this->points();
@ -1111,7 +1111,7 @@ bool Foam::cyclicPolyPatch::order
rotation.setSize(pp.size()); rotation.setSize(pp.size());
rotation = 0; rotation = 0;
if (pp.size() == 0) if (pp.empty())
{ {
// No faces, nothing to change. // No faces, nothing to change.
return false; return false;

View File

@ -211,7 +211,7 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::calcAddressing()
forAll (neiFaces, nfI) forAll (neiFaces, nfI)
{ {
if (neiFaces[nfI].size() > 0 && neiFaces[nfI][0] < minNei) if (neiFaces[nfI].size() && neiFaces[nfI][0] < minNei)
{ {
nextNei = nfI; nextNei = nfI;
minNei = neiFaces[nfI][0]; minNei = neiFaces[nfI][0];

View File

@ -127,7 +127,7 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::
} }
} }
} }
} while (faceOrder.size() > 0); } while (faceOrder.size());
} }
} }

View File

@ -53,7 +53,7 @@ checkEdges
// boundary edges have one face // boundary edges have one face
// interior edges have two faces // interior edges have two faces
if (myFaces.size() == 0) if (myFaces.empty())
{ {
FatalErrorIn FatalErrorIn
( (

View File

@ -97,12 +97,12 @@ void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::markZone
} }
} }
if (newChangedFaces.size() == 0) if (newChangedFaces.empty())
{ {
break; break;
} }
// New dynamicList: can leave dynamicList unshrunk // transfer from dynamic to normal list
changedFaces.transfer(newChangedFaces); changedFaces.transfer(newChangedFaces);
} }
} }

View File

@ -760,7 +760,7 @@ bool primitiveMesh::checkPoints
forAll (pf, pointI) forAll (pf, pointI)
{ {
if (pf[pointI].size() == 0) if (pf[pointI].empty())
{ {
if (setPtr) if (setPtr)
{ {
@ -776,7 +776,7 @@ bool primitiveMesh::checkPoints
{ {
const labelList& pc = pointCells(pointI); const labelList& pc = pointCells(pointI);
if (pc.size() == 0) if (pc.empty())
{ {
if (setPtr) if (setPtr)
{ {

View File

@ -130,7 +130,7 @@ void patchZones::markZone(label faceI)
<< endl; << endl;
} }
if (changedEdges.size() == 0) if (changedEdges.empty())
{ {
break; break;
} }
@ -144,7 +144,7 @@ void patchZones::markZone(label faceI)
<< endl; << endl;
} }
if (changedFaces.size() == 0) if (changedEdges.empty())
{ {
break; break;
} }

View File

@ -29,22 +29,14 @@ Description
#include "walkPatch.H" #include "walkPatch.H"
#include "ListOps.H" #include "ListOps.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
defineTypeNameAndDebug(walkPatch, 0);
defineTypeNameAndDebug(Foam::walkPatch, 0);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Get other face using v0, v1 (in localFaces numbering). Or -1. // Get other face using v0, v1 (in localFaces numbering). Or -1.
label walkPatch::getNeighbour Foam::label Foam::walkPatch::getNeighbour
( (
const label faceI, const label faceI,
const label fp, const label fp,
@ -104,19 +96,11 @@ label walkPatch::getNeighbour
const labelList& eFaces = pp_.edgeFaces()[nbrEdgeI]; const labelList& eFaces = pp_.edgeFaces()[nbrEdgeI];
if (eFaces.size() > 2 || eFaces.size() <= 0) if (eFaces.size() == 1)
{
FatalErrorIn("getNeighbour")
<< "Illegal surface on patch. Face " << faceI
<< " at vertices " << v0 << ',' << v1 << " has more than 2"
<< " or less than 1 neighbours" << abort(FatalError);
return -1;
}
else if (eFaces.size() == 1)
{ {
return -1; return -1;
} }
else else if (eFaces.size() == 2)
{ {
label nbrFaceI = eFaces[0]; label nbrFaceI = eFaces[0];
@ -127,12 +111,21 @@ label walkPatch::getNeighbour
return nbrFaceI; return nbrFaceI;
} }
else
{
FatalErrorIn("getNeighbour")
<< "Illegal surface on patch. Face " << faceI
<< " at vertices " << v0 << ',' << v1
<< " has fewer than 1 or more than 2 neighbours"
<< abort(FatalError);
return -1;
}
} }
// Gets labels of changed faces and enterVertices on faces. // Gets labels of changed faces and enterVertices on faces.
// Returns labels of faces changed and enterVertices on them. // Returns labels of faces changed and enterVertices on them.
void walkPatch::faceToFace void Foam::walkPatch::faceToFace
( (
const labelList& changedFaces, const labelList& changedFaces,
const labelList& enterVerts, const labelList& enterVerts,
@ -225,7 +218,7 @@ Foam::walkPatch::walkPatch
// Corresponding list of entry vertices // Corresponding list of entry vertices
labelList enterVerts(1, enterVertI); labelList enterVerts(1, enterVertI);
while(1) while (true)
{ {
labelList nbrFaces; labelList nbrFaces;
labelList nbrEnterVerts; labelList nbrEnterVerts;
@ -240,7 +233,7 @@ Foam::walkPatch::walkPatch
); );
if (nbrFaces.size() == 0) if (nbrFaces.empty())
{ {
break; break;
} }
@ -254,8 +247,4 @@ Foam::walkPatch::walkPatch
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -26,8 +26,7 @@ Primitive
bool bool
Description Description
C++ 4.0 supports a builtin type bool but older compilers do not. System bool
This is a simple typedef to emulate the standard bool type.
SourceFiles SourceFiles
boolIO.C boolIO.C

View File

@ -23,10 +23,9 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description Description
Reads an bool from an input stream, for a given version Reads an bool from an input stream, for a given version number and file
number and File format. If an ascii File is being read, format. If an ASCII file is being read, then the line numbers are counted
then the line numbers are counted and an erroneous read and an erroneous read is reported.
ised.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/

View File

@ -26,7 +26,10 @@ Class
Foam::nil Foam::nil
Description Description
A class without any storage. Used, for example, in HashSet. A zero-sized class without any storage. Used, for example, in HashSet.
Note
A zero-sized class actually does still require at least 1 byte storage.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/

View File

@ -238,9 +238,9 @@ void Foam::fileName::operator=(const char* str)
Foam::fileName Foam::operator/(const string& a, const string& b) Foam::fileName Foam::operator/(const string& a, const string& b)
{ {
if (a.size() > 0) // First string non-null if (a.size()) // First string non-null
{ {
if (b.size() > 0) // Second string non-null if (b.size()) // Second string non-null
{ {
return fileName(a + '/' + b); return fileName(a + '/' + b);
} }
@ -251,7 +251,7 @@ Foam::fileName Foam::operator/(const string& a, const string& b)
} }
else // First string null else // First string null
{ {
if (b.size() > 0) // Second string non-null if (b.size()) // Second string non-null
{ {
return b; return b;
} }

View File

@ -162,17 +162,17 @@ inline void Foam::word::operator=(const char* q)
inline Foam::word Foam::operator&(const word& a, const word& b) inline Foam::word Foam::operator&(const word& a, const word& b)
{ {
if (!b.size()) if (b.size())
{
return a;
}
else
{ {
string ub = b; string ub = b;
ub.string::operator[](0) = char(toupper(ub.string::operator[](0))); ub.string::operator[](0) = char(toupper(ub.string::operator[](0)));
return a + ub; return a + ub;
} }
else
{
return a;
}
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -61,7 +61,7 @@ Foam::Istream& Foam::operator>>(Istream& is, word& w)
string::stripInvalid<word>(w); string::stripInvalid<word>(w);
// flag empty strings and bad chars as an error // flag empty strings and bad chars as an error
if (!w.size() || w.size() != t.stringToken().size()) if (w.empty() || w.size() != t.stringToken().size())
{ {
is.setBad(); is.setBad();
FatalIOErrorIn("operator>>(Istream&, word&)", is) FatalIOErrorIn("operator>>(Istream&, word&)", is)

View File

@ -98,7 +98,7 @@ bool OPstream::write
<< Foam::abort(FatalError); << Foam::abort(FatalError);
} }
if (maxSendSize.size() == 0) if (maxSendSize.empty())
{ {
// Intialize maxSendSize to the initial size of the receive buffers. // Intialize maxSendSize to the initial size of the receive buffers.
maxSendSize.setSize(Pstream::nProcs()); maxSendSize.setSize(Pstream::nProcs());

View File

@ -191,7 +191,7 @@ Foam::label Foam::IPstream::read
void Foam::IPstream::waitRequests() void Foam::IPstream::waitRequests()
{ {
if (IPstream_outstandingRequests_.size() > 0) if (IPstream_outstandingRequests_.size())
{ {
if if
( (

Some files were not shown because too many files have changed in this diff Show More