From 5ed4b3489c93c5ce3c77a9a92c677ef966fb291c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Jasi=C5=84ski?= <daniel.jasinski@gmail.com>
Date: Thu, 8 Nov 2018 07:00:14 +0100
Subject: [PATCH] fanFvPatchField: Renamed to fanPressureJumpFvPatchScalarField
 and added support for defining fan curve.

---
 src/finiteVolume/Make/files                        |   2 +-
 .../fvPatchFields/derived/fan/fanFvPatchField.C    | 135 ------------
 .../fvPatchFields/derived/fan/fanFvPatchField.H    | 219 --------------------
 .../fvPatchFields/derived/fan/fanFvPatchFields.C   |  99 ---------
 .../fvPatchFields/derived/fan/fanFvPatchFields.H   |  49 -----
 .../derived/fan/fanFvPatchFieldsFwd.H              |  50 -----
 .../fanPressureJumpFvPatchScalarField.C            | 228 +++++++++++++++++++++
 .../fanPressureJumpFvPatchScalarField.H            | 212 +++++++++++++++++++
 8 files changed, 441 insertions(+), 553 deletions(-)
 delete mode 100644 src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C
 delete mode 100644 src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H
 delete mode 100644 src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C
 delete mode 100644 src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.H
 delete mode 100644 src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFieldsFwd.H
 create mode 100644 src/finiteVolume/fields/fvPatchFields/derived/fanPressureJump/fanPressureJumpFvPatchScalarField.C
 create mode 100644 src/finiteVolume/fields/fvPatchFields/derived/fanPressureJump/fanPressureJumpFvPatchScalarField.H

diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files
index c4bb131..8200e8f 100644
--- a/src/finiteVolume/Make/files
+++ b/src/finiteVolume/Make/files
@@ -139,7 +139,7 @@ $(derivedFvPatchFields)/codedFixedValue/codedFixedValueFvPatchFields.C
 $(derivedFvPatchFields)/codedMixed/codedMixedFvPatchFields.C
 $(derivedFvPatchFields)/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.C
 $(derivedFvPatchFields)/externalCoupledMixed/externalCoupledMixedFvPatchFields.C
