From 1971c1eb88fcdb7c71a573c3eff0598e519d7cdc Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 28 May 2015 20:42:47 +0100 Subject: [PATCH] fvPatchFields: Support explicitly named U, phi and rho in all BCs Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1717 --- .../derived/fan/fanFvPatchField.H | 13 ++++- .../derived/fan/fanFvPatchFields.C | 8 ++- .../freestreamPressureFvPatchScalarField.C | 57 ++++++++++++------- .../freestreamPressureFvPatchScalarField.H | 21 ++++++- .../syringePressureFvPatchScalarField.C | 57 ++++++++++--------- .../syringePressureFvPatchScalarField.H | 3 + 6 files changed, 106 insertions(+), 53 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H index 218b4b1862..fd27dfecd3 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -40,6 +40,8 @@ Description Property | Description | Required | Default value patchType | underlying patch type should be \c cyclic| yes | jumpTable | jump data, e.g. \c csvFile | yes | + phi | flux field name | no | phi + rho | density field name | no | none \endtable Example of the boundary condition specification: @@ -98,6 +100,15 @@ class fanFvPatchField : public uniformJumpFvPatchField { + // Private data + + //- Name of the flux transporting the field + word phiName_; + + //- Name of the density field used to normalise the mass flux + // if neccessary + word rhoName_; + // Private Member Functions diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C index 40b0777386..ea9ecdea57 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C @@ -49,7 +49,7 @@ void Foam::fanFvPatchField::calcFanJump() if (this->cyclicPatch().owner()) { const surfaceScalarField& phi = - db().lookupObject("phi"); + db().lookupObject(phiName_); const fvsPatchField& phip = patch().patchField(phi); @@ -58,7 +58,7 @@ void Foam::fanFvPatchField::calcFanJump() if (phi.dimensions() == dimDensity*dimVelocity*dimArea) { - Un /= patch().lookupPatchField("rho"); + Un /= patch().lookupPatchField(rhoName_); } this->jump_ = max(this->jumpTable_->value(Un), scalar(0)); @@ -76,7 +76,9 @@ Foam::fanFvPatchField::fanFvPatchField const dictionary& dict ) : - uniformJumpFvPatchField(p, iF) + uniformJumpFvPatchField(p, iF), + phiName_(dict.lookupOrDefault("phi", "phi")), + rhoName_(dict.lookupOrDefault("rho", "none")) { if (this->cyclicPatch().owner()) { diff --git a/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.C index b266b78a69..c2f272244c 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -30,8 +30,6 @@ License #include "surfaceFields.H" #include "addToRunTimeSelectionTable.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::freestreamPressureFvPatchScalarField:: @@ -41,7 +39,25 @@ freestreamPressureFvPatchScalarField const DimensionedField& iF ) : - zeroGradientFvPatchScalarField(p, iF) + zeroGradientFvPatchScalarField(p, iF), + UName_("U"), + phiName_("phi"), + rhoName_("none") +{} + + +Foam::freestreamPressureFvPatchScalarField:: +freestreamPressureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + zeroGradientFvPatchScalarField(p, iF, dict), + UName_(dict.lookupOrDefault("U", "U")), + phiName_(dict.lookupOrDefault("phi", "phi")), + rhoName_(dict.lookupOrDefault("rho", "none")) {} @@ -54,19 +70,10 @@ freestreamPressureFvPatchScalarField const fvPatchFieldMapper& mapper ) : - zeroGradientFvPatchScalarField(ptf, p, iF, mapper) -{} - - -Foam::freestreamPressureFvPatchScalarField:: -freestreamPressureFvPatchScalarField -( - const fvPatch& p, - const DimensionedField& iF, - const dictionary& dict -) -: - zeroGradientFvPatchScalarField(p, iF, dict) + zeroGradientFvPatchScalarField(ptf, p, iF, mapper), + UName_(ptf.UName_), + phiName_(ptf.phiName_), + rhoName_(ptf.rhoName_) {} @@ -76,7 +83,10 @@ freestreamPressureFvPatchScalarField const freestreamPressureFvPatchScalarField& wbppsf ) : - zeroGradientFvPatchScalarField(wbppsf) + zeroGradientFvPatchScalarField(wbppsf), + UName_(wbppsf.UName_), + phiName_(wbppsf.phiName_), + rhoName_(wbppsf.rhoName_) {} @@ -87,7 +97,10 @@ freestreamPressureFvPatchScalarField const DimensionedField& iF ) : - zeroGradientFvPatchScalarField(wbppsf, iF) + zeroGradientFvPatchScalarField(wbppsf, iF), + UName_(wbppsf.UName_), + phiName_(wbppsf.phiName_), + rhoName_(wbppsf.rhoName_) {} @@ -103,11 +116,11 @@ void Foam::freestreamPressureFvPatchScalarField::updateCoeffs() const freestreamFvPatchVectorField& Up = refCast ( - patch().lookupPatchField("U") + patch().lookupPatchField(UName_) ); const surfaceScalarField& phi = - db().lookupObject("phi"); + db().lookupObject(phiName_); fvsPatchField& phip = const_cast&> @@ -122,7 +135,7 @@ void Foam::freestreamPressureFvPatchScalarField::updateCoeffs() else if (phi.dimensions() == dimDensity*dimVelocity*dimArea) { const fvPatchField& rhop = - patch().lookupPatchField("rho"); + patch().lookupPatchField(rhoName_); phip = rhop*(patch().Sf() & Up.freestreamValue()); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.H index fa5233308c..4d8c5d1807 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -34,6 +34,13 @@ Description \heading Patch usage + \table + Property | Description | Required | Default value + U | velocity field name | no | U + phi | flux field name | no | phi + rho | density field name | no | none + \endtable + Example of the boundary condition specification: \verbatim myPatch @@ -73,6 +80,18 @@ class freestreamPressureFvPatchScalarField : public zeroGradientFvPatchScalarField { + // Private data + + //- Name of the velocity field + word UName_; + + //- Name of the flux transporting the field + word phiName_; + + //- Name of the density field used to normalise the mass flux + // if neccessary + word rhoName_; + public: diff --git a/src/finiteVolume/fields/fvPatchFields/derived/syringePressure/syringePressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/syringePressure/syringePressureFvPatchScalarField.C index 116de777b4..3318c15dd6 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/syringePressure/syringePressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/syringePressure/syringePressureFvPatchScalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -38,30 +38,7 @@ Foam::syringePressureFvPatchScalarField::syringePressureFvPatchScalarField ) : fixedValueFvPatchScalarField(p, iF), - curTimeIndex_(-1) -{} - - -Foam::syringePressureFvPatchScalarField::syringePressureFvPatchScalarField -( - const syringePressureFvPatchScalarField& sppsf, - const fvPatch& p, - const DimensionedField& iF, - const fvPatchFieldMapper& mapper -) -: - fixedValueFvPatchScalarField(sppsf, p, iF, mapper), - Ap_(sppsf.Ap_), - Sp_(sppsf.Sp_), - VsI_(sppsf.VsI_), - tas_(sppsf.tas_), - tae_(sppsf.tae_), - tds_(sppsf.tds_), - tde_(sppsf.tde_), - psI_(sppsf.psI_), - psi_(sppsf.psi_), - ams_(sppsf.ams_), - ams0_(sppsf.ams0_), + phiName_("phi"), curTimeIndex_(-1) {} @@ -85,6 +62,7 @@ Foam::syringePressureFvPatchScalarField::syringePressureFvPatchScalarField psi_(readScalar(dict.lookup("psi"))), ams_(readScalar(dict.lookup("ams"))), ams0_(ams_), + phiName_(dict.lookupOrDefault("phi", "phi")), curTimeIndex_(-1) { scalar ps = (psI_*VsI_ + ams_/psi_)/Vs(db().time().value()); @@ -92,6 +70,31 @@ Foam::syringePressureFvPatchScalarField::syringePressureFvPatchScalarField } +Foam::syringePressureFvPatchScalarField::syringePressureFvPatchScalarField +( + const syringePressureFvPatchScalarField& sppsf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(sppsf, p, iF, mapper), + Ap_(sppsf.Ap_), + Sp_(sppsf.Sp_), + VsI_(sppsf.VsI_), + tas_(sppsf.tas_), + tae_(sppsf.tae_), + tds_(sppsf.tds_), + tde_(sppsf.tde_), + psI_(sppsf.psI_), + psi_(sppsf.psi_), + ams_(sppsf.ams_), + ams0_(sppsf.ams0_), + phiName_(sppsf.phiName_), + curTimeIndex_(-1) +{} + + Foam::syringePressureFvPatchScalarField::syringePressureFvPatchScalarField ( const syringePressureFvPatchScalarField& sppsf, @@ -110,6 +113,7 @@ Foam::syringePressureFvPatchScalarField::syringePressureFvPatchScalarField psi_(sppsf.psi_), ams_(sppsf.ams_), ams0_(sppsf.ams0_), + phiName_(sppsf.phiName_), curTimeIndex_(-1) {} @@ -131,6 +135,7 @@ Foam::syringePressureFvPatchScalarField::syringePressureFvPatchScalarField psi_(sppsf.psi_), ams_(sppsf.ams_), ams0_(sppsf.ams0_), + phiName_(sppsf.phiName_), curTimeIndex_(-1) {} @@ -193,7 +198,7 @@ void Foam::syringePressureFvPatchScalarField::updateCoeffs() scalar deltaT = db().time().deltaTValue(); const surfaceScalarField& phi = - db().lookupObject("phi"); + db().lookupObject(phiName_); const fvsPatchField& phip = patch().patchField(phi); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/syringePressure/syringePressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/syringePressure/syringePressureFvPatchScalarField.H index 3fb31d25b0..9182037a7e 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/syringePressure/syringePressureFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/syringePressure/syringePressureFvPatchScalarField.H @@ -133,6 +133,9 @@ class syringePressureFvPatchScalarField //- Added gas mass at previous time step scalar ams0_; + //- Name of the flux transporting the field + word phiName_; + //- Current time index used to store ms0_ label curTimeIndex_;