src/OpenFOAM: Use Zero rather than pTraits<Type>

This commit is contained in:
Henry Weller
2016-03-22 10:38:30 +00:00
parent 983b3e2ca4
commit ffe2c2ac46
28 changed files with 78 additions and 86 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -35,12 +35,12 @@ Foam::BinSum<IndexType, List, CombineOp>::BinSum
const IndexType delta
)
:
List(ceil((max-min)/delta), pTraits<typename List::value_type>::zero),
List(ceil((max-min)/delta), Zero),
min_(min),
max_(max),
delta_(delta),
lowSum_(pTraits<typename List::value_type>::zero),
highSum_(pTraits<typename List::value_type>::zero)
lowSum_(Zero),
highSum_(Zero)
{}
@ -55,12 +55,12 @@ Foam::BinSum<IndexType, List, CombineOp>::BinSum
const CombineOp& cop
)
:
List(ceil((max-min)/delta), pTraits<typename List::value_type>::zero),
List(ceil((max-min)/delta), Zero),
min_(min),
max_(max),
delta_(delta),
lowSum_(pTraits<typename List::value_type>::zero),
highSum_(pTraits<typename List::value_type>::zero)
lowSum_(Zero),
highSum_(Zero)
{
forAll(indexVals, i)
{

View File

@ -196,7 +196,7 @@ Foam::Pair<Foam::label> Foam::Distribution<Type>::validLimits
template<class Type>
Type Foam::Distribution<Type>::mean() const
{
Type meanValue(pTraits<Type>::zero);
Type meanValue(Zero);
for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++)
{
@ -225,7 +225,7 @@ Type Foam::Distribution<Type>::mean() const
template<class Type>
Type Foam::Distribution<Type>::median() const
{
Type medianValue(pTraits<Type>::zero);
Type medianValue(Zero);
List<List<Pair<scalar>>> normDistribution = normalised();

View File

@ -137,7 +137,7 @@ Foam::dimensioned<Type>::dimensioned
:
name_(name),
dimensions_(dimSet),
value_(pTraits<Type>::zero)
value_(Zero)
{
initialize(is);
}
@ -153,7 +153,7 @@ Foam::dimensioned<Type>::dimensioned
:
name_(name),
dimensions_(dimSet),
value_(pTraits<Type>::zero)
value_(Zero)
{
initialize(dict.lookup(name));
}
@ -165,7 +165,7 @@ Foam::dimensioned<Type>::dimensioned
:
name_("undefined"),
dimensions_(dimless),
value_(pTraits<Type>::zero)
value_(Zero)
{}

View File

@ -468,7 +468,7 @@ Type sum(const FieldField<Field, Type>& f)
{
if (f.size())
{
Type Sum = pTraits<Type>::zero;
Type Sum = Zero;
forAll(f, i)
{
@ -479,7 +479,7 @@ Type sum(const FieldField<Field, Type>& f)
}
else
{
return pTraits<Type>::zero;
return Zero;
}
}
@ -524,7 +524,7 @@ Type average(const FieldField<Field, Type>& f)
WarningInFunction
<< "empty fieldField, returning zero" << endl;
return pTraits<Type>::zero;
return Zero;
}
Type avrg = sum(f)/n;
@ -536,7 +536,7 @@ Type average(const FieldField<Field, Type>& f)
WarningInFunction
<< "empty fieldField, returning zero" << endl;
return pTraits<Type>::zero;
return Zero;
}
}
@ -585,7 +585,7 @@ Type gAverage(const FieldField<Field, Type>& f)
WarningInFunction
<< "empty fieldField, returning zero" << endl;
return pTraits<Type>::zero;
return Zero;
}
}

View File

