janafThermo.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2017 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "janafThermo.H"
29#include "IOstreams.H"
30
31// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32
33template<class EquationOfState>
35{
36 if (Tlow_ >= Thigh_)
37 {
39 << "Tlow(" << Tlow_ << ") >= Thigh(" << Thigh_ << ')'
40 << exit(FatalError);
41 }
42
43 if (Tcommon_ <= Tlow_)
44 {
46 << "Tcommon(" << Tcommon_ << ") <= Tlow(" << Tlow_ << ')'
47 << exit(FatalError);
48 }
49
50 if (Tcommon_ > Thigh_)
51 {
53 << "Tcommon(" << Tcommon_ << ") > Thigh(" << Thigh_ << ')'
54 << exit(FatalError);
55 }
56}
57
58
59// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
60
61template<class EquationOfState>
63:
64 EquationOfState(dict),
65 Tlow_(dict.subDict("thermodynamics").get<scalar>("Tlow")),
66 Thigh_(dict.subDict("thermodynamics").get<scalar>("Thigh")),
67 Tcommon_(dict.subDict("thermodynamics").get<scalar>("Tcommon")),
68 highCpCoeffs_(dict.subDict("thermodynamics").lookup("highCpCoeffs")),
69 lowCpCoeffs_(dict.subDict("thermodynamics").lookup("lowCpCoeffs"))
70{
71 // Convert coefficients to mass-basis
72 for (label coefLabel=0; coefLabel<nCoeffs_; coefLabel++)
73 {
74 highCpCoeffs_[coefLabel] *= this->R();
75 lowCpCoeffs_[coefLabel] *= this->R();
76 }
77
78 checkInputData();
79}
80
81
82// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
83
84template<class EquationOfState>
86{
87 EquationOfState::write(os);
88
89 // Convert coefficients back to dimensionless form
90 coeffArray highCpCoeffs;
91 coeffArray lowCpCoeffs;
92 for (label coefLabel=0; coefLabel<nCoeffs_; coefLabel++)
93 {
94 highCpCoeffs[coefLabel] = highCpCoeffs_[coefLabel]/this->R();
95 lowCpCoeffs[coefLabel] = lowCpCoeffs_[coefLabel]/this->R();
96 }
97
98 // Entries in dictionary format
99 {
100 os.beginBlock("thermodynamics");
101 os.writeEntry("Tlow", Tlow_);
102 os.writeEntry("Thigh", Thigh_);
103 os.writeEntry("Tcommon", Tcommon_);
104 os.writeEntry("highCpCoeffs", highCpCoeffs);
105 os.writeEntry("lowCpCoeffs", lowCpCoeffs);
106 os.endBlock();
107 }
108}
109
110
111// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
112
113template<class EquationOfState>
114Foam::Ostream& Foam::operator<<
115(
116 Ostream& os,
118)
119{
120 jt.write(os);
121 return os;
122}
123
124
125// ************************************************************************* //
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
#define R(A, B, C, D, E, F, K, M)
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
virtual Ostream & endBlock()
Write end block group.
Definition: Ostream.C:105
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:239
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
Definition: Ostream.C:87
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
virtual bool write()
Write the output fields.
JANAF tables based thermodynamics package templated into the equation of state.
Definition: janafThermo.H:94
static constexpr int nCoeffs_
Definition: janafThermo.H:99
Lookup type of boundary radiation properties.
Definition: lookup.H:66
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
OBJstream os(runTime.globalPath()/outputName)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
dictionary dict