fvPatchFields: Use 'Zero' rather than 'pTraits<Type>::zero' to initialize to 0

This new approach to 0 initialization is simpler, cleaner, more readable
and more efficient.  The rest of the OpenFOAM code will be updated in
due course.
This commit is contained in:
Henry Weller
2016-03-22 08:27:59 +00:00
parent 6f70b18bd2
commit beb00e22d6
20 changed files with 49 additions and 49 deletions

View File

@ -36,7 +36,7 @@ Foam::fixedGradientFvPatchField<Type>::fixedGradientFvPatchField
)
:
fvPatchField<Type>(p, iF),
gradient_(p.size(), pTraits<Type>::zero)
gradient_(p.size(), Zero)
{}
@ -176,7 +176,7 @@ Foam::fixedGradientFvPatchField<Type>::gradientInternalCoeffs() const
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), pTraits<Type>::zero)
new Field<Type>(this->size(), Zero)
);
}

View File

@ -117,7 +117,7 @@ Foam::fixedValueFvPatchField<Type>::valueInternalCoeffs
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), pTraits<Type>::zero)
new Field<Type>(this->size(), Zero)
);
}

View File

@ -125,7 +125,7 @@ Foam::zeroGradientFvPatchField<Type>::valueBoundaryCoeffs
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), pTraits<Type>::zero)
new Field<Type>(this->size(), Zero)
);
}
@ -136,7 +136,7 @@ Foam::zeroGradientFvPatchField<Type>::gradientInternalCoeffs() const
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), pTraits<Type>::zero)
new Field<Type>(this->size(), Zero)
);
}
@ -147,7 +147,7 @@ Foam::zeroGradientFvPatchField<Type>::gradientBoundaryCoeffs() const
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), pTraits<Type>::zero)
new Field<Type>(this->size(), Zero)
);
}

View File

@ -143,7 +143,7 @@ public:
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), pTraits<Type>::zero)
new Field<Type>(this->size(), Zero)
);
}

View File

@ -45,11 +45,11 @@ Foam::advectiveFvPatchField<Type>::advectiveFvPatchField
mixedFvPatchField<Type>(p, iF),
phiName_("phi"),
rhoName_("rho"),
fieldInf_(pTraits<Type>::zero),
fieldInf_(Zero),
lInf_(-GREAT)
{
this->refValue() = pTraits<Type>::zero;
this->refGrad() = pTraits<Type>::zero;
this->refValue() = Zero;
this->refGrad() = Zero;
this->valueFraction() = 0.0;
}
@ -82,7 +82,7 @@ Foam::advectiveFvPatchField<Type>::advectiveFvPatchField
mixedFvPatchField<Type>(p, iF),
phiName_(dict.lookupOrDefault<word>("phi", "phi")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
fieldInf_(pTraits<Type>::zero),
fieldInf_(Zero),
lInf_(-GREAT)
{
if (dict.found("value"))
@ -98,7 +98,7 @@ Foam::advectiveFvPatchField<Type>::advectiveFvPatchField
}
this->refValue() = *this;
this->refGrad() = pTraits<Type>::zero;
this->refGrad() = Zero;
this->valueFraction() = 0.0;
if (dict.readIfPresent("lInf", lInf_))

View File

@ -40,8 +40,8 @@ cylindricalInletVelocityFvPatchVectorField
)
:
fixedValueFvPatchField<vector>(p, iF),
centre_(pTraits<vector>::zero),
axis_(pTraits<vector>::zero),
centre_(Zero),
axis_(Zero),
axialVelocity_(),
radialVelocity_(),
rpm_()

View File

@ -455,8 +455,8 @@ externalCoupledMixedFvPatchField
initialised_(false),
coupledPatchIDs_()
{
this->refValue() = pTraits<Type>::zero;
this->refGrad() = pTraits<Type>::zero;
this->refValue() = Zero;
this->refGrad() = Zero;
this->valueFraction() = 0.0;
}
@ -534,7 +534,7 @@ externalCoupledMixedFvPatchField
// initialise as a fixed value
this->refValue() = *this;
this->refGrad() = pTraits<Type>::zero;
this->refGrad() = Zero;
this->valueFraction() = 1.0;
}

View File

