From 3b6eb380d0f4e2bc2e06ffa21fa82d62eff81abd Mon Sep 17 00:00:00 2001
From: Henry Weller <http://openfoam.org>
Date: Tue, 8 Aug 2017 10:16:08 +0100
Subject: [PATCH] Function1: Optimized field evaluations

---
 src/OpenFOAM/Make/files                       |  2 +-
 .../primitives/functions/Function1/CSV/CSV.H  |  6 --
 .../functions/Function1/Constant/Constant.C   | 15 +++--
 .../functions/Function1/Constant/Constant.H   | 24 ++++++-
 .../functions/Function1/Constant/ConstantI.H  | 48 ++++++++++++++
 .../functions/Function1/Function1/Function1.C | 39 +++++++++--
 .../functions/Function1/Function1/Function1.H | 65 +++++++++++++++++--
 .../functions/Function1/One/OneConstant.C     | 13 ++--
 .../functions/Function1/One/OneConstant.H     | 16 ++++-
 .../functions/Function1/One/OneConstantI.H    | 48 ++++++++++++++
 .../PolynomialEntry/PolynomialEntry.H         | 12 +---
 .../functions/Function1/Scale/Scale.C         |  7 --
 .../functions/Function1/Scale/Scale.H         | 10 +--
 .../functions/Function1/Scale/ScaleI.H        | 37 +++++++++++
 .../functions/Function1/Sine/Sine.C           | 12 ----
 .../functions/Function1/Sine/Sine.H           | 10 +--
 .../functions/Function1/Sine/SineI.H          | 42 ++++++++++++
 .../functions/Function1/Square/Square.C       | 23 -------
 .../functions/Function1/Square/Square.H       | 10 +--
 .../functions/Function1/Square/SquareI.H      | 53 +++++++++++++++
 .../functions/Function1/Table/Table.H         |  6 --
 .../functions/Function1/TableFile/TableFile.H |  6 --
 .../functions/Function1/Zero/ZeroConstant.C   | 18 -----
 .../functions/Function1/Zero/ZeroConstant.H   | 12 ++--
 .../functions/Function1/Zero/ZeroConstantI.H  | 51 +++++++++++++++
 .../Function1/halfCosineRamp/halfCosineRamp.C |  9 ---
 .../Function1/halfCosineRamp/halfCosineRamp.H | 12 ++--
 .../halfCosineRamp/halfCosineRampI.H          | 40 ++++++++++++
 .../Function1/linearRamp/linearRamp.C         |  8 ---
 .../Function1/linearRamp/linearRamp.H         | 12 ++--
 .../Function1/linearRamp/linearRampI.H        | 39 +++++++++++
 .../{makeDataEntries.C => makeFunction1s.C}   | 15 ++++-
 .../Function1/quadraticRamp/quadraticRamp.C   |  8 ---
 .../Function1/quadraticRamp/quadraticRamp.H   | 12 ++--
 .../Function1/quadraticRamp/quadraticRampI.H  | 39 +++++++++++
 .../quarterCosineRamp/quarterCosineRamp.C     | 12 ----
 .../quarterCosineRamp/quarterCosineRamp.H     | 12 ++--
 .../quarterCosineRamp/quarterCosineRampI.H    | 40 ++++++++++++
 .../quarterSineRamp/quarterSineRamp.C         |  9 ---
 .../quarterSineRamp/quarterSineRamp.H         | 12 ++--
 .../quarterSineRamp/quarterSineRampI.H        | 40 ++++++++++++
 .../functions/Function1/ramp/ramp.H           |  2 +-
 .../derived/fan/fanFvPatchFields.C            | 36 +---------
 43 files changed, 677 insertions(+), 265 deletions(-)
 create mode 100644 src/OpenFOAM/primitives/functions/Function1/Constant/ConstantI.H
 create mode 100644 src/OpenFOAM/primitives/functions/Function1/One/OneConstantI.H
 create mode 100644 src/OpenFOAM/primitives/functions/Function1/Scale/ScaleI.H
 create mode 100644 src/OpenFOAM/primitives/functions/Function1/Sine/SineI.H
 create mode 100644 src/OpenFOAM/primitives/functions/Function1/Square/SquareI.H
 create mode 100644 src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstantI.H
 create mode 100644 src/OpenFOAM/primitives/functions/Function1/halfCosineRamp/halfCosineRampI.H
 create mode 100644 src/OpenFOAM/primitives/functions/Function1/linearRamp/linearRampI.H
 rename src/OpenFOAM/primitives/functions/Function1/{makeDataEntries.C => makeFunction1s.C} (91%)
 create mode 100644 src/OpenFOAM/primitives/functions/Function1/quadraticRamp/quadraticRampI.H
 create mode 100644 src/OpenFOAM/primitives/functions/Function1/quarterCosineRamp/quarterCosineRampI.H
 create mode 100644 src/OpenFOAM/primitives/functions/Function1/quarterSineRamp/quarterSineRampI.H

diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files
index 46a3c7db22d..ac475a06fee 100644
--- a/src/OpenFOAM/Make/files
+++ b/src/OpenFOAM/Make/files
@@ -89,7 +89,7 @@ primitives/septernion/septernion.C
 primitives/triad/triad.C
 
 /* Run-time selectable functions */
-primitives/functions/Function1/makeDataEntries.C
+primitives/functions/Function1/makeFunction1s.C
 primitives/functions/Function1/ramp/ramp.C
 primitives/functions/Function1/linearRamp/linearRamp.C
 primitives/functions/Function1/quadraticRamp/quadraticRamp.C
diff --git a/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.H b/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.H
index fe427300c2f..42633d1d7dd 100644
--- a/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.H
+++ b/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.H
@@ -127,12 +127,6 @@ public:
         //- Copy constructor
         CSV(const CSV<Type>& tbl);
 
-        //- Construct and return a clone
-        virtual tmp<Function1<Type>> clone() const
-        {
-            return tmp<Function1<Type>>(new CSV<Type>(*this));
-        }
-
 
     //- Destructor
     virtual ~CSV();
