mixedFvPatchField: Added optional 'valuesRequired' argument to the dictionary constructor

so that derived classes can call the dictionary constructor without reading the
refValue, refGradient or valueFraction entries.  This ensures that the
fvPatchField dictionary constructor is called, setting optional entries like
'libs' as required.
This commit is contained in:
Henry Weller
2022-10-21 12:07:50 +01:00
parent 091cba730d
commit 8d33ad6dda
31 changed files with 83 additions and 51 deletions

View File

@ -60,7 +60,7 @@ Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF, dict, false),
UName_(dict.lookupOrDefault<word>("U", "U")), UName_(dict.lookupOrDefault<word>("U", "U")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")), rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
psiName_(dict.lookupOrDefault<word>("psi", "thermo:psi")), psiName_(dict.lookupOrDefault<word>("psi", "thermo:psi")),

View File

@ -61,7 +61,7 @@ JohnsonJacksonParticleThetaFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF, dict, false),
restitutionCoefficient_ restitutionCoefficient_
( (
"restitutionCoefficient", "restitutionCoefficient",

View File

@ -62,7 +62,7 @@ coupledTemperatureFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF, dict, false),
TnbrName_(dict.lookupOrDefault<word>("Tnbr", "T")), TnbrName_(dict.lookupOrDefault<word>("Tnbr", "T")),
qrNbrName_(dict.lookupOrDefault<word>("qrNbr", "none")), qrNbrName_(dict.lookupOrDefault<word>("qrNbr", "none")),
qrName_(dict.lookupOrDefault<word>("qr", "none")), qrName_(dict.lookupOrDefault<word>("qr", "none")),

View File

@ -70,7 +70,7 @@ externalTemperatureFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF, dict, false),
haveQ_(dict.found("Q")), haveQ_(dict.found("Q")),
Q_(haveQ_ ? dict.lookup<scalar>("Q") : NaN), Q_(haveQ_ ? dict.lookup<scalar>("Q") : NaN),
haveq_(dict.found("q")), haveq_(dict.found("q")),

View File

@ -68,7 +68,7 @@ thermalBaffle1DFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF, dict, false),
TName_("T"), TName_("T"),
baffleActivated_(dict.lookupOrDefault<bool>("baffleActivated", true)), baffleActivated_(dict.lookupOrDefault<bool>("baffleActivated", true)),
thickness_(), thickness_(),

View File

@ -56,7 +56,7 @@ totalFlowRateAdvectiveDiffusiveFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchField<scalar>(p, iF), mixedFvPatchField<scalar>(p, iF, dict, false),
phiName_(dict.lookupOrDefault<word>("phi", "phi")), phiName_(dict.lookupOrDefault<word>("phi", "phi")),
rhoName_(dict.lookupOrDefault<word>("rho", "none")), rhoName_(dict.lookupOrDefault<word>("rho", "none")),
massFluxFraction_(dict.lookupOrDefault<scalar>("massFluxFraction", 1.0)) massFluxFraction_(dict.lookupOrDefault<scalar>("massFluxFraction", 1.0))

View File

@ -46,15 +46,52 @@ Foam::mixedFvPatchField<Type>::mixedFvPatchField
( (
const fvPatch& p, const fvPatch& p,
const DimensionedField<Type, volMesh>& iF, const DimensionedField<Type, volMesh>& iF,
const dictionary& dict const dictionary& dict,
const bool valuesRequired
) )
: :
fvPatchField<Type>(p, iF, dict, false), fvPatchField<Type>(p, iF, dict, false),
refValue_("refValue", dict, p.size()), refValue_(p.size()),
refGrad_("refGradient", dict, p.size()), refGrad_(p.size()),
valueFraction_("valueFraction", dict, p.size()) valueFraction_(p.size())
{ {
evaluate(); if (valuesRequired)
{
if (dict.found("refValue"))
{
refValue_ = Field<Type>("refValue", dict, p.size());
}
else
{
FatalIOErrorInFunction(dict)
<< "Essential entry 'refValue' missing"
<< exit(FatalIOError);
}
if (dict.found("refGradient"))
{
refGrad_ = Field<Type>("refGradient", dict, p.size());
}
else
{
FatalIOErrorInFunction(dict)
<< "Essential entry 'refGradient' missing"
<< exit(FatalIOError);
}
if (dict.found("valueFraction"))
{
valueFraction_ = Field<scalar>("valueFraction", dict, p.size());
}
else
{
FatalIOErrorInFunction(dict)
<< "Essential entry 'valueFraction' missing"
<< exit(FatalIOError);
}
evaluate();
}
} }

View File

@ -114,7 +114,8 @@ public:
( (
const fvPatch&, const fvPatch&,
const DimensionedField<Type, volMesh>&, const DimensionedField<Type, volMesh>&,
const dictionary& const dictionary&,
const bool valuesRequired=true
); );
//- Construct by mapping the given mixedFvPatchField onto a new patch //- Construct by mapping the given mixedFvPatchField onto a new patch

View File

