STYLE: use UPtrList::test() instead of separate bounds checking

This commit is contained in:
Mark Olesen
2023-07-05 20:40:18 +02:00
parent 65cddb6120
commit 8562f4d7a4
5 changed files with 36 additions and 35 deletions

View File

@ -368,11 +368,7 @@ Description
{
const label nPatchFields =
(
(
writeri < patchInterps.size() && patchInterps.set(writeri)
? nVolFields
: 0
)
(patchInterps.test(writeri) ? nVolFields : 0)
+ nPointFields
);

View File

@ -116,7 +116,7 @@ label writeVolFields
label writeri = 0;
for (vtk::patchWriter& writer : patchWriters)
{
if (writeri < patchInterps.size() && patchInterps.set(writeri))
if (patchInterps.test(writeri))
{
writer.write(tfield(), patchInterps[writeri]);
}

View File

@ -712,15 +712,12 @@ void Foam::fvMeshAdder::MapDimField
// Add fields to fields[0] after adding the meshes to meshes[0].
// Mesh[0] is the sum of all meshes. Fields are not yet mapped.
if
(
flds.size() == 0
|| !flds.set(0)
|| cellProcAddressing.size() != flds.size()
)
if (!flds.test(0) || cellProcAddressing.size() != flds.size())
{
FatalErrorInFunction << "Not valid field at element 0"
<< " in field list of size " << flds.size() << exit(FatalError);
FatalErrorInFunction
<< "Not valid field at element 0 in list of size "
<< flds.size() << nl
<< exit(FatalError);
}
@ -766,10 +763,12 @@ void Foam::fvMeshAdder::MapVolField
// Add fields to fields[0] after adding the meshes to meshes[0].
// Mesh[0] is the sum of all meshes. Fields are not yet mapped.
if (flds.size() == 0 || !flds.set(0))
if (!flds.test(0))
{
FatalErrorInFunction << "Not valid field at element 0"
<< " in field list of size " << flds.size() << exit(FatalError);
FatalErrorInFunction
<< "Not valid field at element 0 in list of size "
<< flds.size() << nl
<< exit(FatalError);
}
@ -902,10 +901,12 @@ void Foam::fvMeshAdder::MapSurfaceField
// Add fields to fields[0] after adding the meshes to meshes[0].
// Mesh[0] is the sum of all meshes. Fields are not yet mapped.
if (flds.size() == 0 || !flds.set(0))
if (!flds.test(0))
{
FatalErrorInFunction << "Not valid field at element 0"
<< " in field list of size " << flds.size() << exit(FatalError);
FatalErrorInFunction
<< "Not valid field at element 0 in list of size "
<< flds.size() << nl
<< exit(FatalError);
}
const fvMesh& mesh0 = flds[0].mesh();
@ -1105,12 +1106,14 @@ void Foam::fvMeshAdder::MapVolFields
{
typedef GeometricField<Type, fvPatchField, volMesh> fldType;
if (meshes.size() == 0 || !meshes.set(0))
if (!meshes.test(0))
{
FatalErrorInFunction << "Not valid field at element 0"
<< " in mesh list of size " << meshes.size() << exit(FatalError);
FatalErrorInFunction
<< "Not valid mesh at element 0 in list of size "
<< meshes.size() << nl
<< exit(FatalError);
}
const fvMesh& mesh0 = meshes[0];
const auto& mesh0 = meshes[0];
HashTable<const fldType*> fields
(
@ -1176,12 +1179,14 @@ void Foam::fvMeshAdder::MapDimFields
typedef DimensionedField<Type, volMesh> fldType;
typedef GeometricField<Type, fvPatchField, volMesh> excludeType;
if (meshes.size() == 0 || !meshes.set(0))
if (!meshes.test(0))
{
FatalErrorInFunction << "Not valid field at element 0"
<< " in mesh list of size " << meshes.size() << exit(FatalError);
FatalErrorInFunction
<< "Not valid mesh at element 0 in list of size "
<< meshes.size() << nl
<< exit(FatalError);
}
const fvMesh& mesh0 = meshes[0];
const auto& mesh0 = meshes[0];
HashTable<const fldType*> fields
(
@ -1236,10 +1241,12 @@ void Foam::fvMeshAdder::MapSurfaceFields
{
typedef GeometricField<Type, fvsPatchField, surfaceMesh> fldType;
if (meshes.size() == 0 || !meshes.set(0))
if (!meshes.test(0))
{
FatalErrorInFunction << "Not valid field at element 0"
<< " in mesh list of size " << meshes.size() << exit(FatalError);
FatalErrorInFunction
<< "Not valid mesh at element 0 in list of size "
<< meshes.size() << nl
<< exit(FatalError);
}
const auto& mesh0 = meshes[0];

View File

@ -627,9 +627,7 @@ bool Foam::functionObjects::vtkWrite::write()
{
const label nPatchFields =
(
writeri < patchInterps.size() && patchInterps.set(writeri)
? nVolFields
: 0
patchInterps.test(writeri) ? nVolFields : 0
);
if (nPatchFields)

View File

@ -128,7 +128,7 @@ Foam::label Foam::functionObjects::vtkWrite::writeVolFieldsImpl
label writeri = 0;
for (vtk::patchWriter& writer : patchWriters)
{
if (writeri < patchInterps.size() && patchInterps.set(writeri))
if (patchInterps.test(writeri))
{
ok = true;
writer.write(field, patchInterps[writeri]);