diff --git a/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.C index 1fcc5feb7..f0f380233 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,10 +24,8 @@ License \*---------------------------------------------------------------------------*/ #include "variableHeightFlowRateInletVelocityFvPatchVectorField.H" -#include "volFields.H" #include "addToRunTimeSelectionTable.H" -#include "fvPatchFieldMapper.H" -#include "surfaceFields.H" +#include "volFields.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -39,11 +37,25 @@ Foam::variableHeightFlowRateInletVelocityFvPatchVectorField ) : fixedValueFvPatchField(p, iF), - flowRate_(0), + flowRate_(), alphaName_("none") {} +Foam::variableHeightFlowRateInletVelocityFvPatchVectorField +::variableHeightFlowRateInletVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchField(p, iF, dict), + flowRate_(Function1::New("flowRate", dict)), + alphaName_(dict.lookup("alpha")) +{} + + Foam::variableHeightFlowRateInletVelocityFvPatchVectorField ::variableHeightFlowRateInletVelocityFvPatchVectorField ( @@ -54,25 +66,11 @@ Foam::variableHeightFlowRateInletVelocityFvPatchVectorField ) : fixedValueFvPatchField(ptf, p, iF, mapper), - flowRate_(ptf.flowRate_), + flowRate_(ptf.flowRate_, false), alphaName_(ptf.alphaName_) {} -Foam::variableHeightFlowRateInletVelocityFvPatchVectorField -::variableHeightFlowRateInletVelocityFvPatchVectorField -( - const fvPatch& p, - const DimensionedField& iF, - const dictionary& dict -) -: - fixedValueFvPatchField(p, iF, dict), - flowRate_(readScalar(dict.lookup("flowRate"))), - alphaName_(dict.lookup("alpha")) -{} - - Foam::variableHeightFlowRateInletVelocityFvPatchVectorField ::variableHeightFlowRateInletVelocityFvPatchVectorField ( @@ -80,7 +78,7 @@ Foam::variableHeightFlowRateInletVelocityFvPatchVectorField ) : fixedValueFvPatchField(ptf), - flowRate_(ptf.flowRate_), + flowRate_(ptf.flowRate_, false), alphaName_(ptf.alphaName_) {} @@ -93,7 +91,7 @@ Foam::variableHeightFlowRateInletVelocityFvPatchVectorField ) : fixedValueFvPatchField(ptf, iF), - flowRate_(ptf.flowRate_), + flowRate_(ptf.flowRate_, false), alphaName_(ptf.alphaName_) {} @@ -114,8 +112,11 @@ void Foam::variableHeightFlowRateInletVelocityFvPatchVectorField alphap = max(alphap, scalar(0)); alphap = min(alphap, scalar(1)); + const scalar t = db().time().timeOutputValue(); + scalar flowRate = flowRate_->value(t); + // a simpler way of doing this would be nice - scalar avgU = -flowRate_/gSum(patch().magSf()*alphap); + scalar avgU = -flowRate/gSum(patch().magSf()*alphap); vectorField n(patch().nf()); @@ -131,11 +132,8 @@ void Foam::variableHeightFlowRateInletVelocityFvPatchVectorField::write ) const { fvPatchField::write(os); - - os.writeKeyword("flowRate") << flowRate_ - << token::END_STATEMENT << nl; - os.writeKeyword("alpha") << alphaName_ - << token::END_STATEMENT << nl; + flowRate_->writeData(os); + os.writeKeyword("alpha") << alphaName_ << token::END_STATEMENT << nl; writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.H index 34742c756..eed993702 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.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-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -53,6 +53,8 @@ Description } \endverbatim + The \c flowRate entry is a \c Function1 of time, see Foam::Function1Types. + Note - the value is positive into the domain - may not work correctly for transonic inlets @@ -61,6 +63,7 @@ Note SeeAlso Foam::fixedValueFvPatchField + Foam::Function1Types SourceFiles variableHeightFlowRateInletVelocityFvPatchVectorField.C @@ -71,6 +74,7 @@ SourceFiles #define variableHeightFlowRateInletVelocityFvPatchVectorField_H #include "fixedValueFvPatchFields.H" +#include "Function1.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -87,7 +91,7 @@ class variableHeightFlowRateInletVelocityFvPatchVectorField // Private data //- Inlet integral flow rate - scalar flowRate_; + autoPtr> flowRate_; //- Name of the phase-fraction field word alphaName_; @@ -168,21 +172,6 @@ public: // Member functions - // Access - - //- Return the flux - scalar flowRate() const - { - return flowRate_; - } - - //- Return reference to the flux to allow adjustment - scalar& flowRate() - { - return flowRate_; - } - - //- Update the coefficients associated with the patch field virtual void updateCoeffs();