From e72e7c5625cc55315cb070120859577a526e3350 Mon Sep 17 00:00:00 2001
From: Henry Weller <http://cfd.direct>
Date: Sat, 8 Apr 2017 22:06:41 +0100
Subject: [PATCH] externalWallHeatFluxTemperatureFvPatchScalarField: Added
 "power" heat source option

by combining with and rationalizing functionality from
turbulentHeatFluxTemperatureFvPatchScalarField.
externalWallHeatFluxTemperatureFvPatchScalarField now replaces
turbulentHeatFluxTemperatureFvPatchScalarField which is no longer needed and has
been removed.

Description
    This boundary condition applies a heat flux condition to temperature
    on an external wall in one of three modes:

      - fixed power: supply Q
      - fixed heat flux: supply q
      - fixed heat transfer coefficient: supply h and Ta

    where:
    \vartable
        Q  | Power [W]
        q  | Heat flux [W/m^2]
        h  | Heat transfer coefficient [W/m^2/K]
        Ta | Ambient temperature [K]
    \endvartable

    For heat transfer coefficient mode optional thin thermal layer resistances
    can be specified through thicknessLayers and kappaLayers entries.

    The thermal conductivity \c kappa can either be retrieved from various
    possible sources, as detailed in the class temperatureCoupledBase.

Usage
    \table
    Property     | Description                 | Required | Default value
    mode         | 'power', 'flux' or 'coefficient' | yes |
    Q            | Power [W]                   | for mode 'power'     |
    q            | Heat flux [W/m^2]           | for mode 'flux'     |
    h            | Heat transfer coefficient [W/m^2/K] | for mode 'coefficent' |
    Ta           | Ambient temperature [K]     | for mode 'coefficient' |
    thicknessLayers | Layer thicknesses [m] | no |
    kappaLayers  | Layer thermal conductivities [W/m/K] | no |
    qr           | Name of the radiative field | no | none
    qrRelaxation | Relaxation factor for radiative field | no | 1
    kappaMethod  | Inherited from temperatureCoupledBase | inherited |
    kappa        | Inherited from temperatureCoupledBase | inherited |
    \endtable

    Example of the boundary condition specification:
    \verbatim
    <patchName>
    {
        type            externalWallHeatFluxTemperature;

        mode            coefficient;

        Ta              uniform 300.0;
        h               uniform 10.0;
        thicknessLayers (0.1 0.2 0.3 0.4);
        kappaLayers     (1 2 3 4);

        kappaMethod     fluidThermo;

        value           $internalField;
    }
    \endverbatim
---
 etc/controlDict                               |   1 -
 src/TurbulenceModels/compressible/Make/files  |   1 -
 ...allHeatFluxTemperatureFvPatchScalarField.C | 340 +++++++++++-------
 ...allHeatFluxTemperatureFvPatchScalarField.H |  88 ++---
 ...entHeatFluxTemperatureFvPatchScalarField.C | 262 --------------
 ...entHeatFluxTemperatureFvPatchScalarField.H | 231 ------------
 6 files changed, 263 insertions(+), 660 deletions(-)
 delete mode 100644 src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C
 delete mode 100644 src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.H

diff --git a/etc/controlDict b/etc/controlDict
index ed0606904d..832e63b55b 100644
--- a/etc/controlDict
+++ b/etc/controlDict
@@ -847,7 +847,6 @@ DebugSwitches
     triSurface          0;
     triSurfaceMesh      0;
     turbulenceModel     0;
-    turbulentHeatFluxTemperature 0;
     turbulentInlet      0;
     turbulentIntensityKineticEnergyInlet 0;
     turbulentMixingLengthDissipationRateInlet 0;
diff --git a/src/TurbulenceModels/compressible/Make/files b/src/TurbulenceModels/compressible/Make/files
index c4aab94251..56de74799c 100644
--- a/src/TurbulenceModels/compressible/Make/files
+++ b/src/TurbulenceModels/compressible/Make/files
@@ -2,7 +2,6 @@ compressibleTurbulenceModel.C
 turbulentFluidThermoModels/turbulentFluidThermoModels.C
 
 BCs = turbulentFluidThermoModels/derivedFvPatchFields
-$(BCs)/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C
 $(BCs)/temperatureCoupledBase/temperatureCoupledBase.C
 $(BCs)/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C
 $(BCs)/thermalBaffle1D/thermalBaffle1DFvPatchScalarFields.C
diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C
index 4c74daaf89..186722c21e 100644
--- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C
+++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.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
@@ -40,12 +40,11 @@ namespace Foam
         3
     >::names[] =
     {
-        "fixed_heat_flux",
-        "fixed_heat_transfer_coefficient",
-        "unknown"
+        "power",
+        "flux",
+        "coefficient"
     };
-
-} // End namespace Foam
+}
 
 const Foam::NamedEnum
 <
@@ -65,45 +64,19 @@ externalWallHeatFluxTemperatureFvPatchScalarField
 :
     mixedFvPatchScalarField(p, iF),
     temperatureCoupledBase(patch(), "undefined", "undefined", "undefined-K"),
-    mode_(unknown),
-    q_(p.size(), 0.0),
-    h_(p.size(), 0.0),
-    Ta_(p.size(), 0.0),
-    QrPrevious_(p.size(), 0.0),
-    QrRelaxation_(1),
-    QrName_("undefined-Qr"),
+    mode_(fixedHeatFlux),
+    Q_(0),
+    qrRelaxation_(1),
+    qrName_("undefined-qr"),
     thicknessLayers_(),
     kappaLayers_()
 {
-    refValue() = 0.0;
-    refGrad() = 0.0;
-    valueFraction() = 1.0;
+    refValue() = 0;
+    refGrad() = 0;
+    valueFraction() = 1;
 }
 
 
-Foam::externalWallHeatFluxTemperatureFvPatchScalarField::
-externalWallHeatFluxTemperatureFvPatchScalarField
-(
-    const externalWallHeatFluxTemperatureFvPatchScalarField& ptf,
-    const fvPatch& p,
-    const DimensionedField<scalar, volMesh>& iF,
-    const fvPatchFieldMapper& mapper
-)
-:
-    mixedFvPatchScalarField(ptf, p, iF, mapper),
-    temperatureCoupledBase(patch(), ptf),
-    mode_(ptf.mode_),
-    q_(ptf.q_, mapper),
-    h_(ptf.h_, mapper),
-    Ta_(ptf.Ta_, mapper),
-    QrPrevious_(ptf.QrPrevious_, mapper),
-    QrRelaxation_(ptf.QrRelaxation_),
-    QrName_(ptf.QrName_),
-    thicknessLayers_(ptf.thicknessLayers_),
-    kappaLayers_(ptf.kappaLayers_)
-{}
-
-
 Foam::externalWallHeatFluxTemperatureFvPatchScalarField::
 externalWallHeatFluxTemperatureFvPatchScalarField
 (
@@ -114,48 +87,54 @@ externalWallHeatFluxTemperatureFvPatchScalarField
 :
     mixedFvPatchScalarField(p, iF),
     temperatureCoupledBase(patch(), dict),
-    mode_(unknown),
-    q_(p.size(), 0.0),
-    h_(p.size(), 0.0),
-    Ta_(p.size(), 0.0),
-    QrPrevious_(p.size(), 0.0),
-    QrRelaxation_(dict.lookupOrDefault<scalar>("relaxation", 1)),
-    QrName_(dict.lookupOrDefault<word>("Qr", "none")),
+    mode_(operationModeNames.read(dict.lookup("mode"))),
+    Q_(0),
+    qrRelaxation_(dict.lookupOrDefault<scalar>("qrRelaxation", 1)),
+    qrName_(dict.lookupOrDefault<word>("qr", "none")),
     thicknessLayers_(),
     kappaLayers_()
 {
-    if (dict.found("q") && !dict.found("h") && !dict.found("Ta"))
-    {
-        mode_ = fixedHeatFlux;
-        q_ = scalarField("q", dict, p.size());
-    }
-    else if (dict.found("h") && dict.found("Ta") && !dict.found("q"))
+    switch (mode_)
     {
-        mode_ = fixedHeatTransferCoeff;
-        h_ = scalarField("h", dict, p.size());
-        Ta_ = scalarField("Ta", dict, p.size());
-        if (dict.found("thicknessLayers"))
+        case fixedPower:
         {
-            dict.lookup("thicknessLayers") >> thicknessLayers_;
-            dict.lookup("kappaLayers") >> kappaLayers_;
+            dict.lookup("Q") >> Q_;
+
+            break;
+        }
+        case fixedHeatFlux:
+        {
+            q_ = scalarField("q", dict, p.size());
+
+            break;
+        }
+        case fixedHeatTransferCoeff:
+        {
+            h_ = scalarField("h", dict, p.size());
+            Ta_ = scalarField("Ta", dict, p.size());
+
+            if (dict.found("thicknessLayers"))
+            {
+                dict.lookup("thicknessLayers") >> thicknessLayers_;
+                dict.lookup("kappaLayers") >> kappaLayers_;
+            }
+
+            break;
         }
-    }
-    else
-    {
-        FatalErrorInFunction
-            << "\n patch type '" << p.type()
-            << "' either q or h and Ta were not found '"
-            << "\n for patch " << p.name()
-            << " of field " << internalField().name()
-            << " in file " << internalField().objectPath()
-            << exit(FatalError);
     }
 
     fvPatchScalarField::operator=(scalarField("value", dict, p.size()));
 
-    if (dict.found("QrPrevious"))
+    if (qrName_ != "none")
     {
-        QrPrevious_ = scalarField("QrPrevious", dict, p.size());
+        if (dict.found("qrPrevious"))
+        {
+            qrPrevious_ = scalarField("qrPrevious", dict, p.size());
+        }
+        else
+        {
+            qrPrevious_.setSize(p.size(), 0);
+        }
     }
 
     if (dict.found("refValue"))
@@ -169,8 +148,54 @@ externalWallHeatFluxTemperatureFvPatchScalarField
     {
         // Start from user entered data. Assume fixedValue.
         refValue() = *this;
-        refGrad() = 0.0;
-        valueFraction() = 1.0;
+        refGrad() = 0;
+        valueFraction() = 1;
+    }
+}
+
+
+Foam::externalWallHeatFluxTemperatureFvPatchScalarField::
+externalWallHeatFluxTemperatureFvPatchScalarField
+(
+    const externalWallHeatFluxTemperatureFvPatchScalarField& ptf,
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const fvPatchFieldMapper& mapper
+)
+:
+    mixedFvPatchScalarField(ptf, p, iF, mapper),
+    temperatureCoupledBase(patch(), ptf),
+    mode_(ptf.mode_),
+    Q_(ptf.Q_),
+    qrRelaxation_(ptf.qrRelaxation_),
+    qrName_(ptf.qrName_),
+    thicknessLayers_(ptf.thicknessLayers_),
+    kappaLayers_(ptf.kappaLayers_)
+{
+    switch (mode_)
+    {
+        case fixedPower:
+        {
+            break;
+        }
+        case fixedHeatFlux:
+        {
+            q_.autoMap(mapper);
+
+            break;
+        }
+        case fixedHeatTransferCoeff:
+        {
+            h_.autoMap(mapper);
+            Ta_.autoMap(mapper);
+
+            break;
+        }
+    }
+
+    if (qrName_ != "none")
+    {
+        qrPrevious_.autoMap(mapper);
     }
 }
 
@@ -184,12 +209,13 @@ externalWallHeatFluxTemperatureFvPatchScalarField
     mixedFvPatchScalarField(tppsf),
     temperatureCoupledBase(tppsf),
     mode_(tppsf.mode_),
+    Q_(tppsf.Q_),
     q_(tppsf.q_),
     h_(tppsf.h_),
     Ta_(tppsf.Ta_),
-    QrPrevious_(tppsf.QrPrevious_),
-    QrRelaxation_(tppsf.QrRelaxation_),
-    QrName_(tppsf.QrName_),
+    qrPrevious_(tppsf.qrPrevious_),
+    qrRelaxation_(tppsf.qrRelaxation_),
+    qrName_(tppsf.qrName_),
     thicknessLayers_(tppsf.thicknessLayers_),
     kappaLayers_(tppsf.kappaLayers_)
 {}
@@ -205,12 +231,13 @@ externalWallHeatFluxTemperatureFvPatchScalarField
     mixedFvPatchScalarField(tppsf, iF),
     temperatureCoupledBase(patch(), tppsf),
     mode_(tppsf.mode_),
+    Q_(tppsf.Q_),
     q_(tppsf.q_),
     h_(tppsf.h_),
     Ta_(tppsf.Ta_),
-    QrPrevious_(tppsf.QrPrevious_),
-    QrRelaxation_(tppsf.QrRelaxation_),
-    QrName_(tppsf.QrName_),
+    qrPrevious_(tppsf.qrPrevious_),
+    qrRelaxation_(tppsf.qrRelaxation_),
+    qrName_(tppsf.qrName_),
     thicknessLayers_(tppsf.thicknessLayers_),
     kappaLayers_(tppsf.kappaLayers_)
 {}
@@ -224,10 +251,32 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::autoMap
 )
 {
     mixedFvPatchScalarField::autoMap(m);
-    q_.autoMap(m);
-    h_.autoMap(m);
-    Ta_.autoMap(m);
-    QrPrevious_.autoMap(m);
+
+    switch (mode_)
+    {
+        case fixedPower:
+        {
+            break;
+        }
+        case fixedHeatFlux:
+        {
+            q_.autoMap(m);
+
+            break;
+        }
+        case fixedHeatTransferCoeff:
+        {
+            h_.autoMap(m);
+            Ta_.autoMap(m);
+
+            break;
+        }
+    }
+
+    if (qrName_ != "none")
+    {
+        qrPrevious_.autoMap(m);
+    }
 }
 
 
@@ -242,10 +291,31 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::rmap
     const externalWallHeatFluxTemperatureFvPatchScalarField& tiptf =
         refCast<const externalWallHeatFluxTemperatureFvPatchScalarField>(ptf);
 
-    q_.rmap(tiptf.q_, addr);
-    h_.rmap(tiptf.h_, addr);
-    Ta_.rmap(tiptf.Ta_, addr);
-    QrPrevious_.rmap(tiptf.QrPrevious_, addr);
+    switch (mode_)
+    {
+        case fixedPower:
+        {
+            break;
+        }
+        case fixedHeatFlux:
+        {
+            q_.rmap(tiptf.q_, addr);
+
+            break;
+        }
+        case fixedHeatTransferCoeff:
+        {
+            h_.rmap(tiptf.h_, addr);
+            Ta_.rmap(tiptf.Ta_, addr);
+
+            break;
+        }
+    }
+
+    if (qrName_ != "none")
+    {
+        qrPrevious_.rmap(tiptf.qrPrevious_, addr);
+    }
 }
 
 
@@ -257,64 +327,68 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::updateCoeffs()
     }
 
     const scalarField Tp(*this);
-    scalarField hp(patch().size(), 0.0);
+    scalarField hp(patch().size(), 0);
 
-    scalarField Qr(Tp.size(), 0.0);
-    if (QrName_ != "none")
+    scalarField qr(Tp.size(), 0);
+    if (qrName_ != "none")
     {
-        Qr = patch().lookupPatchField<volScalarField, scalar>(QrName_);
+        qr =
+            qrRelaxation_
+           *patch().lookupPatchField<volScalarField, scalar>(qrName_)
+          + (1 - qrRelaxation_)*qrPrevious_;
 
-        Qr = QrRelaxation_*Qr + (1.0 - QrRelaxation_)*QrPrevious_;
-        QrPrevious_ = Qr;
+        qrPrevious_ = qr;
     }
 
     switch (mode_)
     {
+        case fixedPower:
+        {
+            refGrad() = (Q_/gSum(patch().magSf()) + qr)/kappa(Tp);
+            refValue() = 0;
+            valueFraction() = 0;
+
+            break;
+        }
         case fixedHeatFlux:
         {
-            refGrad() = (q_ + Qr)/kappa(Tp);
-            refValue() = 0.0;
-            valueFraction() = 0.0;
+            refGrad() = (q_ + qr)/kappa(Tp);
+            refValue() = 0;
+            valueFraction() = 0;
 
             break;
         }
         case fixedHeatTransferCoeff:
         {
-            scalar totalSolidRes = 0.0;
-            if (thicknessLayers_.size() > 0)
+            scalar totalSolidRes = 0;
+            if (thicknessLayers_.size())
             {
                 forAll(thicknessLayers_, iLayer)
                 {
                     const scalar l = thicknessLayers_[iLayer];
-                    if (kappaLayers_[iLayer] > 0.0)
+                    if (kappaLayers_[iLayer] > 0)
                     {
                         totalSolidRes += l/kappaLayers_[iLayer];
                     }
                 }
             }
-            hp = 1.0/(1.0/h_ + totalSolidRes);
+            hp = 1/(1/h_ + totalSolidRes);
 
-            Qr /= Tp;
-            refGrad() = 0.0;
-            refValue() = hp*Ta_/(hp - Qr);
+            qr /= Tp;
+            refGrad() = 0;
+            refValue() = hp*Ta_/(hp - qr);
             valueFraction() =
-                (hp - Qr)/((hp - Qr) + kappa(Tp)*patch().deltaCoeffs());
+                (hp - qr)/((hp - qr) + kappa(Tp)*patch().deltaCoeffs());
 
             break;
         }
-        default:
-        {
-            FatalErrorInFunction
-                << "Illegal heat flux mode " << operationModeNames[mode_]
-                << exit(FatalError);
-        }
     }
 
     mixedFvPatchScalarField::updateCoeffs();
 
     if (debug)
     {
-        scalar Q = gSum(kappa(Tp)*patch().magSf()*snGrad());
+        const scalar Q = gSum(kappa(Tp)*patch().magSf()*snGrad());
 
         Info<< patch().boundaryMesh().mesh().name() << ':'
             << patch().name() << ':'
@@ -334,37 +408,55 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::write
     Ostream& os
 ) const
 {
-    mixedFvPatchScalarField::write(os);
-    temperatureCoupledBase::write(os);
+    fvPatchScalarField::write(os);
 
-    QrPrevious_.writeEntry("QrPrevious", os);
-    os.writeKeyword("Qr")<< QrName_ << token::END_STATEMENT << nl;
-    os.writeKeyword("relaxation")<< QrRelaxation_
-        << token::END_STATEMENT << nl;
+    os.writeKeyword("mode")
+        << operationModeNames[mode_] << token::END_STATEMENT << nl;
+    temperatureCoupledBase::write(os);
 
     switch (mode_)
     {
+        case fixedPower:
+        {
+            os.writeKeyword("Q")
+                << Q_ << token::END_STATEMENT << nl;
 
+            break;
+        }
         case fixedHeatFlux:
         {
             q_.writeEntry("q", os);
+
             break;
         }
         case fixedHeatTransferCoeff:
         {
             h_.writeEntry("h", os);
             Ta_.writeEntry("Ta", os);
-            thicknessLayers_.writeEntry("thicknessLayers", os);
-            kappaLayers_.writeEntry("kappaLayers", os);
+
+            if (thicknessLayers_.size())
+            {
+                thicknessLayers_.writeEntry("thicknessLayers", os);
+                kappaLayers_.writeEntry("kappaLayers", os);
+            }
+
             break;
         }
-        default:
-        {
-            FatalErrorInFunction
-                << "Illegal heat flux mode " << operationModeNames[mode_]
-                << abort(FatalError);
-        }
     }
+
+    os.writeKeyword("qr")<< qrName_ << token::END_STATEMENT << nl;
+
+    if (qrName_ != "none")
+    {
+        qrPrevious_.writeEntry("qrPrevious", os);
+        os.writeKeyword("qrRelaxation")
+            << qrRelaxation_ << token::END_STATEMENT << nl;
+    }
+
+    refValue().writeEntry("refValue", os);
+    refGrad().writeEntry("refGradient", os);
+    valueFraction().writeEntry("valueFraction", os);
+    writeEntry("value", os);
 }
 
 
diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.H b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.H
index 9b15197851..2389f60ec3 100644
--- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.H
+++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.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
@@ -28,37 +28,41 @@ Group
     grpThermoBoundaryConditions grpWallBoundaryConditions
 
 Description
-    This boundary condition supplies a heat flux condition for temperature
-    on an external wall. Optional thin thermal layer resistances can be
-    specified through thicknessLayers and kappaLayers entries for the
-    fixed heat transfer coefficient mode.
+    This boundary condition applies a heat flux condition to temperature
+    on an external wall in one of three modes:
 
-    The condition can operate in two modes:
-      - fixed heat transfer coefficient: supply h and Ta
+      - fixed power: supply Q
       - fixed heat flux: supply q
+      - fixed heat transfer coefficient: supply h and Ta
 
     where:
     \vartable
-        h  | heat transfer coefficient [W/m^2/K]
-        Ta | ambient temperature [K]
-        q  | heat flux [W/m^2]
+        Q  | Power [W]
+        q  | Heat flux [W/m^2]
+        h  | Heat transfer coefficient [W/m^2/K]
+        Ta | Ambient temperature [K]
     \endvartable
 
+    For heat transfer coefficient mode optional thin thermal layer resistances
+    can be specified through thicknessLayers and kappaLayers entries.
+
     The thermal conductivity \c kappa can either be retrieved from various
     possible sources, as detailed in the class temperatureCoupledBase.
 
 Usage
     \table
-        Property     | Description                 | Required | Default value
-        q            | heat flux [W/m^2]           | yes*     |
-        Ta           | ambient temperature [K]     | yes*     |
-        h            | heat transfer coefficient [W/m^2/K] | yes*|
-        thicknessLayers | list of thicknesses per layer [m] | yes |
-        kappaLayers  | list of thermal conductivities per layer [W/m/K] | yes |
-        Qr           | name of the radiative field | no | no
-        relaxation   | relaxation factor for radiative field | no | 1
-        kappaMethod  | inherited from temperatureCoupledBase | inherited |
-        kappa        | inherited from temperatureCoupledBase | inherited |
+    Property     | Description                 | Required | Default value
+    mode         | 'power', 'flux' or 'coefficient' | yes |
+    Q            | Power [W]                   | for mode 'power'     |
+    q            | Heat flux [W/m^2]           | for mode 'flux'     |
+    h            | Heat transfer coefficient [W/m^2/K] | for mode 'coefficent' |
+    Ta           | Ambient temperature [K]     | for mode 'coefficient' |
+    thicknessLayers | Layer thicknesses [m] | no |
+    kappaLayers  | Layer thermal conductivities [W/m/K] | no |
+    qr           | Name of the radiative field | no | none
+    qrRelaxation | Relaxation factor for radiative field | no | 1
+    kappaMethod  | Inherited from temperatureCoupledBase | inherited |
+    kappa        | Inherited from temperatureCoupledBase | inherited |
     \endtable
 
     Example of the boundary condition specification:
@@ -66,24 +70,23 @@ Usage
     <patchName>
     {
         type            externalWallHeatFluxTemperature;
-        q               uniform 1000;
+
+        mode            coefficient;
+
         Ta              uniform 300.0;
         h               uniform 10.0;
         thicknessLayers (0.1 0.2 0.3 0.4);
         kappaLayers     (1 2 3 4);
-        value           uniform 300.0;
-        Qr              none;
-        relaxation      1;
-        kappaMethod           fluidThermo;
-        kappa       none;
+
+        kappaMethod     fluidThermo;
+
+        value           $internalField;
     }
     \endverbatim
 
-    Note:
-      - Only supply \c h and \c Ta, or \c q in the dictionary (see above)
-
 See also
     Foam::temperatureCoupledBase
+    Foam::mixedFvPatchScalarField
 
 SourceFiles
     externalWallHeatFluxTemperatureFvPatchScalarField.C
@@ -117,9 +120,9 @@ public:
         //- Operation mode enumeration
         enum operationMode
         {
+            fixedPower,
             fixedHeatFlux,
-            fixedHeatTransferCoeff,
-            unknown
+            fixedHeatTransferCoeff
         };
 
         static const NamedEnum<operationMode, 3> operationModeNames;
@@ -132,23 +135,26 @@ private:
         //- Operation mode
         operationMode mode_;
 
-        //- Heat flux / [W/m2]
+        //- Heat power [W]
+        scalar Q_;
+
+        //- Heat flux [W/m2]
         scalarField q_;
 
-        //- Heat transfer coefficient / [W/m2K]
+        //- Heat transfer coefficient [W/m2K]
         scalarField h_;
 
-        //- Ambient temperature / [K]
+        //- Ambient temperature [K]
         scalarField Ta_;
 
-        //- Chache Qr for relaxation
-        scalarField QrPrevious_;
+        //- Chache qr for relaxation
+        scalarField qrPrevious_;
 
-        //- Relaxation for Qr
-        scalar QrRelaxation_;
+        //- Relaxation for qr
+        scalar qrRelaxation_;
 
         //- Name of the radiative heat flux
-        const word QrName_;
+        const word qrName_;
 
         //- Thickness of layers
         scalarList thicknessLayers_;
@@ -181,8 +187,8 @@ public:
         );
 
         //- Construct by mapping given