@ -35,7 +35,7 @@ Foam::fixedJumpFvPatchField<Type>::fixedJumpFvPatchField
)
:
jumpCyclicFvPatchField<Type>(p, iF),
jump_(this->size(), pTraits<Type>::zero)
jump_(this->size(), Zero)
{}
@ -62,7 +62,7 @@ Foam::fixedJumpFvPatchField<Type>::fixedJumpFvPatchField
)
:
jumpCyclicFvPatchField<Type>(p, iF),
jump_(p.size(), pTraits<Type>::zero)
jump_(p.size(), Zero)
{
if (this->cyclicPatch().owner())
{

View File

@ -35,7 +35,7 @@ Foam::fixedJumpAMIFvPatchField<Type>::fixedJumpAMIFvPatchField
)
:
jumpCyclicAMIFvPatchField<Type>(p, iF),
jump_(this->size(), pTraits<Type>::zero)
jump_(this->size(), Zero)
{}
@ -62,7 +62,7 @@ Foam::fixedJumpAMIFvPatchField<Type>::fixedJumpAMIFvPatchField
)
:
jumpCyclicAMIFvPatchField<Type>(p, iF),
jump_(p.size(), pTraits<Type>::zero)
jump_(p.size(), Zero)
{
if (this->cyclicAMIPatch().owner())
{
@ -128,7 +128,7 @@ Foam::tmp<Foam::Field<Type>> Foam::fixedJumpAMIFvPatchField<Type>::jump() const
return this->cyclicAMIPatch().interpolate
(
nbrPatch.jump(),
Field<Type>(this->size(), pTraits<Type>::zero)
Field<Type>(this->size(), Zero)
);
}
else

View File

@ -37,7 +37,7 @@ Foam::fixedNormalSlipFvPatchField<Type>::fixedNormalSlipFvPatchField
)
:
transformFvPatchField<Type>(p, iF),
fixedValue_(p.size(), pTraits<Type>::zero)
fixedValue_(p.size(), Zero)
{}

View File

@ -37,8 +37,8 @@ Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
mixedFvPatchField<Type>(p, iF),
phiName_("phi")
{
this->refValue() = pTraits<Type>::zero;
this->refGrad() = pTraits<Type>::zero;
this->refValue() = Zero;
this->refGrad() = Zero;
this->valueFraction() = 0.0;
}
@ -82,7 +82,7 @@ Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
fvPatchField<Type>::operator=(this->refValue());
}
this->refGrad() = pTraits<Type>::zero;
this->refGrad() = Zero;
this->valueFraction() = 0.0;
}

View File

@ -44,8 +44,8 @@ inletOutletTotalTemperatureFvPatchScalarField
gamma_(0.0),
T0_(p.size(), 0.0)
{
this->refValue() = pTraits<scalar>::zero;
this->refGrad() = pTraits<scalar>::zero;
this->refValue() = Zero;
this->refGrad() = Zero;
this->valueFraction() = 0.0;
}
@ -83,7 +83,7 @@ inletOutletTotalTemperatureFvPatchScalarField
{
this->phiName_ = dict.lookupOrDefault<word>("phi", "phi");
this->refValue() = pTraits<scalar>::zero;
this->refValue() = Zero;
if (dict.found("value"))
{
fvPatchField<scalar>::operator=
@ -96,7 +96,7 @@ inletOutletTotalTemperatureFvPatchScalarField
fvPatchField<scalar>::operator=(T0_);
}
this->refGrad() = pTraits<scalar>::zero;
this->refGrad() = Zero;
this->valueFraction() = 0.0;
}

View File

@ -94,7 +94,7 @@ mappedPatchFieldBase<Type>::mappedPatchFieldBase
patchField_(patchField),
fieldName_(patchField_.dimensionedInternalField().name()),
setAverage_(false),
average_(pTraits<Type>::zero),
average_(Zero),
interpolationScheme_(interpolationCell<Type>::typeName)
{}
@ -259,7 +259,7 @@ tmp<Field<Type>> mappedPatchFieldBase<Type>::mappedField() const
}
case mappedPatchBase::NEARESTFACE:
{
Field<Type> allValues(nbrMesh.nFaces(), pTraits<Type>::zero);
Field<Type> allValues(nbrMesh.nFaces(), Zero);
const fieldType& nbrField = sampleField();

View File

@ -145,7 +145,7 @@ void Foam::mappedFixedInternalValueFvPatchField<Type>::updateCoeffs()
}
case mappedPatchBase::NEARESTFACE:
{
Field<Type> allValues(nbrMesh.nFaces(), pTraits<Type>::zero);
Field<Type> allValues(nbrMesh.nFaces(), Zero);
const FieldType& nbrField = this->sampleField();

View File

@ -38,7 +38,7 @@ Foam::outletInletFvPatchField<Type>::outletInletFvPatchField
phiName_("phi")
{
this->refValue() = *this;
this->refGrad() = pTraits<Type>::zero;
this->refGrad() = Zero;
this->valueFraction() = 0.0;
}
@ -82,7 +82,7 @@ Foam::outletInletFvPatchField<Type>::outletInletFvPatchField
fvPatchField<Type>::operator=(this->refValue());
}
this->refGrad() = pTraits<Type>::zero;
this->refGrad() = Zero;
this->valueFraction() = 0.0;
}

View File

@ -50,7 +50,7 @@ Foam::AverageIOField<Type>::AverageIOField
:
regIOobject(io),
Field<Type>(size),
average_(pTraits<Type>::zero)
average_(Zero)
{}

View File

@ -45,10 +45,10 @@ timeVaryingMappedFixedValueFvPatchField
sampleTimes_(0),
startSampleTime_(-1),
startSampledValues_(0),
startAverage_(pTraits<Type>::zero),
startAverage_(Zero),
endSampleTime_(-1),
endSampledValues_(0),
endAverage_(pTraits<Type>::zero),
endAverage_(Zero),
offset_()
{}
@ -78,10 +78,10 @@ timeVaryingMappedFixedValueFvPatchField
sampleTimes_(0),
startSampleTime_(-1),
startSampledValues_(0),
startAverage_(pTraits<Type>::zero),
startAverage_(Zero),
endSampleTime_(-1),
endSampledValues_(0),
endAverage_(pTraits<Type>::zero),
endAverage_(Zero),
offset_(Function1<Type>::New("offset", dict))
{
if
@ -134,10 +134,10 @@ timeVaryingMappedFixedValueFvPatchField
sampleTimes_(0),
startSampleTime_(-1),
startSampledValues_(0),
startAverage_(pTraits<Type>::zero),
startAverage_(Zero),
endSampleTime_(-1),
endSampledValues_(0),
endAverage_(pTraits<Type>::zero),
endAverage_(Zero),
offset_(ptf.offset_, false)
{}

View File

@ -36,7 +36,7 @@ Foam::turbulentInletFvPatchField<Type>::turbulentInletFvPatchField
:
fixedValueFvPatchField<Type>(p, iF),
ranGen_(label(0)),
fluctuationScale_(pTraits<Type>::zero),
fluctuationScale_(Zero),
referenceField_(p.size()),
alpha_(0.1),
curTimeIndex_(-1)

View File

@ -37,8 +37,8 @@ Foam::uniformInletOutletFvPatchField<Type>::uniformInletOutletFvPatchField
mixedFvPatchField<Type>(p, iF),
phiName_("phi")
{
this->refValue() = pTraits<Type>::zero;
this->refGrad() = pTraits<Type>::zero;
this->refValue() = Zero;
this->refGrad() = Zero;
this->valueFraction() = 0.0;
}
@ -70,7 +70,7 @@ Foam::uniformInletOutletFvPatchField<Type>::uniformInletOutletFvPatchField
fvPatchField<Type>::operator=(this->refValue());
}
this->refGrad() = pTraits<Type>::zero;
this->refGrad() = Zero;
this->valueFraction() = 0.0;
}
@ -94,7 +94,7 @@ Foam::uniformInletOutletFvPatchField<Type>::uniformInletOutletFvPatchField
this->refValue() =
uniformInletValue_->value(this->db().time().timeOutputValue());
this->refGrad() = pTraits<Type>::zero;
this->refGrad() = Zero;
this->valueFraction() = 0.0;
// Initialize the patch value to the refValue

View File

@ -116,14 +116,14 @@ Foam::fvPatchField<Type>::fvPatchField
{
if (dict.found("value"))
{
fvPatchField<Type>::operator=
Field<Type>::operator=
(
Field<Type>("value", dict, p.size())
);
}
else if (!valueRequired)
{
fvPatchField<Type>::operator=(pTraits<Type>::zero);
Field<Type>::operator=(Zero);
}
else
{