Use new last() method for List-type classes

- use first() method in some places as well where it helps clarity

- there are a few remaining cases: git grep 'size()-1]'
This commit is contained in:
Mark Olesen
2009-11-26 13:35:57 +01:00
parent b2d7439b86
commit d17d015f88
45 changed files with 121 additions and 124 deletions

View File

@ -126,41 +126,41 @@ int main(int argc, char *argv[])
// Create bin0. Have upperlimit as factor times lowerlimit. // Create bin0. Have upperlimit as factor times lowerlimit.
bins.append(DynamicList<label>()); bins.append(DynamicList<label>());
lowerLimits.append(sortedVols[0]); lowerLimits.append(sortedVols[0]);
upperLimits.append(1.1*lowerLimits[lowerLimits.size()-1]); upperLimits.append(1.1 * lowerLimits.last());
forAll(sortedVols, i) forAll(sortedVols, i)
{ {
if (sortedVols[i] > upperLimits[upperLimits.size()-1]) if (sortedVols[i] > upperLimits.last())
{ {
// New value outside of current bin // New value outside of current bin
// Shrink old bin. // Shrink old bin.
DynamicList<label>& bin = bins[bins.size()-1]; DynamicList<label>& bin = bins.last();
bin.shrink(); bin.shrink();
Info<< "Collected " << bin.size() << " elements in bin " Info<< "Collected " << bin.size() << " elements in bin "
<< lowerLimits[lowerLimits.size()-1] << " .. " << lowerLimits.last() << " .. "
<< upperLimits[upperLimits.size()-1] << endl; << upperLimits.last() << endl;
// Create new bin. // Create new bin.
bins.append(DynamicList<label>()); bins.append(DynamicList<label>());
lowerLimits.append(sortedVols[i]); lowerLimits.append(sortedVols[i]);
upperLimits.append(1.1*lowerLimits[lowerLimits.size()-1]); upperLimits.append(1.1 * lowerLimits.last());
Info<< "Creating new bin " << lowerLimits[lowerLimits.size()-1] Info<< "Creating new bin " << lowerLimits.last()
<< " .. " << upperLimits[upperLimits.size()-1] << " .. " << upperLimits.last()
<< endl; << endl;
} }
// Append to current bin. // Append to current bin.
DynamicList<label>& bin = bins[bins.size()-1]; DynamicList<label>& bin = bins.last();
bin.append(sortedVols.indices()[i]); bin.append(sortedVols.indices()[i]);
} }
Info<< endl; Info<< endl;
bins[bins.size()-1].shrink(); bins.last().shrink();
bins.shrink(); bins.shrink();
lowerLimits.shrink(); lowerLimits.shrink();
upperLimits.shrink(); upperLimits.shrink();

View File

@ -324,7 +324,7 @@ endOfSection {space}")"{space}
// point group type skipped // point group type skipped
strtol(endPtr, &endPtr, 16); strtol(endPtr, &endPtr, 16);
pointi = pointGroupStartIndex[pointGroupStartIndex.size()-1]; pointi = pointGroupStartIndex.last();
// reset number of components to default // reset number of components to default
pointGroupNumberOfComponents = 3; pointGroupNumberOfComponents = 3;
@ -336,11 +336,11 @@ endOfSection {space}")"{space}
} }
Info<< "PointGroup: " Info<< "PointGroup: "
<< pointGroupZoneID[pointGroupZoneID.size()-1] << pointGroupZoneID.last()
<< " start: " << " start: "
<< pointGroupStartIndex[pointGroupStartIndex.size()-1] << pointGroupStartIndex.last()
<< " end: " << " end: "
<< pointGroupEndIndex[pointGroupEndIndex.size()-1] << flush; << pointGroupEndIndex.last() << flush;
} }
<readNumberOfPoints,readPointGroupData>{endOfSection} { <readNumberOfPoints,readPointGroupData>{endOfSection} {
@ -387,14 +387,14 @@ endOfSection {space}")"{space}
Info<< "done." << endl; Info<< "done." << endl;
// check read of points // check read of points
if (pointi != pointGroupEndIndex[pointGroupEndIndex.size()-1]+1) if (pointi != pointGroupEndIndex.last()+1)
{ {
Warning Warning
<< "Problem with reading points: " << nl << "Problem with reading points: " << nl
<< " start index: " << " start index: "
<< pointGroupStartIndex[pointGroupStartIndex.size()-1] << pointGroupStartIndex.last()
<< " end index: " << " end index: "
<< pointGroupEndIndex[pointGroupEndIndex.size()-1] << pointGroupEndIndex.last()
<< " last points read: " << pointi << nl << " last points read: " << pointi << nl
<< " on line " << lineNo << endl; << " on line " << lineNo << endl;
} }
@ -440,14 +440,14 @@ endOfSection {space}")"{space}
faceGroupElementType = strtol(endPtr, &endPtr, 16); faceGroupElementType = strtol(endPtr, &endPtr, 16);
facei = faceGroupStartIndex[faceGroupStartIndex.size()-1]; facei = faceGroupStartIndex.last();
Info<< "FaceGroup: " Info<< "FaceGroup: "
<< faceGroupZoneID[faceGroupZoneID.size()-1] << faceGroupZoneID.last()
<< " start: " << " start: "
<< faceGroupStartIndex[faceGroupStartIndex.size()-1] << faceGroupStartIndex.last()
<< " end: " << " end: "
<< faceGroupEndIndex[faceGroupEndIndex.size()-1] << flush; << faceGroupEndIndex.last() << flush;
} }
<readNumberOfFaces,readFaceGroupData>{space}{endOfSection} { <readNumberOfFaces,readFaceGroupData>{space}{endOfSection} {
@ -507,14 +507,14 @@ endOfSection {space}")"{space}
Info<< "done." << endl; Info<< "done." << endl;
// check read of fluentFaces // check read of fluentFaces
if (facei != faceGroupEndIndex[faceGroupEndIndex.size()-1]+1) if (facei != faceGroupEndIndex.last()+1)
{ {
Warning Warning
<< "Problem with reading fluentFaces: " << nl << "Problem with reading fluentFaces: " << nl
<< " start index: " << " start index: "
<< faceGroupStartIndex[faceGroupStartIndex.size()-1] << faceGroupStartIndex.last()
<< " end index: " << " end index: "
<< faceGroupEndIndex[faceGroupEndIndex.size()-1] << faceGroupEndIndex.last()
<< " last fluentFaces read: " << facei << nl << " last fluentFaces read: " << facei << nl
<< " on line " << lineNo << endl; << " on line " << lineNo << endl;
} }
@ -560,13 +560,13 @@ endOfSection {space}")"{space}
cellGroupType.append(strtol(endPtr, &endPtr, 16)); cellGroupType.append(strtol(endPtr, &endPtr, 16));
Info<< "CellGroup: " Info<< "CellGroup: "
<< cellGroupZoneID[cellGroupZoneID.size()-1] << cellGroupZoneID.last()
<< " start: " << " start: "
<< cellGroupStartIndex[cellGroupStartIndex.size()-1] << cellGroupStartIndex.last()
<< " end: " << " end: "
<< cellGroupEndIndex[cellGroupEndIndex.size()-1] << cellGroupEndIndex.last()
<< " type: " << " type: "
<< cellGroupType[cellGroupType.size()-1] << cellGroupType.last()
<< endl; << endl;
} }
@ -587,13 +587,13 @@ endOfSection {space}")"{space}
strtol(endPtr, &endPtr, 16); strtol(endPtr, &endPtr, 16);
Info<< "CellGroup: " Info<< "CellGroup: "
<< cellGroupZoneID[cellGroupZoneID.size()-1] << cellGroupZoneID.last()
<< " start: " << " start: "
<< cellGroupStartIndex[cellGroupStartIndex.size()-1] << cellGroupStartIndex.last()
<< " end: " << " end: "
<< cellGroupEndIndex[cellGroupEndIndex.size()-1] << cellGroupEndIndex.last()
<< " type: " << " type: "
<< cellGroupType[cellGroupType.size()-1] << cellGroupType.last()
<< endl; << endl;
} }

View File

@ -885,7 +885,7 @@ int main(int argc, char *argv[])
// Now use the patchFaces to patch up the outside faces of the mesh. // Now use the patchFaces to patch up the outside faces of the mesh.
// Get the patch for all the outside faces (= default patch added as last) // Get the patch for all the outside faces (= default patch added as last)
const polyPatch& pp = mesh.boundaryMesh()[mesh.boundaryMesh().size()-1]; const polyPatch& pp = mesh.boundaryMesh().last();
// Storage for faceZones. // Storage for faceZones.
List<DynamicList<label> > zoneFaces(patchFaces.size()); List<DynamicList<label> > zoneFaces(patchFaces.size());

View File

@ -324,13 +324,13 @@ void readCells
cellVerts.append(cellShape(tet, cVerts, true)); cellVerts.append(cellShape(tet, cVerts, true));
cellMaterial.append(physProp); cellMaterial.append(physProp);
if (cellVerts[cellVerts.size()-1].size() != cVerts.size()) if (cellVerts.last().size() != cVerts.size())
{ {
Pout<< "Line:" << is.lineNumber() Pout<< "Line:" << is.lineNumber()
<< " element:" << cellI << " element:" << cellI
<< " type:" << feID << " type:" << feID
<< " collapsed from " << cVerts << nl << " collapsed from " << cVerts << nl
<< " to:" << cellVerts[cellVerts.size()-1] << " to:" << cellVerts.last()
<< endl; << endl;
} }
} }
@ -347,13 +347,13 @@ void readCells
cellVerts.append(cellShape(prism, cVerts, true)); cellVerts.append(cellShape(prism, cVerts, true));
cellMaterial.append(physProp); cellMaterial.append(physProp);
if (cellVerts[cellVerts.size()-1].size() != cVerts.size()) if (cellVerts.last().size() != cVerts.size())
{ {
Pout<< "Line:" << is.lineNumber() Pout<< "Line:" << is.lineNumber()
<< " element:" << cellI << " element:" << cellI
<< " type:" << feID << " type:" << feID
<< " collapsed from " << cVerts << nl << " collapsed from " << cVerts << nl
<< " to:" << cellVerts[cellVerts.size()-1] << " to:" << cellVerts.last()
<< endl; << endl;
} }
} }
@ -371,13 +371,13 @@ void readCells
cellVerts.append(cellShape(hex, cVerts, true)); cellVerts.append(cellShape(hex, cVerts, true));
cellMaterial.append(physProp); cellMaterial.append(physProp);
if (cellVerts[cellVerts.size()-1].size() != cVerts.size()) if (cellVerts.last().size() != cVerts.size())
{ {
Pout<< "Line:" << is.lineNumber() Pout<< "Line:" << is.lineNumber()
<< " element:" << cellI << " element:" << cellI
<< " type:" << feID << " type:" << feID
<< " collapsed from " << cVerts << nl << " collapsed from " << cVerts << nl
<< " to:" << cellVerts[cellVerts.size()-1] << " to:" << cellVerts.last()
<< endl; << endl;
} }
} }
@ -511,7 +511,7 @@ void readDOFS
} }
Info<< "For DOF set " << group Info<< "For DOF set " << group
<< " named " << patchNames[patchNames.size()-1] << " named " << patchNames.last()
<< " trying to read vertex indices." << " trying to read vertex indices."
<< endl; << endl;
@ -534,7 +534,7 @@ void readDOFS
} }
Info<< "For DOF set " << group Info<< "For DOF set " << group
<< " named " << patchNames[patchNames.size()-1] << " named " << patchNames.last()
<< " read " << vertices.size() << " vertex indices." << endl; << " read " << vertices.size() << " vertex indices." << endl;
dofVertices.append(vertices.shrink()); dofVertices.append(vertices.shrink());

