From b43292e0c014fc8d12495a8b3070b266b83eb2a0 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Mon, 25 Jun 2018 10:53:01 +0100 Subject: [PATCH] chemFoam: factored the thermo type functions into a separate file --- .../solvers/combustion/chemFoam/chemFoam.C | 93 +------------- .../combustion/chemFoam/thermoTypeFunctions.H | 117 ++++++++++++++++++ 2 files changed, 118 insertions(+), 92 deletions(-) create mode 100644 applications/solvers/combustion/chemFoam/thermoTypeFunctions.H diff --git a/applications/solvers/combustion/chemFoam/chemFoam.C b/applications/solvers/combustion/chemFoam/chemFoam.C index 92a45b85e..ff2715695 100644 --- a/applications/solvers/combustion/chemFoam/chemFoam.C +++ b/applications/solvers/combustion/chemFoam/chemFoam.C @@ -40,98 +40,7 @@ Description #include "thermoPhysicsTypes.H" #include "basicSpecieMixture.H" #include "cellModeller.H" - - -template -scalarList W(const rhoReactionThermo& thermo) -{ - const PtrList& specieData = - dynamicCast>(thermo) - .speciesData(); - - scalarList W(specieData.size()); - - forAll(specieData, i) - { - W[i] = specieData[i].W(); - } - - return W; -} - - -template -scalar h0 -( - const rhoReactionThermo& thermo, - const scalarList& Y, - const scalar p, - const scalar T -) -{ - const PtrList& specieData = - dynamic_cast&>(thermo) - .speciesData(); - - scalar h0 = 0; - forAll(Y, i) - { - h0 += Y[i]*specieData[i].Hs(p, T); - } - - return h0; -} - - -scalarList W(const rhoReactionThermo& thermo) -{ - if (isA>(thermo)) - { - return W(thermo); - } - else if (isA>(thermo)) - { - return W(thermo); - } - else - { - FatalErrorInFunction - << "Thermodynamics type " << thermo.type() - << " not supported by chemFoam" - << exit(FatalError); - - return scalarList::null(); - } -} - - -scalar h0 -( - const rhoReactionThermo& thermo, - const scalarList& Y, - const scalar p, - const scalar T -) -{ - if (isA>(thermo)) - { - return h0(thermo, Y, p, T); - } - else if (isA>(thermo)) - { - return h0(thermo, Y, p, T); - } - else - { - FatalErrorInFunction - << "Thermodynamics type " << thermo.type() - << " not supported by chemFoam" - << exit(FatalError); - - return 0; - } -} - +#include "thermoTypeFunctions.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/solvers/combustion/chemFoam/thermoTypeFunctions.H b/applications/solvers/combustion/chemFoam/thermoTypeFunctions.H new file mode 100644 index 000000000..d8fcc68a0 --- /dev/null +++ b/applications/solvers/combustion/chemFoam/thermoTypeFunctions.H @@ -0,0 +1,117 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 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 . + +\*---------------------------------------------------------------------------*/ + +template +scalarList W(const rhoReactionThermo& thermo) +{ + const PtrList& specieData = + dynamicCast>(thermo) + .speciesData(); + + scalarList W(specieData.size()); + + forAll(specieData, i) + { + W[i] = specieData[i].W(); + } + + return W; +} + + +template +scalar h0 +( + const rhoReactionThermo& thermo, + const scalarList& Y, + const scalar p, + const scalar T +) +{ + const PtrList& specieData = + dynamic_cast&>(thermo) + .speciesData(); + + scalar h0 = 0; + forAll(Y, i) + { + h0 += Y[i]*specieData[i].Hs(p, T); + } + + return h0; +} + + +scalarList W(const rhoReactionThermo& thermo) +{ + if (isA>(thermo)) + { + return W(thermo); + } + else if (isA>(thermo)) + { + return W(thermo); + } + else + { + FatalErrorInFunction + << "Thermodynamics type " << thermo.type() + << " not supported by chemFoam" + << exit(FatalError); + + return scalarList::null(); + } +} + + +scalar h0 +( + const rhoReactionThermo& thermo, + const scalarList& Y, + const scalar p, + const scalar T +) +{ + if (isA>(thermo)) + { + return h0(thermo, Y, p, T); + } + else if (isA>(thermo)) + { + return h0(thermo, Y, p, T); + } + else + { + FatalErrorInFunction + << "Thermodynamics type " << thermo.type() + << " not supported by chemFoam" + << exit(FatalError); + + return 0; + } +} + + +// ************************************************************************* //