@ -406,7 +406,7 @@ void Foam::Field<Type>::map
const labelList& localAddrs = mapAddressing[i];
const scalarList& localWeights = mapWeights[i];
f[i] = pTraits<Type>::zero;
f[i] = Zero;
forAll(localAddrs, j)
{
@ -533,7 +533,7 @@ void Foam::Field<Type>::rmap
{
Field<Type>& f = *this;
f = pTraits<Type>::zero;
f = Zero;
forAll(mapF, i)
{

View File

@ -346,13 +346,13 @@ Type sum(const UList<Type>& f)
{
if (f.size())
{
Type Sum = pTraits<Type>::zero;
Type Sum = Zero;
TFOR_ALL_S_OP_F(Type, Sum, +=, Type, f)
return Sum;
}
else
{
return pTraits<Type>::zero;
return Zero;
}
}
@ -379,7 +379,7 @@ Type maxMagSqr(const UList<Type>& f)
}
else
{
return pTraits<Type>::zero;
return Zero;
}
}
@ -417,13 +417,13 @@ scalar sumProd(const UList<Type>& f1, const UList<Type>& f2)
{
if (f1.size() && (f1.size() == f2.size()))
{
scalar SumProd = 0.0;
scalar SumProd = 0;
TFOR_ALL_S_OP_F_OP_F(scalar, SumProd, +=, Type, f1, &&, Type, f2)
return SumProd;
}
else
{
return 0.0;
return 0;
}
}
@ -433,7 +433,7 @@ Type sumCmptProd(const UList<Type>& f1, const UList<Type>& f2)
{
if (f1.size() && (f1.size() == f2.size()))
{
Type SumProd = pTraits<Type>::zero;
Type SumProd = Zero;
TFOR_ALL_S_OP_FUNC_F_F
(
Type,
@ -449,7 +449,7 @@ Type sumCmptProd(const UList<Type>& f1, const UList<Type>& f2)
}
else
{
return pTraits<Type>::zero;
return Zero;
}
}
@ -459,13 +459,13 @@ scalar sumSqr(const UList<Type>& f)
{
if (f.size())
{
scalar SumSqr = 0.0;
scalar SumSqr = 0;
TFOR_ALL_S_OP_FUNC_F(scalar, SumSqr, +=, sqr, Type, f)
return SumSqr;
}
else
{
return 0.0;
return 0;
}
}
@ -476,13 +476,13 @@ scalar sumMag(const UList<Type>& f)
{
if (f.size())
{
scalar SumMag = 0.0;
scalar SumMag = 0;
TFOR_ALL_S_OP_FUNC_F(scalar, SumMag, +=, mag, Type, f)
return SumMag;
}
else
{
return 0.0;
return 0;
}
}
@ -494,13 +494,13 @@ Type sumCmptMag(const UList<Type>& f)
{
if (f.size())
{
Type SumMag = pTraits<Type>::zero;
Type SumMag = Zero;
TFOR_ALL_S_OP_FUNC_F(scalar, SumMag, +=, cmptMag, Type, f)
return SumMag;
}
else
{
return pTraits<Type>::zero;
return Zero;
}
}
@ -520,7 +520,7 @@ Type average(const UList<Type>& f)
WarningInFunction
<< "empty field, returning zero" << endl;
return pTraits<Type>::zero;
return Zero;
}
}
@ -597,7 +597,7 @@ Type gAverage
WarningInFunction
<< "empty field, returning zero." << endl;
return pTraits<Type>::zero;
return Zero;
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -74,7 +74,7 @@ Foam::UniformDimensionedField<Type>::UniformDimensionedField
)
:
regIOobject(io),
dimensioned<Type>(regIOobject::name(), dimless, pTraits<Type>::zero)
dimensioned<Type>(regIOobject::name(), dimless, Zero)
{
dictionary dict(readStream(typeName));
scalar multiplier;

View File

@ -77,7 +77,7 @@ Foam::valuePointPatchField<Type>::valuePointPatchField
}
else if (!valueRequired)
{
Field<Type>::operator=(pTraits<Type>::zero);
Field<Type>::operator=(Zero);
}
else
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -40,7 +40,7 @@ Type Foam::interpolatePointToCell
labelHashSet pointHad(10*cFaces.size());
Type sum(pTraits<Type>::zero);
Type sum = Zero;
forAll(cFaces, i)
{

View File

@ -308,7 +308,7 @@ Type Foam::interpolation2DTable<Type>::operator()
WarningInFunction
<< "cannot interpolate a zero-sized table - returning zero" << endl;
return pTraits<Type>::zero;
return Zero;
}
else if (nX == 1)
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -65,7 +65,7 @@ Foam::interpolationWeights::weightedSum
}
else
{
return pTraits<returnType>::zero;
return Zero;
}
}