@ -62,7 +62,7 @@ Foam::advectiveFvPatchField<Type>::advectiveFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchField<Type>(p, iF), mixedFvPatchField<Type>(p, iF, dict, false),
phiName_(dict.lookupOrDefault<word>("phi", "phi")), phiName_(dict.lookupOrDefault<word>("phi", "phi")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")), rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
fieldInf_(Zero), fieldInf_(Zero),

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -471,7 +471,7 @@ externalCoupledMixedFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchField<Type>(p, iF), mixedFvPatchField<Type>(p, iF, dict, false),
commsDir_(dict.lookup("commsDir")), commsDir_(dict.lookup("commsDir")),
fName_(dict.lookup("file")), fName_(dict.lookup("file")),
waitInterval_(dict.lookupOrDefault("waitInterval", 1)), waitInterval_(dict.lookupOrDefault("waitInterval", 1)),

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -50,7 +50,7 @@ freestreamPressureFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF, dict, false),
UName_(dict.lookupOrDefault<word>("U", "U")), UName_(dict.lookupOrDefault<word>("U", "U")),
supersonic_ supersonic_
( (

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2018-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -45,7 +45,7 @@ Foam::freestreamVelocityFvPatchVectorField::freestreamVelocityFvPatchVectorField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchVectorField(p, iF) mixedFvPatchVectorField(p, iF, dict, false)
{ {
freestreamValue() = vectorField("freestreamValue", dict, p.size()); freestreamValue() = vectorField("freestreamValue", dict, p.size());

View File

@ -51,7 +51,7 @@ Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchField<Type>(p, iF), mixedFvPatchField<Type>(p, iF, dict, false),
phiName_(dict.lookupOrDefault<word>("phi", "phi")) phiName_(dict.lookupOrDefault<word>("phi", "phi"))
{ {
this->refValue() = Field<Type>("inletValue", dict, p.size()); this->refValue() = Field<Type>("inletValue", dict, p.size());

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -51,7 +51,7 @@ Foam::outletInletFvPatchField<Type>::outletInletFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchField<Type>(p, iF), mixedFvPatchField<Type>(p, iF, dict, false),
phiName_(dict.lookupOrDefault<word>("phi", "phi")) phiName_(dict.lookupOrDefault<word>("phi", "phi"))
{ {
this->refValue() = Field<Type>("outletValue", dict, p.size()); this->refValue() = Field<Type>("outletValue", dict, p.size());

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -56,7 +56,7 @@ outletPhaseMeanVelocityFvPatchVectorField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchField<vector>(p, iF), mixedFvPatchField<vector>(p, iF, dict, false),
UnMean_(Function1<scalar>::New("UnMean", dict)), UnMean_(Function1<scalar>::New("UnMean", dict)),
alphaName_(dict.lookup("alpha")) alphaName_(dict.lookup("alpha"))
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -59,7 +59,7 @@ phaseHydrostaticPressureFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF, dict, false),
phaseFraction_(dict.lookupOrDefault<word>("phaseFraction", "alpha")), phaseFraction_(dict.lookupOrDefault<word>("phaseFraction", "alpha")),
rho_(dict.lookup<scalar>("rho")), rho_(dict.lookup<scalar>("rho")),
pRefValue_(dict.lookup<scalar>("pRefValue")), pRefValue_(dict.lookup<scalar>("pRefValue")),

View File

@ -57,7 +57,7 @@ pressureDirectedInletOutletVelocityFvPatchVectorField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchVectorField(p, iF), mixedFvPatchVectorField(p, iF, dict, false),
phiName_(dict.lookupOrDefault<word>("phi", "phi")), phiName_(dict.lookupOrDefault<word>("phi", "phi")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")), rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
inletDir_("inletDirection", dict, p.size()) inletDir_("inletDirection", dict, p.size())

View File

@ -57,7 +57,7 @@ pressureInletOutletParSlipVelocityFvPatchVectorField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchVectorField(p, iF), mixedFvPatchVectorField(p, iF, dict, false),
phiName_(dict.lookupOrDefault<word>("phi", "phi")), phiName_(dict.lookupOrDefault<word>("phi", "phi")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")) rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
{ {

View File

@ -57,7 +57,7 @@ pressureNormalInletOutletVelocityFvPatchVectorField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchVectorField(p, iF), mixedFvPatchVectorField(p, iF, dict, false),
phiName_(dict.lookupOrDefault<word>("phi", "phi")), phiName_(dict.lookupOrDefault<word>("phi", "phi")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")) rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -60,7 +60,7 @@ supersonicFreestreamFvPatchVectorField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchVectorField(p, iF), mixedFvPatchVectorField(p, iF, dict, false),
TName_(dict.lookupOrDefault<word>("T", "T")), TName_(dict.lookupOrDefault<word>("T", "T")),
pName_(dict.lookupOrDefault<word>("p", "p")), pName_(dict.lookupOrDefault<word>("p", "p")),
psiName_(dict.lookupOrDefault<word>("psi", "thermo:psi")), psiName_(dict.lookupOrDefault<word>("psi", "thermo:psi")),

View File

@ -54,7 +54,7 @@ transonicEntrainmentPressureFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF, dict, false),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")), rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
psiName_(dict.lookupOrDefault<word>("psi", "thermo:psi")), psiName_(dict.lookupOrDefault<word>("psi", "thermo:psi")),
phiName_(dict.lookupOrDefault<word>("phi", "phi")), phiName_(dict.lookupOrDefault<word>("phi", "phi")),

View File

@ -51,7 +51,7 @@ Foam::uniformInletOutletFvPatchField<Type>::uniformInletOutletFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchField<Type>(p, iF), mixedFvPatchField<Type>(p, iF, dict, false),
phiName_(dict.lookupOrDefault<word>("phi", "phi")), phiName_(dict.lookupOrDefault<word>("phi", "phi")),
uniformInletValue_(Function1<Type>::New("uniformInletValue", dict)) uniformInletValue_(Function1<Type>::New("uniformInletValue", dict))
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -38,7 +38,7 @@ variableHeightFlowRateFvPatchScalarField
const DimensionedField<scalar, volMesh>& iF const DimensionedField<scalar, volMesh>& iF
) )
: :
mixedFvPatchField<scalar>(p, iF), mixedFvPatchScalarField(p, iF),
phiName_("phi"), phiName_("phi"),
lowerBound_(0.0), lowerBound_(0.0),
upperBound_(1.0) upperBound_(1.0)
@ -57,7 +57,7 @@ variableHeightFlowRateFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF, dict, false),
phiName_(dict.lookupOrDefault<word>("phi", "phi")), phiName_(dict.lookupOrDefault<word>("phi", "phi")),
lowerBound_(dict.lookup<scalar>("lowerBound")), lowerBound_(dict.lookup<scalar>("lowerBound")),
upperBound_(dict.lookup<scalar>("upperBound")) upperBound_(dict.lookup<scalar>("upperBound"))

View File

@ -72,6 +72,7 @@ Foam::fvPatchField<Type>::fvPatchField
) )
: :
Field<Type>(p.size()), Field<Type>(p.size()),
libs_(dict.lookupOrDefault("libs", fileNameList::null())),
patch_(p), patch_(p),
internalField_(iF), internalField_(iF),
updated_(false), updated_(false),

View File

@ -168,14 +168,7 @@ Foam::tmp<Foam::fvPatchField<Type>> Foam::fvPatchField<Type>::New
} }
} }
tmp<fvPatchField<Type>> ptf(cstrIter()(p, iF, dict)); return cstrIter()(p, iF, dict);
if (dict.found("libs"))
{
dict.lookup("libs") >> ptf.ref().libs_;
}
return ptf;
} }

