From b6ac82315ca2a3f911026ae0895d0b8f02e01c8c Mon Sep 17 00:00:00 2001
From: Henry Weller <http://cfd.direct>
Date: Wed, 10 Feb 2016 09:46:37 +0000
Subject: [PATCH] variableHeightFlowRateInletVelocityFvPatchVectorField:
 Changed the flow-rate to a Function1 to support time-variation

---
 ...tFlowRateInletVelocityFvPatchVectorField.C | 42 +++++++++----------
 ...tFlowRateInletVelocityFvPatchVectorField.H | 23 +++-------
 2 files changed, 26 insertions(+), 39 deletions(-)

diff --git a/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.C
index 1fcc5feb7d..f0f3802339 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,7 +37,7 @@ Foam::variableHeightFlowRateInletVelocityFvPatchVectorField
 )
 :
     fixedValueFvPatchField<vector>(p, iF),
-    flowRate_(0),
+    flowRate_(),
     alphaName_("none")
 {}
 
@@ -47,29 +45,29 @@ Foam::variableHeightFlowRateInletVelocityFvPatchVectorField
 Foam::variableHeightFlowRateInletVelocityFvPatchVectorField
 ::variableHeightFlowRateInletVelocityFvPatchVectorField
 (
-    const variableHeightFlowRateInletVelocityFvPatchVectorField& ptf,
     const fvPatch& p,
     const DimensionedField<vector, volMesh>& iF,
-    const fvPatchFieldMapper& mapper
+    const dictionary& dict
 )
 :
-    fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
-    flowRate_(ptf.flowRate_),
-    alphaName_(ptf.alphaName_)
+    fixedValueFvPatchField<vector>(p, iF, dict),
+    flowRate_(Function1<scalar>::New("flowRate", dict)),
+    alphaName_(dict.lookup("alpha"))
 {}
 
 
 Foam::variableHeightFlowRateInletVelocityFvPatchVectorField
 ::variableHeightFlowRateInletVelocityFvPatchVectorField
 (
+    const variableHeightFlowRateInletVelocityFvPatchVectorField& ptf,
     const fvPatch& p,
     const DimensionedField<vector, volMesh>& iF,
-    const dictionary& dict
+    const fvPatchFieldMapper& mapper
 )
 :
-    fixedValueFvPatchField<vector>(p, iF, dict),
-    flowRate_(readScalar(dict.lookup("flowRate"))),
-    alphaName_(dict.lookup("alpha"))
+    fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
+    flowRate_(ptf.flowRate_, false),
+    alphaName_(ptf.alphaName_)
 {}
 
 
@@ -80,7 +78,7 @@ Foam::variableHeightFlowRateInletVelocityFvPatchVectorField
 )
 :
     fixedValueFvPatchField<vector>(ptf),
-    flowRate_(ptf.flowRate_),
+    flowRate_(ptf.flowRate_, false),
     alphaName_(ptf.alphaName_)
 {}
 
@@ -93,7 +91,7 @@ Foam::variableHeightFlowRateInletVelocityFvPatchVectorField
 )
 :
     fixedValueFvPatchField<vector>(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<vector>::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 34742c7567..eed9937029 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<Function1<scalar>> 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();
 
-- 
GitLab