diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 3fa33b7e20..7928295d99 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -156,7 +156,7 @@ $(derivedFvPatchFields)/turbulentIntensityKineticEnergyInlet/turbulentIntensityK $(derivedFvPatchFields)/uniformFixedValue/uniformFixedValueFvPatchFields.C $(derivedFvPatchFields)/waveTransmissive/waveTransmissiveFvPatchFields.C $(derivedFvPatchFields)/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.C -$(derivedFvPatchFields)/swirlMassFlowRateInletVelocity/swirlMassFlowRateInletVelocityFvPatchVectorField.C +$(derivedFvPatchFields)/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.C fvsPatchFields = fields/fvsPatchFields $(fvsPatchFields)/fvsPatchField/fvsPatchFields.C diff --git a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C index 489b82927f..a0684b9618 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C @@ -118,9 +118,9 @@ void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs() } // a simpler way of doing this would be nice - scalar avgU = -flowRate_/gSum(patch().magSf()); + const scalar avgU = -flowRate_/gSum(patch().magSf()); - vectorField n = patch().nf(); + tmp n = patch().nf(); const surfaceScalarField& phi = db().lookupObject(phiName_); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.H index f86fdbe29a..690c7160b0 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.H @@ -37,9 +37,9 @@ Description @verbatim inlet { - type flowRateInletVelocity; - flowRate 0.2; // Volumetric/mass flow rate [m3/s or kg/s] - value uniform (0 0 0); // placeholder + type flowRateInletVelocity; + flowRate 0.2; // Volumetric/mass flow rate [m3/s or kg/s] + value uniform (0 0 0); // placeholder } @endverbatim diff --git a/src/finiteVolume/fields/fvPatchFields/derived/swirlMassFlowRateInletVelocity/swirlMassFlowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.C similarity index 71% rename from src/finiteVolume/fields/fvPatchFields/derived/swirlMassFlowRateInletVelocity/swirlMassFlowRateInletVelocityFvPatchVectorField.C rename to src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.C index 44a2239dca..7114dc1d26 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/swirlMassFlowRateInletVelocity/swirlMassFlowRateInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.C @@ -23,7 +23,7 @@ License \*---------------------------------------------------------------------------*/ -#include "swirlMassFlowRateInletVelocityFvPatchVectorField.H" +#include "swirlFlowRateInletVelocityFvPatchVectorField.H" #include "volFields.H" #include "addToRunTimeSelectionTable.H" #include "fvPatchFieldMapper.H" @@ -33,8 +33,8 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam:: -swirlMassFlowRateInletVelocityFvPatchVectorField:: -swirlMassFlowRateInletVelocityFvPatchVectorField +swirlFlowRateInletVelocityFvPatchVectorField:: +swirlFlowRateInletVelocityFvPatchVectorField ( const fvPatch& p, const DimensionedField& iF @@ -49,10 +49,10 @@ swirlMassFlowRateInletVelocityFvPatchVectorField Foam:: -swirlMassFlowRateInletVelocityFvPatchVectorField:: -swirlMassFlowRateInletVelocityFvPatchVectorField +swirlFlowRateInletVelocityFvPatchVectorField:: +swirlFlowRateInletVelocityFvPatchVectorField ( - const swirlMassFlowRateInletVelocityFvPatchVectorField& ptf, + const swirlFlowRateInletVelocityFvPatchVectorField& ptf, const fvPatch& p, const DimensionedField& iF, const fvPatchFieldMapper& mapper @@ -66,8 +66,8 @@ swirlMassFlowRateInletVelocityFvPatchVectorField Foam:: -swirlMassFlowRateInletVelocityFvPatchVectorField:: -swirlMassFlowRateInletVelocityFvPatchVectorField +swirlFlowRateInletVelocityFvPatchVectorField:: +swirlFlowRateInletVelocityFvPatchVectorField ( const fvPatch& p, const DimensionedField& iF, @@ -83,10 +83,10 @@ swirlMassFlowRateInletVelocityFvPatchVectorField Foam:: -swirlMassFlowRateInletVelocityFvPatchVectorField:: -swirlMassFlowRateInletVelocityFvPatchVectorField +swirlFlowRateInletVelocityFvPatchVectorField:: +swirlFlowRateInletVelocityFvPatchVectorField ( - const swirlMassFlowRateInletVelocityFvPatchVectorField& ptf + const swirlFlowRateInletVelocityFvPatchVectorField& ptf ) : fixedValueFvPatchField(ptf), @@ -98,10 +98,10 @@ swirlMassFlowRateInletVelocityFvPatchVectorField Foam:: -swirlMassFlowRateInletVelocityFvPatchVectorField:: -swirlMassFlowRateInletVelocityFvPatchVectorField +swirlFlowRateInletVelocityFvPatchVectorField:: +swirlFlowRateInletVelocityFvPatchVectorField ( - const swirlMassFlowRateInletVelocityFvPatchVectorField& ptf, + const swirlFlowRateInletVelocityFvPatchVectorField& ptf, const DimensionedField& iF ) : @@ -115,25 +115,28 @@ swirlMassFlowRateInletVelocityFvPatchVectorField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::swirlMassFlowRateInletVelocityFvPatchVectorField::updateCoeffs() +void Foam::swirlFlowRateInletVelocityFvPatchVectorField::updateCoeffs() { if (updated()) { return; } - scalar totArea = gSum(patch().magSf()); + const scalar totArea = gSum(patch().magSf()); // a simpler way of doing this would be nice - scalar avgU = -flowRate_/totArea; + const scalar avgU = -flowRate_/totArea; - vector center = gSum(patch().Cf()*patch().magSf())/totArea; - vector normal = gSum(patch().nf()*patch().magSf())/totArea; + const vector avgCenter = gSum(patch().Cf()*patch().magSf())/totArea; + const vector avgNormal = gSum(patch().Sf())/totArea; - vectorField tangVelo = + // Update angular velocity - convert [rpm] to [rad/s] + vectorField tangentialVelocity = + ( (rpm_*constant::mathematical::pi/30.0) - *(patch().Cf() - center) ^ normal; + * (patch().Cf() - avgCenter) ^ avgNormal + ); - vectorField n = patch().nf(); + tmp n = patch().nf(); const surfaceScalarField& phi = db().lookupObject(phiName_); @@ -141,7 +144,7 @@ void Foam::swirlMassFlowRateInletVelocityFvPatchVectorField::updateCoeffs() if (phi.dimensions() == dimVelocity*dimArea) { // volumetric flow-rate - operator==(tangVelo + n*avgU); + operator==(tangentialVelocity + n*avgU); } else if (phi.dimensions() == dimDensity*dimVelocity*dimArea) { @@ -149,13 +152,13 @@ void Foam::swirlMassFlowRateInletVelocityFvPatchVectorField::updateCoeffs() patch().lookupPatchField(rhoName_); // mass flow-rate - operator==(tangVelo + n*avgU/rhop); + operator==(tangentialVelocity + n*avgU/rhop); } else { FatalErrorIn ( - "swirlMassFlowRateInletVelocityFvPatchVectorField::updateCoeffs()" + "swirlFlowRateInletVelocityFvPatchVectorField::updateCoeffs()" ) << "dimensions of " << phiName_ << " are incorrect" << nl << " on patch " << this->patch().name() << " of field " << this->dimensionedInternalField().name() @@ -167,18 +170,15 @@ void Foam::swirlMassFlowRateInletVelocityFvPatchVectorField::updateCoeffs() } -void Foam::swirlMassFlowRateInletVelocityFvPatchVectorField::write(Ostream& os) const +void Foam::swirlFlowRateInletVelocityFvPatchVectorField::write +( + Ostream& os +) const { fvPatchField::write(os); 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; - } + writeEntryIfDifferent(os, "phi", "phi", phiName_); + writeEntryIfDifferent(os, "rho", "rho", rhoName_); os.writeKeyword("rpm") << rpm_ << token::END_STATEMENT << nl; writeEntry("value", os); } @@ -191,7 +191,7 @@ namespace Foam makePatchTypeField ( fvPatchVectorField, - swirlMassFlowRateInletVelocityFvPatchVectorField + swirlFlowRateInletVelocityFvPatchVectorField ); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/swirlMassFlowRateInletVelocity/swirlMassFlowRateInletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.H similarity index 70% rename from src/finiteVolume/fields/fvPatchFields/derived/swirlMassFlowRateInletVelocity/swirlMassFlowRateInletVelocityFvPatchVectorField.H rename to src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.H index 0ea56eb798..4576f39c6c 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/swirlMassFlowRateInletVelocity/swirlMassFlowRateInletVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.H @@ -22,11 +22,11 @@ License along with OpenFOAM. If not, see . Class - Foam::swirlMassFlowRateInletVelocityFvPatchVectorField + Foam::swirlFlowRateInletVelocityFvPatchVectorField Description Describes a volumetric/mass flow normal vector boundary condition by its - magnitude as an integral over its area with a swirl component determined + magnitude as an integral over its area, with a swirl component determined by the RPM The basis of the patch (volumetric or mass) is determined by the @@ -38,22 +38,30 @@ Description @verbatim inlet { - type swirlMassFlowRateInletVelocity; - flowRate 0.2; // Volumetric/mass flow rate [m3/s or kg/s] - rpm 100; + type swirlFlowRateInletVelocity; + flowRate 0.2; // Volumetric/mass flow rate [m3/s or kg/s] + rpm 100; + value uniform (0 0 0); // placeholder } @endverbatim Note - The value is positive inwards + - May not work correctly for transonic inlets + - Swirl is defined in RPM about the patch centre-axis according + to a right-hand rule (inwards axis). + - Primarily useful for planar patches. + +See Also + Foam::flowRateInletVelocityFvPatchVectorField SourceFiles - swirlMassFlowRateInletVelocityFvPatchVectorField.C + swirlFlowRateInletVelocityFvPatchVectorField.C \*---------------------------------------------------------------------------*/ -#ifndef swirlMassFlowRateInletVelocityFvPatchVectorField_H -#define swirlMassFlowRateInletVelocityFvPatchVectorField_H +#ifndef swirlFlowRateInletVelocityFvPatchVectorField_H +#define swirlFlowRateInletVelocityFvPatchVectorField_H #include "fixedValueFvPatchFields.H" @@ -62,10 +70,10 @@ SourceFiles namespace Foam { /*---------------------------------------------------------------------------*\ - Class swirlMassFlowRateInletVelocityFvPatchVectorField Declaration + Class swirlFlowRateInletVelocityFvPatchVectorField Declaration \*---------------------------------------------------------------------------*/ -class swirlMassFlowRateInletVelocityFvPatchVectorField +class swirlFlowRateInletVelocityFvPatchVectorField : public fixedValueFvPatchVectorField { @@ -80,27 +88,27 @@ class swirlMassFlowRateInletVelocityFvPatchVectorField //- Name of the density field used to normalize the mass flux word rhoName_; - //- RPM + //- Swirl rate [rpm] scalar rpm_; public: //- Runtime type information - TypeName("swirlMassFlowRateInletVelocity"); + TypeName("swirlFlowRateInletVelocity"); // Constructors //- Construct from patch and internal field - swirlMassFlowRateInletVelocityFvPatchVectorField + swirlFlowRateInletVelocityFvPatchVectorField ( const fvPatch&, const DimensionedField& ); //- Construct from patch, internal field and dictionary - swirlMassFlowRateInletVelocityFvPatchVectorField + swirlFlowRateInletVelocityFvPatchVectorField ( const fvPatch&, const DimensionedField&, @@ -110,18 +118,18 @@ public: //- Construct by mapping given // flowRateInletVelocityFvPatchVectorField // onto a new patch - swirlMassFlowRateInletVelocityFvPatchVectorField + swirlFlowRateInletVelocityFvPatchVectorField ( - const swirlMassFlowRateInletVelocityFvPatchVectorField&, + const swirlFlowRateInletVelocityFvPatchVectorField&, const fvPatch&, const DimensionedField&, const fvPatchFieldMapper& ); //- Construct as copy - swirlMassFlowRateInletVelocityFvPatchVectorField + swirlFlowRateInletVelocityFvPatchVectorField ( - const swirlMassFlowRateInletVelocityFvPatchVectorField& + const swirlFlowRateInletVelocityFvPatchVectorField& ); //- Construct and return a clone @@ -129,14 +137,14 @@ public: { return tmp ( - new swirlMassFlowRateInletVelocityFvPatchVectorField(*this) + new swirlFlowRateInletVelocityFvPatchVectorField(*this) ); } //- Construct as copy setting internal field reference - swirlMassFlowRateInletVelocityFvPatchVectorField + swirlFlowRateInletVelocityFvPatchVectorField ( - const swirlMassFlowRateInletVelocityFvPatchVectorField&, + const swirlFlowRateInletVelocityFvPatchVectorField&, const DimensionedField& ); @@ -148,7 +156,7 @@ public: { return tmp ( - new swirlMassFlowRateInletVelocityFvPatchVectorField(*this, iF) + new swirlFlowRateInletVelocityFvPatchVectorField(*this, iF) ); } @@ -169,6 +177,18 @@ public: return flowRate_; } + //- Return the swirl rpm + scalar rpm() const + { + return rpm_; + } + + //- Return reference to the swirl rpm to allow adjustment + scalar& rpm() + { + return rpm_; + } + //- Update the coefficients associated with the patch field virtual void updateCoeffs();