Clean-up of patch field default field name I/O

This commit is contained in:
andy
2010-01-15 11:59:29 +00:00
parent dc507b8c7d
commit e2eab734f8
16 changed files with 80 additions and 123 deletions

View File

@ -84,7 +84,7 @@ activeBaffleVelocityFvPatchVectorField
) )
: :
fixedValueFvPatchVectorField(p, iF), fixedValueFvPatchVectorField(p, iF),
pName_("p"), pName_(dict.lookupOrDefault<word>("p", "p")),
cyclicPatchName_(dict.lookup("cyclicPatch")), cyclicPatchName_(dict.lookup("cyclicPatch")),
cyclicPatchLabel_(p.patch().boundaryMesh().findPatchID(cyclicPatchName_)), cyclicPatchLabel_(p.patch().boundaryMesh().findPatchID(cyclicPatchName_)),
orientation_(readLabel(dict.lookup("orientation"))), orientation_(readLabel(dict.lookup("orientation"))),
@ -96,11 +96,6 @@ activeBaffleVelocityFvPatchVectorField
curTimeIndex_(-1) curTimeIndex_(-1)
{ {
fvPatchVectorField::operator=(vector::zero); fvPatchVectorField::operator=(vector::zero);
if (dict.found("p"))
{
dict.lookup("p") >> pName_;
}
} }
@ -219,15 +214,21 @@ void Foam::activeBaffleVelocityFvPatchVectorField::updateCoeffs()
} }
openFraction_ = openFraction_ =
max(min( max
openFraction_ (
+ max min
( (
this->db().time().deltaTValue()/openingTime_, openFraction_
maxOpenFractionDelta_ + max
) (
*(orientation_*sign(forceDiff)), this->db().time().deltaTValue()/openingTime_,
1 - 1e-6), 1e-6); maxOpenFractionDelta_
)
*(orientation_*sign(forceDiff)),
1 - 1e-6
),
1e-6
);
Info<< "openFraction = " << openFraction_ << endl; Info<< "openFraction = " << openFraction_ << endl;
@ -264,8 +265,7 @@ void Foam::activeBaffleVelocityFvPatchVectorField::write(Ostream& os) const
<< maxOpenFractionDelta_ << token::END_STATEMENT << nl; << maxOpenFractionDelta_ << token::END_STATEMENT << nl;
os.writeKeyword("openFraction") os.writeKeyword("openFraction")
<< openFraction_ << token::END_STATEMENT << nl; << openFraction_ << token::END_STATEMENT << nl;
os.writeKeyword("p") writeEntryIfDifferent<word>(os, "p", "p", pName_);
<< pName_ << token::END_STATEMENT << nl;
writeEntry("value", os); writeEntry("value", os);
} }

View File

