Commit 14a392fe authored by Mark Olesen's avatar Mark Olesen
Browse files

derived bcs: consistent treatment of "phi" and "rho" lookups, etc

parent 248b15e7
......@@ -47,8 +47,8 @@ advectiveFvPatchField<Type>::advectiveFvPatchField
)
:
mixedFvPatchField<Type>(p, iF),
phiName_("Undefined"),
rhoName_("Undefined"),
phiName_("phi"),
rhoName_("rho"),
fieldInf_(pTraits<Type>::zero),
lInf_(0.0)
{
......@@ -84,8 +84,8 @@ advectiveFvPatchField<Type>::advectiveFvPatchField
)
:
mixedFvPatchField<Type>(p, iF),
phiName_(dict.lookup("phi")),
rhoName_("Undefined"),
phiName_(dict.lookupOrDefault<word>("phi", "phi")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
fieldInf_(pTraits<Type>::zero),
lInf_(0.0)
{
......@@ -105,15 +105,9 @@ advectiveFvPatchField<Type>::advectiveFvPatchField
this->refGrad() = pTraits<Type>::zero;
this->valueFraction() = 0.0;
if (dict.found("rho"))
{
dict.lookup("rho") >> rhoName_;
}
if (dict.found("lInf"))
if (dict.readIfPresent("lInf", lInf_))
{
dict.lookup("fieldInf") >> fieldInf_;
dict.lookup("lInf") >> lInf_;
if (lInf_ < 0.0)
{
......@@ -123,8 +117,8 @@ advectiveFvPatchField<Type>::advectiveFvPatchField
"advectiveFvPatchField"
"(const fvPatch&, const Field<Type>&, const dictionary&)",
dict
) << "unphysical lInf_ specified (lInf_ < 0)"
<< "\n on patch " << this->patch().name()
) << "unphysical lInf specified (lInf < 0)\n"
<< " on patch " << this->patch().name()
<< " of field " << this->dimensionedInternalField().name()
<< " in file " << this->dimensionedInternalField().objectPath()
<< exit(FatalIOError);
......@@ -167,7 +161,7 @@ advectiveFvPatchField<Type>::advectiveFvPatchField
template<class Type>
tmp<scalarField> advectiveFvPatchField<Type>::advectionSpeed() const
{
const surfaceScalarField& phi =
const surfaceScalarField& phi =
this->db().objectRegistry::lookupObject<surfaceScalarField>(phiName_);
fvsPatchField<scalar> phip = this->patch().lookupPatchField
......@@ -210,7 +204,7 @@ void advectiveFvPatchField<Type>::updateCoeffs()
);
scalar deltaT = this->db().time().deltaT().value();
const GeometricField<Type, fvPatchField, volMesh>& field =
const GeometricField<Type, fvPatchField, volMesh>& field =
this->db().objectRegistry::
lookupObject<GeometricField<Type, fvPatchField, volMesh> >
(
......@@ -239,7 +233,7 @@ void advectiveFvPatchField<Type>::updateCoeffs()
|| ddtScheme == fv::CrankNicholsonDdtScheme<scalar>::typeName
)
{
this->refValue() =
this->refValue() =
(
field.oldTime().boundaryField()[patchi] + k*fieldInf_
)/(1.0 + k);
......@@ -314,9 +308,12 @@ template<class Type>
void advectiveFvPatchField<Type>::write(Ostream& os) const
{
fvPatchField<Type>::write(os);
os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
if (rhoName_ != "Undefined")
if (phiName_ != "phi")
{
os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
}
if (rhoName_ != "rho")
{
os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
}
......@@ -324,9 +321,9 @@ void advectiveFvPatchField<Type>::write(Ostream& os) const
if (lInf_ > SMALL)
{
os.writeKeyword("fieldInf") << fieldInf_
<< token::END_STATEMENT << endl;
<< token::END_STATEMENT << nl;
os.writeKeyword("lInf") << lInf_
<< token::END_STATEMENT << endl;
<< token::END_STATEMENT << nl;
}
this->writeEntry("value", os);
......
......@@ -238,11 +238,11 @@ void directMappedVelocityFluxFixedValueFvPatchField::updateCoeffs()
const word& fieldName = dimensionedInternalField().name();
const volVectorField& UField = db().lookupObject<volVectorField>(fieldName);
surfaceScalarField& phiField =
const_cast<surfaceScalarField&>
(
db().lookupObject<surfaceScalarField>(phiName_)
);
surfaceScalarField& phiField = const_cast<surfaceScalarField&>
(
db().lookupObject<surfaceScalarField>(phiName_)
);
switch (mpp.mode())
{
......
......@@ -52,11 +52,9 @@ void fanFvPatchField<scalar>::updateCoeffs()
if (f_.size() > 1)
{
const surfaceScalarField& phi = db().lookupObject<surfaceScalarField>
(
"phi"
);
const surfaceScalarField& phi =
db().lookupObject<surfaceScalarField>("phi");
const fvsPatchField<scalar>& phip =
patch().patchField<surfaceScalarField, scalar>(phi);
......
......@@ -30,28 +30,23 @@ License
#include "surfaceFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedGradientFvPatchScalarField(p, iF),
UName_("Undefined"),
phiName_("Undefined"),
rhoName_("Undefined"),
UName_("U"),
phiName_("phi"),
rhoName_("rho"),
adjoint_(false)
{}
fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
(
const fixedFluxPressureFvPatchScalarField& ptf,
const fvPatch& p,
......@@ -67,7 +62,7 @@ fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
{}
fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
......@@ -75,9 +70,9 @@ fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
)
:
fixedGradientFvPatchScalarField(p, iF),
UName_(dict.lookup("U")),
phiName_(dict.lookup("phi")),
rhoName_(dict.lookup("rho")),
UName_(dict.lookupOrDefault<word>("U", "U")),
phiName_(dict.lookupOrDefault<word>("phi", "phi")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
adjoint_(dict.lookup("adjoint"))
{
if (dict.found("gradient"))
......@@ -94,7 +89,7 @@ fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
}
fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
(
const fixedFluxPressureFvPatchScalarField& wbppsf
)
......@@ -107,7 +102,7 @@ fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
{}
fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
(
const fixedFluxPressureFvPatchScalarField& wbppsf,
const DimensionedField<scalar, volMesh>& iF
......@@ -123,7 +118,7 @@ fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void fixedFluxPressureFvPatchScalarField::updateCoeffs()
void Foam::fixedFluxPressureFvPatchScalarField::updateCoeffs()
{
if (updated())
{
......@@ -133,8 +128,9 @@ void fixedFluxPressureFvPatchScalarField::updateCoeffs()
const fvPatchField<vector>& Up =
patch().lookupPatchField<volVectorField, vector>(UName_);
const surfaceScalarField& phi =
const surfaceScalarField& phi =
db().lookupObject<surfaceScalarField>(phiName_);
fvsPatchField<scalar> phip =
patch().patchField<surfaceScalarField, scalar>(phi);
......@@ -162,12 +158,21 @@ void fixedFluxPressureFvPatchScalarField::updateCoeffs()
}
void fixedFluxPressureFvPatchScalarField::write(Ostream& os) const
void Foam::fixedFluxPressureFvPatchScalarField::write(Ostream& os) const
{
fvPatchScalarField::write(os);
os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
if (UName_ != "U")
{
os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
}
if (phiName_ != "phi")
{
os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
}
if (rhoName_ != "rho")
{
os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
}
os.writeKeyword("adjoint") << adjoint_ << token::END_STATEMENT << nl;
gradient().writeEntry("gradient", os);
}
......@@ -175,10 +180,13 @@ void fixedFluxPressureFvPatchScalarField::write(Ostream& os) const
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField(fvPatchScalarField, fixedFluxPressureFvPatchScalarField);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
namespace Foam
{
makePatchTypeField
(
fvPatchScalarField,
fixedFluxPressureFvPatchScalarField
);
}
// ************************************************************************* //
......@@ -75,19 +75,9 @@ flowRateInletVelocityFvPatchVectorField
:
fixedValueFvPatchField<vector>(p, iF, dict),
flowRate_(readScalar(dict.lookup("flowRate"))),
phiName_("phi"),
rhoName_("rho")
{
if (dict.found("phi"))
{
dict.lookup("phi") >> phiName_;
}
if (dict.found("rho"))
{
dict.lookup("rho") >> rhoName_;
}
}
phiName_(dict.lookupOrDefault<word>("phi", "phi")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
{}
Foam::
......@@ -133,10 +123,8 @@ void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs()
vectorField n = patch().nf();
const surfaceScalarField& phi = db().lookupObject<surfaceScalarField>
(
phiName_
);
const surfaceScalarField& phi =
db().lookupObject<surfaceScalarField>(phiName_);
if (phi.dimensions() == dimVelocity*dimArea)
{
......@@ -170,20 +158,15 @@ void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs()
void Foam::flowRateInletVelocityFvPatchVectorField::write(Ostream& os) const
{
fvPatchField<vector>::write(os);
os.writeKeyword("flowRate") << flowRate_
<< token::END_STATEMENT << nl;
os.writeKeyword("flowRate") << flowRate_ << token::END_STATEMENT << nl;
if (phiName_ != "phi")
{
os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
}
if (rhoName_ != "rho")
{
os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
}
writeEntry("value", os);
}
......
......@@ -32,12 +32,9 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
fluxCorrectedVelocityFvPatchVectorField::
Foam::fluxCorrectedVelocityFvPatchVectorField::
fluxCorrectedVelocityFvPatchVectorField
(
const fvPatch& p,
......@@ -50,7 +47,7 @@ fluxCorrectedVelocityFvPatchVectorField
{}
fluxCorrectedVelocityFvPatchVectorField::
Foam::fluxCorrectedVelocityFvPatchVectorField::
fluxCorrectedVelocityFvPatchVectorField
(
const fluxCorrectedVelocityFvPatchVectorField& ptf,
......@@ -65,7 +62,7 @@ fluxCorrectedVelocityFvPatchVectorField
{}
fluxCorrectedVelocityFvPatchVectorField::
Foam::fluxCorrectedVelocityFvPatchVectorField::
fluxCorrectedVelocityFvPatchVectorField
(
const fvPatch& p,
......@@ -81,7 +78,7 @@ fluxCorrectedVelocityFvPatchVectorField
}
fluxCorrectedVelocityFvPatchVectorField::
Foam::fluxCorrectedVelocityFvPatchVectorField::
fluxCorrectedVelocityFvPatchVectorField
(
const fluxCorrectedVelocityFvPatchVectorField& fcvpvf,
......@@ -96,7 +93,7 @@ fluxCorrectedVelocityFvPatchVectorField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void fluxCorrectedVelocityFvPatchVectorField::evaluate
void Foam::fluxCorrectedVelocityFvPatchVectorField::evaluate
(
const Pstream::commsTypes
)
......@@ -130,9 +127,12 @@ void fluxCorrectedVelocityFvPatchVectorField::evaluate
}
else
{
FatalErrorIn("fluxCorrectedVelocityFvPatchVectorField::evaluate()")
<< "dimensions of phi are not correct"
<< "\n on patch " << this->patch().name()
FatalErrorIn
(
"fluxCorrectedVelocityFvPatchVectorField::evaluate()"
)
<< "dimensions of phi are incorrect\n"
<< " on patch " << this->patch().name()
<< " of field " << this->dimensionedInternalField().name()
<< " in file " << this->dimensionedInternalField().objectPath()
<< exit(FatalError);
......@@ -140,25 +140,30 @@ void fluxCorrectedVelocityFvPatchVectorField::evaluate
}
void fluxCorrectedVelocityFvPatchVectorField::write(Ostream& os) const
void Foam::fluxCorrectedVelocityFvPatchVectorField::write(Ostream& os) const
{
fvPatchVectorField::write(os);
os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
if (phiName_ != "phi")
{
os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
}
if (rhoName_ != "rho")
{
os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
}
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField
(
fvPatchVectorField,
fluxCorrectedVelocityFvPatchVectorField
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
namespace Foam
{
makePatchTypeField
(
fvPatchVectorField,
fluxCorrectedVelocityFvPatchVectorField
);
}
// ************************************************************************* //
......@@ -72,7 +72,7 @@ inletOutletFvPatchField<Type>::inletOutletFvPatchField
)
:
mixedFvPatchField<Type>(p, iF),
phiName_("phi")
phiName_(dict.lookupOrDefault<word>("phi", "phi"))
{
this->refValue() = Field<Type>("inletValue", dict, p.size());
......@@ -90,11 +90,6 @@ inletOutletFvPatchField<Type>::inletOutletFvPatchField
this->refGrad() = pTraits<Type>::zero;
this->valueFraction() = 0.0;
if (dict.found("phi"))
{
dict.lookup("phi") >> phiName_;
}
}
......@@ -150,8 +145,7 @@ void inletOutletFvPatchField<Type>::write(Ostream& os) const
fvPatchField<Type>::write(os);
if (phiName_ != "phi")
{
os.writeKeyword("phi")
<< phiName_ << token::END_STATEMENT << nl;
os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
}
this->refValue().writeEntry("inletValue", os);
this->writeEntry("value", os);
......
......@@ -32,12 +32,9 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inletOutletTotalTemperatureFvPatchScalarField::
Foam::inletOutletTotalTemperatureFvPatchScalarField::
inletOutletTotalTemperatureFvPatchScalarField
(
const fvPatch& p,
......@@ -45,9 +42,9 @@ inletOutletTotalTemperatureFvPatchScalarField
)
:
mixedFvPatchScalarField(p, iF),
UName_(),
phiName_(),
psiName_(),
UName_("U"),
phiName_("phi"),
psiName_("psi"),
gamma_(0.0),
T0_(p.size(), 0.0)
{
......@@ -57,7 +54,7 @@ inletOutletTotalTemperatureFvPatchScalarField
}
inletOutletTotalTemperatureFvPatchScalarField::
Foam::inletOutletTotalTemperatureFvPatchScalarField::
inletOutletTotalTemperatureFvPatchScalarField
(
const inletOutletTotalTemperatureFvPatchScalarField& ptf,
......@@ -75,7 +72,7 @@ inletOutletTotalTemperatureFvPatchScalarField
{}
inletOutletTotalTemperatureFvPatchScalarField::
Foam::inletOutletTotalTemperatureFvPatchScalarField::
inletOutletTotalTemperatureFvPatchScalarField
(
const fvPatch& p,
......@@ -84,9 +81,9 @@ inletOutletTotalTemperatureFvPatchScalarField
)
:
mixedFvPatchScalarField(p, iF),
UName_(dict.lookup("U")),
phiName_(dict.lookup("phi")),
psiName_(dict.lookup("psi")),
UName_(dict.lookupOrDefault<word>("U", "U")),
phiName_(dict.lookupOrDefault<word>("phi", "phi")),
psiName_(dict.lookupOrDefault<word>("psi", "psi")),
gamma_(readScalar(dict.lookup("gamma"))),
T0_("T0", dict, p.size())
{
......@@ -108,7 +105,7 @@ inletOutletTotalTemperatureFvPatchScalarField
}
inletOutletTotalTemperatureFvPatchScalarField::
Foam::inletOutletTotalTemperatureFvPatchScalarField::
inletOutletTotalTemperatureFvPatchScalarField
(
const inletOutletTotalTemperatureFvPatchScalarField& tppsf
......@@ -123,7 +120,7 @@ inletOutletTotalTemperatureFvPatchScalarField
{}
inletOutletTotalTemperatureFvPatchScalarField::
Foam::inletOutletTotalTemperatureFvPatchScalarField::
inletOutletTotalTemperatureFvPatchScalarField
(
const inletOutletTotalTemperatureFvPatchScalarField& tppsf,
......@@ -141,7 +138,7 @@ inletOutletTotalTemperatureFvPatchScalarField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void inletOutletTotalTemperatureFvPatchScalarField::autoMap
void Foam::inletOutletTotalTemperatureFvPatchScalarField::autoMap
(
const fvPatchFieldMapper& m
)
......@@ -151,7 +148,7 @@ void inletOutletTotalTemperatureFvPatchScalarField::autoMap
}
void inletOutletTotalTemperatureFvPatchScalarField::rmap
void Foam::inletOutletTotalTemperatureFvPatchScalarField::rmap
(
const fvPatchScalarField& ptf,
const labelList& addr
......@@ -166,7 +163,7 @@ void inletOutletTotalTemperatureFvPatchScalarField::rmap
}
void inletOutletTotalTemperatureFvPatchScalarField::updateCoeffs()
void Foam::inletOutletTotalTemperatureFvPatchScalarField::updateCoeffs()
{
if (updated())
{
......@@ -192,13 +189,22 @@ void inletOutletTotalTemperatureFvPatchScalarField::updateCoeffs()
}
void inletOutletTotalTemperatureFvPatchScalarField::write(Ostream& os) const
void