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

@ -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))

View File

@ -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;

View File

@ -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;

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"
<< " 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)
forAll(cuts.cellLoops(), cellI)
{
if (cuts.cellLoops()[cellI].size() > 0)
if (cuts.cellLoops()[cellI].size())
{
//Info<< "Removing cut cell " << cellI << " from wishlist"
// << endl;

View File

@ -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;

View File

@ -1,4 +1,4 @@
/*---------------------------------------------------------------------------*\
/*--------------------------------*- 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;

View File

@ -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);
}

View File

@ -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.

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.
WarningIn(args.executable())

View File

@ -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"

View File

@ -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];

View File

@ -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];

View File

@ -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));

View File

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

View File

@ -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);

View File

@ -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++;
}

View File

@ -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);

View File

@ -1,6 +1,6 @@
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());

View File

@ -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 "

View File

@ -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());

View File

@ -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
wordList curFaceZoneNames = faceZones().names();
if (curFaceZoneNames.size() > 0)
if (curFaceZoneNames.size())
{
faceZoneNames_.setCapacity(2*curFaceZoneNames.size());
}
@ -167,7 +164,7 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io)
// Cell zones
wordList curCellZoneNames = cellZones().names();
if (curCellZoneNames.size() > 0)
if (curCellZoneNames.size())
{
cellZoneNames_.setCapacity(2*curCellZoneNames.size());
}
@ -333,11 +330,11 @@ void Foam::mergePolyMesh::addMesh(const polyMesh& m)
newOwn = own[faceI];
if (newOwn > -1) newOwn = renumberCells[newOwn];
if (newPatch > -1)
if (newPatch > -1)
{
newNei = -1;
}
else
}
else
{
newNei = nei[faceI];
newNei = renumberCells[newNei];
@ -373,7 +370,7 @@ void Foam::mergePolyMesh::addMesh(const polyMesh& m)
)
);
}
}

View File

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

View File

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

View File

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

View File

@ -100,10 +100,10 @@ void checkPatch(const polyBoundaryMesh& bMesh, const word& name)
<< exit(FatalError);
}
if (bMesh[patchI].size() != 0)
if (bMesh[patchI].size())
{
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);
}
}

View File

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

View File

@ -82,7 +82,7 @@ void checkPatch(const polyBoundaryMesh& bMesh, const word& name)
<< exit(FatalError);
}
if (bMesh[patchI].size() == 0)
if (bMesh[patchI].empty())
{
FatalErrorIn("checkPatch(const polyBoundaryMesh&, const word&)")
<< "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())
<< "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()
<< " faces whose owner and neighbour cell should be kept on the"
@ -123,7 +123,7 @@ void domainDecomposition::distributeCells()
*this
);
if (sameProcFaces.size() == 0)
if (sameProcFaces.empty())
{
cellToProc_ = decomposePtr().decompose(cellCentres());
}

View File

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

View File

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

View File

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

View File

@ -57,7 +57,7 @@ void writeEnsDataBinary
std::ofstream& ensightFile
)
{
if (sf.size() > 0)
if (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);
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -4,7 +4,6 @@ nVar -= Num_variables - nSprayVariables;
if (nVar >= 0)
{
word name = lagrangianScalarNames[nVar];
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];
}
@ -36,7 +29,7 @@ if (nVar >= 0)
}
else
{
//Info << "getLagrangianScalar: nVar = " << nVar << endl;
// Info << "getLagrangianScalar: nVar = " << nVar << endl;
return Z_UNDEF;
}

View File

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

View File

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

View File

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

View File

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

View File

@ -242,9 +242,7 @@ int main(int argc, char *argv[])
}
}
illegalFaces.shrink();
if (illegalFaces.size() > 0)
if (illegalFaces.size())
{
Pout<< "Surface has " << illegalFaces.size()
<< " illegal triangles." << endl;
@ -628,7 +626,7 @@ int main(int argc, char *argv[])
triSurfaceSearch querySurf(surf);
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;
}

View File

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

View File

@ -49,9 +49,9 @@ void readNASEdges
edgeList& allEdges
)
{
IFstream OBJfile(inFileName);
IFstream is(inFileName);
if (!OBJfile.good())
if (!is.good())
{
FatalErrorIn("readNASEdges")
<< "Cannot read file " << inFileName
@ -68,14 +68,14 @@ void readNASEdges
DynamicList<label> edgeIndices;
while (OBJfile.good())
while (is.good())
{
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;
}
@ -87,9 +87,9 @@ void readNASEdges
while (true)
{
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);
}

View File

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

View File

@ -86,7 +86,7 @@ int main(int argc, char *argv[])
meshSubsetDict.lookup("zone")
);
if ((markedZone.size() != 0) && (markedZone.size() != 2))
if (markedZone.size() && markedZone.size() != 2)
{
FatalErrorIn(args.executable())
<< "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"
//
if (markedPoints.size() > 0)
if (markedPoints.size())
{
Info << "Found " << markedPoints.size() << " marked point(s)." << endl;
@ -153,7 +153,7 @@ int main(int argc, char *argv[])
// pick up faces connected to "edges"
//
if (markedEdges.size() > 0)
if (markedEdges.size())
{
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
label nFaceNeighbours = 0;
if (markedFaces.size() > 0)
if (markedFaces.size())
{
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;
if (args.options().size() == 0)
if (args.options().empty())
{
FatalErrorIn(args.executable())
<< "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)
{
// empty names are meaningless
if (!pathName.size())
if (pathName.empty())
{
return false;
}
@ -567,10 +567,10 @@ Foam::fileNameList Foam::readDir
{
fileName fName(list->d_name);
// ignore files begining with ., i.e. ., .. and .??*
if (fName.size() > 0 && fName[size_t(0)] != '.')
// ignore files begining with ., i.e. '.', '..' and '.*'
if (fName.size() && fName[0] != '.')
{
word fileNameExt = fName.ext();
word fExt = fName.ext();
if
(
@ -578,11 +578,11 @@ Foam::fileNameList Foam::readDir
||
(
type == fileName::FILE
&& fName[fName.size()-1] != '~'
&& fileNameExt != "bak"
&& fileNameExt != "BAK"
&& fileNameExt != "old"
&& fileNameExt != "save"
&& fName[fName.size()-1] != '~'
&& fExt != "bak"
&& fExt != "BAK"
&& fExt != "old"
&& fExt != "save"
)
)
{
@ -593,7 +593,7 @@ Foam::fileNameList Foam::readDir
dirEntries.setSize(dirEntries.size() + maxNnames);
}
if (filtergz && fileNameExt == "gz")
if (filtergz && fExt == "gz")
{
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)
{
fileName destFile(dest);
// Make sure source exists.
if (!exists(src))
{
return false;
}
fileName destFile(dest);
// Check type of source 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);
}
// Make sure the destination directory extists.
// Make sure the destination directory exists.
if (!dir(destFile) && !mkDir(destFile))
{
return false;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -136,18 +136,18 @@ Foam::Ostream& Foam::OPstream::write(const char* str)
{
word nonWhiteChars(string::validate<word>(str));
if (nonWhiteChars.size() == 0)
{
return *this;
}
else if (nonWhiteChars.size() == 1)
if (nonWhiteChars.size() == 1)
{
return write(nonWhiteChars.c_str()[1]);
}
else
else if (nonWhiteChars.size())
{
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);
if (!timeDirs.size())
if (timeDirs.empty())
{
FatalErrorIn(args.executable())
<< "No times selected"

View File

@ -46,7 +46,7 @@ bool Foam::dictionary::findInPatterns
DLList<autoPtr<regExp> >::const_iterator& reLink
) const
{
if (patternEntries_.size() > 0)
if (patternEntries_.size())
{
while (wcLink != patternEntries_.end())
{
@ -76,7 +76,7 @@ bool Foam::dictionary::findInPatterns
DLList<autoPtr<regExp> >::iterator& reLink
)
{
if (patternEntries_.size() > 0)
if (patternEntries_.size())
{
while (wcLink != patternEntries_.end())
{
@ -240,7 +240,7 @@ bool Foam::dictionary::found(const word& keyword, bool recursive) const
}
else
{
if (patternEntries_.size() > 0)
if (patternEntries_.size())
{
DLList<entry*>::const_iterator wcLink = patternEntries_.begin();
DLList<autoPtr<regExp> >::const_iterator reLink =
@ -276,7 +276,7 @@ const Foam::entry* Foam::dictionary::lookupEntryPtr
if (iter == hashedEntries_.end())
{
if (patternMatch && patternEntries_.size() > 0)
if (patternMatch && patternEntries_.size())
{
DLList<entry*>::const_iterator wcLink =
patternEntries_.begin();
@ -315,7 +315,7 @@ Foam::entry* Foam::dictionary::lookupEntryPtr
if (iter == hashedEntries_.end())
{
if (patternMatch && patternEntries_.size() > 0)
if (patternMatch && patternEntries_.size())
{
DLList<entry*>::iterator wcLink =
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;
if (!varTokens.size())
if (varTokens.empty())
{
label end = tokens.size() - 1;
for(label j=i; j<end; j++)
for (label j=posI; j<end; j++)
{
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 offset = varTokens.size() - 1;
for(label j=end; j>i; j--)
for (label j=end; j>posI; j--)
{
tokens[j] = tokens[j-offset];
}
@ -143,7 +147,7 @@ void Foam::primitiveEntry::insert(const tokenList& varTokens, const label i)
forAll(varTokens, j)
{
tokens[i + j] = varTokens[j];
tokens[posI + j] = varTokens[j];
}
}

View File

@ -58,7 +58,7 @@ namespace Foam
class dictionary;
/*---------------------------------------------------------------------------*\
Class primitiveEntry Declaration
Class primitiveEntry Declaration
\*---------------------------------------------------------------------------*/
class primitiveEntry
@ -99,8 +99,8 @@ public:
//- Read the complete entry from the given stream
void readEntry(const dictionary&, Istream&);
//- Insert the given tokens at token i
void insert(const tokenList&, const label i);
//- Insert the given tokens at token posI
void insert(const tokenList&, const label posI);
public:

View File

@ -55,7 +55,7 @@ bool regIOobject::writeObject
return false;
}
if (!instance().size())
if (instance().empty())
{
SeriousErrorIn("regIOobject::write()")
<< "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)
{
if (!tf.size())
if (tf.empty())
{
return;
}

View File

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

View File

@ -312,7 +312,7 @@ void PatchToPatchInterpolation<FromPatch, ToPatch>::calcFaceAddressing() const
if
(
m < directHitTol // Direct hit
|| neighbours.size() == 0
|| neighbours.empty()
)
{
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,
// add it to the end of the nextCell list
while (nextCell.size() > 0)
while (nextCell.size())
{
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)
{
if (points.size() == 0)
if (points.empty())
{
min_ = point::zero;
max_ = point::zero;

View File

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

View File

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

View File

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

View File

@ -86,7 +86,7 @@ void Foam::cellMapper::calcAddressing() const
weightsPtr_ = new scalarListList(mesh_.nCells());
scalarListList& w = *weightsPtr_;
const List<objectMap>& cfp = mpm_.cellsFromPointsMap();
forAll (cfp, cfpI)
@ -96,7 +96,7 @@ void Foam::cellMapper::calcAddressing() const
label cellI = cfp[cfpI].index();
if (addr[cellI].size() > 0)
if (addr[cellI].size())
{
FatalErrorIn("void cellMapper::calcAddressing() const")
<< "Master cell " << cellI
@ -118,7 +118,7 @@ void Foam::cellMapper::calcAddressing() const
label cellI = cfe[cfeI].index();
if (addr[cellI].size() > 0)
if (addr[cellI].size())
{
FatalErrorIn("void cellMapper::calcAddressing() const")
<< "Master cell " << cellI
@ -140,7 +140,7 @@ void Foam::cellMapper::calcAddressing() const
label cellI = cff[cffI].index();
if (addr[cellI].size() > 0)
if (addr[cellI].size())
{
FatalErrorIn("void cellMapper::calcAddressing() const")
<< "Master cell " << cellI
@ -162,7 +162,7 @@ void Foam::cellMapper::calcAddressing() const
label cellI = cfc[cfcI].index();
if (addr[cellI].size() > 0)
if (addr[cellI].size())
{
FatalErrorIn("void cellMapper::calcAddressing() const")
<< "Master cell " << cellI
@ -183,7 +183,7 @@ void Foam::cellMapper::calcAddressing() const
forAll (cm, cellI)
{
if (cm[cellI] > -1 && addr[cellI].size() == 0)
if (cm[cellI] > -1 && addr[cellI].empty())
{
// Mapped from a single cell
addr[cellI] = labelList(1, cm[cellI]);
@ -200,7 +200,7 @@ void Foam::cellMapper::calcAddressing() const
forAll (addr, cellI)
{
if (addr[cellI].size() == 0)
if (addr[cellI].empty())
{
// Mapped from a dummy cell
addr[cellI] = labelList(1, 0);
@ -242,10 +242,10 @@ Foam::cellMapper::cellMapper(const mapPolyMesh& mpm)
// Check for possibility of direct mapping
if
(
mpm_.cellsFromPointsMap().size() == 0
&& mpm_.cellsFromEdgesMap().size() == 0
&& mpm_.cellsFromFacesMap().size() == 0
&& mpm_.cellsFromCellsMap().size() == 0
mpm_.cellsFromPointsMap().empty()
&& mpm_.cellsFromEdgesMap().empty()
&& mpm_.cellsFromFacesMap().empty()
&& mpm_.cellsFromCellsMap().empty()
)
{
direct_ = true;
@ -256,7 +256,7 @@ Foam::cellMapper::cellMapper(const mapPolyMesh& mpm)
}
// 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;
}
@ -412,7 +412,7 @@ const Foam::labelList& Foam::cellMapper::insertedObjectLabels() const
return *insertedCellLabelsPtr_;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //

View File

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

View File

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

View File

@ -50,7 +50,7 @@ void Foam::mapDistribute::distribute
{
const labelList& map = subMap[domain];
if (domain != Pstream::myProcNo() && map.size() > 0)
if (domain != Pstream::myProcNo() && map.size())
{
List<T> subField(map.size());
forAll(map, i)
@ -86,7 +86,7 @@ void Foam::mapDistribute::distribute
{
const labelList& map = constructMap[domain];
if (domain != Pstream::myProcNo() && map.size() > 0)
if (domain != Pstream::myProcNo() && map.size())
{
IPstream fromNbr(Pstream::blocking, domain);
List<T> subField(fromNbr);
@ -227,7 +227,7 @@ void Foam::mapDistribute::distribute
{
const labelList& map = subMap[domain];
if (domain != Pstream::myProcNo() && map.size() > 0)
if (domain != Pstream::myProcNo() && map.size())
{
List<T>& subField = sendFields[domain];
subField.setSize(map.size());
@ -254,7 +254,7 @@ void Foam::mapDistribute::distribute
{
const labelList& map = constructMap[domain];
if (domain != Pstream::myProcNo() && map.size() > 0)
if (domain != Pstream::myProcNo() && map.size())
{
recvFields[domain].setSize(map.size());
IPstream::read
@ -303,14 +303,14 @@ void Foam::mapDistribute::distribute
OPstream::waitRequests();
IPstream::waitRequests();
// Collect neighbour fields
for (label domain = 0; domain < Pstream::nProcs(); 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())
{
@ -372,7 +372,7 @@ void Foam::mapDistribute::distribute
{
const labelList& map = subMap[domain];
if (domain != Pstream::myProcNo() && map.size() > 0)
if (domain != Pstream::myProcNo() && map.size())
{
List<T> subField(map.size());
forAll(map, i)
@ -409,7 +409,7 @@ void Foam::mapDistribute::distribute
{
const labelList& map = constructMap[domain];
if (domain != Pstream::myProcNo() && map.size() > 0)
if (domain != Pstream::myProcNo() && map.size())
{
IPstream fromNbr(Pstream::blocking, domain);
List<T> subField(fromNbr);
@ -550,7 +550,7 @@ void Foam::mapDistribute::distribute
{
const labelList& map = subMap[domain];
if (domain != Pstream::myProcNo() && map.size() > 0)
if (domain != Pstream::myProcNo() && map.size())
{
List<T>& subField = sendFields[domain];
subField.setSize(map.size());
@ -577,7 +577,7 @@ void Foam::mapDistribute::distribute
{
const labelList& map = constructMap[domain];
if (domain != Pstream::myProcNo() && map.size() > 0)
if (domain != Pstream::myProcNo() && map.size())
{
recvFields[domain].setSize(map.size());
IPstream::read
@ -625,14 +625,14 @@ void Foam::mapDistribute::distribute
OPstream::waitRequests();
IPstream::waitRequests();
// Collect neighbour fields
for (label domain = 0; domain < Pstream::nProcs(); 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())
{

View File

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

View File

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

View File

@ -47,7 +47,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class coupledPolyPatch Declaration
Class coupledPolyPatch Declaration
\*---------------------------------------------------------------------------*/
class coupledPolyPatch
@ -256,7 +256,7 @@ public:
//- Are the cyclic planes parallel
bool parallel() const
{
return forwardT_.size() == 0;
return forwardT_.empty();
}
//- Return face transformation tensor

View File

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

View File

@ -211,7 +211,7 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::calcAddressing()
forAll (neiFaces, nfI)
{
if (neiFaces[nfI].size() > 0 && neiFaces[nfI][0] < minNei)
if (neiFaces[nfI].size() && neiFaces[nfI][0] < minNei)
{
nextNei = nfI;
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
// interior edges have two faces
if (myFaces.size() == 0)
if (myFaces.empty())
{
FatalErrorIn
(

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -26,7 +26,10 @@ Class
Foam::nil
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)
{
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);
}
@ -251,7 +251,7 @@ Foam::fileName Foam::operator/(const string& a, const string& b)
}
else // First string null
{
if (b.size() > 0) // Second string non-null
if (b.size()) // Second string non-null
{
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)
{
if (!b.size())
{
return a;
}
else
if (b.size())
{
string ub = b;
ub.string::operator[](0) = char(toupper(ub.string::operator[](0)));
return a + ub;
}
else
{
return a;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -61,7 +61,7 @@ Foam::Istream& Foam::operator>>(Istream& is, word& w)
string::stripInvalid<word>(w);
// 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();
FatalIOErrorIn("operator>>(Istream&, word&)", is)

View File

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

View File

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

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