Commit e23bd3bb authored by Mark Olesen's avatar Mark Olesen
Browse files

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)
parent 2ad36438
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
); );
} }
scalarList Y0(nSpecie, 0.0); scalarList Y0(nSpecie, Zero);
scalarList X0(nSpecie, 0.0); scalarList X0(nSpecie, Zero);
dictionary fractions(initialConditions.subDict("fractions")); dictionary fractions(initialConditions.subDict("fractions"));
if (fractionBasis == "mole") if (fractionBasis == "mole")
......
...@@ -44,7 +44,7 @@ Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField ...@@ -44,7 +44,7 @@ Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
psiName_("thermo:psi"), psiName_("thermo:psi"),
muName_("thermo:mu"), muName_("thermo:mu"),
accommodationCoeff_(1.0), accommodationCoeff_(1.0),
Twall_(p.size(), 0.0), Twall_(p.size(), Zero),
gamma_(1.4) gamma_(1.4)
{ {
refValue() = 0.0; refValue() = 0.0;
......
...@@ -45,7 +45,7 @@ Foam::maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatchVectorField ...@@ -45,7 +45,7 @@ Foam::maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatchVectorField
muName_("thermo:mu"), muName_("thermo:mu"),
tauMCName_("tauMC"), tauMCName_("tauMC"),
accommodationCoeff_(1.0), accommodationCoeff_(1.0),
Uwall_(p.size(), vector(0.0, 0.0, 0.0)), Uwall_(p.size(), Zero),
thermalCreep_(true), thermalCreep_(true),
curvature_(true) curvature_(true)
{} {}
......
...@@ -12,7 +12,7 @@ PtrList<radiation::radiationModel> radiation(fluidRegions.size()); ...@@ -12,7 +12,7 @@ PtrList<radiation::radiationModel> radiation(fluidRegions.size());
List<scalar> initialMassFluid(fluidRegions.size()); List<scalar> initialMassFluid(fluidRegions.size());
List<label> pRefCellFluid(fluidRegions.size(), -1); List<label> pRefCellFluid(fluidRegions.size(), -1);
List<scalar> pRefValueFluid(fluidRegions.size(), 0.0); List<scalar> pRefValueFluid(fluidRegions.size(), Zero);
List<bool> frozenFlowFluid(fluidRegions.size(), false); List<bool> frozenFlowFluid(fluidRegions.size(), false);
PtrList<dimensionedScalar> rhoMax(fluidRegions.size()); PtrList<dimensionedScalar> rhoMax(fluidRegions.size());
......
...@@ -248,7 +248,7 @@ forAll(fluidRegions, i) ...@@ -248,7 +248,7 @@ forAll(fluidRegions, i)
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
), ),
fluidRegions[i], fluidRegions[i],
dimensionedScalar("Qdot", dimEnergy/dimVolume/dimTime, 0.0) dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero)
) )
); );
......
List<scalar> cumulativeContErr(fluidRegions.size(), 0.0); List<scalar> cumulativeContErr(fluidRegions.size(), Zero);
...@@ -11,7 +11,7 @@ labelListList donorCell(mesh.nInternalFaces()); ...@@ -11,7 +11,7 @@ labelListList donorCell(mesh.nInternalFaces());
scalarListList weightCellCells(mesh.nInternalFaces()); scalarListList weightCellCells(mesh.nInternalFaces());
// Interpolated HbyA faces // Interpolated HbyA faces
vectorField UIntFaces(mesh.nInternalFaces(), vector::zero); vectorField UIntFaces(mesh.nInternalFaces(), Zero);
// Determine receptor neighbour cells // Determine receptor neighbour cells
labelList receptorNeigCell(mesh.nInternalFaces(), -1); labelList receptorNeigCell(mesh.nInternalFaces(), -1);
...@@ -23,7 +23,7 @@ labelList receptorNeigCell(mesh.nInternalFaces(), -1); ...@@ -23,7 +23,7 @@ labelList receptorNeigCell(mesh.nInternalFaces(), -1);
label nZones = gMax(zoneID)+1; label nZones = gMax(zoneID)+1;
PtrList<fvMeshSubset> meshParts(nZones); PtrList<fvMeshSubset> meshParts(nZones);
labelList nCellsPerZone(nZones, 0); labelList nCellsPerZone(nZones, Zero);
// A mesh subset for each zone // A mesh subset for each zone
forAll(meshParts, zonei) forAll(meshParts, zonei)
...@@ -173,7 +173,7 @@ labelList receptorNeigCell(mesh.nInternalFaces(), -1); ...@@ -173,7 +173,7 @@ labelList receptorNeigCell(mesh.nInternalFaces(), -1);
} }
// contravariant U // contravariant U
vectorField U1Contrav(mesh.nInternalFaces(), vector::zero); vectorField U1Contrav(mesh.nInternalFaces(), Zero);
surfaceVectorField faceNormals(mesh.Sf()/mesh.magSf()); surfaceVectorField faceNormals(mesh.Sf()/mesh.magSf());
...@@ -192,7 +192,8 @@ forAll(isNeiInterpolatedFace, faceI) ...@@ -192,7 +192,8 @@ forAll(isNeiInterpolatedFace, faceI)
if (cellId != -1) if (cellId != -1)
{ {
const vector& n = faceNormals[faceI]; const vector& n = faceNormals[faceI];
vector n1 = vector::zero; vector n1(Zero);
// 2-D cases // 2-D cases
if (mesh.nSolutionD() == 2) if (mesh.nSolutionD() == 2)
{ {
......
...@@ -266,7 +266,7 @@ void VoFPatchTransfer::correct ...@@ -266,7 +266,7 @@ void VoFPatchTransfer::correct
getModelProperty<scalarField> getModelProperty<scalarField>
( (
"patchTransferredMasses", "patchTransferredMasses",
scalarField(patchTransferredMasses_.size(), 0) scalarField(patchTransferredMasses_.size(), Zero)
) )
); );
...@@ -302,7 +302,7 @@ void VoFPatchTransfer::patchTransferredMassTotals ...@@ -302,7 +302,7 @@ void VoFPatchTransfer::patchTransferredMassTotals
getModelProperty<scalarField> getModelProperty<scalarField>
( (
"patchTransferredMasses", "patchTransferredMasses",
scalarField(patchTransferredMasses_.size(), 0) scalarField(patchTransferredMasses_.size(), Zero)
) )
); );
......
...@@ -48,8 +48,8 @@ Foam::DTRMParticle::DTRMParticle ...@@ -48,8 +48,8 @@ Foam::DTRMParticle::DTRMParticle
) )
: :
particle(mesh, is, readFields, newFormat), particle(mesh, is, readFields, newFormat),
p0_(point::zero), p0_(Zero),
p1_(point::zero), p1_(Zero),
I0_(0), I0_(0),
I_(0), I_(0),
dA_(0), dA_(0),
......
...@@ -67,7 +67,7 @@ Foam::vector Foam::radiation::noReflection::R ...@@ -67,7 +67,7 @@ Foam::vector Foam::radiation::noReflection::R
const vector& n const vector& n
) const ) const
{ {
return (vector::zero); return vector::zero;
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
kappaEff = thermo->kappa() + rho*cp*turbulence->nut()/Prt; kappaEff = thermo->kappa() + rho*cp*turbulence->nut()/Prt;
pDivU = dimensionedScalar("pDivU", p.dimensions()/dimTime, 0.0); pDivU = dimensionedScalar("pDivU", p.dimensions()/dimTime, Zero);
if (thermo->pDivU()) if (thermo->pDivU())
{ {
......
...@@ -44,7 +44,7 @@ fixedMultiPhaseHeatFluxFvPatchScalarField ...@@ -44,7 +44,7 @@ fixedMultiPhaseHeatFluxFvPatchScalarField
) )
: :
fixedValueFvPatchScalarField(p, iF), fixedValueFvPatchScalarField(p, iF),
q_(p.size(), 0.0), q_(p.size(), Zero),
relax_(1.0) relax_(1.0)
{} {}
...@@ -131,9 +131,9 @@ void Foam::fixedMultiPhaseHeatFluxFvPatchScalarField::updateCoeffs() ...@@ -131,9 +131,9 @@ void Foam::fixedMultiPhaseHeatFluxFvPatchScalarField::updateCoeffs()
const scalarField& Tp = *this; const scalarField& Tp = *this;
scalarField A(Tp.size(), scalar(0)); scalarField A(Tp.size(), Zero);
scalarField B(Tp.size(), scalar(0)); scalarField B(Tp.size(), Zero);
scalarField Q(Tp.size(), scalar(0)); scalarField Q(Tp.size(), Zero);
forAll(fluid.phases(), phasei) forAll(fluid.phases(), phasei)
{ {
......
...@@ -43,7 +43,7 @@ tractionDisplacementFvPatchVectorField ...@@ -43,7 +43,7 @@ tractionDisplacementFvPatchVectorField
: :
fixedGradientFvPatchVectorField(p, iF), fixedGradientFvPatchVectorField(p, iF),
traction_(p.size(), Zero), traction_(p.size(), Zero),
pressure_(p.size(), 0.0) pressure_(p.size(), Zero)
{ {
fvPatchVectorField::operator=(patchInternalField()); fvPatchVectorField::operator=(patchInternalField());
gradient() = Zero; gradient() = Zero;
......
...@@ -43,7 +43,7 @@ tractionDisplacementCorrectionFvPatchVectorField ...@@ -43,7 +43,7 @@ tractionDisplacementCorrectionFvPatchVectorField
: :
fixedGradientFvPatchVectorField(p, iF), fixedGradientFvPatchVectorField(p, iF),
traction_(p.size(), Zero), traction_(p.size(), Zero),
pressure_(p.size(), 0.0) pressure_(p.size(), Zero)
{ {
fvPatchVectorField::operator=(patchInternalField()); fvPatchVectorField::operator=(patchInternalField());
gradient() = Zero; gradient() = Zero;
......
...@@ -47,7 +47,7 @@ int main(int argc, char *argv[]) ...@@ -47,7 +47,7 @@ int main(int argc, char *argv[])
Info<< "cll1:" << cll1 << endl; Info<< "cll1:" << cll1 << endl;
// Resize and assign row by row // Resize and assign row by row
labelList row0(2, label(0)); labelList row0(2, Zero);
labelList row1(3, label(1)); labelList row1(3, label(1));
labelList rowSizes(2); labelList rowSizes(2);
......
...@@ -94,7 +94,7 @@ int main(int argc, char *argv[]) ...@@ -94,7 +94,7 @@ int main(int argc, char *argv[])
false false
), ),
mesh, mesh,
dimensionedVector(vector::zero) dimensionedVector(Zero)
); );
fld.boundaryFieldRef()[0] == function1().value(x0); fld.boundaryFieldRef()[0] == function1().value(x0);
......
...@@ -61,7 +61,7 @@ void testMapDistribute() ...@@ -61,7 +61,7 @@ void testMapDistribute()
// Send all ones to processor indicated by .first() // Send all ones to processor indicated by .first()
// Count how many to send // Count how many to send
labelList nSend(Pstream::nProcs(), 0); labelList nSend(Pstream::nProcs(), Zero);
forAll(complexData, i) forAll(complexData, i)
{ {
label procI = complexData[i].first(); label procI = complexData[i].first();
......
...@@ -404,7 +404,7 @@ void testPointSync(const polyMesh& mesh, Random& rndGen) ...@@ -404,7 +404,7 @@ void testPointSync(const polyMesh& mesh, Random& rndGen)
// Test masterPoints // Test masterPoints
{ {
labelList nMasters(mesh.nPoints(), 0); labelList nMasters(mesh.nPoints(), Zero);
bitSet isMasterPoint(syncTools::getMasterPoints(mesh)); bitSet isMasterPoint(syncTools::getMasterPoints(mesh));
...@@ -480,7 +480,7 @@ void testEdgeSync(const polyMesh& mesh, Random& rndGen) ...@@ -480,7 +480,7 @@ void testEdgeSync(const polyMesh& mesh, Random& rndGen)
// Test masterEdges // Test masterEdges
{ {
labelList nMasters(edges.size(), 0); labelList nMasters(edges.size(), Zero);
bitSet isMasterEdge(syncTools::getMasterEdges(mesh)); bitSet isMasterEdge(syncTools::getMasterEdges(mesh));
...@@ -549,7 +549,7 @@ void testFaceSync(const polyMesh& mesh, Random& rndGen) ...@@ -549,7 +549,7 @@ void testFaceSync(const polyMesh& mesh, Random& rndGen)
// Test masterFaces // Test masterFaces
{ {
labelList nMasters(mesh.nFaces(), 0); labelList nMasters(mesh.nFaces(), Zero);
bitSet isMasterFace(syncTools::getMasterFaces(mesh)); bitSet isMasterFace(syncTools::getMasterFaces(mesh));
......
...@@ -606,7 +606,7 @@ int main(int argc, char *argv[]) ...@@ -606,7 +606,7 @@ int main(int argc, char *argv[])
List<pointEdgeCollapse> allPointInfo; List<pointEdgeCollapse> allPointInfo;
const globalIndex globalPoints(mesh.nPoints()); const globalIndex globalPoints(mesh.nPoints());
labelList pointPriority(mesh.nPoints(), 0); labelList pointPriority(mesh.nPoints(), Zero);
cutter.consistentCollapse cutter.consistentCollapse
( (
......
...@@ -263,7 +263,7 @@ int main(int argc, char *argv[]) ...@@ -263,7 +263,7 @@ int main(int argc, char *argv[])
IOobject::NO_READ, IOobject::NO_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
), ),
labelList(mesh.nCells(), 0) labelList(mesh.nCells(), Zero)
); );
if (readLevel) if (readLevel)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment