From 448561718c999775d884792946fd84b96c9210e8 Mon Sep 17 00:00:00 2001
From: Henry Weller <http://cfd.direct>
Date: Thu, 13 Apr 2017 14:03:58 +0100
Subject: [PATCH] fvOption::radiation: New fvOption providing the radiation
 source to the energy equation

Radiative heat transfer may now be added to any solver in which an energy
equation is solved at run-time rather than having to change the solver code.

For example, radiative heat transfer is now enabled in the SandiaD_LTS
reactingFoam tutorial by providing a constant/fvOptions file containing

radiation
{
    type            radiation;
    libs ("libradiationModels.so");
}

and appropriate settings in the constant/radiationProperties file.
---
 src/thermophysicalModels/radiation/Make/files |   3 +
 .../radiation/fvOptions/radiation/radiation.C |  96 +++++++++++++
 .../radiation/fvOptions/radiation/radiation.H | 129 ++++++++++++++++++
 .../reactingFoam/RAS/SandiaD_LTS/0.orig/G     |  44 ++++++
 .../RAS/SandiaD_LTS/constant/fvOptions        |  24 ++++
 .../SandiaD_LTS/constant/radiationProperties  |  41 +-----
 .../RAS/SandiaD_LTS/system/controlDict        |   3 +-
 .../RAS/SandiaD_LTS/system/fvSolution         |  14 ++
 8 files changed, 318 insertions(+), 36 deletions(-)
 create mode 100644 src/thermophysicalModels/radiation/fvOptions/radiation/radiation.C
 create mode 100644 src/thermophysicalModels/radiation/fvOptions/radiation/radiation.H
 create mode 100644 tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/0.orig/G
 create mode 100644 tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/constant/fvOptions

diff --git a/src/thermophysicalModels/radiation/Make/files b/src/thermophysicalModels/radiation/Make/files
index 5f520b2dcd2..81ad973eb3f 100644
--- a/src/thermophysicalModels/radiation/Make/files
+++ b/src/thermophysicalModels/radiation/Make/files
@@ -40,4 +40,7 @@ derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedF
 derivedFvPatchFields/radiationCoupledBase/radiationCoupledBase.C
 derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C
 
+/* fvOptions */
+fvOptions/radiation/radiation.C
+
 LIB = $(FOAM_LIBBIN)/libradiationModels
