ENH: Updated derived fvPatchField template coding style

This commit is contained in:
andy
2010-12-14 16:29:18 +00:00
parent 34f55c4f9d
commit e71993f896
6 changed files with 83 additions and 98 deletions

View File

@ -163,21 +163,19 @@ tmp<scalarField> advectiveFvPatchField<Type>::advectionSpeed() const
const surfaceScalarField& phi = const surfaceScalarField& phi =
this->db().objectRegistry::lookupObject<surfaceScalarField>(phiName_); this->db().objectRegistry::lookupObject<surfaceScalarField>(phiName_);
fvsPatchField<scalar> phip = this->patch().lookupPatchField fvsPatchField<scalar> phip =
( this->patch().template lookupPatchField<surfaceScalarField, scalar>
phiName_, (
reinterpret_cast<const surfaceScalarField*>(0), phiName_
reinterpret_cast<const scalar*>(0) );
);
if (phi.dimensions() == dimDensity*dimVelocity*dimArea) if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
{ {
const fvPatchScalarField& rhop = this->patch().lookupPatchField const fvPatchScalarField& rhop =
( this->patch().template lookupPatchField<volScalarField, scalar>
rhoName_, (
reinterpret_cast<const volScalarField*>(0), rhoName_
reinterpret_cast<const scalar*>(0) );
);
return phip/(rhop*this->patch().magSf()); return phip/(rhop*this->patch().magSf());
} }

View File