diff --git a/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.C b/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.C
index 883a05d00a0..d72e0c0de74 100644
--- a/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.C
+++ b/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
      \\/     M anipulation  | Copyright (C) 2015 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
@@ -85,17 +85,20 @@ Foam::Function1Types::Constant<Type>::~Constant()
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 template<class Type>
-Type Foam::Function1Types::Constant<Type>::value(const scalar x) const
+Foam::tmp<Foam::Field<Type>> Foam::Function1Types::Constant<Type>::value
+(
+    const scalarField& x
+) const
 {
-    return value_;
+    return tmp<Field<Type>>(new Field<Type>(x.size(), value_));
 }
 
 
 template<class Type>
-Type Foam::Function1Types::Constant<Type>::integrate
+Foam::tmp<Foam::Field<Type>> Foam::Function1Types::Constant<Type>::integrate
 (
-    const scalar x1,
-    const scalar x2
+    const scalarField& x1,
+    const scalarField& x2
 ) const
 {
     return (x2 - x1)*value_;
diff --git a/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.H b/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.H
index 744b07b4f6b..e2698206741 100644
--- a/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.H
+++ b/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.H
@@ -106,16 +106,34 @@ public:
     // Member Functions
 
         //- Return constant value
-        Type value(const scalar) const;
+        virtual inline Type value(const scalar) const;
 
         //- Integrate between two values
-        Type integrate(const scalar x1, const scalar x2) const;
+        virtual inline Type integrate(const scalar x1, const scalar x2) const;
+
+        //- Return value as a function of (scalar) independent variable
+        virtual tmp<Field<Type>> value(const scalarField& x) const;
+
+        //- Integrate between two (scalar) values
+        virtual tmp<Field<Type>> integrate
+        (
+            const scalarField& x1,
+            const scalarField& x2
+        ) const;
 
         //- Write in dictionary format
         virtual void writeData(Ostream& os) const;
 };
 
 
+template<>
+tmp<Field<label>> Function1Types::Constant<label>::integrate
+(
+    const scalarField& x1,
+    const scalarField& x2
+) const;
+
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace Function1Types
@@ -123,6 +141,8 @@ public:
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
+#include "ConstantI.H"
+
 #ifdef NoRepository
     #include "Constant.C"
     #include "Function1New.C"
diff --git a/src/OpenFOAM/primitives/functions/Function1/Constant/ConstantI.H b/src/OpenFOAM/primitives/functions/Function1/Constant/ConstantI.H
new file mode 100644
index 00000000000..477e40222db
--- /dev/null
+++ b/src/OpenFOAM/primitives/functions/Function1/Constant/ConstantI.H
@@ -0,0 +1,48 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenFOAM Foundation
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "Constant.H"
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+template<class Type>
+inline Type Foam::Function1Types::Constant<Type>::value(const scalar x) const
+{
+    return value_;
+}
+
+
+template<class Type>
+inline Type Foam::Function1Types::Constant<Type>::integrate
+(
+    const scalar x1,
+    const scalar x2
+) const
+{
+    return (x2 - x1)*value_;
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C
index c551c912711..bd4098d7f97 100644
--- a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C
+++ b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -82,8 +82,9 @@ Type Foam::Function1<Type>::integrate(const scalar x1, const scalar x2) const
 }
 
 
-template<class Type>
-Foam::tmp<Foam::Field<Type>> Foam::Function1<Type>::value
+template<class Function1Type>
+Foam::tmp<Foam::Field<typename Function1Type::returnType>>
+Foam::FieldFunction1<Function1Type>::value
 (
     const scalarField& x
 ) const
@@ -93,14 +94,37 @@ Foam::tmp<Foam::Field<Type>> Foam::Function1<Type>::value
 
     forAll(x, i)
     {
-        fld[i] = this->value(x[i]);
+        fld[i] = Function1Type::value(x[i]);
     }
     return tfld;
 }
 
 
-template<class Type>
-Foam::tmp<Foam::Field<Type>> Foam::Function1<Type>::integrate
+template<class Function1Type>
+Foam::FieldFunction1<Function1Type>::FieldFunction1
+(
+    const word& entryName,
+    const dictionary& dict
+)
+:
+    Function1Type(entryName, dict)
+{}
+
+
+template<class Function1Type>
+Foam::tmp<Foam::Function1<typename Function1Type::returnType>>
+Foam::FieldFunction1<Function1Type>::clone() const
+{
+    return tmp<Function1<Type>>
+    (
+        new FieldFunction1<Function1Type>(*this)
+    );
+}
+
+
+template<class Function1Type>
+Foam::tmp<Foam::Field<typename Function1Type::returnType>>
+Foam::FieldFunction1<Function1Type>::integrate
 (
     const scalarField& x1,
     const scalarField& x2
@@ -111,8 +135,9 @@ Foam::tmp<Foam::Field<Type>> Foam::Function1<Type>::integrate
 
     forAll(x1, i)
     {
-        fld[i] = this->integrate(x1[i], x2[i]);
+        fld[i] = Function1Type::integrate(x1[i], x2[i]);
     }
+
     return tfld;
 }
 
diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H
index 3f364bdf6b7..8b31dc953d4 100644
--- a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H
+++ b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H
@@ -55,7 +55,7 @@ template<class Type> class Function1;
 template<class Type> Ostream& operator<<(Ostream&, const Function1<Type>&);
 
 /*---------------------------------------------------------------------------*\
-                         Class Function1 Declaration
+                          Class Function1 Declaration
 \*---------------------------------------------------------------------------*/
 
 template<class Type>
@@ -79,6 +79,8 @@ protected:
 
 public:
 
+    typedef Type returnType;
+
     //- Runtime type information
     TypeName("Function1")
 
@@ -96,13 +98,13 @@ public:
     );
 
 
