Commit 40291579 authored by Henry Weller's avatar Henry Weller
Browse files

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.
parent 4edb771e
......@@ -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)
);
}
......
......@@ -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)
);
}
......
......@@ -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)
);
}
......
......@@ -143,7 +143,7 @@ public:
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), pTraits<Type>::zero)
new Field<Type>(this->size(), Zero)
);
}
......
......@@ -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_))
......
......@@ -40,8 +40,8 @@ cylindricalInletVelocityFvPatchVectorField
)
:
fixedValueFvPatchField<vector>(p, iF),
centre_(pTraits<vector>::zero),
axis_(pTraits<vector>::zero),
centre_(Zero),
axis_(Zero),
axialVelocity_(),
radialVelocity_(),
rpm_()
......
......@@ -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;
}
......
......@@ -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())
{
......
......@@ -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
......
......@@ -37,7 +37,7 @@ Foam::fixedNormalSlipFvPatchField<Type>::fixedNormalSlipFvPatchField
)
:
transformFvPatchField<Type>(p, iF),
fixedValue_(p.size(), pTraits<Type>::zero)
fixedValue_(p.size(), Zero)
{}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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();
......
......@@ -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();
......
......@@ -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;
}
......
......@@ -50,7 +50,7 @@ Foam::AverageIOField<Type>::AverageIOField
:
regIOobject(io),
Field<Type>(size),
average_(pTraits<Type>::zero)
average_(Zero)
{}
......
......@@ -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)
{}
......
......@@ -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)
......
......@@ -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
......
......@@ -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
{
......
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