-$(derivedFvPatchFields)/fan/fanFvPatchFields.C
+$(derivedFvPatchFields)/fanPressureJump/fanPressureJumpFvPatchScalarField.C
 $(derivedFvPatchFields)/fanPressure/fanPressureFvPatchScalarField.C
 $(derivedFvPatchFields)/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C
 $(derivedFvPatchFields)/fixedFluxExtrapolatedPressure/fixedFluxExtrapolatedPressureFvPatchScalarField.C
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C
deleted file mode 100644
index 6498687..0000000
--- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C
+++ /dev/null
@@ -1,135 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     | Website:  https://openfoam.org
-    \\  /    A nd           | Copyright (C) 2011-2018 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 "fanFvPatchField.H"
-
-// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
-
-template<class Type>
-void Foam::fanFvPatchField<Type>::calcFanJump()
-{
-    if (this->cyclicPatch().owner())
-    {
-        this->jump_ = this->jumpTable_->value(this->db().time().value());
-    }
-}
-
-
-// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
-
-template<class Type>
-Foam::fanFvPatchField<Type>::fanFvPatchField
-(
-    const fvPatch& p,
-    const DimensionedField<Type, volMesh>& iF
-)
-:
-    uniformJumpFvPatchField<Type>(p, iF),
-    phiName_("phi"),
-    rhoName_("rho")
-{}
-
-
-template<class Type>
-Foam::fanFvPatchField<Type>::fanFvPatchField
-(
-    const fvPatch& p,
-    const DimensionedField<Type, volMesh>& iF,
-    const dictionary& dict
-)
-:
-    uniformJumpFvPatchField<Type>(p, iF, dict),
-    phiName_(dict.lookupOrDefault<word>("phi", "phi")),
-    rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
-{}
-
-
-template<class Type>
-Foam::fanFvPatchField<Type>::fanFvPatchField
-(
-    const fanFvPatchField<Type>& ptf,
-    const fvPatch& p,
-    const DimensionedField<Type, volMesh>& iF,
-    const fvPatchFieldMapper& mapper
-)
-:
-    uniformJumpFvPatchField<Type>(ptf, p, iF, mapper),
-    phiName_(ptf.phiName_),
-    rhoName_(ptf.rhoName_)
-{}
-
-
-template<class Type>
-Foam::fanFvPatchField<Type>::fanFvPatchField
-(
-    const fanFvPatchField<Type>& ptf
-)
-:
-    uniformJumpFvPatchField<Type>(ptf),
-    phiName_(ptf.phiName_),
-    rhoName_(ptf.rhoName_)
-{}
-
-
-template<class Type>
-Foam::fanFvPatchField<Type>::fanFvPatchField
-(
-    const fanFvPatchField<Type>& ptf,
-    const DimensionedField<Type, volMesh>& iF
-)
-:
-    uniformJumpFvPatchField<Type>(ptf, iF),
-    phiName_(ptf.phiName_),
-    rhoName_(ptf.rhoName_)
-{}
-
-
-// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
-
-template<class Type>
-void Foam::fanFvPatchField<Type>::updateCoeffs()
-{
-    if (this->updated())
-    {
-        return;
-    }
-
-    calcFanJump();
-
-    // Call fixedJump variant - uniformJump will overwrite the jump value
-    fixedJumpFvPatchField<Type>::updateCoeffs();
-}
-
-
-template<class Type>
-void Foam::fanFvPatchField<Type>::write(Ostream& os) const
-{
-    uniformJumpFvPatchField<Type>::write(os);
-    this->template writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
-    this->template writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
-}
-
-
-// ************************************************************************* //
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H
deleted file mode 100644
index 39c649a..0000000
--- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H
+++ /dev/null
@@ -1,219 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     | Website:  https://openfoam.org
-    \\  /    A nd           | Copyright (C) 2011-2018 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/>.
-
-Class
-    Foam::fanFvPatchField
-
-Description
-    This boundary condition provides a jump condition, using the \c cyclic
-    condition as a base.
-
-    The jump is specified as a \c Function1 type, to enable the use of, e.g.
-    constant, polynomial, table values.
-
-Usage
-    \table
-        Property     | Description             | Required    | Default value
-        patchType    | underlying patch type should be \c cyclic| yes |
-        jumpTable    | jump data, e.g. \c csvFile | yes      |
-        phi          | flux field name         | no          | phi
-        rho          | density field name      | no          | none
-    \endtable
-
-    Example of the boundary condition specification:
-    \verbatim
-    <patchName>
-    {
-        type            fan;
-        patchType       cyclic;
-        jumpTable       csvFile;
-        csvFileCoeffs
-        {
-            hasHeaderLine   1;
-            refColumn       0;
-            componentColumns 1(1);
-            separator       ",";
-            file           "$FOAM_CASE/constant/pressureVsU";
-        }
-        value           uniform 0;
-    }
-    \endverbatim
-
-    The above example shows the use of a comma separated (CSV) file to specify
-    the jump condition.
-
-Note
-     The underlying \c patchType should be set to \c cyclic
-
-See also
-    Foam::Function1Types
-
-SourceFiles
-    fanFvPatchField.C
-    fanFvPatchFields.H
-    fanFvPatchFields.C
-    fanFvPatchFieldsFwd.H
-
-\*---------------------------------------------------------------------------*/
-
-#ifndef fanFvPatchField_H
-#define fanFvPatchField_H
-
-#include "uniformJumpFvPatchField.H"
-#include "Function1.H"
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-
-/*---------------------------------------------------------------------------*\
-                       Class fanFvPatchField Declaration
-\*---------------------------------------------------------------------------*/
-
-template<class Type>
-class fanFvPatchField
-:
-    public uniformJumpFvPatchField<Type>
-{
-    // Private data
-
-        //- Name of the flux transporting the field
-        word phiName_;
-
-        //- Name of the density field used to normalise the mass flux
-        //  if necessary
-        word rhoName_;
-
-
-    // Private Member Functions
-
-        //- Calculate the fan pressure jump
-        void calcFanJump();
-
-
-public:
-
-    //- Runtime type information
-    TypeName("fan");
-
-
-    // Constructors
-
-        //- Construct from patch and internal field
-        fanFvPatchField
-        (
-            const fvPatch&,
-            const DimensionedField<Type, volMesh>&
-        );
-
-        //- Construct from patch, internal field and dictionary
-        fanFvPatchField
-        (
-            const fvPatch&,
-            const DimensionedField<Type, volMesh>&,
-            const dictionary&
-        );
-
-        //- Construct by mapping given fanFvPatchField onto a new patch
-        fanFvPatchField
-        (
-            const fanFvPatchField<Type>&,
-            const fvPatch&,
-            const DimensionedField<Type, volMesh>&,
-            const fvPatchFieldMapper&
-        );
-
-        //- Construct as copy
-        fanFvPatchField
-        (
-            const fanFvPatchField<Type>&
-        );
-
-        //- Construct and return a clone
-        virtual tmp<fvPatchField<Type>> clone() const
-        {
-            return tmp<fvPatchField<Type>>
-            (
-                new fanFvPatchField<Type>(*this)
-            );
-        }
-
-        //- Construct as copy setting internal field reference
-        fanFvPatchField
-        (
-            const fanFvPatchField<Type>&,
-            const DimensionedField<Type, volMesh>&
-        );
-
-        //- Construct and return a clone setting internal field reference
-        virtual tmp<fvPatchField<Type>> clone
-        (
-            const DimensionedField<Type, volMesh>& iF
-        ) const
-        {
-            return tmp<fvPatchField<Type>>
-            (
-                new fanFvPatchField<Type>(*this, iF)
-            );
-        }
-
-
-    // Member functions
-
-        //- Update the coefficients associated with the patch field
-        virtual void updateCoeffs();
-
-        //- Write
-        virtual void write(Ostream&) const;
-};
-
-
-//- Specialisation of the jump-condition for the pressure
-template<>
-void fanFvPatchField<scalar>::calcFanJump();
-
-template<>
-fanFvPatchField<scalar>::fanFvPatchField
-(
-    const fvPatch&,
-    const DimensionedField<scalar, volMesh>&,
-    const dictionary&
-);
-
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#ifdef NoRepository
-    #include "fanFvPatchField.C"
-#endif
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#endif
-
-// ************************************************************************* //
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C
deleted file mode 100644
index f5d33b7..0000000
--- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C
+++ /dev/null
@@ -1,99 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     | Website:  https://openfoam.org
-    \\  /    A nd           | Copyright (C) 2011-2018 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 "fanFvPatchFields.H"
-#include "addToRunTimeSelectionTable.H"
-#include "volFields.H"
-#include "surfaceFields.H"
-#include "Tuple2.H"
-#include "PolynomialEntry.H"
-
-// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
-
-template<>
-void Foam::fanFvPatchField<Foam::scalar>::calcFanJump()
-{
-    if (this->cyclicPatch().owner())
-    {
-        const surfaceScalarField& phi =
-            db().lookupObject<surfaceScalarField>(phiName_);
-
-        const fvsPatchField<scalar>& phip =
-            patch().patchField<surfaceScalarField, scalar>(phi);
-
-        scalarField Un(max(phip/patch().magSf(), scalar(0)));
-
-        if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
-        {
-            Un /= patch().lookupPatchField<volScalarField, scalar>(rhoName_);
-        }
-
-        this->jump_ = max(this->jumpTable_->value(Un), scalar(0));
-    }
-}
-
-
-// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
-
-template<>
-Foam::fanFvPatchField<Foam::scalar>::fanFvPatchField
-(
-    const fvPatch& p,
-    const DimensionedField<scalar, volMesh>& iF,
-    const dictionary& dict
-)
-:
-    uniformJumpFvPatchField<scalar>(p, iF),
-    phiName_(dict.lookupOrDefault<word>("phi", "phi")),
-    rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
-{
-    if (this->cyclicPatch().owner())
-    {
-        this->jumpTable_ = Function1<scalar>::New("jumpTable", dict);
-    }
-
-    if (dict.found("value"))
-    {
-        fvPatchScalarField::operator=
-        (
-            scalarField("value", dict, p.size())
-        );
-    }
-    else
-    {
-        this->evaluate(Pstream::commsTypes::blocking);
-    }
-}
-
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-    makeTemplatePatchTypeField(scalar, fan);
-}
-
-
-// ************************************************************************* //
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.H b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.H
deleted file mode 100644
index ad86908..0000000
--- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.H
+++ /dev/null
@@ -1,49 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     | Website:  https://openfoam.org
-    \\  /    A nd           | Copyright (C) 2011-2018 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/>.
-
-\*---------------------------------------------------------------------------*/
-
-#ifndef fanFvPatchFields_H
-#define fanFvPatchFields_H
-
-#include "fanFvPatchField.H"
-#include "fieldTypes.H"
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-makePatchTypeFieldTypedefs(fan);
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#endif
-
-// ************************************************************************* //
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFieldsFwd.H b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFieldsFwd.H
deleted file mode 100644
index b9775f9..0000000
--- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFieldsFwd.H
+++ /dev/null
@@ -1,50 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     | Website:  https://openfoam.org
-    \\  /    A nd           | Copyright (C) 2011-2018 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/>.
-
-\*---------------------------------------------------------------------------*/
-
-#ifndef fanFvPatchFieldsFwd_H
-#define fanFvPatchFieldsFwd_H
-
-#include "fieldTypes.H"
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-template<class Type> class fanFvPatchField;
-
-makePatchTypeFieldTypedefs(fan);
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#endif
-
-// ************************************************************************* //
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fanPressureJump/fanPressureJumpFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/fanPressureJump/fanPressureJumpFvPatchScalarField.C
new file mode 100644
index 0000000..a9314fb
--- /dev/null
+++ b/src/finiteVolume/fields/fvPatchFields/derived/fanPressureJump/fanPressureJumpFvPatchScalarField.C
@@ -0,0 +1,228 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     | Website:  https://openfoam.org
+    \\  /    A nd           | Copyright (C) 2011-2018 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 "fanPressureJumpFvPatchScalarField.H"
+#include "addToRunTimeSelectionTable.H"
+#include "volFields.H"
+#include "surfaceFields.H"
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+void Foam::fanPressureJumpFvPatchScalarField::calcFanJump()
+{
+    const fvsPatchField<scalar>& phip =
+        patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
+
+    const bool massBasedFlux =
+        phip.internalField().dimensions() == dimDensity*dimVelocity*dimArea;
+
+    const scalar dir =  reverse_ ? -1 : 1;
+
+    //- Jump table is defined in backward compatibility mode
+    if(jumpTable_.valid())
+    {
+        //- Patch normal velocity field
+        scalarField Un(max(dir*phip/patch().magSf(), scalar(0)));
+
+        if (massBasedFlux)
+        {
+            const fvPatchField<scalar>& rhop =
+                patch().lookupPatchField<volScalarField, scalar>(rhoName_);
+
+            Un /= rhop;
+        }
+
+        jump_ = dir*max(jumpTable_->value(Un), scalar(0));
+    }
+    else
+    {
+        scalar volFlowRate = 0;
+
+        if (massBasedFlux)
+        {
+            const scalarField& rhop =
+                patch().lookupPatchField<volScalarField, scalar>(rhoName_);
+
+            volFlowRate = gSum(phip/rhop);
+        }
+        else
+        {
+            volFlowRate = gSum(phip);
+        }
+
+
+        jump_ = dir*max(fanCurve_->value(max(dir*volFlowRate, 0)), 0);
+    }
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::fanPressureJumpFvPatchScalarField::fanPressureJumpFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedJumpFvPatchScalarField(p, iF),
+    fanCurve_(),
+    jumpTable_(),
+    reverse_(false),
+    phiName_("phi"),
+    rhoName_("rho")
+{}
+
+
+Foam::fanPressureJumpFvPatchScalarField::fanPressureJumpFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const dictionary& dict
+)
+:
+    fixedJumpFvPatchScalarField(p, iF),
+    fanCurve_(),
+    jumpTable_(),
+    reverse_(dict.lookupOrDefault<Switch>("reverse", false)),
+    phiName_(dict.lookupOrDefault<word>("phi", "phi")),
+    rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
+{
+    if (cyclicPatch().owner())
+    {
+        if (dict.found("jumpTable"))
+        {
+            //- backward compatibility model
+            jumpTable_ = Function1<scalar>::New("jumpTable", dict);
+        }
+        else
+        {
+            fanCurve_ = Function1<scalar>::New("fanCurve", dict);
+        }
+    }
+
+    if (dict.found("value"))
+    {
+        fvPatchScalarField::operator=
+        (
+            scalarField("value", dict, p.size())
+        );
+    }
+    else
+    {
+        evaluate(Pstream::commsTypes::blocking);
+    }
+}
+
+
+Foam::fanPressureJumpFvPatchScalarField::fanPressureJumpFvPatchScalarField
+(
+    const fanPressureJumpFvPatchScalarField& ptf,
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const fvPatchFieldMapper& mapper
+)
+:
+    fixedJumpFvPatchScalarField(ptf, p, iF, mapper),
+    fanCurve_(ptf.fanCurve_, false),
+    jumpTable_(ptf.jumpTable_, false),
+    reverse_(ptf.reverse_),
+    phiName_(ptf.phiName_),
+    rhoName_(ptf.rhoName_)
+{}
+
+
+Foam::fanPressureJumpFvPatchScalarField::fanPressureJumpFvPatchScalarField
+(
+    const fanPressureJumpFvPatchScalarField& ptf
+)
+:
+    fixedJumpFvPatchScalarField(ptf),
+    fanCurve_(ptf.fanCurve_, false),
+    jumpTable_(ptf.jumpTable_, false),
+    reverse_(ptf.reverse_),
+    phiName_(ptf.phiName_),
+    rhoName_(ptf.rhoName_)
+{}
+
+
+Foam::fanPressureJumpFvPatchScalarField::fanPressureJumpFvPatchScalarField
+(
+    const fanPressureJumpFvPatchScalarField& ptf,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedJumpFvPatchScalarField(ptf, iF),
+    fanCurve_(ptf.fanCurve_, false),
+    jumpTable_(ptf.jumpTable_, false),
+    reverse_(ptf.reverse_),
+    phiName_(ptf.phiName_),
+    rhoName_(ptf.rhoName_)
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void Foam::fanPressureJumpFvPatchScalarField::updateCoeffs()
+{
+    if (updated())
+    {
+        return;
+    }
+
+    if (cyclicPatch().owner())
+    {
+        calcFanJump();
+    }
+
+    fixedJumpFvPatchScalarField::updateCoeffs();
+}
+
+
+void Foam::fanPressureJumpFvPatchScalarField::write(Ostream& os) const
+{
+    fixedJumpFvPatchScalarField::write(os);
+
+    if (jumpTable_.valid()) jumpTable_->writeData(os);
+    if (fanCurve_.valid()) fanCurve_->writeData(os);
+
+    writeEntryIfDifferent<Switch>(os, "reverse", false, reverse_);
+    writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
+    writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+    makePatchTypeField
+    (
+        fvPatchScalarField,
+        fanPressureJumpFvPatchScalarField
+    );
+};
+
+
+// ************************************************************************* //
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fanPressureJump/fanPressureJumpFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/fanPressureJump/fanPressureJumpFvPatchScalarField.H
new file mode 100644
index 0000000..e78ac2c
--- /dev/null
+++ b/src/finiteVolume/fields/fvPatchFields/derived/fanPressureJump/fanPressureJumpFvPatchScalarField.H
@@ -0,0 +1,212 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     | Website:  https://openfoam.org
+    \\  /    A nd           | Copyright (C) 2011-2018 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/>.
+
+Class
+    Foam::fanPressureJumpFvPatchScalarField
+
+Description
+    This boundary condition provides a pressure jump condition, using
+    the \c cyclic condition as a base.
+
+    The jump is specified as a \c Function1 type, to enable the use of, e.g.
+    constant, polynomial, table values. This boundary condition can operate
+    in two modes - standard and backward compatibility.
+    In standard mode, jump is specified as a function of total volumetric
+    flow rate through the patch. In backward compatibility mode, the boundary
+    conditions serves as a direct replacement for the fanFvPatchField, where
+    jump is defined as a function of local velocity.
+
+Usage
+    \table
+        Property     | Description             | Required    | Default value
+        patchType    | underlying patch type should be \c cyclic| yes |
+        fanCurve     | fan curve, e.g. \c csvFile | yes      |
+        jumpTable    | jump data (backward compatibility mode) | no       |
+        reverse      | reverse jump direction  | no | false
+        phi          | flux field name         | no          | phi
+        rho          | density field name      | no          | rho
+    \endtable
+
+    Example of the boundary condition specification:
+    \verbatim
+    <patchName>
+    {
+        type            fan;
+        patchType       cyclic;
+        fanCurve       csvFile;
+        csvFileCoeffs
+        {
+            hasHeaderLine   1;
+            refColumn       0;
+            componentColumns 1(1);
+            separator       ",";
+            file           "$FOAM_CASE/constant/pressureVsQ";
+        }
+        value           uniform 0;
+    }
+    \endverbatim
+
+    The above example shows the use of a comma separated (CSV) file to specify
+    the jump condition.
+
+Note
+     The underlying \c patchType should be set to \c cyclic
+
+See also
+    Foam::Function1Types
+
+SourceFiles
+    fanPressureJumpFvPatchScalarField.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef fanPressureJumpFvPatchScalarField_H
+#define fanPressureJumpFvPatchScalarField_H
+
+#include "fixedJumpFvPatchFields.H"
+#include "Function1.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+              Class fanPressureJumpFvPatchScalarField Declaration
+\*---------------------------------------------------------------------------*/
+
+class fanPressureJumpFvPatchScalarField
+:
+    public fixedJumpFvPatchScalarField
+{
+    // Private data
+
+        //- Fan curve
+        autoPtr<Function1<scalar>> fanCurve_;
+
+        //- Jump table (backward compatibility)
+        autoPtr<Function1<scalar>> jumpTable_;
+
+        //- Set true to reverse jump direction
+        Switch reverse_;
+
+        //- Name of the flux transporting the field
+        word phiName_;
+
+        //- Name of the density field used to normalise the mass flux
+        //  if necessary
+        word rhoName_;
+
+
+    // Private Member Functions
+
+        //- Calculate the fan pressure jump
+        void calcFanJump();
+
+
+public:
+
+    //- Runtime type information
+    TypeName("fanPressureJump");
+
+
+    // Constructors
+
+        //- Construct from patch and internal field
+        fanPressureJumpFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct from patch, internal field and dictionary
+        fanPressureJumpFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const dictionary&
+        );
+
+        //- Construct by mapping given patch onto a new patch
+        fanPressureJumpFvPatchScalarField
+        (
+            const fanPressureJumpFvPatchScalarField&,
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const fvPatchFieldMapper&
+        );
+
+        //- Construct as copy
+        fanPressureJumpFvPatchScalarField
+        (
+            const fanPressureJumpFvPatchScalarField&
+        );
+
+        //- Construct and return a clone
+        virtual tmp<fvPatchScalarField> clone() const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new fanPressureJumpFvPatchScalarField(*this)
+            );
+        }
+
+        //- Construct as copy setting internal field reference
+        fanPressureJumpFvPatchScalarField
+        (
+            const fanPressureJumpFvPatchScalarField&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct and return a clone setting internal field reference
+        virtual tmp<fvPatchField<scalar>> clone
+        (
+            const DimensionedField<scalar, volMesh>& iF
+        ) const
+        {
+            return tmp<fvPatchField<scalar>>
+            (
+                new fanPressureJumpFvPatchScalarField(*this, iF)
+            );
+        }
+
+
+    // Member functions
+
+        //- Update the coefficients associated with the patch field
+        virtual void updateCoeffs();
+
+        //- Write
+        virtual void write(Ostream&) const;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
-- 
2.7.4

