From e1913362ad56722a762d9247dcb580f149016c6d Mon Sep 17 00:00:00 2001
From: andy <andy>
Date: Thu, 31 Jan 2013 15:39:56 +0000
Subject: [PATCH] ENH: Added new thermoFoam utility

---
 .../solvers/heatTransfer/thermoFoam/EEqn.H    |  34 ++++++
 .../heatTransfer/thermoFoam/Make/files        |   3 +
 .../heatTransfer/thermoFoam/Make/options      |  24 ++++
 .../heatTransfer/thermoFoam/createFields.H    |  54 +++++++++
 .../heatTransfer/thermoFoam/setAlphaEff.H     |  93 +++++++++++++++
 .../heatTransfer/thermoFoam/thermoFoam.C      | 107 ++++++++++++++++++
 6 files changed, 315 insertions(+)
 create mode 100644 applications/solvers/heatTransfer/thermoFoam/EEqn.H
 create mode 100644 applications/solvers/heatTransfer/thermoFoam/Make/files
 create mode 100644 applications/solvers/heatTransfer/thermoFoam/Make/options
 create mode 100644 applications/solvers/heatTransfer/thermoFoam/createFields.H
 create mode 100644 applications/solvers/heatTransfer/thermoFoam/setAlphaEff.H
 create mode 100644 applications/solvers/heatTransfer/thermoFoam/thermoFoam.C

