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
......@@ -221,7 +221,7 @@ void Foam::multiply
<< abort(FatalError);
}
ans = scalarRectangularMatrix(A.m(), C.n(), scalar(0));
ans = scalarRectangularMatrix(A.m(), C.n(), Zero);
for (label i=0; i<A.m(); i++)
{
......@@ -265,7 +265,7 @@ void Foam::multiply
<< abort(FatalError);
}
ans = scalarRectangularMatrix(A.m(), C.n(), scalar(0));
ans = scalarRectangularMatrix(A.m(), C.n(), Zero);
for (label i=0; i<A.m(); i++)
{
......
......@@ -249,7 +249,7 @@ void Foam::multiply
<< abort(FatalError);
}
ans = Matrix<Form, Type>(A.m(), B.n(), scalar(0));
ans = Matrix<Form, Type>(A.m(), B.n(), Zero);
for (label i=0; i<A.m(); i++)
{
......
......@@ -242,7 +242,7 @@ Foam::commSchedule::commSchedule
// Sort schedule_ by processor
labelList nProcScheduled(nProcs, 0);
labelList nProcScheduled(nProcs, Zero);
// Count
forAll(schedule_, i)
......
......@@ -152,7 +152,7 @@ Foam::labelList Foam::bandCompression
)
{
// Count number of neighbours
labelList numNbrs(offsets.size()-1, 0);
labelList numNbrs(offsets.size()-1, Zero);
forAll(numNbrs, celli)
{
label start = offsets[celli];
......
......@@ -132,7 +132,7 @@ Foam::labelList Foam::lduPrimitiveMesh::upperTriOrder
const labelUList& upper
)
{
labelList nNbrs(nCells, 0);
labelList nNbrs(nCells, Zero);
// Count number of upper neighbours
forAll(lower, facei)
......@@ -377,7 +377,7 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
label nOtherInterfaces = 0;
labelList nCoupledFaces(nMeshes, 0);
labelList nCoupledFaces(nMeshes, Zero);
for (label procMeshI = 0; procMeshI < nMeshes; procMeshI++)
{
......
......@@ -84,9 +84,9 @@ Foam::cellShape Foam::degenerateMatcher::match(const faceList& faces)
return match
(
faces,
labelList(faces.size(), 0), // cell 0 is owner of all faces
0, // cell 0
identity(faces.size()) // cell 0 consists of all faces
labelList(faces.size(), Zero), // cell 0 is owner of all faces
0, // cell 0
identity(faces.size()) // cell 0 consists of all faces
);
}
......
......@@ -287,10 +287,10 @@ bool Foam::hexMatcher::isA(const faceList& faces)
return matchShape
(
true,
faces, // all faces in mesh
labelList(faces.size(), 0), // cell 0 is owner of all faces
0, // cell label
identity(faces.size()) // faces of cell 0
faces, // all faces in mesh
labelList(faces.size(), Zero), // cell 0 is owner of all faces
0, // cell label
identity(faces.size()) // faces of cell 0
);
}
......
......@@ -346,10 +346,10 @@ bool Foam::prismMatcher::isA(const faceList& faces)
return matchShape
(
true,
faces, // all faces in mesh
labelList(faces.size(), 0), // cell 0 is owner of all faces
0, // cell label
identity(faces.size()) // faces of cell 0
faces, // all faces in mesh
labelList(faces.size(), Zero), // cell 0 is owner of all faces
0, // cell label
identity(faces.size()) // faces of cell 0
);
}
......
......@@ -268,10 +268,10 @@ bool Foam::pyrMatcher::isA(const faceList& faces)
return matchShape
(
true,
faces, // all faces in mesh
labelList(faces.size(), 0), // cell 0 is owner of all faces
0, // cell label
identity(faces.size()) // faces of cell 0
faces, // all faces in mesh
labelList(faces.size(), Zero), // cell 0 is owner of all faces
0, // cell label
identity(faces.size()) // faces of cell 0
);
}
......
......@@ -227,10 +227,10 @@ bool Foam::tetMatcher::isA(const faceList& faces)
return matchShape
(
true,
faces, // all faces in mesh
labelList(faces.size(), 0), // cell 0 is owner of all faces
0, // cell label
identity(faces.size()) // faces of cell 0
faces, // all faces in mesh
labelList(faces.size(), Zero), // cell 0 is owner of all faces
0, // cell label
identity(faces.size()) // faces of cell 0
);
}
......
......@@ -273,10 +273,10 @@ bool Foam::tetWedgeMatcher::isA(const faceList& faces)
return matchShape
(
true,
faces, // all faces in mesh
labelList(faces.size(), 0), // cell 0 is owner of all faces
0, // cell label
identity(faces.size()) // faces of cell 0
faces, // all faces in mesh
labelList(faces.size(), Zero), // cell 0 is owner of all faces
0, // cell label
identity(faces.size()) // faces of cell 0
);
}
......
......@@ -373,10 +373,10 @@ bool Foam::wedgeMatcher::isA(const faceList& faces)
return matchShape
(
true,
faces, // all faces in mesh
labelList(faces.size(), 0), // cell 0 is owner of all faces
0, // cell label
identity(faces.size()) // faces of cell 0
faces, // all faces in mesh
labelList(faces.size(), Zero), // cell 0 is owner of all faces
0, // cell label
identity(faces.size()) // faces of cell 0
);
}
......
......@@ -118,7 +118,7 @@ void Foam::pointMapper::calcAddressing() const
{
// Mapped from a single point
addr[pointi] = labelList(1, cm[pointi]);
w[pointi] = scalarList(1, 1.0);
w[pointi] = scalarList(1, scalar(1));
}
}
......@@ -134,8 +134,8 @@ void Foam::pointMapper::calcAddressing() const
if (addr[pointi].empty())
{
// Mapped from a dummy point. Take point 0 with weight 1.
addr[pointi] = labelList(1, label(0));
w[pointi] = scalarList(1, 1.0);
addr[pointi] = labelList(1, Zero);
w[pointi] = scalarList(1, scalar(1));
insertedPoints[nInsertedPoints] = pointi;
nInsertedPoints++;
......
......@@ -83,14 +83,14 @@ void Foam::pointPatchMapper::calcAddressing() const
if (ppm[i] >= 0)
{
addr[i] = labelList(1, ppm[i]);
w[i] = scalarList(1, 1.0);
w[i] = scalarList(1, scalar(1));
}
else
{
// Inserted point.
///// Map from point0 (arbitrary choice)
//addr[i] = labelList(1, label(0));
//w[i] = scalarList(1, 1.0);
//addr[i] = labelList(1, Zero);
//w[i] = scalarList(1, scalar(1));
hasUnmapped_ = true;
}
}
......
......@@ -1234,7 +1234,7 @@ void Foam::globalMeshData::calcPointBoundaryFaces
// 1. Count
labelList nPointFaces(coupledPatch().nPoints(), 0);
labelList nPointFaces(coupledPatch().nPoints(), Zero);
forAll(bMesh, patchi)
{
......
......@@ -262,8 +262,8 @@ void Foam::cellMapper::calcAddressing() const
if (addr[celli].empty())
{
// Mapped from a dummy cell
addr[celli] = labelList(1, label(0));
w[celli] = scalarList(1, 1.0);
addr[celli] = labelList(1, Zero);
w[celli] = scalarList(1, scalar(1));
insertedCells[nInsertedCells] = celli;
nInsertedCells++;
......
......@@ -177,8 +177,8 @@ void Foam::faceMapper::calcAddressing() const
if (addr[facei].empty())
{
// Mapped from a dummy face
addr[facei] = labelList(1, label(0));
w[facei] = scalarList(1, 1.0);
addr[facei] = labelList(1, Zero);
w[facei] = scalarList(1, scalar(1));
insertedFaces[nInsertedFaces] = facei;
nInsertedFaces++;
......
......@@ -311,7 +311,7 @@ Foam::mapDistribute::mapDistribute
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Count per transformIndex
label nTrafo = globalTransforms.transformPermutations().size();
labelList nPerTransform(nTrafo, 0);
labelList nPerTransform(nTrafo, Zero);
forAll(transformedElements, i)
{
labelPair elem = transformedElements[i];
......@@ -420,7 +420,7 @@ Foam::mapDistribute::mapDistribute
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Count per transformIndex
label nTrafo = globalTransforms.transformPermutations().size();
labelList nPerTransform(nTrafo, 0);
labelList nPerTransform(nTrafo, Zero);
forAll(transformedElements, celli)
{
const labelPairList& elems = transformedElements[celli];
......
......@@ -289,7 +289,7 @@ void Foam::mapDistributeBase::calcCompactAddressing
compactMap.setSize(Pstream::nProcs());
// Count all (non-local) elements needed. Just for presizing map.
labelList nNonLocal(Pstream::nProcs(), 0);
labelList nNonLocal(Pstream::nProcs(), Zero);
forAll(elements, i)
{
......@@ -338,7 +338,7 @@ void Foam::mapDistributeBase::calcCompactAddressing
compactMap.setSize(Pstream::nProcs());
// Count all (non-local) elements needed. Just for presizing map.
labelList nNonLocal(Pstream::nProcs(), 0);
labelList nNonLocal(Pstream::nProcs(), Zero);
forAll(cellCells, cellI)
{
......@@ -616,8 +616,8 @@ Foam::mapDistributeBase::mapDistributeBase
}
// Per processor the number of samples we have to send/receive.
labelList nSend(Pstream::nProcs(), 0);
labelList nRecv(Pstream::nProcs(), 0);
labelList nSend(Pstream::nProcs(), Zero);
labelList nRecv(Pstream::nProcs(), Zero);
forAll(sendProcs, sampleI)
{
......
......@@ -55,7 +55,7 @@ Foam::label Foam::polyMeshTetDecomposition::findSharedBasePoint
const point& oCc = pC[oCI];
List<scalar> tetQualities(2, 0.0);
List<scalar> tetQualities(2, Zero);
forAll(f, faceBasePtI)
{
......
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