View File

@ -418,8 +418,8 @@ int main(int argc, char *argv[])
frontPatchFaces.setSize(layerFaces.size()); frontPatchFaces.setSize(layerFaces.size());
forAll(backPatchFaces, i) forAll(backPatchFaces, i)
{ {
backPatchFaces[i] = layerFaces[i][0]; backPatchFaces[i] = layerFaces[i].first();
frontPatchFaces[i] = layerFaces[i][layerFaces[i].size()-1]; frontPatchFaces[i] = layerFaces[i].last();
} }
// Create dummy fvSchemes, fvSolution // Create dummy fvSchemes, fvSolution

View File

@ -186,7 +186,7 @@ int main(int argc, char *argv[])
{ {
newPatches.append(findPatchID(mesh, patchNames[i])); newPatches.append(findPatchID(mesh, patchNames[i]));
Info<< "Using additional patch " << patchNames[i] Info<< "Using additional patch " << patchNames[i]
<< " at index " << newPatches[newPatches.size()-1] << endl; << " at index " << newPatches.last() << endl;
} }
} }

View File

@ -175,7 +175,7 @@ int main(int argc, char *argv[])
ensightMesh eMesh(mesh, args, binary); ensightMesh eMesh(mesh, args, binary);
// Set Time to the last time before looking for the lagrangian objects // Set Time to the last time before looking for the lagrangian objects
runTime.setTime(Times[Times.size()-1], Times.size()-1); runTime.setTime(Times.last(), Times.size()-1);
IOobjectList objects(mesh, runTime.timeName()); IOobjectList objects(mesh, runTime.timeName());

View File

