mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -154,6 +154,11 @@ class vtkPV3Foam
|
||||
return size_;
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
return (size_ == 0);
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
start_ = -1;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user