@ -25,15 +25,10 @@ License
#include "inletOutletFvPatchField.H" #include "inletOutletFvPatchField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type> template<class Type>
inletOutletFvPatchField<Type>::inletOutletFvPatchField Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
( (
const fvPatch& p, const fvPatch& p,
const DimensionedField<Type, volMesh>& iF const DimensionedField<Type, volMesh>& iF
@ -49,7 +44,7 @@ inletOutletFvPatchField<Type>::inletOutletFvPatchField
template<class Type> template<class Type>
inletOutletFvPatchField<Type>::inletOutletFvPatchField Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
( (
const inletOutletFvPatchField<Type>& ptf, const inletOutletFvPatchField<Type>& ptf,
const fvPatch& p, const fvPatch& p,
@ -63,7 +58,7 @@ inletOutletFvPatchField<Type>::inletOutletFvPatchField
template<class Type> template<class Type>
inletOutletFvPatchField<Type>::inletOutletFvPatchField Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
( (
const fvPatch& p, const fvPatch& p,
const DimensionedField<Type, volMesh>& iF, const DimensionedField<Type, volMesh>& iF,
@ -93,7 +88,7 @@ inletOutletFvPatchField<Type>::inletOutletFvPatchField
template<class Type> template<class Type>
inletOutletFvPatchField<Type>::inletOutletFvPatchField Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
( (
const inletOutletFvPatchField<Type>& ptf const inletOutletFvPatchField<Type>& ptf
) )
@ -104,7 +99,7 @@ inletOutletFvPatchField<Type>::inletOutletFvPatchField
template<class Type> template<class Type>
inletOutletFvPatchField<Type>::inletOutletFvPatchField Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
( (
const inletOutletFvPatchField<Type>& ptf, const inletOutletFvPatchField<Type>& ptf,
const DimensionedField<Type, volMesh>& iF const DimensionedField<Type, volMesh>& iF
@ -118,19 +113,18 @@ inletOutletFvPatchField<Type>::inletOutletFvPatchField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type> template<class Type>
void inletOutletFvPatchField<Type>::updateCoeffs() void Foam::inletOutletFvPatchField<Type>::updateCoeffs()
{ {
if (this->updated()) if (this->updated())
{ {
return; return;
} }
const Field<scalar>& phip = this->patch().lookupPatchField const Field<scalar>& phip =
( this->patch().template lookupPatchField<surfaceScalarField, scalar>
phiName_, (
reinterpret_cast<const surfaceScalarField*>(0), phiName_
reinterpret_cast<const scalar*>(0) );
);
this->valueFraction() = 1.0 - pos(phip); this->valueFraction() = 1.0 - pos(phip);
@ -139,7 +133,7 @@ void inletOutletFvPatchField<Type>::updateCoeffs()
template<class Type> template<class Type>
void inletOutletFvPatchField<Type>::write(Ostream& os) const void Foam::inletOutletFvPatchField<Type>::write(Ostream& os) const
{ {
fvPatchField<Type>::write(os); fvPatchField<Type>::write(os);
if (phiName_ != "phi") if (phiName_ != "phi")
@ -154,7 +148,7 @@ void inletOutletFvPatchField<Type>::write(Ostream& os) const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Type> template<class Type>
void inletOutletFvPatchField<Type>::operator= void Foam::inletOutletFvPatchField<Type>::operator=
( (
const fvPatchField<Type>& ptf const fvPatchField<Type>& ptf
) )
@ -167,8 +161,4 @@ void inletOutletFvPatchField<Type>::operator=
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -56,6 +56,7 @@ protected:
// Protected data // Protected data
//- Name of flux field
word phiName_; word phiName_;

View File

@ -25,21 +25,17 @@ License
#include "outletInletFvPatchField.H" #include "outletInletFvPatchField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type> template<class Type>
outletInletFvPatchField<Type>::outletInletFvPatchField Foam::outletInletFvPatchField<Type>::outletInletFvPatchField
( (
const fvPatch& p, const fvPatch& p,
const DimensionedField<Type, volMesh>& iF const DimensionedField<Type, volMesh>& iF
) )
: :
mixedFvPatchField<Type>(p, iF) mixedFvPatchField<Type>(p, iF),
phiName_("phi")
{ {
this->refValue() = *this; this->refValue() = *this;
this->refGrad() = pTraits<Type>::zero; this->refGrad() = pTraits<Type>::zero;
@ -48,7 +44,7 @@ outletInletFvPatchField<Type>::outletInletFvPatchField
template<class Type> template<class Type>
outletInletFvPatchField<Type>::outletInletFvPatchField Foam::outletInletFvPatchField<Type>::outletInletFvPatchField
( (
const outletInletFvPatchField<Type>& ptf, const outletInletFvPatchField<Type>& ptf,
const fvPatch& p, const fvPatch& p,
@ -56,19 +52,21 @@ outletInletFvPatchField<Type>::outletInletFvPatchField
const fvPatchFieldMapper& mapper const fvPatchFieldMapper& mapper
) )
: :
mixedFvPatchField<Type>(ptf, p, iF, mapper) mixedFvPatchField<Type>(ptf, p, iF, mapper),
phiName_(ptf.phiName_)
{} {}
template<class Type> template<class Type>
outletInletFvPatchField<Type>::outletInletFvPatchField Foam::outletInletFvPatchField<Type>::outletInletFvPatchField
( (
const fvPatch& p, const fvPatch& p,
const DimensionedField<Type, volMesh>& iF, const DimensionedField<Type, volMesh>& iF,
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchField<Type>(p, iF) mixedFvPatchField<Type>(p, iF),
phiName_(dict.lookupOrDefault<word>("phi", "phi"))
{ {
this->refValue() = Field<Type>("outletValue", dict, p.size()); this->refValue() = Field<Type>("outletValue", dict, p.size());
@ -90,42 +88,43 @@ outletInletFvPatchField<Type>::outletInletFvPatchField
template<class Type> template<class Type>
outletInletFvPatchField<Type>::outletInletFvPatchField Foam::outletInletFvPatchField<Type>::outletInletFvPatchField
( (
const outletInletFvPatchField<Type>& ptf const outletInletFvPatchField<Type>& ptf
) )
: :
mixedFvPatchField<Type>(ptf) mixedFvPatchField<Type>(ptf),
phiName_(ptf.phiName_)
{} {}
template<class Type> template<class Type>
outletInletFvPatchField<Type>::outletInletFvPatchField Foam::outletInletFvPatchField<Type>::outletInletFvPatchField
( (
const outletInletFvPatchField<Type>& ptf, const outletInletFvPatchField<Type>& ptf,
const DimensionedField<Type, volMesh>& iF const DimensionedField<Type, volMesh>& iF
) )
: :
mixedFvPatchField<Type>(ptf, iF) mixedFvPatchField<Type>(ptf, iF),
phiName_(ptf.phiName_)
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type> template<class Type>
void outletInletFvPatchField<Type>::updateCoeffs() void Foam::outletInletFvPatchField<Type>::updateCoeffs()
{ {
if (this->updated()) if (this->updated())
{ {
return; return;
} }
const fvsPatchField<scalar>& phip = this->patch().lookupPatchField const fvsPatchField<scalar>& phip =
( this->patch().template lookupPatchField<surfaceScalarField, scalar>
"phi", (
reinterpret_cast<const surfaceScalarField*>(0), phiName_
reinterpret_cast<const scalar*>(0) );
);
this->valueFraction() = pos(phip); this->valueFraction() = pos(phip);
@ -134,16 +133,16 @@ void outletInletFvPatchField<Type>::updateCoeffs()
template<class Type> template<class Type>
void outletInletFvPatchField<Type>::write(Ostream& os) const void Foam::outletInletFvPatchField<Type>::write(Ostream& os) const
{ {
fvPatchField<Type>::write(os); fvPatchField<Type>::write(os);
if (phiName_ != "phi")
{
os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
}
this->refValue().writeEntry("outletValue", os); this->refValue().writeEntry("outletValue", os);
this->writeEntry("value", os); this->writeEntry("value", os);
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -52,6 +52,14 @@ class outletInletFvPatchField
public mixedFvPatchField<Type> public mixedFvPatchField<Type>
{ {
protected:
// Protected data
//- Name of flux field
word phiName_;
public: public:
//- Runtime type information //- Runtime type information

View File

@ -31,15 +31,10 @@ License
#include "CrankNicholsonDdtScheme.H" #include "CrankNicholsonDdtScheme.H"
#include "backwardDdtScheme.H" #include "backwardDdtScheme.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type> template<class Type>
waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField Foam::waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
( (
const fvPatch& p, const fvPatch& p,
const DimensionedField<Type, volMesh>& iF const DimensionedField<Type, volMesh>& iF
@ -52,7 +47,7 @@ waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
template<class Type> template<class Type>
waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField Foam::waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
( (
const waveTransmissiveFvPatchField& ptf, const waveTransmissiveFvPatchField& ptf,
const fvPatch& p, const fvPatch& p,
@ -67,7 +62,7 @@ waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
template<class Type> template<class Type>
waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField Foam::waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
( (
const fvPatch& p, const fvPatch& p,
const DimensionedField<Type, volMesh>& iF, const DimensionedField<Type, volMesh>& iF,
@ -81,7 +76,7 @@ waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
template<class Type> template<class Type>
waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField Foam::waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
( (
const waveTransmissiveFvPatchField& ptpsf const waveTransmissiveFvPatchField& ptpsf
) )
@ -93,7 +88,7 @@ waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
template<class Type> template<class Type>
waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField Foam::waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
( (
const waveTransmissiveFvPatchField& ptpsf, const waveTransmissiveFvPatchField& ptpsf,
const DimensionedField<Type, volMesh>& iF const DimensionedField<Type, volMesh>& iF
@ -108,35 +103,32 @@ waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type> template<class Type>
tmp<scalarField> waveTransmissiveFvPatchField<Type>::advectionSpeed() const Foam::tmp<Foam::scalarField>
Foam::waveTransmissiveFvPatchField<Type>::advectionSpeed() const
{ {
// Lookup the velocity and compressibility of the patch // Lookup the velocity and compressibility of the patch
const fvPatchField<scalar>& psip = this->patch().lookupPatchField const fvPatchField<scalar>& psip =
( this->patch().template lookupPatchField<volScalarField, scalar>
psiName_, (
reinterpret_cast<const volScalarField*>(0), psiName_
reinterpret_cast<const scalar*>(0) );
);
const surfaceScalarField& phi = const surfaceScalarField& phi =
this->db().objectRegistry::lookupObject<surfaceScalarField> this->db().template lookupObject<surfaceScalarField>(this->phiName_);
(this->phiName_);
fvsPatchField<scalar> phip = this->patch().lookupPatchField fvsPatchField<scalar> phip =
( this->patch().template lookupPatchField<surfaceScalarField, scalar>
this->phiName_, (
reinterpret_cast<const surfaceScalarField*>(0), this->phiName_
reinterpret_cast<const scalar*>(0) );
);
if (phi.dimensions() == dimDensity*dimVelocity*dimArea) if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
{ {
const fvPatchScalarField& rhop = this->patch().lookupPatchField const fvPatchScalarField& rhop =
( this->patch().template lookupPatchField<volScalarField, scalar>
this->rhoName_, (
reinterpret_cast<const volScalarField*>(0), this->rhoName_
reinterpret_cast<const scalar*>(0) );
);
phip /= rhop; phip /= rhop;
} }
@ -149,7 +141,7 @@ tmp<scalarField> waveTransmissiveFvPatchField<Type>::advectionSpeed() const
template<class Type> template<class Type>
void waveTransmissiveFvPatchField<Type>::write(Ostream& os) const void Foam::waveTransmissiveFvPatchField<Type>::write(Ostream& os) const
{ {
fvPatchField<Type>::write(os); fvPatchField<Type>::write(os);
@ -165,6 +157,7 @@ void waveTransmissiveFvPatchField<Type>::write(Ostream& os) const
{ {
os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl; os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
} }
os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl; os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
if (this->lInf_ > SMALL) if (this->lInf_ > SMALL)
@ -179,8 +172,4 @@ void waveTransmissiveFvPatchField<Type>::write(Ostream& os) const
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //