mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -126,41 +126,41 @@ int main(int argc, char *argv[])
|
||||
// Create bin0. Have upperlimit as factor times lowerlimit.
|
||||
bins.append(DynamicList<label>());
|
||||
lowerLimits.append(sortedVols[0]);
|
||||
upperLimits.append(1.1*lowerLimits[lowerLimits.size()-1]);
|
||||
upperLimits.append(1.1 * lowerLimits.last());
|
||||
|
||||
forAll(sortedVols, i)
|
||||
{
|
||||
if (sortedVols[i] > upperLimits[upperLimits.size()-1])
|
||||
if (sortedVols[i] > upperLimits.last())
|
||||
{
|
||||
// New value outside of current bin
|
||||
|
||||
// Shrink old bin.
|
||||
DynamicList<label>& bin = bins[bins.size()-1];
|
||||
DynamicList<label>& bin = bins.last();
|
||||
|
||||
bin.shrink();
|
||||
|
||||
Info<< "Collected " << bin.size() << " elements in bin "
|
||||
<< lowerLimits[lowerLimits.size()-1] << " .. "
|
||||
<< upperLimits[upperLimits.size()-1] << endl;
|
||||
<< lowerLimits.last() << " .. "
|
||||
<< upperLimits.last() << endl;
|
||||
|
||||
// Create new bin.
|
||||
bins.append(DynamicList<label>());
|
||||
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]
|
||||
<< " .. " << upperLimits[upperLimits.size()-1]
|
||||
Info<< "Creating new bin " << lowerLimits.last()
|
||||
<< " .. " << upperLimits.last()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// Append to current bin.
|
||||
DynamicList<label>& bin = bins[bins.size()-1];
|
||||
DynamicList<label>& bin = bins.last();
|
||||
|
||||
bin.append(sortedVols.indices()[i]);
|
||||
}
|
||||
Info<< endl;
|
||||
|
||||
bins[bins.size()-1].shrink();
|
||||
bins.last().shrink();
|
||||
bins.shrink();
|
||||
lowerLimits.shrink();
|
||||
upperLimits.shrink();
|
||||
|
||||
@ -324,7 +324,7 @@ endOfSection {space}")"{space}
|
||||
// point group type skipped
|
||||
strtol(endPtr, &endPtr, 16);
|
||||
|
||||
pointi = pointGroupStartIndex[pointGroupStartIndex.size()-1];
|
||||
pointi = pointGroupStartIndex.last();
|
||||
|
||||
// reset number of components to default
|
||||
pointGroupNumberOfComponents = 3;
|
||||
@ -336,11 +336,11 @@ endOfSection {space}")"{space}
|
||||
}
|
||||
|
||||
Info<< "PointGroup: "
|
||||
<< pointGroupZoneID[pointGroupZoneID.size()-1]
|
||||
<< pointGroupZoneID.last()
|
||||
<< " start: "
|
||||
<< pointGroupStartIndex[pointGroupStartIndex.size()-1]
|
||||
<< pointGroupStartIndex.last()
|
||||
<< " end: "
|
||||
<< pointGroupEndIndex[pointGroupEndIndex.size()-1] << flush;
|
||||
<< pointGroupEndIndex.last() << flush;
|
||||
}
|
||||
|
||||
<readNumberOfPoints,readPointGroupData>{endOfSection} {
|
||||
@ -387,14 +387,14 @@ endOfSection {space}")"{space}
|
||||
Info<< "done." << endl;
|
||||
|
||||
// check read of points
|
||||
if (pointi != pointGroupEndIndex[pointGroupEndIndex.size()-1]+1)
|
||||
if (pointi != pointGroupEndIndex.last()+1)
|
||||
{
|
||||
Warning
|
||||
<< "Problem with reading points: " << nl
|
||||
<< " start index: "
|
||||
<< pointGroupStartIndex[pointGroupStartIndex.size()-1]
|
||||
<< pointGroupStartIndex.last()
|
||||
<< " end index: "
|
||||
<< pointGroupEndIndex[pointGroupEndIndex.size()-1]
|
||||
<< pointGroupEndIndex.last()
|
||||
<< " last points read: " << pointi << nl
|
||||
<< " on line " << lineNo << endl;
|
||||
}
|
||||
@ -440,14 +440,14 @@ endOfSection {space}")"{space}
|
||||
|
||||
faceGroupElementType = strtol(endPtr, &endPtr, 16);
|
||||
|
||||
facei = faceGroupStartIndex[faceGroupStartIndex.size()-1];
|
||||
facei = faceGroupStartIndex.last();
|
||||
|
||||
Info<< "FaceGroup: "
|
||||
<< faceGroupZoneID[faceGroupZoneID.size()-1]
|
||||
<< faceGroupZoneID.last()
|
||||
<< " start: "
|
||||
<< faceGroupStartIndex[faceGroupStartIndex.size()-1]
|
||||
<< faceGroupStartIndex.last()
|
||||
<< " end: "
|
||||
<< faceGroupEndIndex[faceGroupEndIndex.size()-1] << flush;
|
||||
<< faceGroupEndIndex.last() << flush;
|
||||
}
|
||||
|
||||
<readNumberOfFaces,readFaceGroupData>{space}{endOfSection} {
|
||||
@ -507,14 +507,14 @@ endOfSection {space}")"{space}
|
||||
Info<< "done." << endl;
|
||||
|
||||
// check read of fluentFaces
|
||||
if (facei != faceGroupEndIndex[faceGroupEndIndex.size()-1]+1)
|
||||
if (facei != faceGroupEndIndex.last()+1)
|
||||
{
|
||||
Warning
|
||||
<< "Problem with reading fluentFaces: " << nl
|
||||
<< " start index: "
|
||||
<< faceGroupStartIndex[faceGroupStartIndex.size()-1]
|
||||
<< faceGroupStartIndex.last()
|
||||
<< " end index: "
|
||||
<< faceGroupEndIndex[faceGroupEndIndex.size()-1]
|
||||
<< faceGroupEndIndex.last()
|
||||
<< " last fluentFaces read: " << facei << nl
|
||||
<< " on line " << lineNo << endl;
|
||||
}
|
||||
@ -560,13 +560,13 @@ endOfSection {space}")"{space}
|
||||
cellGroupType.append(strtol(endPtr, &endPtr, 16));
|
||||
|
||||
Info<< "CellGroup: "
|
||||
<< cellGroupZoneID[cellGroupZoneID.size()-1]
|
||||
<< cellGroupZoneID.last()
|
||||
<< " start: "
|
||||
<< cellGroupStartIndex[cellGroupStartIndex.size()-1]
|
||||
<< cellGroupStartIndex.last()
|
||||
<< " end: "
|
||||
<< cellGroupEndIndex[cellGroupEndIndex.size()-1]
|
||||
<< cellGroupEndIndex.last()
|
||||
<< " type: "
|
||||
<< cellGroupType[cellGroupType.size()-1]
|
||||
<< cellGroupType.last()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
@ -587,13 +587,13 @@ endOfSection {space}")"{space}
|
||||
strtol(endPtr, &endPtr, 16);
|
||||
|
||||
Info<< "CellGroup: "
|
||||
<< cellGroupZoneID[cellGroupZoneID.size()-1]
|
||||
<< cellGroupZoneID.last()
|
||||
<< " start: "
|
||||
<< cellGroupStartIndex[cellGroupStartIndex.size()-1]
|
||||
<< cellGroupStartIndex.last()
|
||||
<< " end: "
|
||||
<< cellGroupEndIndex[cellGroupEndIndex.size()-1]
|
||||
<< cellGroupEndIndex.last()
|
||||
<< " type: "
|
||||
<< cellGroupType[cellGroupType.size()-1]
|
||||
<< cellGroupType.last()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
@ -885,7 +885,7 @@ int main(int argc, char *argv[])
|
||||
// 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)
|
||||
const polyPatch& pp = mesh.boundaryMesh()[mesh.boundaryMesh().size()-1];
|
||||
const polyPatch& pp = mesh.boundaryMesh().last();
|
||||
|
||||
// Storage for faceZones.
|
||||
List<DynamicList<label> > zoneFaces(patchFaces.size());
|
||||
|
||||
@ -324,13 +324,13 @@ void readCells
|
||||
cellVerts.append(cellShape(tet, cVerts, true));
|
||||
cellMaterial.append(physProp);
|
||||
|
||||
if (cellVerts[cellVerts.size()-1].size() != cVerts.size())
|
||||
if (cellVerts.last().size() != cVerts.size())
|
||||
{
|
||||
Pout<< "Line:" << is.lineNumber()
|
||||
<< " element:" << cellI
|
||||
<< " type:" << feID
|
||||
<< " collapsed from " << cVerts << nl
|
||||
<< " to:" << cellVerts[cellVerts.size()-1]
|
||||
<< " to:" << cellVerts.last()
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
@ -347,13 +347,13 @@ void readCells
|
||||
cellVerts.append(cellShape(prism, cVerts, true));
|
||||
cellMaterial.append(physProp);
|
||||
|
||||
if (cellVerts[cellVerts.size()-1].size() != cVerts.size())
|
||||
if (cellVerts.last().size() != cVerts.size())
|
||||
{
|
||||
Pout<< "Line:" << is.lineNumber()
|
||||
<< " element:" << cellI
|
||||
<< " type:" << feID
|
||||
<< " collapsed from " << cVerts << nl
|
||||
<< " to:" << cellVerts[cellVerts.size()-1]
|
||||
<< " to:" << cellVerts.last()
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
@ -371,13 +371,13 @@ void readCells
|
||||
cellVerts.append(cellShape(hex, cVerts, true));
|
||||
cellMaterial.append(physProp);
|
||||
|
||||
if (cellVerts[cellVerts.size()-1].size() != cVerts.size())
|
||||
if (cellVerts.last().size() != cVerts.size())
|
||||
{
|
||||
Pout<< "Line:" << is.lineNumber()
|
||||
<< " element:" << cellI
|
||||
<< " type:" << feID
|
||||
<< " collapsed from " << cVerts << nl
|
||||
<< " to:" << cellVerts[cellVerts.size()-1]
|
||||
<< " to:" << cellVerts.last()
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
@ -511,7 +511,7 @@ void readDOFS
|
||||
}
|
||||
|
||||
Info<< "For DOF set " << group
|
||||
<< " named " << patchNames[patchNames.size()-1]
|
||||
<< " named " << patchNames.last()
|
||||
<< " trying to read vertex indices."
|
||||
<< endl;
|
||||
|
||||
@ -534,7 +534,7 @@ void readDOFS
|
||||
}
|
||||
|
||||
Info<< "For DOF set " << group
|
||||
<< " named " << patchNames[patchNames.size()-1]
|
||||
<< " named " << patchNames.last()
|
||||
<< " read " << vertices.size() << " vertex indices." << endl;
|
||||
|
||||
dofVertices.append(vertices.shrink());
|
||||
|
||||
@ -418,8 +418,8 @@ int main(int argc, char *argv[])
|
||||
frontPatchFaces.setSize(layerFaces.size());
|
||||
forAll(backPatchFaces, i)
|
||||
{
|
||||
backPatchFaces[i] = layerFaces[i][0];
|
||||
frontPatchFaces[i] = layerFaces[i][layerFaces[i].size()-1];
|
||||
backPatchFaces[i] = layerFaces[i].first();
|
||||
frontPatchFaces[i] = layerFaces[i].last();
|
||||
}
|
||||
|
||||
// Create dummy fvSchemes, fvSolution
|
||||
|
||||
@ -186,7 +186,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
newPatches.append(findPatchID(mesh, patchNames[i]));
|
||||
Info<< "Using additional patch " << patchNames[i]
|
||||
<< " at index " << newPatches[newPatches.size()-1] << endl;
|
||||
<< " at index " << newPatches.last() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -175,7 +175,7 @@ int main(int argc, char *argv[])
|
||||
ensightMesh eMesh(mesh, args, binary);
|
||||
|
||||
// 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());
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ HashTable< HashTable<word> > cloudFields;
|
||||
|
||||
if (timeDirs.size())
|
||||
{
|
||||
IOobjectList objs(mesh, timeDirs[timeDirs.size()-1].name());
|
||||
IOobjectList objs(mesh, timeDirs.last().name());
|
||||
|
||||
forAllConstIter(IOobjectList, objs, fieldIter)
|
||||
{
|
||||
@ -34,7 +34,7 @@ if (timeDirs.size())
|
||||
fileNameList cloudDirs = readDir
|
||||
(
|
||||
runTime.path()
|
||||
/ timeDirs[timeDirs.size()-1].name()
|
||||
/ timeDirs.last().name()
|
||||
/ regionPrefix
|
||||
/ cloud::prefix,
|
||||
fileName::DIRECTORY
|
||||
@ -54,7 +54,7 @@ if (timeDirs.size())
|
||||
IOobjectList objs
|
||||
(
|
||||
mesh,
|
||||
timeDirs[timeDirs.size()-1].name(),
|
||||
timeDirs.last().name(),
|
||||
cloud::prefix/cloudName
|
||||
);
|
||||
|
||||
|
||||
@ -87,7 +87,7 @@ int USERD_set_filenames
|
||||
|
||||
// set the number of fields and store their names
|
||||
// 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());
|
||||
|
||||
fieldNames = objects.names();
|
||||
|
||||
@ -103,7 +103,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
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];
|
||||
|
||||
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
# include "createMesh.H"
|
||||
|
||||
runTime.setTime(timeDirs[timeDirs.size()-1], timeDirs.size()-1);
|
||||
runTime.setTime(timeDirs.last(), timeDirs.size()-1);
|
||||
|
||||
volScalarField pMean
|
||||
(
|
||||
|
||||
@ -93,13 +93,13 @@ Foam::scalar Foam::tabulatedWallFunctions::general::interpolate
|
||||
{
|
||||
case itLinear:
|
||||
{
|
||||
if (xi < x[0])
|
||||
if (xi <= x[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
|
||||
{
|
||||
|
||||
@ -128,7 +128,7 @@ static void splitTri
|
||||
labelledTri
|
||||
(
|
||||
f[fp2],
|
||||
splitPoints[splitPoints.size()-1],
|
||||
splitPoints.last(),
|
||||
f[fp1],
|
||||
f.region()
|
||||
)
|
||||
@ -144,7 +144,7 @@ static void splitTri
|
||||
(
|
||||
f[fp1],
|
||||
f[fp2],
|
||||
splitPoints[splitPoints.size()-1],
|
||||
splitPoints.last(),
|
||||
f.region()
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user