View File

@ -51,11 +51,7 @@ PatchToPatchInterpolation<FromPatch, ToPatch>::pointInterpolate
tmp<Field<Type>> tresult
(
new Field<Type>
(
toPatch_.nPoints(),
pTraits<Type>::zero
)
new Field<Type>(toPatch_.nPoints(), Zero)
);
Field<Type>& result = tresult();
@ -119,11 +115,7 @@ PatchToPatchInterpolation<FromPatch, ToPatch>::faceInterpolate
tmp<Field<Type>> tresult
(
new Field<Type>
(
toPatch_.size(),
pTraits<Type>::zero
)
new Field<Type>(toPatch_.size(), Zero)
);
Field<Type>& result = tresult();

View File

@ -188,7 +188,7 @@ tmp<Field<Type>> PrimitivePatchInterpolation<Patch>::faceToPointInterpolate
(
new Field<Type>
(
patch_.nPoints(), pTraits<Type>::zero
patch_.nPoints(), Zero
)
);
@ -245,7 +245,7 @@ tmp<Field<Type>> PrimitivePatchInterpolation<Patch>::pointToFaceInterpolate
new Field<Type>
(
patch_.size(),
pTraits<Type>::zero
Zero
)
);
@ -300,7 +300,7 @@ tmp<Field<Type>> PrimitivePatchInterpolation<Patch>::faceToEdgeInterpolate
tmp<Field<Type>> tresult
(
new Field<Type>(patch_.nEdges(), pTraits<Type>::zero)
new Field<Type>(patch_.nEdges(), Zero)
);
Field<Type>& result = tresult.ref();

View File

@ -129,7 +129,7 @@ Foam::LUscalarMatrix::LUscalarMatrix
nCells += lduMatrices[i].size();
}
scalarSquareMatrix m(nCells, nCells, 0.0);
scalarSquareMatrix m(nCells, 0.0);
transfer(m);
convert(lduMatrices);
}
@ -137,7 +137,7 @@ Foam::LUscalarMatrix::LUscalarMatrix
else
{
label nCells = ldum.lduAddr().size();
scalarSquareMatrix m(nCells, nCells, 0.0);
scalarSquareMatrix m(nCells, 0.0);
transfer(m);
convert(ldum, interfaceCoeffs, interfaces);
}

View File

