ENH: use Zero when zero-initializing types

- makes the intent clearer and avoids the need for additional
  constructor casting. Eg,

      labelList(10, Zero)    vs.  labelList(10, 0)
      scalarField(10, Zero)  vs.  scalarField(10, scalar(0))
      vectorField(10, Zero)  vs.  vectorField(10, vector::zero)
This commit is contained in:
Mark Olesen
2018-12-11 23:50:15 +01:00
parent 6e8cf684d1
commit 1d85fecf4d
342 changed files with 814 additions and 803 deletions

View File

@ -33,8 +33,8 @@ using namespace Foam::constant;
Foam::functionObjects::eulerianParticle::eulerianParticle()
:
faceIHit(-1),
VC(vector::zero),
VU(vector::zero),
VC(Zero),
VU(Zero),
V(0),
time(0)
{}

View File

@ -721,8 +721,8 @@ bool Foam::functionObjects::fluxSummary::surfaceModeWrite()
const boolList& flips = faceFlip_[surfi];
scalar phiPos = scalar(0);
scalar phiNeg = scalar(0);
scalar phiPos(0);
scalar phiNeg(0);
tmp<scalarField> tphis = phi & s.Sf();
const scalarField& phis = tphis();
@ -1047,9 +1047,9 @@ bool Foam::functionObjects::fluxSummary::write()
const labelList& facePatchID = facePatchID_[zonei];
const boolList& faceFlips = faceFlip_[zonei];
scalar phiPos = scalar(0);
scalar phiNeg = scalar(0);
scalar phif = scalar(0);
scalar phiPos(0);
scalar phiNeg(0);
scalar phif(0);
forAll(faceID, i)
{

View File

@ -169,7 +169,7 @@ Foam::heatTransferCoeffModels::ReynoldsAnalogy::Cf() const
forAll(Cf, patchi)
{
Cf.set(patchi, new Field<scalar>(Ubf[patchi].size(), 0));
Cf.set(patchi, new Field<scalar>(Ubf[patchi].size(), Zero));
}
const volSymmTensorField R(devReff());
@ -203,7 +203,7 @@ Foam::heatTransferCoeffModels::ReynoldsAnalogy::ReynoldsAnalogy
:
heatTransferCoeffModel(dict, mesh, TName),
UName_("U"),
URef_(vector::zero),
URef_(Zero),
rhoName_("rho"),
rhoRef_(0.0),
CpName_("Cp"),

View File

@ -193,8 +193,8 @@ bool Foam::functionObjects::histogram::write()
x += delta;
}
scalarField dataNormalized(nBins_, 0);
labelField dataCount(nBins_, 0);
scalarField dataNormalized(nBins_, Zero);
labelField dataCount(nBins_, Zero);
const scalarField& V = mesh_.V();
forAll(field, celli)

View File

@ -255,7 +255,7 @@ bool Foam::functionObjects::pressure::read(const dictionary& dict)
dict.readEntry("calcTotal", calcTotal_);
if (calcTotal_)
{
pRef_ = dict.lookupOrDefault<scalar>("pRef", 0.0);
pRef_ = dict.lookupOrDefault<scalar>("pRef", 0);
}
dict.readEntry("calcCoeff", calcCoeff_);

View File

@ -74,7 +74,7 @@ Foam::functionObjects::reference::reference
:
fieldExpression(name, runTime, dict),
localDict_(dict),
position_(point::zero),
position_(Zero),
positionIsSet_(false),
celli_(-1),
interpolationScheme_("cell"),

View File

