From 74d1844d9e2cb3d65477082878e04de57b03c8d1 Mon Sep 17 00:00:00 2001
From: sergio <sergio>
Date: Mon, 25 Mar 2019 10:13:00 -0700
Subject: [PATCH] ENH: Adding Function1 functionality to rpm in
 swirlFanVelocityFvPatch

---
 .../swirlFanVelocityFvPatchField.C            | 26 ++++++++++++-------
 .../swirlFanVelocityFvPatchField.H            |  5 ++--
 2 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/src/finiteVolume/fields/fvPatchFields/derived/swirlFanVelocity/swirlFanVelocityFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/swirlFanVelocity/swirlFanVelocityFvPatchField.C
index 253541ae394..3d0c0f9fd22 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/swirlFanVelocity/swirlFanVelocityFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/swirlFanVelocity/swirlFanVelocityFvPatchField.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2018 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2018-2019 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -36,6 +36,8 @@ void Foam::swirlFanVelocityFvPatchField::calcFanJump()
 {
     if (this->cyclicPatch().owner())
     {
+        const scalar rpm = rpm_->value(this->db().time().timeOutputValue());
+
         const surfaceScalarField& phi =
             db().lookupObject<surfaceScalarField>(phiName_);
 
@@ -80,7 +82,7 @@ void Foam::swirlFanVelocityFvPatchField::calcFanJump()
                 if (rMag > rInner_ && rMag < rOuter_)
                 {
                     magTangU[i] =
-                        deltaP[i]/rMag/fanEff_/rpmToRads(rpm_);
+                        deltaP[i]/rMag/fanEff_/rpmToRads(rpm);
                 }
             }
         }
@@ -94,7 +96,7 @@ void Foam::swirlFanVelocityFvPatchField::calcFanJump()
                     << exit(FatalError);
             }
             magTangU =
-                deltaP/rEff_/fanEff_/rpmToRads(rpm_);
+                deltaP/rEff_/fanEff_/rpmToRads(rpm);
         }
 
         // Calculate the tangential velocity
@@ -119,7 +121,7 @@ Foam::swirlFanVelocityFvPatchField::swirlFanVelocityFvPatchField
     pName_("p"),
     rhoName_("rho"),
     origin_(),
-    rpm_(0.0),
+    rpm_(),
     rEff_(0.0),
     fanEff_(1.0),
     useRealRadius_(false),
@@ -149,7 +151,13 @@ Foam::swirlFanVelocityFvPatchField::swirlFanVelocityFvPatchField
           : Zero
         )
     ),
-    rpm_(dict.lookupOrDefault<scalar>("rpm", 0)),
+    rpm_
+    (
+        this->cyclicPatch().owner()
+      ? Function1<scalar>::New("rpm", dict)
+      : nullptr
+
+    ),
     rEff_(dict.lookupOrDefault<scalar>("rEff", 0)),
     fanEff_(dict.lookupOrDefault<scalar>("fanEff", 1)),
     useRealRadius_(dict.lookupOrDefault("useRealRadius", false)),
@@ -171,7 +179,7 @@ Foam::swirlFanVelocityFvPatchField::swirlFanVelocityFvPatchField
     pName_(ptf.pName_),
     rhoName_(ptf.rhoName_),
     origin_(ptf.origin_),
-    rpm_(ptf.rpm_),
+    rpm_(ptf.rpm_.clone()),
     rEff_(ptf.rEff_),
     fanEff_(ptf.fanEff_),
     useRealRadius_(ptf.useRealRadius_),
@@ -190,7 +198,7 @@ Foam::swirlFanVelocityFvPatchField::swirlFanVelocityFvPatchField
     pName_(ptf.pName_),
     rhoName_(ptf.rhoName_),
     origin_(ptf.origin_),
-    rpm_(ptf.rpm_),
+    rpm_(ptf.rpm_.clone()),
     rEff_(ptf.rEff_),
     useRealRadius_(ptf.useRealRadius_),
     rInner_(ptf.rInner_),
@@ -209,7 +217,7 @@ Foam::swirlFanVelocityFvPatchField::swirlFanVelocityFvPatchField
     pName_(ptf.pName_),
     rhoName_(ptf.rhoName_),
     origin_(ptf.origin_),
-    rpm_(ptf.rpm_),
+    rpm_(ptf.rpm_.clone()),
     rEff_(ptf.rEff_),
     useRealRadius_(ptf.useRealRadius_),
     rInner_(ptf.rInner_),
@@ -240,7 +248,7 @@ void Foam::swirlFanVelocityFvPatchField::write(Ostream& os) const
         os.writeEntryIfDifferent<word>("p", "p", pName_);
         os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
         os.writeEntry("origin", origin_);
-        os.writeEntry("rpm", rpm_);
+        rpm_->writeData(os);
 
         os.writeEntryIfDifferent<scalar>("rEff", 0.0, rEff_);
         os.writeEntryIfDifferent<bool>("useRealRadius", false, useRealRadius_);
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/swirlFanVelocity/swirlFanVelocityFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/swirlFanVelocity/swirlFanVelocityFvPatchField.H
index a9f6933258d..040aa515d4e 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/swirlFanVelocity/swirlFanVelocityFvPatchField.H
+++ b/src/finiteVolume/fields/fvPatchFields/derived/swirlFanVelocity/swirlFanVelocityFvPatchField.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2018 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2018-2019 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -103,6 +103,7 @@ SourceFiles
 #define swirlFanVelocityFvPatchField_H
 
 #include "fixedJumpFvPatchField.H"
+#include "Function1.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -132,7 +133,7 @@ class swirlFanVelocityFvPatchField
         const vector origin_;
 
         //- Fan rpm
-        scalar rpm_;
+        autoPtr<Function1<scalar>> rpm_;
 
         //- Effective fan radius
         scalar rEff_;
-- 
GitLab