diff --git a/src/thermophysicalModels/radiation/fvOptions/radiation/radiation.C b/src/thermophysicalModels/radiation/fvOptions/radiation/radiation.C
new file mode 100644
index 00000000000..2a817e4e6c2
--- /dev/null
+++ b/src/thermophysicalModels/radiation/fvOptions/radiation/radiation.C
@@ -0,0 +1,96 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  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 "radiation.H"
+#include "fluidThermo.H"
+#include "fvMatrices.H"
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace fv
+{
+    defineTypeNameAndDebug(radiation, 0);
+
+    addToRunTimeSelectionTable
+    (
+        option,
+        radiation,
+        dictionary
+    );
+}
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::fv::radiation::radiation
+(
+    const word& sourceName,
+    const word& modelType,
+    const dictionary& dict,
+    const fvMesh& mesh
+)
+:
+    option(sourceName, modelType, dict, mesh)
+{
+    const basicThermo& thermo =
+        mesh_.lookupObject<basicThermo>(basicThermo::dictName);
+
+    fieldNames_.setSize(1);
+    fieldNames_[0] = thermo.he().name();
+    applied_.setSize(fieldNames_.size(), false);
+
+    radiation_ = Foam::radiation::radiationModel::New(thermo.T());
+}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+bool Foam::fv::radiation::read(const dictionary& dict)
+{
+    return option::read(dict);
+}
+
+
+void Foam::fv::radiation::addSup
+(
+    const volScalarField& rho,
+    fvMatrix<scalar>& eqn,
+    const label fieldi
+)
+{
+    const basicThermo& thermo =
+        mesh_.lookupObject<basicThermo>(basicThermo::dictName);
+
+    radiation_->correct();
+
+    eqn += radiation_->Sh(thermo, eqn.psi());
+}
+
+
+// ************************************************************************* //
diff --git a/src/thermophysicalModels/radiation/fvOptions/radiation/radiation.H b/src/thermophysicalModels/radiation/fvOptions/radiation/radiation.H
new file mode 100644
index 00000000000..57927a28f7d
--- /dev/null
+++ b/src/thermophysicalModels/radiation/fvOptions/radiation/radiation.H
@@ -0,0 +1,129 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  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/>.
+
+Class
+    Foam::fv::radiation
+
+Description
+    Calculates and applies the buoyancy energy source rho*(U&g) to the energy
+    equation.
+
+Usage
+    Example usage:
+    \verbatim
+    radiationCoeffs
+    {
+        fields          (h);                    // Name of energy field
+    }
+    \endverbatim
+
+SourceFiles
+    radiation.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef radiation_H
+#define radiation_H
+
+#include "fvOption.H"
+#include "uniformDimensionedFields.H"
+#include "radiationModel.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace fv
+{
+
+/*---------------------------------------------------------------------------*\
+               Class radiation Declaration
+\*---------------------------------------------------------------------------*/
+
+class radiation
+:
+    public option
+{
+    // Private data
+
+        //- The radiation model pointer
+        autoPtr<Foam::radiation::radiationModel> radiation_;
+
+
+    // Private Member Functions
+
+        //- Disallow default bitwise copy construct
+        radiation(const radiation&);
+
+        //- Disallow default bitwise assignment
+        void operator=(const radiation&);
+
+
+public:
+
+    //- Runtime type information
+    TypeName("radiation");
+
+
+    // Constructors
+
+        //- Construct from explicit source name and mesh
+        radiation
+        (
+            const word& sourceName,
+            const word& modelType,
+            const dictionary& dict,
+            const fvMesh& mesh
+        );
+
+
+    // Member Functions
+
+        // Evaluate
+
+            //- Add explicit contribution to compressible momentum equation
+            virtual void addSup
+            (
+                const volScalarField& rho,
+                fvMatrix<scalar>& eqn,
+                const label fieldi
+            );
+
+
+        // IO
+
+            //- Read source dictionary
+            virtual bool read(const dictionary& dict);
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace fv
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/0.orig/G b/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/0.orig/G
new file mode 100644
index 00000000000..7df3bfdcd0c
--- /dev/null
+++ b/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/0.orig/G
@@ -0,0 +1,44 @@
+/*--------------------------------*- C++ -*----------------------------------* \
+| =========                 |                                                 |
+| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
+|  \\    /   O peration     | Version:  dev                                   |
+|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|    \\/     M anipulation  |                                                 |
+\*---------------------------------------------------------------------------*/
+FoamFile
+{
+    version     2.0;
+    format      ascii;
+    class       volScalarField;
+    object      G;
+}
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+dimensions      [1 0 -3 0 0 0 0];
+
+internalField   uniform 0;
+
+boundaryField
+{
+    ".*"
+    {
+        type            MarshakRadiation;
+        T               T;
+        emissivityMode  lookup;
+        emissivity      uniform 1.0;
+        value           uniform 0;
+    }
+
+    frontAndBack_pos
+    {
+        type            wedge;
+    }
+
+    frontAndBack_neg
+    {
+        type            wedge;
+    }
+}
+
+
+// ************************************************************************* //
diff --git a/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/constant/fvOptions b/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/constant/fvOptions
new file mode 100644
index 00000000000..3763a839bf2
--- /dev/null
+++ b/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/constant/fvOptions
@@ -0,0 +1,24 @@
+/*--------------------------------*- C++ -*----------------------------------*\
+| =========                 |                                                 |
+| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
+|  \\    /   O peration     | Version:  dev                                   |
+|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|    \\/     M anipulation  |                                                 |
+\*---------------------------------------------------------------------------*/
+FoamFile
+{
+    version     2.0;
+    format      ascii;
+    class       dictionary;
+    location    "constant";
+    object      fvOptions;
+}
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+radiation
+{
+    type            radiation;
+    libs ("libradiationModels.so");
+}
+
+// ************************************************************************* //
diff --git a/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/constant/radiationProperties b/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/constant/radiationProperties
index c1ca1d2d7bf..c74f341d4f3 100644
--- a/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/constant/radiationProperties
+++ b/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/constant/radiationProperties
@@ -5,6 +5,7 @@
 |   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
+
 FoamFile
 {
     version     2.0;
@@ -15,48 +16,19 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-// Radiation model on/off
-radiation       on;
+radiation on;
 
-// Radiation model
 radiationModel  P1;
 
-// Absorption coefficients model
-absorptionEmissionModel greyMeanAbsorptionEmission;
-
-// Number of flow iterations per radiation iteration
-solverFreq 1;
-
-//
-noRadiation
-{
-}
-
-// P1 Model
 P1Coeffs
 {
-
+    C               C [0 0 0 0 0 0 0] 0;
 }
 
+// Number of flow iterations per radiation iteration
+solverFreq 1;
 
-fvDOMCoeffs
-{
-    nPhi        2;          // azimuthal angles in PI/2 on X-Y.(from Y to X)
-    nTheta      2;          // polar angles in PI (from Z to X-Y plane)
-    convergence 1e-1;       // convergence criteria for radiation iteration
-    maxIter     1;          // maximum number of iterations
-    cacheDiv    true;       // cache the div of the RTE equation.
-
-//  NOTE: Caching div is "only" accurate if the upwind scheme is used in
-//  div(Ji,Ii_h)
-}
-
-constantAbsorptionEmissionCoeffs
-{
-    absorptivity    absorptivity    [ m^-1 ]       0.01;
-    emissivity      emissivity      [ m^-1 ]       0.01;
-    E               E               [ kg m^-1 s^-3 ]  0;
-}
+absorptionEmissionModel greyMeanAbsorptionEmission;
 
 greyMeanAbsorptionEmissionCoeffs
 {
@@ -206,5 +178,4 @@ scatterModel    none;
 
 sootModel       none;
 
-
 // ************************************************************************* //
diff --git a/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/system/controlDict b/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/system/controlDict
index eb014fbe9c9..97c43525a82 100644
--- a/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/system/controlDict
+++ b/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/system/controlDict
@@ -13,6 +13,7 @@ FoamFile
     location        "system";
     object          controlDict;
 }
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 application     reactingFoam;
 
@@ -22,7 +23,7 @@ startTime       0;
 
 stopAt          endTime;
 
-endTime         5000;
+endTime         7000;
 
 deltaT          1;
 
diff --git a/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/system/fvSolution b/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/system/fvSolution
index 6e2e7422f83..ebd58b1685f 100644
--- a/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/system/fvSolution
+++ b/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/system/fvSolution
@@ -56,6 +56,20 @@ solvers
         tolerance       1e-8;
         relTol          0.1;
     }
+
+    G
+    {
+        solver          PCG;
+        preconditioner  DIC;
+        tolerance       1e-5;
+        relTol          0.1;
+    }
+
+    GFinal
+    {
+        $G;
+        relTol          0;
+    }
 }
 
 PIMPLE
-- 
GitLab