@ -239,7 +239,7 @@ void Foam::functionObjects::regionSizeDistribution::writeGraphs
if (Pstream::master())
{
// Calculate per-bin average
scalarField binSum(nBins_, 0.0);
scalarField binSum(nBins_, Zero);
forAll(sortedField, i)
{
binSum[indices[i]] += sortedField[i];
@ -248,7 +248,7 @@ void Foam::functionObjects::regionSizeDistribution::writeGraphs
scalarField binAvg(divide(binSum, binCount));
// Per bin deviation
scalarField binSqrSum(nBins_, 0.0);
scalarField binSqrSum(nBins_, Zero);
forAll(sortedField, i)
{
binSqrSum[indices[i]] += Foam::sqr(sortedField[i]);
@ -694,7 +694,7 @@ bool Foam::functionObjects::regionSizeDistribution::write()
)
);
vectorField centroids(sortedVols.size(), vector::zero);
vectorField centroids(sortedVols.size(), Zero);
// Check if downstream bins are calculated
if (isoPlanes_)
@ -748,7 +748,7 @@ bool Foam::functionObjects::regionSizeDistribution::write()
}
}
scalarField binDownCount(nDownstreamBins_, 0.0);
scalarField binDownCount(nDownstreamBins_, Zero);
forAll(distToPlane, i)
{
if (downstreamIndices[i] != -1)
@ -815,7 +815,7 @@ bool Foam::functionObjects::regionSizeDistribution::write()
}
// Calculate the counts per diameter bin
scalarField binCount(nBins_, 0.0);
scalarField binCount(nBins_, Zero);
forAll(sortedDiameters, i)
{
binCount[indices[i]] += 1.0;

View File

@ -115,7 +115,7 @@ Foam::functionObjects::setFlow::setFlow
mode_(modeType::FUNCTION),
reverseTime_(VGREAT),
scalePtr_(nullptr),
origin_(vector::zero),
origin_(Zero),
R_(tensor::I),
omegaPtr_(nullptr),
velocityPtr_(nullptr)

View File

@ -492,10 +492,10 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor
),
tolerance_(0.001),
error_(mesh_.nCells(), 0.0),
errorIntegral_(mesh_.nCells(), 0.0),
oldError_(mesh_.nCells(), 0.0),
oldErrorIntegral_(mesh_.nCells(), 0.0),
error_(mesh_.nCells(), Zero),
errorIntegral_(mesh_.nCells(), Zero),
oldError_(mesh_.nCells(), Zero),
oldErrorIntegral_(mesh_.nCells(), Zero),
P_(dict.lookupOrDefault<scalar>("P", 3)),
I_(dict.lookupOrDefault<scalar>("I", 0.0)),
D_(dict.lookupOrDefault<scalar>("D", 0.25))

View File

@ -847,7 +847,7 @@ bool Foam::functionObjects::forces::read(const dictionary& dict)
}
// Reference pressure, 0 by default
pRef_ = dict.lookupOrDefault<scalar>("pRef", 0.0);
pRef_ = dict.lookupOrDefault<scalar>("pRef", 0);
}
coordSys_.clear();

View File

@ -87,7 +87,7 @@ void Foam::functionObjects::energySpectrum::calcAndWriteSpectrum
}
Log << "Computing energy spectrum" << endl;
scalarField E(nMax, 0);
scalarField E(nMax, Zero);
const scalarField Ec(0.5*magSqr(Uf));
forAll(C, celli)
{

View File

@ -101,7 +101,7 @@ void Foam::functionObjects::residuals::createField(const word& fieldName)
IOobject::NO_READ,
IOobject::NO_WRITE
),
Field<scalar>(mesh_.nCells(), scalar(0))
Field<scalar>(mesh_.nCells(), Zero)
);
fieldPtr->store();

View File

@ -103,13 +103,13 @@ void Foam::functionObjects::thermoCoupleProbes::derivatives
scalarField& dydx
) const
{
scalarField G(y.size(), 0.0);
scalarField Tc(y.size(), 0.0);
scalarField Uc(y.size(), 0.0);
scalarField rhoc(y.size(), 0.0);
scalarField muc(y.size(), 0.0);
scalarField Cpc(y.size(), 0.0);
scalarField kappac(y.size(), 0.0);
scalarField G(y.size(), Zero);
scalarField Tc(y.size(), Zero);
scalarField Uc(y.size(), Zero);
scalarField rhoc(y.size(), Zero);
scalarField muc(y.size(), Zero);
scalarField Cpc(y.size(), Zero);
scalarField kappac(y.size(), Zero);
if (radiationFieldName_ != "none")
{