@ -8,7 +8,7 @@ HashTable< HashTable<word> > cloudFields;
if (timeDirs.size()) if (timeDirs.size())
{ {
IOobjectList objs(mesh, timeDirs[timeDirs.size()-1].name()); IOobjectList objs(mesh, timeDirs.last().name());
forAllConstIter(IOobjectList, objs, fieldIter) forAllConstIter(IOobjectList, objs, fieldIter)
{ {
@ -34,7 +34,7 @@ if (timeDirs.size())
fileNameList cloudDirs = readDir fileNameList cloudDirs = readDir
( (
runTime.path() runTime.path()
/ timeDirs[timeDirs.size()-1].name() / timeDirs.last().name()
/ regionPrefix / regionPrefix
/ cloud::prefix, / cloud::prefix,
fileName::DIRECTORY fileName::DIRECTORY
@ -54,7 +54,7 @@ if (timeDirs.size())
IOobjectList objs IOobjectList objs
( (
mesh, mesh,
timeDirs[timeDirs.size()-1].name(), timeDirs.last().name(),
cloud::prefix/cloudName cloud::prefix/cloudName
); );

View File

@ -87,7 +87,7 @@ int USERD_set_filenames
// set the number of fields and store their names // set the number of fields and store their names
// a valid field must exist for all time-steps // a valid field must exist for all time-steps
runTime.setTime(timeDirs[timeDirs.size()-1], timeDirs.size()-1); runTime.setTime(timeDirs.last(), timeDirs.size()-1);
IOobjectList objects(*meshPtr, runTime.timeName()); IOobjectList objects(*meshPtr, runTime.timeName());
fieldNames = objects.names(); fieldNames = objects.names();

View File

@ -103,7 +103,7 @@ int main(int argc, char *argv[])
{ {
startIds[i+1] += startIds[i] + numIds[i]; startIds[i+1] += startIds[i] + numIds[i];
} }
label nParticle = startIds[startIds.size()-1] + numIds[startIds.size()-1]; label nParticle = startIds.last() + numIds[startIds.size()-1];

View File

@ -47,7 +47,7 @@ int main(int argc, char *argv[])
# include "createMesh.H" # include "createMesh.H"
runTime.setTime(timeDirs[timeDirs.size()-1], timeDirs.size()-1); runTime.setTime(timeDirs.last(), timeDirs.size()-1);
volScalarField pMean volScalarField pMean
( (

View File

@ -93,13 +93,13 @@ Foam::scalar Foam::tabulatedWallFunctions::general::interpolate
{ {
case itLinear: case itLinear:
{ {
if (xi < x[0]) if (xi <= x[0])
{ {
return fx[0]; return fx[0];
} }
else if (xi > x[x.size()-1]) else if (xi >= x.last())
{ {
return fx[x.size()-1]; return fx.last();
} }
else else
{ {

View File

@ -128,7 +128,7 @@ static void splitTri
labelledTri labelledTri
( (
f[fp2], f[fp2],
splitPoints[splitPoints.size()-1], splitPoints.last(),
f[fp1], f[fp1],
f.region() f.region()
) )
@ -144,7 +144,7 @@ static void splitTri
( (
f[fp1], f[fp1],
f[fp2], f[fp2],
splitPoints[splitPoints.size()-1], splitPoints.last(),
f.region() f.region()
) )
); );

View File

@ -129,7 +129,7 @@ void Foam::Time::setControls()
{ {
if (timeDirs.size()) if (timeDirs.size())
{ {
startTime_ = timeDirs[timeDirs.size()-1].value(); startTime_ = timeDirs.last().value();
} }
} }
else else
@ -419,9 +419,9 @@ Foam::instant Foam::Time::findClosestTime(const scalar t) const
{ {
return timeDirs[1]; return timeDirs[1];
} }
else if (t > timeDirs[timeDirs.size()-1].value()) else if (t > timeDirs.last().value())
{ {
return timeDirs[timeDirs.size()-1]; return timeDirs.last();
} }
label nearestIndex = -1; label nearestIndex = -1;

View File

@ -95,7 +95,7 @@ Foam::PatchTools::checkOrientation
const Face& f = p[faceI]; const Face& f = p[faceI];
const point& p0 = p.points()[f[0]]; const point& p0 = p.points()[f[0]];
const point& p1 = p.points()[f[1]]; const point& p1 = p.points()[f[1]];
const point& p2 = p.points()[f[f.size()-1]]; const point& p2 = p.points()[f.last()];
const vector pointNormal((p1 - p0) ^ (p2 - p0)); const vector pointNormal((p1 - p0) ^ (p2 - p0));
if ((pointNormal & p.faceNormals()[faceI]) < 0) if ((pointNormal & p.faceNormals()[faceI]) < 0)

View File

@ -856,7 +856,7 @@ bool Foam::primitiveMesh::checkFaceAngles
const face& f = fcs[faceI]; const face& f = fcs[faceI];
// Get edge from f[0] to f[size-1]; // Get edge from f[0] to f[size-1];
vector ePrev(p[f[0]] - p[f[f.size()-1]]); vector ePrev(p[f.first()] - p[f.last()]);
scalar magEPrev = mag(ePrev); scalar magEPrev = mag(ePrev);
ePrev /= magEPrev + VSMALL; ePrev /= magEPrev + VSMALL;

View File

@ -1015,7 +1015,7 @@ void Foam::polyDualMesh::calcDual
{ {
// Check orientation. // Check orientation.
const face& f = dynDualFaces[dynDualFaces.size()-1]; const face& f = dynDualFaces.last();
vector n = f.normal(dualPoints); vector n = f.normal(dualPoints);
if (((mesh.points()[owner] - dualPoints[f[0]]) & n) > 0) if (((mesh.points()[owner] - dualPoints[f[0]]) & n) > 0)
{ {
@ -1130,7 +1130,7 @@ void Foam::polyDualMesh::calcDual
{ {
// Check orientation. // Check orientation.
const face& f = dynDualFaces[dynDualFaces.size()-1]; const face& f = dynDualFaces.last();
vector n = f.normal(dualPoints); vector n = f.normal(dualPoints);
if (((mesh.points()[owner] - dualPoints[f[0]]) & n) > 0) if (((mesh.points()[owner] - dualPoints[f[0]]) & n) > 0)
{ {

View File

@ -88,14 +88,14 @@ Foam::solidBodyMotionFunctions::tabulated6DoFMotion::transformation() const
<< exit(FatalError); << exit(FatalError);
} }
if (t > times_[times_.size()-1]) if (t > times_.last())
{ {
FatalErrorIn FatalErrorIn
( (
"solidBodyMotionFunctions::tabulated6DoFMotion::transformation()" "solidBodyMotionFunctions::tabulated6DoFMotion::transformation()"
) << "current time (" << t ) << "current time (" << t
<< ") is greater than the maximum in the data table (" << ") is greater than the maximum in the data table ("
<< times_[times_.size()-1] << ')' << times_.last() << ')'
<< exit(FatalError); << exit(FatalError);
} }

View File

@ -1276,7 +1276,7 @@ bool Foam::polyMeshGeometry::checkFaceAngles
faceNormal /= mag(faceNormal) + VSMALL; faceNormal /= mag(faceNormal) + VSMALL;
// Get edge from f[0] to f[size-1]; // Get edge from f[0] to f[size-1];
vector ePrev(p[f[0]] - p[f[f.size()-1]]); vector ePrev(p[f.first()] - p[f.last()]);
scalar magEPrev = mag(ePrev); scalar magEPrev = mag(ePrev);
ePrev /= magEPrev + VSMALL; ePrev /= magEPrev + VSMALL;

View File

@ -1278,7 +1278,7 @@ void Foam::addPatchCellLayer::setRefinement
doneEdge[fEdges[fp]] = true; doneEdge[fEdges[fp]] = true;
fp = f.fcIndex(fp); fp = f.fcIndex(fp);
} }
stringedVerts[stringedVerts.size()-1] = f[fp]; stringedVerts.last() = f[fp];
// Now stringedVerts contains the vertices in order of face f. // Now stringedVerts contains the vertices in order of face f.
@ -1296,7 +1296,7 @@ void Foam::addPatchCellLayer::setRefinement
for (label i = 0; i < numEdgeSideFaces; i++) for (label i = 0; i < numEdgeSideFaces; i++)
{ {
label vEnd = stringedVerts[stringedVerts.size()-1]; label vEnd = stringedVerts.last();
label vStart = stringedVerts[0]; label vStart = stringedVerts[0];
// calculate number of points making up a face // calculate number of points making up a face

View File

@ -62,7 +62,7 @@ bool Foam::combineFaces::convexFace
n /= mag(n); n /= mag(n);
// Get edge from f[0] to f[size-1]; // Get edge from f[0] to f[size-1];
vector ePrev(points[f[0]] - points[f[f.size()-1]]); vector ePrev(points[f.first()] - points[f.last()]);
scalar magEPrev = mag(ePrev); scalar magEPrev = mag(ePrev);
ePrev /= magEPrev + VSMALL; ePrev /= magEPrev + VSMALL;

View File

@ -2222,7 +2222,7 @@ Foam::labelList Foam::hexRef8::consistentSlowRefinement
faceCount faceCount
) )
); );
allFaceInfo[faceI] = seedFacesInfo[seedFacesInfo.size()-1]; allFaceInfo[faceI] = seedFacesInfo.last();
} }
else else
{ {
@ -2238,7 +2238,7 @@ Foam::labelList Foam::hexRef8::consistentSlowRefinement
faceCount faceCount
) )
); );
allFaceInfo[faceI] = seedFacesInfo[seedFacesInfo.size()-1]; allFaceInfo[faceI] = seedFacesInfo.last();
} }
} }

View File

@ -745,7 +745,7 @@ Pout<< "refinementHistory::distribute :"
newSplitCells.append(splitCells_[index]); newSplitCells.append(splitCells_[index]);
Pout<< "Added oldCell " << index Pout<< "Added oldCell " << index
<< " info " << newSplitCells[newSplitCells.size()-1] << " info " << newSplitCells.last()
<< " at position " << newSplitCells.size()-1 << " at position " << newSplitCells.size()-1
<< endl; << endl;
} }

View File

@ -179,7 +179,7 @@ displacementInterpolationFvMotionSolver
// Slightly tweak min and max face zone so points sort within // Slightly tweak min and max face zone so points sort within
zoneCoordinates[0] -= SMALL; zoneCoordinates[0] -= SMALL;
zoneCoordinates[zoneCoordinates.size()-1] += SMALL; zoneCoordinates.last() += SMALL;
// Check if we have static min and max mesh bounds // Check if we have static min and max mesh bounds
const scalarField meshCoords = points0().component(dir); const scalarField meshCoords = points0().component(dir);
@ -237,7 +237,7 @@ displacementInterpolationFvMotionSolver
} }
rangeI++; rangeI++;
} }
if (maxCoord > zoneCoordinates[zoneCoordinates.size()-1]) if (maxCoord > zoneCoordinates.last())
{ {
label sz = rangeToCoord.size(); label sz = rangeToCoord.size();
rangeToCoord.setSize(sz+1); rangeToCoord.setSize(sz+1);

View File

@ -104,8 +104,8 @@ Foam::commonRailInjector::commonRailInjector
if if
( (
mag(injectionPressureProfile_[injectionPressureProfile_.size()-1][0] mag(injectionPressureProfile_.last()[0]
- massFlowRateProfile_[massFlowRateProfile_.size()-1][0]) - massFlowRateProfile_.last()[0])
> SMALL > SMALL
) )
{ {
@ -330,13 +330,13 @@ Foam::scalar Foam::commonRailInjector::T(const scalar time) const
Foam::scalar Foam::commonRailInjector::tsoi() const Foam::scalar Foam::commonRailInjector::tsoi() const
{ {
return massFlowRateProfile_[0][0]; return massFlowRateProfile_.first()[0];
} }
Foam::scalar Foam::commonRailInjector::teoi() const Foam::scalar Foam::commonRailInjector::teoi() const
{ {
return massFlowRateProfile_[massFlowRateProfile_.size()-1][0]; return massFlowRateProfile_.last()[0];
} }

View File

@ -99,8 +99,7 @@ Foam::definedInjector::definedInjector
if if
( (
mag(massFlowRateProfile_[massFlowRateProfile_.size()-1][0] mag(massFlowRateProfile_.last()[0] - velocityProfile_.last()[0])
- velocityProfile_[velocityProfile_.size()-1][0])
> SMALL > SMALL
) )
{ {
@ -331,13 +330,13 @@ Foam::scalar Foam::definedInjector::T(const scalar time) const
Foam::scalar Foam::definedInjector::tsoi() const Foam::scalar Foam::definedInjector::tsoi() const
{ {
return massFlowRateProfile_[0][0]; return massFlowRateProfile_.first()[0];
} }
Foam::scalar Foam::definedInjector::teoi() const Foam::scalar Foam::definedInjector::teoi() const
{ {
return massFlowRateProfile_[massFlowRateProfile_.size()-1][0]; return massFlowRateProfile_.last()[0];
} }

View File

@ -91,8 +91,7 @@ Foam::multiHoleInjector::multiHoleInjector
if if
( (
mag(massFlowRateProfile_[massFlowRateProfile_.size()-1][0] mag(massFlowRateProfile_.last()[0] - TProfile_.last()[0])
- TProfile_[TProfile_.size()-1][0])
> SMALL > SMALL
) )
{ {
@ -351,13 +350,13 @@ Foam::scalar Foam::multiHoleInjector::T(const scalar time) const
Foam::scalar Foam::multiHoleInjector::tsoi() const Foam::scalar Foam::multiHoleInjector::tsoi() const
{ {
return massFlowRateProfile_[0][0]; return massFlowRateProfile_.first()[0];
} }
Foam::scalar Foam::multiHoleInjector::teoi() const Foam::scalar Foam::multiHoleInjector::teoi() const
{ {
return massFlowRateProfile_[massFlowRateProfile_.size()-1][0]; return massFlowRateProfile_.last()[0];
} }

View File

@ -384,13 +384,13 @@ Foam::scalar Foam::swirlInjector::T(const scalar time) const
Foam::scalar Foam::swirlInjector::tsoi() const Foam::scalar Foam::swirlInjector::tsoi() const
{ {
return massFlowRateProfile_[0][0]; return massFlowRateProfile_.first()[0];
} }
Foam::scalar Foam::swirlInjector::teoi() const Foam::scalar Foam::swirlInjector::teoi() const
{ {
return massFlowRateProfile_[massFlowRateProfile_.size()-1][0]; return massFlowRateProfile_.last()[0];
} }

View File

@ -83,8 +83,8 @@ Foam::unitInjector::unitInjector
if if
( (
mag(massFlowRateProfile_[massFlowRateProfile_.size()-1][0] mag(massFlowRateProfile_.last()[0]
- TProfile_[TProfile_.size()-1][0]) - TProfile_.last()[0])
> SMALL > SMALL
) )
{ {
@ -306,13 +306,13 @@ Foam::scalar Foam::unitInjector::T(const scalar time) const
Foam::scalar Foam::unitInjector::tsoi() const Foam::scalar Foam::unitInjector::tsoi() const
{ {
return massFlowRateProfile_[0][0]; return massFlowRateProfile_.first()[0];
} }
Foam::scalar Foam::unitInjector::teoi() const Foam::scalar Foam::unitInjector::teoi() const
{ {
return massFlowRateProfile_[massFlowRateProfile_.size()-1][0]; return massFlowRateProfile_.last()[0];
} }

View File

@ -64,7 +64,7 @@ template<class Type>
Type Foam::Table<Type>::value(const scalar x) const Type Foam::Table<Type>::value(const scalar x) const
{ {
// Return zero if out of bounds // Return zero if out of bounds
if ((x > table_[table_.size()-1].first()) || (x < table_[0].first())) if (x < table_[0].first() || x > table_.last().first())
{ {
return pTraits<Type>::zero; return pTraits<Type>::zero;
} }

View File

@ -256,7 +256,7 @@ void Foam::distribution::insertMissingKeys()
if (keys.size()) if (keys.size())
{ {
for (label k = keys[0]; k < keys[keys.size()-1]; k++) for (label k = keys[0]; k < keys.last(); k++)
{ {
iter = find(k); iter = find(k);

View File

@ -835,7 +835,7 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
vector::zero // passive data vector::zero // passive data
) )
); );
pointMedialDist[pointI] = maxInfo[maxInfo.size()-1]; pointMedialDist[pointI] = maxInfo.last();
} }
} }
} }
@ -879,7 +879,7 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
vector::zero // passive data vector::zero // passive data
) )
); );
pointMedialDist[pointI] = maxInfo[maxInfo.size()-1]; pointMedialDist[pointI] = maxInfo.last();
} }
} }
} }

