ENH: add operator[](const word&) as "find-by-name" to some classes

- affected: polyBoundary, fvBoundaryMesh, ZoneMesh, searchableSurfaces

  before:
      const label zoneI = mesh.cellZones().findZoneID(zoneName);
      const cellZone& cz = mesh.cellZones()[zoneI];
  after:
      const cellZone& cz = mesh.cellZones()[zoneName];
This commit is contained in:
Mark Olesen
2010-04-29 10:12:35 +02:00
parent 845314b280
commit 72f7d46f23
46 changed files with 438 additions and 258 deletions

View File

@ -65,8 +65,8 @@ int main(int argc, char *argv[])
{
mesh.readUpdate();
label patchi = mesh.boundaryMesh().findPatchID(patchName);
if (patchi < 0)
const label patchI = mesh.boundaryMesh().findPatchID(patchName);
if (patchI < 0)
{
FatalError
<< "Unable to find patch " << patchName << nl
@ -78,20 +78,20 @@ int main(int argc, char *argv[])
Info<< " Reading volScalarField " << fieldName << endl;
volScalarField field(fieldHeader, mesh);
scalar area = gSum(mesh.magSf().boundaryField()[patchi]);
scalar area = gSum(mesh.magSf().boundaryField()[patchI]);
scalar sumField = 0;
if (area > 0)
{
sumField = gSum
(
mesh.magSf().boundaryField()[patchi]
* field.boundaryField()[patchi]
mesh.magSf().boundaryField()[patchI]
* field.boundaryField()[patchI]
) / area;
}
Info<< " Average of " << fieldName << " over patch "
<< patchName << '[' << patchi << ']' << " = "
<< patchName << '[' << patchI << ']' << " = "
<< sumField << endl;
}
else

View File

@ -67,8 +67,8 @@ int main(int argc, char *argv[])
{
mesh.readUpdate();
label patchi = mesh.boundaryMesh().findPatchID(patchName);
if (patchi < 0)
const label patchI = mesh.boundaryMesh().findPatchID(patchName);
if (patchI < 0)
{
FatalError
<< "Unable to find patch " << patchName << nl
@ -76,16 +76,16 @@ int main(int argc, char *argv[])
}
// Give patch area
if (isA<cyclicPolyPatch>(mesh.boundaryMesh()[patchi]))
if (isA<cyclicPolyPatch>(mesh.boundaryMesh()[patchI]))
{
Info<< " Cyclic patch vector area: " << nl;
label nFaces = mesh.boundaryMesh()[patchi].size();
label nFaces = mesh.boundaryMesh()[patchI].size();
vector sum1 = vector::zero;
vector sum2 = vector::zero;
for (label i=0; i<nFaces/2; i++)
{
sum1 += mesh.Sf().boundaryField()[patchi][i];
sum2 += mesh.Sf().boundaryField()[patchi][i+nFaces/2];
sum1 += mesh.Sf().boundaryField()[patchI][i];
sum2 += mesh.Sf().boundaryField()[patchI][i+nFaces/2];
}
reduce(sum1, sumOp<vector>());
reduce(sum2, sumOp<vector>());
@ -94,16 +94,16 @@ int main(int argc, char *argv[])
<< " - total = " << (sum1 + sum2) << ", "
<< mag(sum1 + sum2) << endl;
Info<< " Cyclic patch area magnitude = "
<< gSum(mesh.magSf().boundaryField()[patchi])/2.0 << endl;
<< gSum(mesh.magSf().boundaryField()[patchI])/2.0 << endl;
}
else
{
Info<< " Area vector of patch "
<< patchName << '[' << patchi << ']' << " = "
<< gSum(mesh.Sf().boundaryField()[patchi]) << endl;
<< patchName << '[' << patchI << ']' << " = "
<< gSum(mesh.Sf().boundaryField()[patchI]) << endl;
Info<< " Area magnitude of patch "
<< patchName << '[' << patchi << ']' << " = "
<< gSum(mesh.magSf().boundaryField()[patchi]) << endl;
<< patchName << '[' << patchI << ']' << " = "
<< gSum(mesh.magSf().boundaryField()[patchI]) << endl;
}
// Read field and calc integral
@ -116,21 +116,21 @@ int main(int argc, char *argv[])
Info<< " Integral of " << fieldName
<< " over vector area of patch "
<< patchName << '[' << patchi << ']' << " = "
<< patchName << '[' << patchI << ']' << " = "
<< gSum
(
mesh.Sf().boundaryField()[patchi]
*field.boundaryField()[patchi]
mesh.Sf().boundaryField()[patchI]
*field.boundaryField()[patchI]
)
<< nl;
Info<< " Integral of " << fieldName
<< " over area magnitude of patch "
<< patchName << '[' << patchi << ']' << " = "
<< patchName << '[' << patchI << ']' << " = "
<< gSum
(
mesh.magSf().boundaryField()[patchi]
*field.boundaryField()[patchi]
mesh.magSf().boundaryField()[patchI]
*field.boundaryField()[patchI]
)
<< nl;
}
@ -143,10 +143,10 @@ int main(int argc, char *argv[])
<< fieldName << endl;
surfaceScalarField field(fieldHeader, mesh);
scalar sumField = gSum(field.boundaryField()[patchi]);
scalar sumField = gSum(field.boundaryField()[patchI]);
Info<< " Integral of " << fieldName << " over patch "
<< patchName << '[' << patchi << ']' << " = "
<< patchName << '[' << patchI << ']' << " = "
<< sumField << nl;
}
else