diff --git a/applications/solvers/heatTransfer/thermoFoam/EEqn.H b/applications/solvers/heatTransfer/thermoFoam/EEqn.H
new file mode 100644
index 00000000000..51232bf0bec
--- /dev/null
+++ b/applications/solvers/heatTransfer/thermoFoam/EEqn.H
@@ -0,0 +1,34 @@
+{
+    volScalarField& he = thermo.he();
+
+    fvScalarMatrix EEqn
+    (
+        fvm::ddt(rho, he) + fvm::div(phi, he)
+      + fvc::ddt(rho, K) + fvc::div(phi, K)
+      + (
+            he.name() == "e"
+          ? fvc::div
+            (
+                fvc::absolute(phi/fvc::interpolate(rho), U),
+                p,
+                "div(phiv,p)"
+            )
+          : -dpdt
+        )
+      - fvm::laplacian(alphaEff, he)
+     ==
+        radiation->Sh(thermo)
+      + fvOptions(rho, he)
+    );
+
+    EEqn.relax();
+
+    fvOptions.constrain(EEqn);
+
+    EEqn.solve();
+
+    fvOptions.correct(he);
+
+    thermo.correct();
+    radiation->correct();
+}
diff --git a/applications/solvers/heatTransfer/thermoFoam/Make/files b/applications/solvers/heatTransfer/thermoFoam/Make/files
new file mode 100644
index 00000000000..825ed0cba8a
--- /dev/null
+++ b/applications/solvers/heatTransfer/thermoFoam/Make/files
@@ -0,0 +1,3 @@
+thermoFoam.C
+
+EXE = $(FOAM_APPBIN)/thermoFoam
diff --git a/applications/solvers/heatTransfer/thermoFoam/Make/options b/applications/solvers/heatTransfer/thermoFoam/Make/options
new file mode 100644
index 00000000000..14bd0d4d24e
--- /dev/null
+++ b/applications/solvers/heatTransfer/thermoFoam/Make/options
@@ -0,0 +1,24 @@
+EXE_INC = \
+    -I$(LIB_SRC)/finiteVolume/lnInclude \
+    -I$(LIB_SRC)/sampling/lnInclude \
+    -I$(LIB_SRC)/meshTools/lnInclude \
+    -I$(LIB_SRC)/fvOptions/lnInclude \
+    -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
+    -I$(LIB_SRC)/thermophysicalModels/radiationModels/lnInclude \
+    -I$(LIB_SRC)/turbulenceModels \
+    -I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel/lnInclude \
+    -I$(LIB_SRC)/turbulenceModels/compressible/RAS/lnInclude \
+    -I$(LIB_SRC)/turbulenceModels/compressible/LES/lnInclude \
+    -I$(LIB_SRC)/turbulenceModels/LES/LESdeltas/lnInclude
+
+EXE_LIBS = \
+    -lfiniteVolume \
+    -lsampling \
+    -lmeshTools \
+    -lfvOptions \
+    -lfluidThermophysicalModels \
+    -lradiationModels \
+    -lspecie \
+    -lcompressibleTurbulenceModel \
+    -lcompressibleRASModels \
+    -lcompressibleLESModels
diff --git a/applications/solvers/heatTransfer/thermoFoam/createFields.H b/applications/solvers/heatTransfer/thermoFoam/createFields.H
new file mode 100644
index 00000000000..ffa6c3f3b52
--- /dev/null
+++ b/applications/solvers/heatTransfer/thermoFoam/createFields.H
@@ -0,0 +1,54 @@
+    Info<< "Reading thermophysical properties\n" << endl;
+
+    autoPtr<rhoThermo> pThermo(rhoThermo::New(mesh));
+    rhoThermo& thermo = pThermo();
+    thermo.validate(args.executable(), "h", "e");
+
+    volScalarField rho
+    (
+        IOobject
+        (
+            "rho",
+            runTime.timeName(),
+            mesh,
+            IOobject::NO_READ,
+            IOobject::NO_WRITE
+        ),
+        thermo.rho()
+    );
+
+    volScalarField& p = thermo.p();
+
+    Info<< "Reading field U\n" << endl;
+    volVectorField U
+    (
+        IOobject
+        (
+            "U",
+            runTime.timeName(),
+            mesh,
+            IOobject::MUST_READ,
+            IOobject::AUTO_WRITE
+        ),
+        mesh
+    );
+
+    #include "compressibleCreatePhi.H"
+
+    #include "setAlphaEff.H"
+
+    Info<< "Creating field dpdt\n" << endl;
+    volScalarField dpdt
+    (
+        IOobject
+        (
+            "dpdt",
+            runTime.timeName(),
+            mesh
+        ),
+        mesh,
+        dimensionedScalar("dpdt", p.dimensions()/dimTime, 0)
+    );
+
+    Info<< "Creating field kinetic energy K\n" << endl;
+    volScalarField K("K", 0.5*magSqr(U));
diff --git a/applications/solvers/heatTransfer/thermoFoam/setAlphaEff.H b/applications/solvers/heatTransfer/thermoFoam/setAlphaEff.H
new file mode 100644
index 00000000000..90b475794b6
--- /dev/null
+++ b/applications/solvers/heatTransfer/thermoFoam/setAlphaEff.H
@@ -0,0 +1,93 @@
+    Info<< "Creating turbulence model\n" << endl;
+    tmp<volScalarField> talphaEff;
+
+    IOobject turbulenceHeader
+    (
+        "turbulenceProperties",
+        runTime.constant(),
+        mesh,
+        IOobject::MUST_READ
+    );
+
+    IOobject RASHeader
+    (
+        "RASProperties",
+        runTime.constant(),
+        mesh,
+        IOobject::MUST_READ
+    );
+
+    IOobject LESHeader
+    (
+        "LESProperties",
+        runTime.constant(),
+        mesh,
+        IOobject::MUST_READ
+    );
+
+    if (turbulenceHeader.headerOk())
+    {
+        autoPtr<compressible::turbulenceModel> turbulence
+        (
+            compressible::turbulenceModel::New
+            (
+                rho,
+                U,
+                phi,
+                thermo
+            )
+        );
+
+        talphaEff = turbulence->alphaEff();
+    }
+    else if (RASHeader.headerOk())
+    {
+        autoPtr<compressible::RASModel> turbulence
+        (
+            compressible::RASModel::New
+            (
+                rho,
+                U,
+                phi,
+                thermo
+            )
+        );
+
+        talphaEff = turbulence->alphaEff();
+    }
+    else if (LESHeader.headerOk())
+    {
+        autoPtr<compressible::LESModel> turbulence
+        (
+            compressible::LESModel::New
+            (
+                rho,
+                U,
+                phi,
+                thermo
+            )
+        );
+
+        talphaEff = turbulence->alphaEff();
+    }
+    else
+    {
+        talphaEff = tmp<volScalarField>
+        (
+            new volScalarField
+            (
+                IOobject
+                (
+                    "alphaEff",
+                    runTime.timeName(),
+                    mesh,
+                    IOobject::NO_READ,
+                    IOobject::NO_WRITE
+                ),
+                mesh,
+                dimensionedScalar("0", dimMass/dimLength/dimTime, 0.0)
+            )
+        );
+    }
+
+    const volScalarField& alphaEff = talphaEff();
diff --git a/applications/solvers/heatTransfer/thermoFoam/thermoFoam.C b/applications/solvers/heatTransfer/thermoFoam/thermoFoam.C
new file mode 100644
index 00000000000..f5f88232d2c
--- /dev/null
+++ b/applications/solvers/heatTransfer/thermoFoam/thermoFoam.C
@@ -0,0 +1,107 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2013 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/>.
+
+Application
+    thermoFoam
+
+Description
+    Evolves the thermodynamics on a forzen flow field
+
+\*---------------------------------------------------------------------------*/
+
+#include "fvCFD.H"
+#include "rhoThermo.H"
+#include "turbulenceModel.H"
+#include "RASModel.H"
+#include "LESModel.H"
+#include "radiationModel.H"
+#include "fvIOoptionList.H"
+#include "simpleControl.H"
+#include "pimpleControl.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+int main(int argc, char *argv[])
+{
+    #include "setRootCase.H"
+
+    #include "createTime.H"
+    #include "createMesh.H"
+    #include "createFields.H"
+    #include "createFvOptions.H"
+    #include "createRadiationModel.H"
+
+    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+    Info<< "\nEvolving thermodynamics\n" << endl;
+
+    if (mesh.solutionDict().found("SIMPLE"))
+    {
+        simpleControl simple(mesh);
+
+        while (simple.loop())
+        {
+            Info<< "Time = " << runTime.timeName() << nl << endl;
+
+            while (simple.correctNonOrthogonal())
+            {
+                #include "EEqn.H"
+            }
+
+            Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
+                << "  ClockTime = " << runTime.elapsedClockTime() << " s"
+                << nl << endl;
+
+            runTime.write();
+        }
+    }
+    else
+    {
+        pimpleControl pimple(mesh);
+
+        while (runTime.run())
+        {
+            runTime++;
+
+            Info<< "Time = " << runTime.timeName() << nl << endl;
+
+            while (pimple.correctNonOrthogonal())
+            {
+                #include "EEqn.H"
+            }
+
+            Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
+                << "  ClockTime = " << runTime.elapsedClockTime() << " s"
+                << nl << endl;
+
+            runTime.write();
+        }
+    }
+
+    Info<< "End\n" << endl;
+
+    return 0;
+}
+
+
+// ************************************************************************* //
-- 
GitLab