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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -43,7 +43,8 @@ movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
const DimensionedField<vector, volMesh>& iF
)
:
fixedValueFvPatchVectorField(p, iF)
fixedValueFvPatchVectorField(p, iF),
UName_("U")
{}
@ -55,7 +56,8 @@ movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
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
)
:
fixedValueFvPatchVectorField(p, iF)
fixedValueFvPatchVectorField(p, iF),
UName_(dict.lookupOrDefault<word>("U", "U"))
{
fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
}
@ -74,20 +77,22 @@ movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
(
const movingWallVelocityFvPatchVectorField& pivpvf
const movingWallVelocityFvPatchVectorField& mwvpvf
)
:
fixedValueFvPatchVectorField(pivpvf)
fixedValueFvPatchVectorField(mwvpvf),
UName_(mwvpvf.UName_)
{}
movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
(
const movingWallVelocityFvPatchVectorField& pivpvf,
const movingWallVelocityFvPatchVectorField& mwvpvf,
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();
const volVectorField& U = db().lookupObject<volVectorField>("U");
const volVectorField& U = db().lookupObject<volVectorField>(UName_);
scalarField phip =
p.patchField<surfaceScalarField, scalar>(fvc::meshPhi(U));
@ -132,6 +137,7 @@ void movingWallVelocityFvPatchVectorField::updateCoeffs()
void movingWallVelocityFvPatchVectorField::write(Ostream& os) const
{
fvPatchVectorField::write(os);
writeEntryIfDifferent<word>(os, "U", "U", UName_);
writeEntry("value", os);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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