@ -191,7 +191,7 @@ Foam::Field<DType>& Foam::LduMatrix<Type, DType, LUType>::diag()
{
if (!diagPtr_)
{
diagPtr_ = new Field<DType>(lduAddr().size(), pTraits<DType>::zero);
diagPtr_ = new Field<DType>(lduAddr().size(), Zero);
}
return *diagPtr_;
@ -212,7 +212,7 @@ Foam::Field<LUType>& Foam::LduMatrix<Type, DType, LUType>::upper()
upperPtr_ = new Field<LUType>
(
lduAddr().lowerAddr().size(),
pTraits<LUType>::zero
Zero
);
}
}
@ -235,7 +235,7 @@ Foam::Field<LUType>& Foam::LduMatrix<Type, DType, LUType>::lower()
lowerPtr_ = new Field<LUType>
(
lduAddr().lowerAddr().size(),
pTraits<LUType>::zero
Zero
);
}
}
@ -249,7 +249,7 @@ Foam::Field<Type>& Foam::LduMatrix<Type, DType, LUType>::source()
{
if (!sourcePtr_)
{
sourcePtr_ = new Field<Type>(lduAddr().size(), pTraits<Type>::zero);
sourcePtr_ = new Field<Type>(lduAddr().size(), Zero);
}
return *sourcePtr_;

View File

@ -89,7 +89,7 @@ Foam::LduMatrix<Type, DType, LUType>::H(const Field<Type>& psi) const
{
tmp<Field<Type>> tHpsi
(
new Field<Type>(lduAddr().size(), pTraits<Type>::zero)
new Field<Type>(lduAddr().size(), Zero)
);
if (lowerPtr_ || upperPtr_)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -131,7 +131,7 @@ Foam::LduMatrix<Type, DType, LUType>::solver::solver
maxIter_(1000),
minIter_(0),
tolerance_(1e-6*pTraits<Type>::one),
relTol_(pTraits<Type>::zero)
relTol_(Zero)
{
readControls();
}

View File

@ -110,8 +110,8 @@ public:
SolverPerformance()
:
initialResidual_(pTraits<Type>::zero),
finalResidual_(pTraits<Type>::zero),
initialResidual_(Zero),
finalResidual_(Zero),
noIterations_(0),
converged_(false),
singular_(false)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -67,8 +67,8 @@ Foam::DiagonalSolver<Type, DType, LUType>::solve
(
typeName,
this->fieldName_,
pTraits<Type>::zero,
pTraits<Type>::zero,
Zero,
Zero,
0,
true,
false

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -69,7 +69,7 @@ Foam::PBiCCCG<Type, DType, LUType>::solve
Field<Type> pA(nCells);
Type* __restrict__ pAPtr = pA.begin();
Field<Type> pT(nCells, pTraits<Type>::zero);
Field<Type> pT(nCells, Zero);
Type* __restrict__ pTPtr = pT.begin();
Field<Type> wA(nCells);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -66,7 +66,7 @@ Foam::PBiCICG<Type, DType, LUType>::solve(Field<Type>& psi) const
Field<Type> pA(nCells);
Type* __restrict__ pAPtr = pA.begin();
Field<Type> pT(nCells, pTraits<Type>::zero);
Field<Type> pT(nCells, Zero);
Type* __restrict__ pTPtr = pT.begin();
Field<Type> wA(nCells);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -85,7 +85,7 @@ Foam::SmoothSolver<Type, DType, LUType>::solve(Field<Type>& psi) const
}
else
{
Type normFactor = pTraits<Type>::zero;
Type normFactor = Zero;
{
Field<Type> Apsi(psi.size());

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -71,7 +71,7 @@ Type Foam::face::average
label nPoints = size();
point centrePoint = point::zero;
Type cf = pTraits<Type>::zero;
Type cf = Zero;
for (label pI=0; pI<nPoints; pI++)
{
@ -83,7 +83,7 @@ Type Foam::face::average
cf /= nPoints;
scalar sumA = 0;
Type sumAf = pTraits<Type>::zero;
Type sumAf = Zero;
for (label pI=0; pI<nPoints; pI++)
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -50,7 +50,7 @@ Foam::demandDrivenEntry<Type>::demandDrivenEntry
:
dict_(dict),
keyword_(keyword),
value_(pTraits<Type>::zero),
value_(Zero),
stored_(false)
{}

View File

@ -35,7 +35,7 @@ Foam::Function1Types::Constant<Type>::Constant
)
:
Function1<Type>(entryName),
value_(pTraits<Type>::zero)
value_(Zero)
{
Istream& is(dict.lookup(entryName));
word entryType(is);

View File

@ -69,7 +69,7 @@ Type Foam::Function1<Type>::value(const scalar x) const
{
NotImplemented;
return pTraits<Type>::zero;
return Zero;
}
@ -78,7 +78,7 @@ Type Foam::Function1<Type>::integrate(const scalar x1, const scalar x2) const
{
NotImplemented;
return pTraits<Type>::zero;
return Zero;
}

View File

@ -146,7 +146,7 @@ void Foam::Function1Types::Polynomial<Type>::convertTimeBase(const Time& t)
template<class Type>
Type Foam::Function1Types::Polynomial<Type>::value(const scalar x) const
{
Type y(pTraits<Type>::zero);
Type y(Zero);
forAll(coeffs_, i)
{
y += cmptMultiply
@ -167,7 +167,7 @@ Type Foam::Function1Types::Polynomial<Type>::integrate
const scalar x2
) const
{
Type intx(pTraits<Type>::zero);
Type intx(Zero);
if (canIntegrate_)
{

View File

@ -394,7 +394,7 @@ Foam::tmp<Foam::scalarField> Foam::Function1Types::TableBase<Type>::x() const
template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::Function1Types::TableBase<Type>::y() const
{
tmp<Field<Type>> tfld(new Field<Type>(table_.size(), pTraits<Type>::zero));
tmp<Field<Type>> tfld(new Field<Type>(table_.size(), Zero));
Field<Type>& fld = tfld.ref();
forAll(table_, i)