View File

@ -47,7 +47,7 @@ void Foam::polyLine::calcDistances()
} }
// normalize // normalize
lineLength_ = distances_[distances_.size()-1]; lineLength_ = distances_.last();
for (label i=1; i<distances_.size(); i++) for (label i=1; i<distances_.size(); i++)
{ {
distances_[i] /= lineLength_; distances_[i] /= lineLength_;
@ -95,7 +95,7 @@ Foam::vector Foam::polyLine::position(const scalar lambda) const
} }
else if (lambda > 1 - SMALL) else if (lambda > 1 - SMALL)
{ {
return controlPoints_[controlPoints_.size()-1]; return controlPoints_.last();
} }

View File

@ -796,7 +796,7 @@ bool Foam::primitiveMeshGeometry::checkFaceAngles
faceNormal /= mag(faceNormal) + VSMALL; faceNormal /= mag(faceNormal) + VSMALL;
// Get edge from f[0] to f[size-1]; // Get edge from f[0] to f[size-1];
vector ePrev(p[f[0]] - p[f[f.size()-1]]); vector ePrev(p[f.first()] - p[f.last()]);
scalar magEPrev = mag(ePrev); scalar magEPrev = mag(ePrev);
ePrev /= magEPrev + VSMALL; ePrev /= magEPrev + VSMALL;