View File

@ -55,7 +55,7 @@ Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF, dict, false),
radiationCoupledBase(p, dict), radiationCoupledBase(p, dict),
TName_(dict.lookupOrDefault<word>("T", "T")) TName_(dict.lookupOrDefault<word>("T", "T"))
{ {

View File

@ -57,7 +57,7 @@ MarshakRadiationFixedTemperatureFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF, dict, false),
radiationCoupledBase(p, dict), radiationCoupledBase(p, dict),
Trad_("Trad", dict, p.size()) Trad_("Trad", dict, p.size())
{ {

View File

@ -61,7 +61,7 @@ greyDiffusiveRadiationMixedFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF, dict, false),
radiationCoupledBase(p, dict), radiationCoupledBase(p, dict),
TName_(dict.lookupOrDefault<word>("T", "T")) TName_(dict.lookupOrDefault<word>("T", "T"))
{ {

View File

@ -62,7 +62,7 @@ wideBandDiffusiveRadiationMixedFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF, dict, false),
radiationCoupledBase(p, dict), radiationCoupledBase(p, dict),
TName_(dict.lookupOrDefault<word>("T", "T")) TName_(dict.lookupOrDefault<word>("T", "T"))
{ {

View File

@ -100,7 +100,7 @@ specieTransferMassFractionFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF, dict, false),
phiName_(dict.lookupOrDefault<word>("phi", "phi")), phiName_(dict.lookupOrDefault<word>("phi", "phi")),
UName_(dict.lookupOrDefault<word>("U", "U")), UName_(dict.lookupOrDefault<word>("U", "U")),
phiYp_(p.size(), 0), phiYp_(p.size(), 0),

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2019-2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2019-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -55,7 +55,7 @@ Foam::waveInletOutletFvPatchField<Type>::waveInletOutletFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchField<Type>(p, iF), mixedFvPatchField<Type>(p, iF, dict, false),
inletValueAbove_(Function1<Type>::New("inletValueAbove", dict)), inletValueAbove_(Function1<Type>::New("inletValueAbove", dict)),
inletValueBelow_(Function1<Type>::New("inletValueBelow", dict)), inletValueBelow_(Function1<Type>::New("inletValueBelow", dict)),
phiName_(dict.lookupOrDefault<word>("phi", "phi")) phiName_(dict.lookupOrDefault<word>("phi", "phi"))