-    // Constructor
+    // Constructors
 
         //- Construct from entry name
         Function1(const word& entryName);
 
         //- Copy constructor
-        Function1(const Function1<Type>& de);
+        Function1(const Function1<Type>& f1);
 
         //- Construct and return a clone
         virtual tmp<Function1<Type>> clone() const = 0;
@@ -140,7 +142,7 @@ public:
             virtual Type value(const scalar x) const;
 
             //- Return value as a function of (scalar) independent variable
-            virtual tmp<Field<Type>> value(const scalarField& x) const;
+            virtual tmp<Field<Type>> value(const scalarField& x) const = 0;
 
             //- Integrate between two (scalar) values
             virtual Type integrate(const scalar x1, const scalar x2) const;
@@ -150,7 +152,7 @@ public:
             (
                 const scalarField& x1,
                 const scalarField& x2
-            ) const;
+            ) const = 0;
 
 
         // I/O
@@ -167,6 +169,54 @@ public:
 };
 
 
+/*---------------------------------------------------------------------------*\
+                        Class FieldFunction1 Declaration
+\*---------------------------------------------------------------------------*/
+
+template<class Function1Type>
+class FieldFunction1
+:
+    public Function1Type
+{
+
+public:
+
+    typedef typename Function1Type::returnType Type;
+
+
+    // Constructors
+
+        //- Construct from entry name and dictionary
+        FieldFunction1(const word& entryName, const dictionary& dict);
+
+        //- Construct and return a clone
+        virtual tmp<Function1<Type>> clone() const;
+
+
+    //- Destructor
+    virtual ~FieldFunction1()
+    {}
+
+
+    // Member Functions
+
+        // Evaluation
+
+            using Function1Type::value;
+            using Function1Type::integrate;
+
+            //- Return value as a function of (scalar) independent variable
+            virtual tmp<Field<Type>> value(const scalarField& x) const;
+
+            //- Integrate between two (scalar) values
+            virtual tmp<Field<Type>> integrate
+            (
+                const scalarField& x1,
+                const scalarField& x2
+            ) const;
+};
+
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace Foam
@@ -188,7 +238,8 @@ public:
                                                                                \
     defineNamedTemplateTypeNameAndDebug(Function1Types::SS<Type>, 0);          \
                                                                                \
-    Function1<Type>::adddictionaryConstructorToTable<Function1Types::SS<Type>> \
+    Function1<Type>::adddictionaryConstructorToTable                           \
+        <FieldFunction1<Function1Types::SS<Type>>>                             \
         add##SS##Type##ConstructorToTable_;
 
 
@@ -196,7 +247,7 @@ public:
                                                                                \
     defineTypeNameAndDebug(SS, 0);                                             \
                                                                                \
-    Function1<scalar>::adddictionaryConstructorToTable<SS>                     \
+    Function1<scalar>::adddictionaryConstructorToTable<FieldFunction1<SS>>     \
         add##SS##ConstructorToTable_;
 
 
diff --git a/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.C b/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.C
index 42779f7953e..707abfc1c1b 100644
--- a/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.C
+++ b/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.C
@@ -55,17 +55,20 @@ Foam::Function1Types::OneConstant<Type>::~OneConstant()
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 template<class Type>
-Type Foam::Function1Types::OneConstant<Type>::value(const scalar x) const
+Foam::tmp<Foam::Field<Type>> Foam::Function1Types::OneConstant<Type>::value
+(
+    const scalarField& x
+) const
 {
-    return pTraits<Type>::one;
+    return tmp<Field<Type>>(new Field<Type>(x.size(), pTraits<Type>::one));
 }
 
 
 template<class Type>
-Type Foam::Function1Types::OneConstant<Type>::integrate
+Foam::tmp<Foam::Field<Type>> Foam::Function1Types::OneConstant<Type>::integrate
 (
-    const scalar x1,
-    const scalar x2
+    const scalarField& x1,
+    const scalarField& x2
 ) const
 {
     return (x2 - x1)*pTraits<Type>::one;
diff --git a/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.H b/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.H
index 60ec52c3e4e..9bf4cf9c431 100644
--- a/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.H
+++ b/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.H
@@ -92,10 +92,20 @@ public:
     // Member Functions
 
         //- Return constant value
-        Type value(const scalar) const;
+        virtual inline Type value(const scalar) const;
 
         //- Integrate between two values
-        Type integrate(const scalar x1, const scalar x2) const;
+        virtual inline Type integrate(const scalar x1, const scalar x2) const;
+
+        //- Return value as a function of (scalar) independent variable
+        virtual tmp<Field<Type>> value(const scalarField& x) const;
+
+        //- Integrate between two (scalar) values
+        virtual tmp<Field<Type>> integrate
+        (
+            const scalarField& x1,
+            const scalarField& x2
+        ) const;
 
         //- Write in dictionary format
         virtual void writeData(Ostream& os) const;
@@ -109,6 +119,8 @@ public:
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
+#include "OneConstantI.H"
+
 #ifdef NoRepository
     #include "OneConstant.C"
 #endif
diff --git a/src/OpenFOAM/primitives/functions/Function1/One/OneConstantI.H b/src/OpenFOAM/primitives/functions/Function1/One/OneConstantI.H
new file mode 100644
index 00000000000..a36cd717ddd
--- /dev/null
+++ b/src/OpenFOAM/primitives/functions/Function1/One/OneConstantI.H
@@ -0,0 +1,48 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenFOAM Foundation
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "OneConstant.H"
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+template<class Type>
+inline Type Foam::Function1Types::OneConstant<Type>::value(const scalar x) const
+{
+    return pTraits<Type>::one;
+}
+
+
+template<class Type>
+inline Type Foam::Function1Types::OneConstant<Type>::integrate
+(
+    const scalar x1,
+    const scalar x2
+) const
+{
+    return (x2 - x1)*pTraits<Type>::one;
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/functions/Function1/PolynomialEntry/PolynomialEntry.H b/src/OpenFOAM/primitives/functions/Function1/PolynomialEntry/PolynomialEntry.H
index 5afa5027515..69c11ccb6fc 100644
--- a/src/OpenFOAM/primitives/functions/Function1/PolynomialEntry/PolynomialEntry.H
+++ b/src/OpenFOAM/primitives/functions/Function1/PolynomialEntry/PolynomialEntry.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -100,12 +100,6 @@ public:
         //- Copy constructor
         Polynomial(const Polynomial& poly);
 
-        //- Construct and return a clone
-        virtual tmp<Function1<Type>> clone() const
-        {
-            return tmp<Function1<Type>>(new Polynomial(*this));
-        }
-
 
     //- Destructor
     virtual ~Polynomial();
@@ -122,10 +116,10 @@ public:
         // Evaluation
 
             //- Return Polynomial value
-            Type value(const scalar x) const;
+            virtual Type value(const scalar x) const;
 
             //- Integrate between two (scalar) values
-            Type integrate(const scalar x1, const scalar x2) const;
+            virtual Type integrate(const scalar x1, const scalar x2) const;
 
 
         //- Write in dictionary format
diff --git a/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C b/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C
index 37342b2e575..db5779edda3 100644
--- a/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C
+++ b/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C
@@ -66,13 +66,6 @@ Foam::Function1Types::Scale<Type>::~Scale()
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-template<class Type>
-Type Foam::Function1Types::Scale<Type>::value(const scalar t) const
-{
-    return scale_->value(t)*value_->value(t);
-}
-
-
 template<class Type>
 void Foam::Function1Types::Scale<Type>::writeData(Ostream& os) const
 {
diff --git a/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.H b/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.H
index 80f5f639bdb..7366a94a935 100644
--- a/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.H
+++ b/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.H
@@ -126,12 +126,6 @@ public:
         //- Copy constructor
         Scale(const Scale<Type>& se);
 
-        //- Construct and return a clone
-        virtual tmp<Function1<Type>> clone() const
-        {
-            return tmp<Function1<Type>>(new Scale<Type>(*this));
-        }
-
 
     //- Destructor
     virtual ~Scale();
@@ -140,7 +134,7 @@ public:
     // Member Functions
 
         //- Return value for time t
-        Type value(const scalar t) const;
+        virtual inline Type value(const scalar t) const;
 
         //- Write in dictionary format
         virtual void writeData(Ostream& os) const;
@@ -154,6 +148,8 @@ public:
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
+#include "ScaleI.H"
+
 #ifdef NoRepository
     #include "Scale.C"
 #endif
diff --git a/src/OpenFOAM/primitives/functions/Function1/Scale/ScaleI.H b/src/OpenFOAM/primitives/functions/Function1/Scale/ScaleI.H
new file mode 100644
index 00000000000..ba9d8b9867f
--- /dev/null
+++ b/src/OpenFOAM/primitives/functions/Function1/Scale/ScaleI.H
@@ -0,0 +1,37 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenFOAM Foundation
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "Scale.H"
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+template<class Type>
+inline Type Foam::Function1Types::Scale<Type>::value(const scalar t) const
+{
+    return scale_->value(t)*value_->value(t);
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.C b/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.C
index d6b0a6659f0..7fa813c79d6 100644
--- a/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.C
+++ b/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.C
@@ -24,7 +24,6 @@ License
 \*---------------------------------------------------------------------------*/
 
 #include "Sine.H"
-#include "mathematicalConstants.H"
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
@@ -73,17 +72,6 @@ Foam::Function1Types::Sine<Type>::~Sine()
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-template<class Type>
-Type Foam::Function1Types::Sine<Type>::value(const scalar t) const
-{
-    return
-        amplitude_->value(t)
-       *sin(constant::mathematical::twoPi*frequency_->value(t)*(t - t0_))
-       *scale_->value(t)
-      + level_->value(t);
-}
-
-
 template<class Type>
 void Foam::Function1Types::Sine<Type>::writeData(Ostream& os) const
 {
diff --git a/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.H b/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.H
index d18291862f2..22474f7fbfa 100644
--- a/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.H
+++ b/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.H
@@ -138,12 +138,6 @@ public:
         //- Copy constructor
         Sine(const Sine<Type>& se);
 
-        //- Construct and return a clone
-        virtual tmp<Function1<Type>> clone() const
-        {
-            return tmp<Function1<Type>>(new Sine<Type>(*this));
-        }
-
 
     //- Destructor
     virtual ~Sine();
@@ -152,7 +146,7 @@ public:
     // Member Functions
 
         //- Return value for time t
-        Type value(const scalar t) const;
+        virtual inline Type value(const scalar t) const;
 
         //- Write in dictionary format
         virtual void writeData(Ostream& os) const;
@@ -166,6 +160,8 @@ public:
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
+#include "SineI.H"
+
 #ifdef NoRepository
     #include "Sine.C"
 #endif
diff --git a/src/OpenFOAM/primitives/functions/Function1/Sine/SineI.H b/src/OpenFOAM/primitives/functions/Function1/Sine/SineI.H
new file mode 100644
index 00000000000..0ae89acec39
--- /dev/null
+++ b/src/OpenFOAM/primitives/functions/Function1/Sine/SineI.H
@@ -0,0 +1,42 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenFOAM Foundation
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "Sine.H"
+#include "mathematicalConstants.H"
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+template<class Type>
+inline Type Foam::Function1Types::Sine<Type>::value(const scalar t) const
+{
+    return
+        amplitude_->value(t)
+       *sin(constant::mathematical::twoPi*frequency_->value(t)*(t - t0_))
+       *scale_->value(t)
+      + level_->value(t);
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/functions/Function1/Square/Square.C b/src/OpenFOAM/primitives/functions/Function1/Square/Square.C
index 5442e8a989c..e18ed2da7c5 100644
--- a/src/OpenFOAM/primitives/functions/Function1/Square/Square.C
+++ b/src/OpenFOAM/primitives/functions/Function1/Square/Square.C
@@ -74,29 +74,6 @@ Foam::Function1Types::Square<Type>::~Square()
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-template<class Type>
-Type Foam::Function1Types::Square<Type>::value(const scalar t) const
-{
-    // Number of waves including fractions
-    scalar waves = frequency_->value(t)*(t - t0_);
-
-    // Number of complete waves
-    scalar nWaves;
-
-    // Fraction of last incomplete wave
-    scalar waveFrac = std::modf(waves, &nWaves);
-
-    // Mark fraction of a wave
-    scalar markFrac = markSpace_/(1.0 + markSpace_);
-
-    return
-        amplitude_->value(t)
-       *(waveFrac < markFrac ? 1 : -1)
-       *scale_->value(t)
-      + level_->value(t);
-}
-
-
 template<class Type>
 void Foam::Function1Types::Square<Type>::writeData(Ostream& os) const
 {
diff --git a/src/OpenFOAM/primitives/functions/Function1/Square/Square.H b/src/OpenFOAM/primitives/functions/Function1/Square/Square.H
index df6ec25deb4..75d7fac94d5 100644
--- a/src/OpenFOAM/primitives/functions/Function1/Square/Square.H
+++ b/src/OpenFOAM/primitives/functions/Function1/Square/Square.H
@@ -145,12 +145,6 @@ public:
         //- Copy constructor
         Square(const Square<Type>& se);
 
-        //- Construct and return a clone
-        virtual tmp<Function1<Type>> clone() const
-        {
-            return tmp<Function1<Type>>(new Square<Type>(*this));
-        }
-
 
     //- Destructor
     virtual ~Square();
@@ -159,7 +153,7 @@ public:
     // Member Functions
 
         //- Return value for time t
-        Type value(const scalar t) const;
+        virtual inline Type value(const scalar t) const;
 
         //- Write in dictionary format
         virtual void writeData(Ostream& os) const;
@@ -173,6 +167,8 @@ public:
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
+#include "SquareI.H"
+
 #ifdef NoRepository
     #include "Square.C"
 #endif
diff --git a/src/OpenFOAM/primitives/functions/Function1/Square/SquareI.H b/src/OpenFOAM/primitives/functions/Function1/Square/SquareI.H
new file mode 100644
index 00000000000..6976132d500
--- /dev/null
+++ b/src/OpenFOAM/primitives/functions/Function1/Square/SquareI.H
@@ -0,0 +1,53 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenFOAM Foundation
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "Square.H"
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+template<class Type>
+inline Type Foam::Function1Types::Square<Type>::value(const scalar t) const
+{
+    // Number of waves including fractions
+    scalar waves = frequency_->value(t)*(t - t0_);
+
+    // Number of complete waves
+    scalar nWaves;
+
+    // Fraction of last incomplete wave
+    scalar waveFrac = std::modf(waves, &nWaves);
+
+    // Mark fraction of a wave
+    scalar markFrac = markSpace_/(1.0 + markSpace_);
+
+    return
+        amplitude_->value(t)
+       *(waveFrac < markFrac ? 1 : -1)
+       *scale_->value(t)
+      + level_->value(t);
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/functions/Function1/Table/Table.H b/src/OpenFOAM/primitives/functions/Function1/Table/Table.H
index 5d50acca48c..2c15a83c764 100644
--- a/src/OpenFOAM/primitives/functions/Function1/Table/Table.H
+++ b/src/OpenFOAM/primitives/functions/Function1/Table/Table.H
@@ -86,12 +86,6 @@ public:
         //- Copy constructor
         Table(const Table<Type>& tbl);
 
-        //- Construct and return a clone
-        virtual tmp<Function1<Type>> clone() const
-        {
-            return tmp<Function1<Type>>(new Table<Type>(*this));
-        }
-
 
     //- Destructor
     virtual ~Table();
diff --git a/src/OpenFOAM/primitives/functions/Function1/TableFile/TableFile.H b/src/OpenFOAM/primitives/functions/Function1/TableFile/TableFile.H
index d4973639bf4..8d570b14d6f 100644
--- a/src/OpenFOAM/primitives/functions/Function1/TableFile/TableFile.H
+++ b/src/OpenFOAM/primitives/functions/Function1/TableFile/TableFile.H
@@ -101,12 +101,6 @@ public:
         //- Copy constructor
         TableFile(const TableFile<Type>& tbl);
 
-        //- Construct and return a clone
-        virtual tmp<Function1<Type>> clone() const
-        {
-            return tmp<Function1<Type>>(new TableFile<Type>(*this));
-        }
-
 
     //- Destructor
     virtual ~TableFile();
diff --git a/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.C b/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.C
index fd89eff02dc..a420d0ab13e 100644
--- a/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.C
+++ b/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.C
@@ -47,24 +47,6 @@ Foam::Function1Types::ZeroConstant<Type>::~ZeroConstant()
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-template<class Type>
-Type Foam::Function1Types::ZeroConstant<Type>::value(const scalar x) const
-{
-    return pTraits<Type>::zero;
-}
-
-
-template<class Type>
-Type Foam::Function1Types::ZeroConstant<Type>::integrate
-(
-    const scalar x1,
-    const scalar x2
-) const
-{
-    return pTraits<Type>::zero;
-}
-
-
 template<class Type>
 void Foam::Function1Types::ZeroConstant<Type>::writeData(Ostream& os) const
 {
diff --git a/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.H b/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.H
index bf5f2452abc..719c619b0b4 100644
--- a/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.H
+++ b/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.H
@@ -75,12 +75,6 @@ public:
         //- Construct from entry name and dictionary
         ZeroConstant(const word& entryName, const dictionary& dict);
 
-        //- Construct and return a clone
-        virtual tmp<Function1<Type>> clone() const
-        {
-            return tmp<Function1<Type>>(new ZeroConstant<Type>(*this));
-        }
-
 
     //- Destructor
     virtual ~ZeroConstant();
@@ -89,10 +83,10 @@ public:
     // Member Functions
 
         //- Return constant value
-        Type value(const scalar) const;
+        virtual inline Type value(const scalar) const;
 
         //- Integrate between two values
-        Type integrate(const scalar x1, const scalar x2) const;
+        virtual inline Type integrate(const scalar x1, const scalar x2) const;
 
         //- Write in dictionary format
         virtual void writeData(Ostream& os) const;
@@ -106,6 +100,8 @@ public:
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
+#include "ZeroConstantI.H"
+
 #ifdef NoRepository
     #include "ZeroConstant.C"
 #endif
diff --git a/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstantI.H b/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstantI.H
new file mode 100644
index 00000000000..34e3e9ca5cb
--- /dev/null
+++ b/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstantI.H
@@ -0,0 +1,51 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenFOAM Foundation
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "ZeroConstant.H"
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+template<class Type>
+inline Type Foam::Function1Types::ZeroConstant<Type>::value
+(
+    const scalar x
+) const
+{
+    return pTraits<Type>::zero;
+}
+
+
+template<class Type>
+inline Type Foam::Function1Types::ZeroConstant<Type>::integrate
+(
+    const scalar x1,
+    const scalar x2
+) const
+{
+    return pTraits<Type>::zero;
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/functions/Function1/halfCosineRamp/halfCosineRamp.C b/src/OpenFOAM/primitives/functions/Function1/halfCosineRamp/halfCosineRamp.C
index 7478be74123..1d1f889dbc7 100644
--- a/src/OpenFOAM/primitives/functions/Function1/halfCosineRamp/halfCosineRamp.C
+++ b/src/OpenFOAM/primitives/functions/Function1/halfCosineRamp/halfCosineRamp.C
@@ -24,7 +24,6 @@ License
 \*---------------------------------------------------------------------------*/
 
 #include "halfCosineRamp.H"
-#include "mathematicalConstants.H"
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
@@ -55,12 +54,4 @@ Foam::Function1Types::halfCosineRamp::~halfCosineRamp()
 {}
 
 
-// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
-
-Foam::scalar Foam::Function1Types::halfCosineRamp::value(const scalar t) const
-{
-    return 0.5*(1 - cos(constant::mathematical::pi*linearRamp(t)));
-}
-
-
 // ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/functions/Function1/halfCosineRamp/halfCosineRamp.H b/src/OpenFOAM/primitives/functions/Function1/halfCosineRamp/halfCosineRamp.H
index 1cf21c2fcf8..003a378f847 100644
--- a/src/OpenFOAM/primitives/functions/Function1/halfCosineRamp/halfCosineRamp.H
+++ b/src/OpenFOAM/primitives/functions/Function1/halfCosineRamp/halfCosineRamp.H
@@ -77,12 +77,6 @@ public:
             const dictionary& dict
         );
 
-        //- Construct and return a clone
-        virtual tmp<Function1<scalar>> clone() const
-        {
-            return tmp<Function1<scalar>>(new halfCosineRamp(*this));
-        }
-
 
     //- Destructor
     virtual ~halfCosineRamp();
@@ -91,7 +85,7 @@ public:
     // Member Functions
 
         //- Return value for time t
-        scalar value(const scalar t) const;
+        virtual inline scalar value(const scalar t) const;
 };
 
 
@@ -102,6 +96,10 @@ public:
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
+#include "halfCosineRampI.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
 #endif
 
 // ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/functions/Function1/halfCosineRamp/halfCosineRampI.H b/src/OpenFOAM/primitives/functions/Function1/halfCosineRamp/halfCosineRampI.H
new file mode 100644
index 00000000000..96bec2daaa3
--- /dev/null
+++ b/src/OpenFOAM/primitives/functions/Function1/halfCosineRamp/halfCosineRampI.H
@@ -0,0 +1,40 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenFOAM Foundation
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "halfCosineRamp.H"
+#include "mathematicalConstants.H"
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+inline Foam::scalar Foam::Function1Types::halfCosineRamp::value
+(
+    const scalar t
+) const
+{
+    return 0.5*(1 - cos(constant::mathematical::pi*linearRamp(t)));
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/functions/Function1/linearRamp/linearRamp.C b/src/OpenFOAM/primitives/functions/Function1/linearRamp/linearRamp.C
index 039e526f68e..cc5c7a0db3c 100644
--- a/src/OpenFOAM/primitives/functions/Function1/linearRamp/linearRamp.C
+++ b/src/OpenFOAM/primitives/functions/Function1/linearRamp/linearRamp.C
@@ -54,12 +54,4 @@ Foam::Function1Types::linearRamp::~linearRamp()
 {}
 
 
-// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
-
-Foam::scalar Foam::Function1Types::linearRamp::value(const scalar t) const
-{
-    return ramp::linearRamp(t);
-}
-
-
 // ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/functions/Function1/linearRamp/linearRamp.H b/src/OpenFOAM/primitives/functions/Function1/linearRamp/linearRamp.H
index a84d1c778ae..0c12f429f0e 100644
--- a/src/OpenFOAM/primitives/functions/Function1/linearRamp/linearRamp.H
+++ b/src/OpenFOAM/primitives/functions/Function1/linearRamp/linearRamp.H
@@ -77,12 +77,6 @@ public:
             const dictionary& dict
         );
 
-        //- Construct and return a clone
-        virtual tmp<Function1<scalar>> clone() const
-        {
-            return tmp<Function1<scalar>>(new linearRamp(*this));
-        }
-
 
     //- Destructor
     virtual ~linearRamp();
@@ -91,7 +85,7 @@ public:
     // Member Functions
 
         //- Return value for time t
-        scalar value(const scalar t) const;
+        virtual inline scalar value(const scalar t) const;
 };
 
 
@@ -102,6 +96,10 @@ public:
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
+#include "linearRampI.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
 #endif
 
 // ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/functions/Function1/linearRamp/linearRampI.H b/src/OpenFOAM/primitives/functions/Function1/linearRamp/linearRampI.H
new file mode 100644
index 00000000000..011b6073f14
--- /dev/null
+++ b/src/OpenFOAM/primitives/functions/Function1/linearRamp/linearRampI.H
@@ -0,0 +1,39 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenFOAM Foundation
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "linearRamp.H"
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+inline Foam::scalar Foam::Function1Types::linearRamp::value
+(
+    const scalar t
+) const
+{
+    return ramp::linearRamp(t);
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/functions/Function1/makeDataEntries.C b/src/OpenFOAM/primitives/functions/Function1/makeFunction1s.C
similarity index 91%
rename from src/OpenFOAM/primitives/functions/Function1/makeDataEntries.C
rename to src/OpenFOAM/primitives/functions/Function1/makeFunction1s.C
index b7c93ca1b3d..f57d384d58d 100644
--- a/src/OpenFOAM/primitives/functions/Function1/makeDataEntries.C
+++ b/src/OpenFOAM/primitives/functions/Function1/makeFunction1s.C
@@ -55,8 +55,6 @@ namespace Foam
 {
     makeFunction1(label);
     makeFunction1Type(Constant, label);
-    // Polynomial functions and interpolation do evaluate to label
-    // Instead evaluate a scalar and convert to label as appropriate
 
     makeFunction1s(scalar);
     makeFunction1s(vector);
@@ -66,4 +64,17 @@ namespace Foam
 }
 
 
+template<>
+Foam::tmp<Foam::Field<Foam::label>>
+Foam::Function1Types::Constant<Foam::label>::integrate
+(
+    const scalarField& x1,
+    const scalarField& x2
+) const
+{
+    NotImplemented;
+    return tmp<Field<label>>(new Field<label>(x1.size()));
+}
+
+
 // ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/functions/Function1/quadraticRamp/quadraticRamp.C b/src/OpenFOAM/primitives/functions/Function1/quadraticRamp/quadraticRamp.C
index 96945a77172..83c423ccf6f 100644
--- a/src/OpenFOAM/primitives/functions/Function1/quadraticRamp/quadraticRamp.C
+++ b/src/OpenFOAM/primitives/functions/Function1/quadraticRamp/quadraticRamp.C
@@ -54,12 +54,4 @@ Foam::Function1Types::quadraticRamp::~quadraticRamp()
 {}
 
 
-// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
-
-Foam::scalar Foam::Function1Types::quadraticRamp::value(const scalar t) const
-{
-    return sqr(linearRamp(t));
-}
-
-
 // ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/functions/Function1/quadraticRamp/quadraticRamp.H b/src/OpenFOAM/primitives/functions/Function1/quadraticRamp/quadraticRamp.H
index 0ec33d1b68e..c9ab24832e9 100644
--- a/src/OpenFOAM/primitives/functions/Function1/quadraticRamp/quadraticRamp.H
+++ b/src/OpenFOAM/primitives/functions/Function1/quadraticRamp/quadraticRamp.H
@@ -77,12 +77,6 @@ public:
             const dictionary& dict
         );
 
-        //- Construct and return a clone
-        virtual tmp<Function1<scalar>> clone() const
-        {
-            return tmp<Function1<scalar>>(new quadraticRamp(*this));
-        }
-
 
     //- Destructor
     virtual ~quadraticRamp();
@@ -91,7 +85,7 @@ public:
     // Member Functions
 
         //- Return value for time t
-        scalar value(const scalar t) const;
+        virtual inline scalar value(const scalar t) const;
 };
 
 
@@ -102,6 +96,10 @@ public:
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
+#include "quadraticRampI.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
 #endif
 
 // ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/functions/Function1/quadraticRamp/quadraticRampI.H b/src/OpenFOAM/primitives/functions/Function1/quadraticRamp/quadraticRampI.H
new file mode 100644
index 00000000000..5d9de1835c5
--- /dev/null
+++ b/src/OpenFOAM/primitives/functions/Function1/quadraticRamp/quadraticRampI.H
@@ -0,0 +1,39 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenFOAM Foundation
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "quadraticRamp.H"
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+inline Foam::scalar Foam::Function1Types::quadraticRamp::value
+(
+    const scalar t
+) const
+{
+    return sqr(linearRamp(t));
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/functions/Function1/quarterCosineRamp/quarterCosineRamp.C b/src/OpenFOAM/primitives/functions/Function1/quarterCosineRamp/quarterCosineRamp.C
index 21b438b748e..9dd832bd58f 100644
--- a/src/OpenFOAM/primitives/functions/Function1/quarterCosineRamp/quarterCosineRamp.C
+++ b/src/OpenFOAM/primitives/functions/Function1/quarterCosineRamp/quarterCosineRamp.C
@@ -24,7 +24,6 @@ License
 \*---------------------------------------------------------------------------*/
 
 #include "quarterCosineRamp.H"
-#include "mathematicalConstants.H"
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
@@ -55,15 +54,4 @@ Foam::Function1Types::quarterCosineRamp::~quarterCosineRamp()
 {}
 
 
-// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
-
-Foam::scalar Foam::Function1Types::quarterCosineRamp::value
-(
-    const scalar t
-) const
-{
-    return 1 - cos(0.5*constant::mathematical::pi*linearRamp(t));
-}
-
-
 // ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/functions/Function1/quarterCosineRamp/quarterCosineRamp.H b/src/OpenFOAM/primitives/functions/Function1/quarterCosineRamp/quarterCosineRamp.H
index cd0776bb39c..ce97e025b39 100644
--- a/src/OpenFOAM/primitives/functions/Function1/quarterCosineRamp/quarterCosineRamp.H
+++ b/src/OpenFOAM/primitives/functions/Function1/quarterCosineRamp/quarterCosineRamp.H
@@ -77,12 +77,6 @@ public:
             const dictionary& dict
         );
 
-        //- Construct and return a clone
-        virtual tmp<Function1<scalar>> clone() const
-        {
-            return tmp<Function1<scalar>>(new quarterCosineRamp(*this));
-        }
-
 
     //- Destructor
     virtual ~quarterCosineRamp();
@@ -91,7 +85,7 @@ public:
     // Member Functions
 
         //- Return value for time t
-        scalar value(const scalar t) const;
+        virtual inline scalar value(const scalar t) const;
 };
 
 
@@ -102,6 +96,10 @@ public:
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
+#include "quarterCosineRampI.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
 #endif
 
 // ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/functions/Function1/quarterCosineRamp/quarterCosineRampI.H b/src/OpenFOAM/primitives/functions/Function1/quarterCosineRamp/quarterCosineRampI.H
new file mode 100644
index 00000000000..bc664d5ea1d
--- /dev/null
+++ b/src/OpenFOAM/primitives/functions/Function1/quarterCosineRamp/quarterCosineRampI.H
@@ -0,0 +1,40 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenFOAM Foundation
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "quarterCosineRamp.H"
+#include "mathematicalConstants.H"
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+inline Foam::scalar Foam::Function1Types::quarterCosineRamp::value
+(
+    const scalar t
+) const
+{
+    return 1 - cos(0.5*constant::mathematical::pi*linearRamp(t));
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/functions/Function1/quarterSineRamp/quarterSineRamp.C b/src/OpenFOAM/primitives/functions/Function1/quarterSineRamp/quarterSineRamp.C
index d6b73876d12..b4ac6c5bf79 100644
--- a/src/OpenFOAM/primitives/functions/Function1/quarterSineRamp/quarterSineRamp.C
+++ b/src/OpenFOAM/primitives/functions/Function1/quarterSineRamp/quarterSineRamp.C
@@ -24,7 +24,6 @@ License
 \*---------------------------------------------------------------------------*/
 
 #include "quarterSineRamp.H"
-#include "mathematicalConstants.H"
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
@@ -55,12 +54,4 @@ Foam::Function1Types::quarterSineRamp::~quarterSineRamp()
 {}
 
 
-// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
-
-Foam::scalar Foam::Function1Types::quarterSineRamp::value(const scalar t) const
-{
-    return sin(0.5*constant::mathematical::pi*linearRamp(t));
-}
-
-
 // ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/functions/Function1/quarterSineRamp/quarterSineRamp.H b/src/OpenFOAM/primitives/functions/Function1/quarterSineRamp/quarterSineRamp.H
index 8f0d0c2dfec..2ef9aedd4a5 100644
--- a/src/OpenFOAM/primitives/functions/Function1/quarterSineRamp/quarterSineRamp.H
+++ b/src/OpenFOAM/primitives/functions/Function1/quarterSineRamp/quarterSineRamp.H
@@ -77,12 +77,6 @@ public:
             const dictionary& dict
         );
 
-        //- Construct and return a clone
-        virtual tmp<Function1<scalar>> clone() const
-        {
-            return tmp<Function1<scalar>>(new quarterSineRamp(*this));
-        }
-
 
     //- Destructor
     virtual ~quarterSineRamp();
@@ -91,7 +85,7 @@ public:
     // Member Functions
 
         //- Return value for time t
-        scalar value(const scalar t) const;
+        virtual inline scalar value(const scalar t) const;
 };
 
 
@@ -102,6 +96,10 @@ public:
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
+#include "quarterSineRampI.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
 #endif
 
 // ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/functions/Function1/quarterSineRamp/quarterSineRampI.H b/src/OpenFOAM/primitives/functions/Function1/quarterSineRamp/quarterSineRampI.H
new file mode 100644
index 00000000000..0b539336e26
--- /dev/null
+++ b/src/OpenFOAM/primitives/functions/Function1/quarterSineRamp/quarterSineRampI.H
@@ -0,0 +1,40 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenFOAM Foundation
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "quarterSineRamp.H"
+#include "mathematicalConstants.H"
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+inline Foam::scalar Foam::Function1Types::quarterSineRamp::value
+(
+    const scalar t
+) const
+{
+    return sin(0.5*constant::mathematical::pi*linearRamp(t));
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.H b/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.H
index 08a5d4c64e8..a44db638ec1 100644
--- a/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.H
+++ b/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.H
@@ -131,7 +131,7 @@ public:
     // Member Functions
 
         //- Return value for time t
-        scalar value(const scalar t) const = 0;
+        virtual scalar value(const scalar t) const = 0;
 
         //- Write in dictionary format
         virtual void writeData(Ostream& os) const;
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C
index 51ad29066f1..6cabc9a3534 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C
@@ -77,41 +77,7 @@ Foam::fanFvPatchField<Foam::scalar>::fanFvPatchField
 {
     if (this->cyclicPatch().owner())
     {
-        if (dict.found("f"))
-        {
-            // Backwards compatibility
-            Istream& is = dict.lookup("f");
-            is.format(IOstream::ASCII);
-            scalarList f(is);
-
-            label nPows = 0;
-            forAll(f, powI)
-            {
-                if (mag(f[powI]) > VSMALL)
-                {
-                    nPows++;
-                }
-            }
-            List<Tuple2<scalar, scalar>> coeffs(nPows);
-            nPows = 0;
-            forAll(f, powI)
-            {
-                if (mag(f[powI]) > VSMALL)
-                {
-                    coeffs[nPows++] = Tuple2<scalar, scalar>(f[powI], powI);
-                }
-            }
-
-            this->jumpTable_.reset
-            (
-                new Function1Types::Polynomial<scalar>("jumpTable", coeffs)
-            );
-        }
-        else
-        {
-            // Generic input constructed from dictionary
-            this->jumpTable_ = Function1<scalar>::New("jumpTable", dict);
-        }
+        this->jumpTable_ = Function1<scalar>::New("jumpTable", dict);
     }
 
     if (dict.found("value"))
-- 
GitLab