-        // externalWallHeatFluxTemperatureFvPatchScalarField
-        // onto a new patch
+        //  externalWallHeatFluxTemperatureFvPatchScalarField
+        //  onto a new patch
         externalWallHeatFluxTemperatureFvPatchScalarField
         (
             const externalWallHeatFluxTemperatureFvPatchScalarField&,
diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C
deleted file mode 100644
index 786ceae3e9..0000000000
--- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C
+++ /dev/null
@@ -1,262 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2015 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 "turbulentHeatFluxTemperatureFvPatchScalarField.H"
-#include "addToRunTimeSelectionTable.H"
-#include "fvPatchFieldMapper.H"
-#include "volFields.H"
-
-
-// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
-
-namespace Foam
-{
-    // declare specialization within 'Foam' namespace
-    template<>
-    const char* NamedEnum
-    <
-        Foam::compressible::
-        turbulentHeatFluxTemperatureFvPatchScalarField::heatSourceType,
-        2
-    >::names[] =
-    {
-        "power",
-        "flux"
-    };
-}
-
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-
-namespace Foam
-{
-
-namespace compressible
-{
-
-// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
-
-const NamedEnum
-<
-    turbulentHeatFluxTemperatureFvPatchScalarField::heatSourceType,
-    2
-> turbulentHeatFluxTemperatureFvPatchScalarField::heatSourceTypeNames_;
-
-
-// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
-
-turbulentHeatFluxTemperatureFvPatchScalarField::
-turbulentHeatFluxTemperatureFvPatchScalarField
-(
-    const fvPatch& p,
-    const DimensionedField<scalar, volMesh>& iF
-)
-:
-    fixedGradientFvPatchScalarField(p, iF),
-    temperatureCoupledBase(patch(), "undefined", "undefined", "undefined-K"),
-    heatSource_(hsPower),
-    q_(p.size(), 0.0),
-    QrName_("undefinedQr")
-{}
-
-
-turbulentHeatFluxTemperatureFvPatchScalarField::
-turbulentHeatFluxTemperatureFvPatchScalarField
-(
-    const turbulentHeatFluxTemperatureFvPatchScalarField& ptf,
-    const fvPatch& p,
-    const DimensionedField<scalar, volMesh>& iF,
-    const fvPatchFieldMapper& mapper
-)
-:
-    fixedGradientFvPatchScalarField(ptf, p, iF, mapper),
-    temperatureCoupledBase(patch(), ptf),
-    heatSource_(ptf.heatSource_),
-    q_(ptf.q_, mapper),
-    QrName_(ptf.QrName_)
-{}
-
-
-turbulentHeatFluxTemperatureFvPatchScalarField::
-turbulentHeatFluxTemperatureFvPatchScalarField
-(
-    const fvPatch& p,
-    const DimensionedField<scalar, volMesh>& iF,
-    const dictionary& dict
-)
-:
-    fixedGradientFvPatchScalarField(p, iF),
-    temperatureCoupledBase(patch(), dict),
-    heatSource_(heatSourceTypeNames_.read(dict.lookup("heatSource"))),
-    q_("q", dict, p.size()),
-    QrName_(dict.lookupOrDefault<word>("Qr", "none"))
-{
-    if (dict.found("value") && dict.found("gradient"))
-    {
-        fvPatchField<scalar>::operator=(Field<scalar>("value", dict, p.size()));
-        gradient() = Field<scalar>("gradient", dict, p.size());
-    }
-    else
-    {
-        // Still reading so cannot yet evaluate. Make up a value.
-        fvPatchField<scalar>::operator=(patchInternalField());
-        gradient() = 0.0;
-    }
-}
-
-
-turbulentHeatFluxTemperatureFvPatchScalarField::
-turbulentHeatFluxTemperatureFvPatchScalarField
-(
-    const turbulentHeatFluxTemperatureFvPatchScalarField& thftpsf
-)
-:
-    fixedGradientFvPatchScalarField(thftpsf),
-    temperatureCoupledBase(patch(), thftpsf),
-    heatSource_(thftpsf.heatSource_),
-    q_(thftpsf.q_),
-    QrName_(thftpsf.QrName_)
-{}
-
-
-turbulentHeatFluxTemperatureFvPatchScalarField::
-turbulentHeatFluxTemperatureFvPatchScalarField
-(
-    const turbulentHeatFluxTemperatureFvPatchScalarField& thftpsf,
-    const DimensionedField<scalar, volMesh>& iF
-)
-:
-    fixedGradientFvPatchScalarField(thftpsf, iF),
-    temperatureCoupledBase(patch(), thftpsf),
-    heatSource_(thftpsf.heatSource_),
-    q_(thftpsf.q_),
-    QrName_(thftpsf.QrName_)
-{}
-
-
-// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
-
-void turbulentHeatFluxTemperatureFvPatchScalarField::autoMap
-(
-    const fvPatchFieldMapper& m
-)
-{
-    fixedGradientFvPatchScalarField::autoMap(m);
-    q_.autoMap(m);
-}
-
-
-void turbulentHeatFluxTemperatureFvPatchScalarField::rmap
-(
-    const fvPatchScalarField& ptf,
-    const labelList& addr
-)
-{
-    fixedGradientFvPatchScalarField::rmap(ptf, addr);
-
-    const turbulentHeatFluxTemperatureFvPatchScalarField& thftptf =
-        refCast<const turbulentHeatFluxTemperatureFvPatchScalarField>
-        (
-            ptf
-        );
-
-    q_.rmap(thftptf.q_, addr);
-}
-
-
-void turbulentHeatFluxTemperatureFvPatchScalarField::updateCoeffs()
-{
-    if (updated())
-    {
-        return;
-    }
-
-    const scalarField& Tp = *this;
-
-    scalarField qr(this->size(), 0.0);
-
-    //- Qr is negative going into the domain
-    if (QrName_ != "none")
-    {
-        qr = patch().lookupPatchField<volScalarField, scalar>(QrName_);
-    }
-
-    switch (heatSource_)
-    {
-        case hsPower:
-        {
-            const scalar Ap = gSum(patch().magSf());
-            gradient() = (q_/Ap + qr)/kappa(Tp);
-            break;
-        }
-        case hsFlux:
-        {
-            gradient() = (q_ + qr)/kappa(Tp);
-            break;
-        }
-        default:
-        {
-            FatalErrorInFunction
-                << "Unknown heat source type. Valid types are: "
-                << heatSourceTypeNames_ << nl << exit(FatalError);
-        }
-    }
-
-    fixedGradientFvPatchScalarField::updateCoeffs();
-}
-
-
-void turbulentHeatFluxTemperatureFvPatchScalarField::write
-(
-    Ostream& os
-) const
-{
-    fixedGradientFvPatchScalarField::write(os);
-    os.writeKeyword("heatSource") << heatSourceTypeNames_[heatSource_]
-        << token::END_STATEMENT << nl;
-    temperatureCoupledBase::write(os);
-    q_.writeEntry("q", os);
-    os.writeKeyword("Qr")<< QrName_ << token::END_STATEMENT << nl;
-    writeEntry("value", os);
-}
-
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-makePatchTypeField
-(
-    fvPatchScalarField,
-    turbulentHeatFluxTemperatureFvPatchScalarField
-);
-
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace compressible
-} // End namespace Foam
-
-
-// ************************************************************************* //
diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.H b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.H
deleted file mode 100644
index a19de4fff8..0000000000
--- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.H
+++ /dev/null
@@ -1,231 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2016 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::compressible::turbulentHeatFluxTemperatureFvPatchScalarField
-
-Description
-    Fixed heat boundary condition to specify temperature gradient. Input
-    heat source either specified in terms of an absolute power [W], or as a
-    flux [W/m^2].
-
-    The thermal conductivity \c kappa can either be retrieved from various
-    possible sources, as detailed in the class temperatureCoupledBase.
-
-Usage
-    \table
-        Property     | Description             | Required    | Default value
-        heatSource   | 'power' [W] or 'flux' [W/m^2] | yes |
-        q            | heat power or flux field      | yes |
-        Qr           | name of the radiative flux field | yes |
-        value        | initial temperature value | no | calculated
-        gradient     | initial gradient value | no | 0.0
-        kappaMethod  | inherited from temperatureCoupledBase | inherited |
-        kappa        | inherited from temperatureCoupledBase | inherited |
-    \endtable
-
-    Note: If needed, both 'value' and 'gradient' must be defined to be used.
-
-    Example usage:
-    \verbatim
-    hotWall
-    {
-        type            compressible::turbulentHeatFluxTemperature;
-        heatSource      flux;
-        q               uniform 10;
-        kappaMethod     fluidThermo;
-        kappa           none;
-        Qr              none;
-    }
-    \endverbatim
-
-See also
-    Foam::temperatureCoupledBase
-
-SourceFiles
-    turbulentHeatFluxTemperatureFvPatchScalarField.C
-
-\*---------------------------------------------------------------------------*/
-
-#ifndef turbulentHeatFluxTemperatureFvPatchScalarFields_H
-#define turbulentHeatFluxTemperatureFvPatchScalarFields_H
-
-#include "fixedGradientFvPatchFields.H"
-#include "temperatureCoupledBase.H"
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-namespace compressible
-{
-
-/*---------------------------------------------------------------------------*\
-      Class turbulentHeatFluxTemperatureFvPatchScalarField Declaration
-\*---------------------------------------------------------------------------*/
-
-class turbulentHeatFluxTemperatureFvPatchScalarField
-:
-    public fixedGradientFvPatchScalarField,
-    public temperatureCoupledBase
-{
-public:
-
-    // Data types
-
-        //- Enumeration listing the possible hest source input modes
-        enum heatSourceType
-        {
-            hsPower,
-            hsFlux
-        };
-
-
-private:
-
-    // Private data
-
-        //- Heat source type names
-        static const NamedEnum<heatSourceType, 2> heatSourceTypeNames_;
-
-        //- Heat source type
-        heatSourceType heatSource_;
-
-        //- Heat power [W] or flux [W/m2]
-        scalarField q_;
-
-        //- Name of radiative in flux field
-        word QrName_;
-
-
-public:
-
-    //- Runtime type information
-    TypeName("compressible::turbulentHeatFluxTemperature");
-
-
-    // Constructors
-
-        //- Construct from patch and internal field
-        turbulentHeatFluxTemperatureFvPatchScalarField
-        (
-            const fvPatch&,
-            const DimensionedField<scalar, volMesh>&
-        );
-
-        //- Construct from patch, internal field and dictionary
-        turbulentHeatFluxTemperatureFvPatchScalarField
-        (
-            const fvPatch&,
-            const DimensionedField<scalar, volMesh>&,
-            const dictionary&
-        );
-
-        //- Construct by mapping given
-        //  turbulentHeatFluxTemperatureFvPatchScalarField onto
-        //  a new patch
-        turbulentHeatFluxTemperatureFvPatchScalarField
-        (
-            const turbulentHeatFluxTemperatureFvPatchScalarField&,
-            const fvPatch&,
-            const DimensionedField<scalar, volMesh>&,
-            const fvPatchFieldMapper&
-        );
-
-        //- Construct as copy
-        turbulentHeatFluxTemperatureFvPatchScalarField
-        (
-            const turbulentHeatFluxTemperatureFvPatchScalarField&
-        );
-
-        //- Construct and return a clone
-        virtual tmp<fvPatchScalarField> clone() const
-        {
-            return tmp<fvPatchScalarField>
-            (
-                new turbulentHeatFluxTemperatureFvPatchScalarField(*this)
-            );
-        }
-
-        //- Construct as copy setting internal field reference
-        turbulentHeatFluxTemperatureFvPatchScalarField
-        (
-            const turbulentHeatFluxTemperatureFvPatchScalarField&,
-            const DimensionedField<scalar, volMesh>&
-        );
-
-        //- Construct and return a clone setting internal field reference
-        virtual tmp<fvPatchScalarField> clone
-        (
-            const DimensionedField<scalar, volMesh>& iF
-        ) const
-        {
-            return tmp<fvPatchScalarField>
-            (
-                new turbulentHeatFluxTemperatureFvPatchScalarField
-                (
-                    *this,
-                    iF
-                )
-            );
-        }
-
-
-    // Member functions
-
-        // Mapping functions
-
-            //- Map (and resize as needed) from self given a mapping object
-            virtual void autoMap(const fvPatchFieldMapper&);
-
-            //- Reverse map the given fvPatchField onto this fvPatchField
-            virtual void rmap
-            (
-                const fvPatchScalarField&,
-                const labelList&
-            );
-
-
-        // Evaluation functions
-
-            //- Update the coefficients associated with the patch field
-            virtual void updateCoeffs();
-
-
-        // I-O
-
-            //- Write
-            virtual void write(Ostream&) const;
-};
-
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace compressible
-} // End namespace Foam
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#endif
-
-// ************************************************************************* //
-- 
GitLab