@ -46,7 +46,7 @@ directMappedVelocityFluxFixedValueFvPatchField
) )
: :
fixedValueFvPatchVectorField(p, iF), fixedValueFvPatchVectorField(p, iF),
phiName_("undefinedPhi") phiName_("phi")
{} {}
@ -93,22 +93,22 @@ directMappedVelocityFluxFixedValueFvPatchField
) )
: :
fixedValueFvPatchVectorField(p, iF, dict), fixedValueFvPatchVectorField(p, iF, dict),
phiName_(dict.lookup("phi")) phiName_(dict.lookupOrDefault<word>("phi", "phi"))
{ {
if (!isA<directMappedPatchBase>(this->patch().patch())) if (!isA<directMappedPatchBase>(this->patch().patch()))
{ {
FatalErrorIn FatalErrorIn
( (
"directMappedVelocityFluxFixedValueFvPatchField::" "directMappedVelocityFluxFixedValueFvPatchField::"
"directMappedVelocityFluxFixedValueFvPatchField\n" "directMappedVelocityFluxFixedValueFvPatchField"
"(\n" "("
" const fvPatch& p,\n" "const fvPatch&, "
" const DimensionedField<vector, volMesh>& iF,\n" "const DimensionedField<vector, volMesh>& iF, "
" const dictionary& dict\n" "const dictionary&"
")\n" ")"
) << "\n patch type '" << p.type() ) << "patch type '" << p.type()
<< "' not type '" << directMappedPatchBase::typeName << "'" << "' not type '" << directMappedPatchBase::typeName << "'"
<< "\n for patch " << p.name() << " for patch " << p.name()
<< " of field " << dimensionedInternalField().name() << " of field " << dimensionedInternalField().name()
<< " in file " << dimensionedInternalField().objectPath() << " in file " << dimensionedInternalField().objectPath()
<< exit(FatalError); << exit(FatalError);
@ -274,7 +274,7 @@ void directMappedVelocityFluxFixedValueFvPatchField::updateCoeffs()
void directMappedVelocityFluxFixedValueFvPatchField::write(Ostream& os) const void directMappedVelocityFluxFixedValueFvPatchField::write(Ostream& os) const
{ {
fvPatchVectorField::write(os); fvPatchVectorField::write(os);
os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
this->writeEntry("value", os); this->writeEntry("value", os);
} }

View File

@ -161,18 +161,9 @@ void Foam::fixedFluxPressureFvPatchScalarField::updateCoeffs()
void Foam::fixedFluxPressureFvPatchScalarField::write(Ostream& os) const void Foam::fixedFluxPressureFvPatchScalarField::write(Ostream& os) const
{ {
fvPatchScalarField::write(os); fvPatchScalarField::write(os);
if (UName_ != "U") writeEntryIfDifferent<word>(os, "U", "U", UName_);
{ writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl; writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
}
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; os.writeKeyword("adjoint") << adjoint_ << token::END_STATEMENT << nl;
gradient().writeEntry("gradient", os); gradient().writeEntry("gradient", os);
} }

View File

@ -45,7 +45,7 @@ fixedPressureCompressibleDensityFvPatchScalarField
) )
: :
fixedValueFvPatchField<scalar>(p, iF), fixedValueFvPatchField<scalar>(p, iF),
pName_("pNameIsUndefined") pName_("p")
{} {}
@ -72,7 +72,7 @@ fixedPressureCompressibleDensityFvPatchScalarField
) )
: :
fixedValueFvPatchField<scalar>(p, iF, dict), fixedValueFvPatchField<scalar>(p, iF, dict),
pName_(dict.lookup("p")) pName_(dict.lookupOrDefault<word>("p", "p"))
{} {}
@ -134,7 +134,7 @@ void fixedPressureCompressibleDensityFvPatchScalarField::write
) const ) const
{ {
fvPatchField<scalar>::write(os); fvPatchField<scalar>::write(os);
os.writeKeyword("p") << pName_ << token::END_STATEMENT << nl; writeEntryIfDifferent<word>(os, "p", "p", pName_);
writeEntry("value", os); writeEntry("value", os);
} }

View File

@ -143,14 +143,8 @@ void Foam::fluxCorrectedVelocityFvPatchVectorField::evaluate
void Foam::fluxCorrectedVelocityFvPatchVectorField::write(Ostream& os) const void Foam::fluxCorrectedVelocityFvPatchVectorField::write(Ostream& os) const
{ {
fvPatchVectorField::write(os); fvPatchVectorField::write(os);
if (phiName_ != "phi") writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
{ writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
}
if (rhoName_ != "rho")
{
os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
}
writeEntry("value", os); writeEntry("value", os);
} }

View File

@ -30,8 +30,6 @@ License
#include "volFields.H" #include "volFields.H"
#include "surfaceFields.H" #include "surfaceFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::inletOutletTotalTemperatureFvPatchScalarField:: Foam::inletOutletTotalTemperatureFvPatchScalarField::
@ -193,18 +191,9 @@ void Foam::inletOutletTotalTemperatureFvPatchScalarField::write(Ostream& os)
const const
{ {
fvPatchScalarField::write(os); fvPatchScalarField::write(os);
if (UName_ != "U") writeEntryIfDifferent<word>(os, "U", "U", UName_);
{ writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl; writeEntryIfDifferent<word>(os, "psi", "psi", psiName_);
}
if (phiName_ != "phi")
{
os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
}
if (phiName_ != "psi")
{
os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
}
os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl; os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
T0_.writeEntry("T0", os); T0_.writeEntry("T0", os);
writeEntry("value", os); writeEntry("value", os);

View File

@ -43,7 +43,8 @@ movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
const DimensionedField<vector, volMesh>& iF const DimensionedField<vector, volMesh>& iF
) )
: :
fixedValueFvPatchVectorField(p, iF) fixedValueFvPatchVectorField(p, iF),
UName_("U")
{} {}
@ -55,7 +56,8 @@ movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
const fvPatchFieldMapper& mapper const fvPatchFieldMapper& mapper
) )
: :
fixedValueFvPatchVectorField(ptf, p, iF, mapper) fixedValueFvPatchVectorField(ptf, p, iF, mapper),
UName_(ptf.UName_)
{} {}
@ -66,7 +68,8 @@ movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchVectorField(p, iF) fixedValueFvPatchVectorField(p, iF),
UName_(dict.lookupOrDefault<word>("U", "U"))
{ {
fvPatchVectorField::operator=(vectorField("value", dict, p.size())); fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
} }
@ -74,20 +77,22 @@ movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
( (
const movingWallVelocityFvPatchVectorField& pivpvf const movingWallVelocityFvPatchVectorField& mwvpvf
) )
: :
fixedValueFvPatchVectorField(pivpvf) fixedValueFvPatchVectorField(mwvpvf),
UName_(mwvpvf.UName_)
{} {}
movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
( (
const movingWallVelocityFvPatchVectorField& pivpvf, const movingWallVelocityFvPatchVectorField& mwvpvf,
const DimensionedField<vector, volMesh>& iF const DimensionedField<vector, volMesh>& iF
) )
: :
fixedValueFvPatchVectorField(pivpvf, iF) fixedValueFvPatchVectorField(mwvpvf, iF),
UName_(mwvpvf.UName_)
{} {}
@ -114,7 +119,7 @@ void movingWallVelocityFvPatchVectorField::updateCoeffs()
vectorField Up = (pp.faceCentres() - oldFc)/mesh.time().deltaTValue(); vectorField Up = (pp.faceCentres() - oldFc)/mesh.time().deltaTValue();
const volVectorField& U = db().lookupObject<volVectorField>("U"); const volVectorField& U = db().lookupObject<volVectorField>(UName_);
scalarField phip = scalarField phip =
p.patchField<surfaceScalarField, scalar>(fvc::meshPhi(U)); p.patchField<surfaceScalarField, scalar>(fvc::meshPhi(U));
@ -132,6 +137,7 @@ void movingWallVelocityFvPatchVectorField::updateCoeffs()
void movingWallVelocityFvPatchVectorField::write(Ostream& os) const void movingWallVelocityFvPatchVectorField::write(Ostream& os) const
{ {
fvPatchVectorField::write(os); fvPatchVectorField::write(os);
writeEntryIfDifferent<word>(os, "U", "U", UName_);
writeEntry("value", os); writeEntry("value", os);
} }

