Commit 6a0df8a4 authored by Henry Weller's avatar Henry Weller
Browse files

fvPatchFields: Rationalized the construction of DataEntry values

parent 0a7ce682
......@@ -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-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -60,9 +60,9 @@ cylindricalInletVelocityFvPatchVectorField
fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
centre_(ptf.centre_),
axis_(ptf.axis_),
axialVelocity_(ptf.axialVelocity_().clone().ptr()),
radialVelocity_(ptf.radialVelocity_().clone().ptr()),
rpm_(ptf.rpm_().clone().ptr())
axialVelocity_(ptf.axialVelocity_, false),
radialVelocity_(ptf.radialVelocity_, false),
rpm_(ptf.rpm_, false)
{}
......@@ -92,9 +92,9 @@ cylindricalInletVelocityFvPatchVectorField
fixedValueFvPatchField<vector>(ptf),
centre_(ptf.centre_),
axis_(ptf.axis_),
axialVelocity_(ptf.axialVelocity_().clone().ptr()),
radialVelocity_(ptf.radialVelocity_().clone().ptr()),
rpm_(ptf.rpm_().clone().ptr())
axialVelocity_(ptf.axialVelocity_, false),
radialVelocity_(ptf.radialVelocity_, false),
rpm_(ptf.rpm_, false)
{}
......@@ -108,9 +108,9 @@ cylindricalInletVelocityFvPatchVectorField
fixedValueFvPatchField<vector>(ptf, iF),
centre_(ptf.centre_),
axis_(ptf.axis_),
axialVelocity_(ptf.axialVelocity_().clone().ptr()),
radialVelocity_(ptf.radialVelocity_().clone().ptr()),
rpm_(ptf.rpm_().clone().ptr())
axialVelocity_(ptf.axialVelocity_, false),
radialVelocity_(ptf.radialVelocity_, false),
rpm_(ptf.rpm_, false)
{}
......
......@@ -44,57 +44,57 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
(
const fixedFluxPressureFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
const dictionary& dict
)
:
fixedGradientFvPatchScalarField(p, iF),
curTimeIndex_(-1)
{
patchType() = ptf.patchType();
// Map gradient. Set unmapped values and overwrite with mapped ptf
gradient() = 0.0;
gradient().map(ptf.gradient(), mapper);
// Evaluate the value field from the gradient if the internal field is valid
if (notNull(iF) && iF.size())
if (dict.found("value") && dict.found("gradient"))
{
scalarField::operator=
fvPatchField<scalar>::operator=
(
//patchInternalField() + gradient()/patch().deltaCoeffs()
// ***HGW Hack to avoid the construction of mesh.deltaCoeffs
// which fails for AMI patches for some mapping operations
patchInternalField() + gradient()*(patch().nf() & patch().delta())
scalarField("value", dict, p.size())
);
gradient() = scalarField("gradient", dict, p.size());
}
else
{
fvPatchField<scalar>::operator=(patchInternalField());
gradient() = 0.0;
}
}
Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
(
const fixedFluxPressureFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
const fvPatchFieldMapper& mapper
)
:
fixedGradientFvPatchScalarField(p, iF),
curTimeIndex_(-1)
{
if (dict.found("value") && dict.found("gradient"))
patchType() = ptf.patchType();
// Map gradient. Set unmapped values and overwrite with mapped ptf
gradient() = 0.0;
gradient().map(ptf.gradient(), mapper);
// Evaluate the value field from the gradient if the internal field is valid
if (notNull(iF) && iF.size())
{
fvPatchField<scalar>::operator=
scalarField::operator=
(
scalarField("value", dict, p.size())
//patchInternalField() + gradient()/patch().deltaCoeffs()
// ***HGW Hack to avoid the construction of mesh.deltaCoeffs
// which fails for AMI patches for some mapping operations
patchInternalField() + gradient()*(patch().nf() & patch().delta())
);
gradient() = scalarField("gradient", dict, p.size());
}
else
{
fvPatchField<scalar>::operator=(patchInternalField());
gradient() = 0.0;
}
}
......
......@@ -56,7 +56,7 @@ flowRateInletVelocityFvPatchVectorField
)
:
fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
flowRate_(ptf.flowRate_().clone().ptr()),
flowRate_(ptf.flowRate_, false),
volumetric_(ptf.volumetric_),
rhoName_(ptf.rhoName_),
rhoInlet_(ptf.rhoInlet_)
......@@ -117,7 +117,7 @@ flowRateInletVelocityFvPatchVectorField
)
:
fixedValueFvPatchField<vector>(ptf),
flowRate_(ptf.flowRate_().clone().ptr()),
flowRate_(ptf.flowRate_, false),
volumetric_(ptf.volumetric_),
rhoName_(ptf.rhoName_),
rhoInlet_(ptf.rhoInlet_)
......@@ -132,7 +132,7 @@ flowRateInletVelocityFvPatchVectorField
)
:
fixedValueFvPatchField<vector>(ptf, iF),
flowRate_(ptf.flowRate_().clone().ptr()),
flowRate_(ptf.flowRate_, false),
volumetric_(ptf.volumetric_),
rhoName_(ptf.rhoName_),
rhoInlet_(ptf.rhoInlet_)
......
......@@ -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-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -74,8 +74,8 @@ oscillatingFixedValueFvPatchField<Type>::oscillatingFixedValueFvPatchField
fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
refValue_(ptf.refValue_, mapper),
offset_(ptf.offset_),
amplitude_(ptf.amplitude_().clone().ptr()),
frequency_(ptf.frequency_().clone().ptr()),
amplitude_(ptf.amplitude_, false),
frequency_(ptf.frequency_, false),
curTimeIndex_(-1)
{}
......@@ -122,8 +122,8 @@ oscillatingFixedValueFvPatchField<Type>::oscillatingFixedValueFvPatchField
fixedValueFvPatchField<Type>(ptf),
refValue_(ptf.refValue_),
offset_(ptf.offset_),
amplitude_(ptf.amplitude_().clone().ptr()),
frequency_(ptf.frequency_().clone().ptr()),
amplitude_(ptf.amplitude_, false),
frequency_(ptf.frequency_, false),
curTimeIndex_(-1)
{}
......@@ -138,8 +138,8 @@ oscillatingFixedValueFvPatchField<Type>::oscillatingFixedValueFvPatchField
fixedValueFvPatchField<Type>(ptf, iF),
refValue_(ptf.refValue_),
offset_(ptf.offset_),
amplitude_(ptf.amplitude_().clone().ptr()),
frequency_(ptf.frequency_().clone().ptr()),
amplitude_(ptf.amplitude_, false),
frequency_(ptf.frequency_, false),
curTimeIndex_(-1)
{}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -71,7 +71,7 @@ rotatingPressureInletOutletVelocityFvPatchVectorField
)
:
pressureInletOutletVelocityFvPatchVectorField(ptf, p, iF, mapper),
omega_(ptf.omega_().clone().ptr())
omega_(ptf.omega_, false)
{
calcTangentialVelocity();
}
......@@ -99,7 +99,7 @@ rotatingPressureInletOutletVelocityFvPatchVectorField
)
:
pressureInletOutletVelocityFvPatchVectorField(rppvf),
omega_(rppvf.omega_().clone().ptr())
omega_(rppvf.omega_, false)
{
calcTangentialVelocity();
}
......@@ -113,7 +113,7 @@ rotatingPressureInletOutletVelocityFvPatchVectorField
)
:
pressureInletOutletVelocityFvPatchVectorField(rppvf, iF),
omega_(rppvf.omega_().clone().ptr())
omega_(rppvf.omega_, false)
{
calcTangentialVelocity();
}
......
......@@ -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-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -53,7 +53,7 @@ rotatingTotalPressureFvPatchScalarField
)
:
totalPressureFvPatchScalarField(ptf, p, iF, mapper),
omega_(ptf.omega_().clone().ptr())
omega_(ptf.omega_, false)
{}
......@@ -77,7 +77,7 @@ rotatingTotalPressureFvPatchScalarField
)
:
totalPressureFvPatchScalarField(rtppsf),
omega_(rtppsf.omega_().clone().ptr())
omega_(rtppsf.omega_, false)
{}
......@@ -89,7 +89,7 @@ rotatingTotalPressureFvPatchScalarField
)
:
totalPressureFvPatchScalarField(rtppsf, iF),
omega_(rtppsf.omega_().clone().ptr())
omega_(rtppsf.omega_, false)
{}
......
......@@ -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-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -56,7 +56,7 @@ rotatingWallVelocityFvPatchVectorField
fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
origin_(ptf.origin_),
axis_(ptf.axis_),
omega_(ptf.omega_().clone().ptr())
omega_(ptf.omega_, false)
{}
......@@ -97,7 +97,7 @@ rotatingWallVelocityFvPatchVectorField
fixedValueFvPatchField<vector>(rwvpvf),
origin_(rwvpvf.origin_),
axis_(rwvpvf.axis_),
omega_(rwvpvf.omega_().clone().ptr())
omega_(rwvpvf.omega_, false)
{}
......@@ -111,7 +111,7 @@ rotatingWallVelocityFvPatchVectorField
fixedValueFvPatchField<vector>(rwvpvf, iF),
origin_(rwvpvf.origin_),
axis_(rwvpvf.axis_),
omega_(rwvpvf.omega_().clone().ptr())
omega_(rwvpvf.omega_, false)
{}
......
......@@ -59,8 +59,8 @@ swirlFlowRateInletVelocityFvPatchVectorField
fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
phiName_(ptf.phiName_),
rhoName_(ptf.rhoName_),
flowRate_(ptf.flowRate_().clone().ptr()),
rpm_(ptf.rpm_().clone().ptr())
flowRate_(ptf.flowRate_, false),
rpm_(ptf.rpm_, false)
{}
......@@ -89,8 +89,8 @@ swirlFlowRateInletVelocityFvPatchVectorField
fixedValueFvPatchField<vector>(ptf),
phiName_(ptf.phiName_),
rhoName_(ptf.rhoName_),
flowRate_(ptf.flowRate_().clone().ptr()),
rpm_(ptf.rpm_().clone().ptr())
flowRate_(ptf.flowRate_, false),
rpm_(ptf.rpm_, false)
{}
......@@ -104,8 +104,8 @@ swirlFlowRateInletVelocityFvPatchVectorField
fixedValueFvPatchField<vector>(ptf, iF),
phiName_(ptf.phiName_),
rhoName_(ptf.rhoName_),
flowRate_(ptf.flowRate_().clone().ptr()),
rpm_(ptf.rpm_().clone().ptr())
flowRate_(ptf.flowRate_, false),
rpm_(ptf.rpm_, false)
{}
......
......@@ -58,38 +58,6 @@ timeVaryingMappedFixedValueFvPatchField
{}
template<class Type>
timeVaryingMappedFixedValueFvPatchField<Type>::
timeVaryingMappedFixedValueFvPatchField
(
const timeVaryingMappedFixedValueFvPatchField<Type>& ptf,
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
fieldTableName_(ptf.fieldTableName_),
setAverage_(ptf.setAverage_),
perturb_(ptf.perturb_),
mapMethod_(ptf.mapMethod_),
mapperPtr_(NULL),
sampleTimes_(0),
startSampleTime_(-1),
startSampledValues_(0),
startAverage_(pTraits<Type>::zero),
endSampleTime_(-1),
endSampledValues_(0),
endAverage_(pTraits<Type>::zero),
offset_
(
ptf.offset_.valid()
? ptf.offset_().clone().ptr()
: NULL
)
{}
template<class Type>
timeVaryingMappedFixedValueFvPatchField<Type>::
timeVaryingMappedFixedValueFvPatchField
......@@ -152,6 +120,33 @@ timeVaryingMappedFixedValueFvPatchField
}
template<class Type>
timeVaryingMappedFixedValueFvPatchField<Type>::
timeVaryingMappedFixedValueFvPatchField
(
const timeVaryingMappedFixedValueFvPatchField<Type>& ptf,
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
fieldTableName_(ptf.fieldTableName_),
setAverage_(ptf.setAverage_),
perturb_(ptf.perturb_),
mapMethod_(ptf.mapMethod_),
mapperPtr_(NULL),
sampleTimes_(0),
startSampleTime_(-1),
startSampledValues_(0),
startAverage_(pTraits<Type>::zero),
endSampleTime_(-1),
endSampledValues_(0),
endAverage_(pTraits<Type>::zero),
offset_(ptf.offset_, false)
{}
template<class Type>
timeVaryingMappedFixedValueFvPatchField<Type>::
timeVaryingMappedFixedValueFvPatchField
......@@ -172,12 +167,7 @@ timeVaryingMappedFixedValueFvPatchField
endSampleTime_(ptf.endSampleTime_),
endSampledValues_(ptf.endSampledValues_),
endAverage_(ptf.endAverage_),
offset_
(
ptf.offset_.valid()
? ptf.offset_().clone().ptr()
: NULL
)
offset_(ptf.offset_, false)
{}
......@@ -202,12 +192,7 @@ timeVaryingMappedFixedValueFvPatchField
endSampleTime_(ptf.endSampleTime_),
endSampledValues_(ptf.endSampledValues_),
endAverage_(ptf.endAverage_),
offset_
(
ptf.offset_.valid()
? ptf.offset_().clone().ptr()
: NULL
)
offset_(ptf.offset_, false)
{}
......
......@@ -55,44 +55,30 @@ Foam::uniformFixedGradientFvPatchField<Type>::uniformFixedGradientFvPatchField
template<class Type>
Foam::uniformFixedGradientFvPatchField<Type>::uniformFixedGradientFvPatchField
(
const uniformFixedGradientFvPatchField<Type>& ptf,
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const fvPatchFieldMapper& mapper
const dictionary& dict
)
:
fixedGradientFvPatchField<Type>(ptf, p, iF, mapper),
uniformGradient_(ptf.uniformGradient_().clone().ptr())
fixedGradientFvPatchField<Type>(p, iF),
uniformGradient_(DataEntry<Type>::New("uniformGradient", dict))
{
// For safety re-evaluate
const scalar t = this->db().time().timeOutputValue();
this->gradient() = uniformGradient_->value(t);
this->evaluate();
}
template<class Type>
Foam::uniformFixedGradientFvPatchField<Type>::uniformFixedGradientFvPatchField
(
const uniformFixedGradientFvPatchField<Type>& ptf,
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const dictionary& dict
const fvPatchFieldMapper& mapper
)
:
fixedGradientFvPatchField<Type>(p, iF),
uniformGradient_(DataEntry<Type>::New("uniformGradient", dict))
{
if (dict.found("gradient"))
{
this->gradient() = Field<Type>("gradient", dict, p.size());
}
else
{
const scalar t = this->db().time().timeOutputValue();
this->gradient() = uniformGradient_->value(t);
}
fixedGradientFvPatchField<Type>::evaluate();
}
fixedGradientFvPatchField<Type>(ptf, p, iF, mapper),
uniformGradient_(ptf.uniformGradient_, false)
{}
template<class Type>
......@@ -102,12 +88,7 @@ Foam::uniformFixedGradientFvPatchField<Type>::uniformFixedGradientFvPatchField
)
:
fixedGradientFvPatchField<Type>(ptf),
uniformGradient_
(
ptf.uniformGradient_.valid()
? ptf.uniformGradient_().clone().ptr()
: NULL
)
uniformGradient_(ptf.uniformGradient_, false)
{}
......@@ -119,19 +100,12 @@ Foam::uniformFixedGradientFvPatchField<Type>::uniformFixedGradientFvPatchField
)
:
fixedGradientFvPatchField<Type>(ptf, iF),
uniformGradient_
(
ptf.uniformGradient_.valid()
? ptf.uniformGradient_().clone().ptr()
: NULL
)
uniformGradient_(ptf.uniformGradient_, false)
{
// For safety re-evaluate
const scalar t = this->db().time().timeOutputValue();
// Evaluate the profile if defined
if (ptf.uniformGradient_.valid())
{
this->gradient() = uniformGradient_->value(t);
this->evaluate();
}
}
......
......@@ -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-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -164,12 +164,8 @@ public:
// Member functions
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
......
......@@ -55,34 +55,32 @@ Foam::uniformFixedValueFvPatchField<Type>::uniformFixedValueFvPatchField
template<class Type>
Foam::uniformFixedValueFvPatchField<Type>::uniformFixedValueFvPatchField
(