View File

@ -496,7 +496,7 @@ void Foam::searchableBox::findLineAll
if if
( (
!inter.hit() !inter.hit()
|| (inter.index() == hits[hits.size()-1].index()) || (inter.index() == hits.last().index())
) )
{ {
break; break;

View File

@ -730,7 +730,7 @@ Foam::pointIndexHit Foam::searchableSurfacesQueries::facesIntersection
} }
} }
nearest[nearest.size()-1] = sumNearest / surfacesToTest.size(); nearest.last() = sumNearest / surfacesToTest.size();
// Get the sum of distances (initial evaluation) // Get the sum of distances (initial evaluation)

View File

@ -632,7 +632,7 @@ void Foam::triSurfaceMesh::findLineAll
if if
( (
!inter.hit() !inter.hit()
|| (inter.index() == hits[hits.size()-1].index()) || (inter.index() == hits.last().index())
) )
{ {
break; break;

View File

@ -213,7 +213,7 @@ Foam::edgeSurface::edgeSurface
( (
edge edge
( (
extraVerts[extraVerts.size()-1] + nSurfacePoints_, extraVerts.last() + nSurfacePoints_,
e.end() e.end()
) )
); );

View File

@ -258,12 +258,12 @@ bool Foam::edgeIntersections::inlinePerturb
bool perturbEnd = false; bool perturbEnd = false;
// Check first intersection. // Check first intersection.
if (edgeEnds[0] == 0) if (edgeEnds.first() == 0)
{ {
perturbStart = true; perturbStart = true;
} }
if (edgeEnds[edgeEnds.size()-1] == 1) if (edgeEnds.last() == 1)
{ {
perturbEnd = true; perturbEnd = true;
} }

View File

@ -242,8 +242,7 @@ void Foam::surfaceIntersection::storeIntersection
// Check whether perhaps degenerate // Check whether perhaps degenerate
const point& prevHit = allCutPoints[*iter]; const point& prevHit = allCutPoints[*iter];
const point& thisHit = allCutPoints.last();
const point& thisHit = allCutPoints[allCutPoints.size()-1];
if (mag(prevHit - thisHit) < SMALL) if (mag(prevHit - thisHit) < SMALL)
{ {

View File

@ -160,7 +160,7 @@ void Foam::surfaceIntersection::removeDuplicates
// Insert others only if they differ from one before // Insert others only if they differ from one before
label newVertI = map[oldElems[vertI]]; label newVertI = map[oldElems[vertI]];
if (newVertI != elems[elems.size()-1]) if (newVertI != elems.last())
{ {
elems[elemI++] = newVertI; elems[elemI++] = newVertI;
} }
@ -300,7 +300,7 @@ void Foam::surfaceIntersection::writeIntersectedEdges
<< extraVerts[i] + surf.nPoints() + 1 << endl; << extraVerts[i] + surf.nPoints() + 1 << endl;
} }
os << "l " << extraVerts[extraVerts.size()-1] + surf.nPoints() + 1 os << "l " << extraVerts.last() + surf.nPoints() + 1
<< ' ' << e.end()+1 << endl; << ' ' << e.end()+1 << endl;
} }
} }