View File

@ -52,6 +52,11 @@ class movingWallVelocityFvPatchVectorField
: :
public fixedValueFvPatchVectorField public fixedValueFvPatchVectorField
{ {
// Private data
//- Name of velocity field
word UName_;
public: public:

View File

@ -196,14 +196,8 @@ void pressureDirectedInletOutletVelocityFvPatchVectorField::
write(Ostream& os) const write(Ostream& os) const
{ {
fvPatchVectorField::write(os); fvPatchVectorField::write(os);
if (phiName_ != "phi") writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
{ writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
}
if (rhoName_ != "rho")
{
os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
}
inletDir_.writeEntry("inletDirection", os); inletDir_.writeEntry("inletDirection", os);
writeEntry("value", os); writeEntry("value", os);
} }

View File

@ -184,14 +184,8 @@ void pressureDirectedInletVelocityFvPatchVectorField::updateCoeffs()
void pressureDirectedInletVelocityFvPatchVectorField::write(Ostream& os) const void pressureDirectedInletVelocityFvPatchVectorField::write(Ostream& os) const
{ {
fvPatchVectorField::write(os); fvPatchVectorField::write(os);
if (phiName_ != "phi") writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
{ writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
}
if (rhoName_ != "rho")
{
os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
}
inletDir_.writeEntry("inletDirection", os); inletDir_.writeEntry("inletDirection", os);
writeEntry("value", os); writeEntry("value", os);
} }

View File

@ -188,10 +188,7 @@ void pressureInletOutletVelocityFvPatchVectorField::updateCoeffs()
void pressureInletOutletVelocityFvPatchVectorField::write(Ostream& os) const void pressureInletOutletVelocityFvPatchVectorField::write(Ostream& os) const
{ {
fvPatchVectorField::write(os); fvPatchVectorField::write(os);
if (phiName_ != "phi") writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
{
os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
}
if (tangentialVelocity_.size()) if (tangentialVelocity_.size())
{ {
tangentialVelocity_.writeEntry("tangentialVelocity", os); tangentialVelocity_.writeEntry("tangentialVelocity", os);

View File

@ -146,14 +146,8 @@ void pressureInletVelocityFvPatchVectorField::updateCoeffs()
void pressureInletVelocityFvPatchVectorField::write(Ostream& os) const void pressureInletVelocityFvPatchVectorField::write(Ostream& os) const
{ {
fvPatchVectorField::write(os); fvPatchVectorField::write(os);
if (phiName_ != "phi") writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
{ writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
}
if (rhoName_ != "rho")
{
os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
}
writeEntry("value", os); writeEntry("value", os);
} }

View File

@ -218,14 +218,8 @@ void Foam::timeVaryingUniformTotalPressureFvPatchScalarField::
write(Ostream& os) const write(Ostream& os) const
{ {
fvPatchScalarField::write(os); fvPatchScalarField::write(os);
if (UName_ != "U") writeEntryIfDifferent<word>(os, "U", "U", UName_);
{ writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
}
if (phiName_ != "phi")
{
os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
}
os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
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;

View File

@ -30,8 +30,6 @@ License
#include "volFields.H" #include "volFields.H"
#include "surfaceFields.H" #include "surfaceFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField
@ -180,18 +178,9 @@ void Foam::totalTemperatureFvPatchScalarField::updateCoeffs()
void Foam::totalTemperatureFvPatchScalarField::write(Ostream& os) const void Foam::totalTemperatureFvPatchScalarField::write(Ostream& os) const
{ {
fvPatchScalarField::write(os); fvPatchScalarField::write(os);
if (UName_ != "U") writeEntryIfDifferent<word>(os, "U", "U", UName_);
{ writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl; writeEntryIfDifferent<word>(os, "psi", "psi", psiName_);
}
if (phiName_ != "phi")
{
os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
}
if (psiName_ != "psi")
{
os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
}
os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl; os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
T0_.writeEntry("T0", os); T0_.writeEntry("T0", os);
writeEntry("value", os); writeEntry("value", os);

View File

@ -40,6 +40,7 @@ turbulentIntensityKineticEnergyInletFvPatchScalarField
) )
: :
fixedValueFvPatchField<scalar>(p, iF), fixedValueFvPatchField<scalar>(p, iF),
UName_("U"),
intensity_(0.05) intensity_(0.05)
{} {}
@ -53,6 +54,7 @@ turbulentIntensityKineticEnergyInletFvPatchScalarField
) )
: :
fixedValueFvPatchField<scalar>(ptf, p, iF, mapper), fixedValueFvPatchField<scalar>(ptf, p, iF, mapper),
UName_(ptf.UName_),
intensity_(ptf.intensity_) intensity_(ptf.intensity_)
{} {}
@ -65,6 +67,7 @@ turbulentIntensityKineticEnergyInletFvPatchScalarField
) )
: :
fixedValueFvPatchField<scalar>(p, iF, dict), fixedValueFvPatchField<scalar>(p, iF, dict),
UName_(dict.lookupOrDefault<word>("U", "U")),
intensity_(readScalar(dict.lookup("intensity"))) intensity_(readScalar(dict.lookup("intensity")))
{ {
if (intensity_ < 0 || intensity_ > 1) if (intensity_ < 0 || intensity_ > 1)
@ -92,6 +95,7 @@ turbulentIntensityKineticEnergyInletFvPatchScalarField
) )
: :
fixedValueFvPatchField<scalar>(ptf), fixedValueFvPatchField<scalar>(ptf),
UName_(ptf.UName_),
intensity_(ptf.intensity_) intensity_(ptf.intensity_)
{} {}
@ -104,6 +108,7 @@ turbulentIntensityKineticEnergyInletFvPatchScalarField
) )
: :
fixedValueFvPatchField<scalar>(ptf, iF), fixedValueFvPatchField<scalar>(ptf, iF),
UName_(ptf.UName_),
intensity_(ptf.intensity_) intensity_(ptf.intensity_)
{} {}
@ -119,7 +124,7 @@ updateCoeffs()
} }
const fvPatchField<vector>& Up = const fvPatchField<vector>& Up =
patch().lookupPatchField<volVectorField, vector>("U"); patch().lookupPatchField<volVectorField, vector>(UName_);
operator==(1.5*sqr(intensity_)*magSqr(Up)); operator==(1.5*sqr(intensity_)*magSqr(Up));
@ -133,6 +138,7 @@ void Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField::write
) const ) const
{ {
fvPatchField<scalar>::write(os); fvPatchField<scalar>::write(os);
writeEntryIfDifferent<word>(os, "U", "U", UName_);
os.writeKeyword("intensity") << intensity_ << token::END_STATEMENT << nl; os.writeKeyword("intensity") << intensity_ << token::END_STATEMENT << nl;
writeEntry("value", os); writeEntry("value", os);
} }

View File

@ -34,6 +34,7 @@ Description
inlet inlet
{ {
type turbulentIntensityKineticEnergyInlet; type turbulentIntensityKineticEnergyInlet;
U U; // Name of U field (optional)
intensity 0.05; // 5% turbulence intensity 0.05; // 5% turbulence
value uniform 1; // placeholder value uniform 1; // placeholder
} }
@ -64,6 +65,9 @@ class turbulentIntensityKineticEnergyInletFvPatchScalarField
{ {
// Private data // Private data
//- Name of belocity field
word UName_;
//- Turbulent intensity as fraction of mean velocity //- Turbulent intensity as fraction of mean velocity
scalar intensity_; scalar intensity_;