View File

@ -165,7 +165,7 @@ void Foam::hierarchGeomDecomp::calculateSortedWeightedSizes
// Non-dimensionalise and multiply by size. // Non-dimensionalise and multiply by size.
scalar globalCurrentLength = returnReduce scalar globalCurrentLength = returnReduce
( (
sortedWeightedSizes[current.size()], sortedWeightedSizes[current.size()],
sumOp<scalar>() sumOp<scalar>()
); );
// Normalise weights by global sum of weights and multiply through // Normalise weights by global sum of weights and multiply through
@ -238,7 +238,7 @@ void Foam::hierarchGeomDecomp::findBinary
if (returnReduce(hasNotChanged, andOp<bool>())) if (returnReduce(hasNotChanged, andOp<bool>()))
{ {
WarningIn("hierarchGeomDecomp::findBinary(..)") WarningIn("hierarchGeomDecomp::findBinary(..)")
<< "unable to find desired deomposition split, making do!" << "unable to find desired deomposition split, making do!"
<< endl; << endl;
break; break;
} }
@ -288,7 +288,7 @@ void Foam::hierarchGeomDecomp::findBinary
Pout<< " low:" << low << " lowValue:" << lowValue Pout<< " low:" << low << " lowValue:" << lowValue
<< " high:" << high << " highValue:" << highValue << " high:" << high << " highValue:" << highValue
<< " mid:" << mid << " midValue:" << midValue << endl << " mid:" << mid << " midValue:" << midValue << endl
<< " globalSize:" << weightedSize << " globalSize:" << weightedSize
<< " wantedSize:" << wantedSize << " wantedSize:" << wantedSize
<< " sizeTol:" << sizeTol << endl; << " sizeTol:" << sizeTol << endl;
} }
@ -318,7 +318,7 @@ void Foam::hierarchGeomDecomp::findBinary
if (returnReduce(hasNotChanged, andOp<bool>())) if (returnReduce(hasNotChanged, andOp<bool>()))
{ {
WarningIn("hierarchGeomDecomp::findBinary(..)") WarningIn("hierarchGeomDecomp::findBinary(..)")
<< "unable to find desired deomposition split, making do!" << "unable to find desired deomposition split, making do!"
<< endl; << endl;
break; break;
} }
@ -375,7 +375,7 @@ void Foam::hierarchGeomDecomp::sortComponent
( (
( (
sortedCoord.size() sortedCoord.size()
? sortedCoord[sortedCoord.size()-1] ? sortedCoord.last()
: -GREAT : -GREAT
), ),
maxOp<scalar>() maxOp<scalar>()
@ -562,14 +562,14 @@ void Foam::hierarchGeomDecomp::sortComponent
( (
( (
sortedCoord.size() sortedCoord.size()
? sortedCoord[sortedCoord.size()-1] ? sortedCoord.last()
: -GREAT : -GREAT
), ),
maxOp<scalar>() maxOp<scalar>()
); );
if (debug) if (debug)
{ {
Pout<< "sortComponent : minCoord:" << minCoord Pout<< "sortComponent : minCoord:" << minCoord
<< " maxCoord:" << maxCoord << endl; << " maxCoord:" << maxCoord << endl;
} }
@ -592,7 +592,7 @@ void Foam::hierarchGeomDecomp::sortComponent
// Value at right of bin (leftIndex+localSize-1) // Value at right of bin (leftIndex+localSize-1)
scalar rightCoord = -GREAT; scalar rightCoord = -GREAT;
if (bin == n_[compI]-1) if (bin == n_[compI]-1)
{ {
// Last bin. Copy all. // Last bin. Copy all.
@ -602,7 +602,7 @@ void Foam::hierarchGeomDecomp::sortComponent
else else
{ {
// For the current bin (starting at leftCoord) we want a rightCoord // For the current bin (starting at leftCoord) we want a rightCoord
// such that the sum of all weighted sizes are // such that the sum of all weighted sizes are
// globalCurrentLength/n_[compI]. // globalCurrentLength/n_[compI].
// We have to iterate to obtain this. // We have to iterate to obtain this.

View File

@ -84,7 +84,7 @@ Foam::vector Foam::streamLineParticle::interpolateFields
const DynamicList<vector>& U = sampledVectors_[td.UIndex_]; const DynamicList<vector>& U = sampledVectors_[td.UIndex_];
return U[U.size()-1]; return U.last();
} }
@ -226,21 +226,21 @@ bool Foam::streamLineParticle::move(streamLineParticle::trackData& td)
// Transfer particle data into trackData. // Transfer particle data into trackData.
//td.allPositions_.append(sampledPositions_); //td.allPositions_.append(sampledPositions_);
td.allPositions_.append(vectorList()); td.allPositions_.append(vectorList());
vectorList& top = td.allPositions_[td.allPositions_.size()-1]; vectorList& top = td.allPositions_.last();
top.transfer(sampledPositions_); top.transfer(sampledPositions_);
forAll(sampledScalars_, i) forAll(sampledScalars_, i)
{ {
//td.allScalars_[i].append(sampledScalars_[i]); //td.allScalars_[i].append(sampledScalars_[i]);
td.allScalars_[i].append(scalarList()); td.allScalars_[i].append(scalarList());
scalarList& top = td.allScalars_[i][td.allScalars_[i].size()-1]; scalarList& top = td.allScalars_[i].last();
top.transfer(sampledScalars_[i]); top.transfer(sampledScalars_[i]);
} }
forAll(sampledVectors_, i) forAll(sampledVectors_, i)
{ {
//td.allVectors_[i].append(sampledVectors_[i]); //td.allVectors_[i].append(sampledVectors_[i]);
td.allVectors_[i].append(vectorList()); td.allVectors_[i].append(vectorList());
vectorList& top = td.allVectors_[i][td.allVectors_[i].size()-1]; vectorList& top = td.allVectors_[i].last();
top.transfer(sampledVectors_[i]); top.transfer(sampledVectors_[i]);
} }
} }

View File

@ -53,7 +53,7 @@ void Foam::MeshedSurface<Face>::checkZones()
<< " ... extending final zone" << " ... extending final zone"
<< endl; << endl;
zones[zones.size()-1].size() += count - this->size(); zones.last().size() += count - this->size();
} }
else if (count > this->size()) else if (count > this->size())
{ {

View File

@ -377,7 +377,7 @@ void Foam::surfMesh::checkZones()
<< " ... extending final zone" << " ... extending final zone"
<< endl; << endl;
zones[zones.size()-1].size() += count - nFaces(); zones.last().size() += count - nFaces();
} }
else if (count > size()) else if (count > size())
{ {