janafThermo.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "janafThermo.H"
27 #include "IOstreams.H"
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
31 template<class EquationOfState>
33 {
34  if (Tlow_ >= Thigh_)
35  {
37  << "Tlow(" << Tlow_ << ") >= Thigh(" << Thigh_ << ')'
38  << exit(FatalError);
39  }
40 
41  if (Tcommon_ <= Tlow_)
42  {
44  << "Tcommon(" << Tcommon_ << ") <= Tlow(" << Tlow_ << ')'
45  << exit(FatalError);
46  }
47 
48  if (Tcommon_ > Thigh_)
49  {
51  << "Tcommon(" << Tcommon_ << ") > Thigh(" << Thigh_ << ')'
52  << exit(FatalError);
53  }
54 }
55 
56 
57 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
58 
59 template<class EquationOfState>
61 :
62  EquationOfState(dict),
63  Tlow_(dict.subDict("thermodynamics").lookup<scalar>("Tlow")),
64  Thigh_(dict.subDict("thermodynamics").lookup<scalar>("Thigh")),
65  Tcommon_(dict.subDict("thermodynamics").lookup<scalar>("Tcommon")),
66  highCpCoeffs_(dict.subDict("thermodynamics").lookup("highCpCoeffs")),
67  lowCpCoeffs_(dict.subDict("thermodynamics").lookup("lowCpCoeffs"))
68 {
69  // Convert coefficients to mass-basis
70  for (label coefLabel=0; coefLabel<nCoeffs_; coefLabel++)
71  {
72  highCpCoeffs_[coefLabel] *= this->R();
73  lowCpCoeffs_[coefLabel] *= this->R();
74  }
75 
76  checkInputData();
77 }
78 
79 
80 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
81 
82 template<class EquationOfState>
84 {
86 
87  // Convert coefficients back to dimensionless form
90  for (label coefLabel=0; coefLabel<nCoeffs_; coefLabel++)
91  {
92  highCpCoeffs[coefLabel] = highCpCoeffs_[coefLabel]/this->R();
93  lowCpCoeffs[coefLabel] = lowCpCoeffs_[coefLabel]/this->R();
94  }
95 
96  dictionary dict("thermodynamics");
97  dict.add("Tlow", Tlow_);
98  dict.add("Thigh", Thigh_);
99  dict.add("Tcommon", Tcommon_);
100  dict.add("highCpCoeffs", highCpCoeffs);
101  dict.add("lowCpCoeffs", lowCpCoeffs);
102  os << indent << dict.dictName() << dict;
103 }
104 
105 
106 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
107 
108 template<class EquationOfState>
109 Foam::Ostream& Foam::operator<<
110 (
111  Ostream& os,
113 )
114 {
115  jt.write(os);
116  return os;
117 }
118 
119 
120 // ************************************************************************* //
dictionary dict
virtual Ostream & write(const char)=0
Write character.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
static const int nCoeffs_
Definition: janafThermo.H:94
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
const coeffArray & highCpCoeffs() const
Return const access to the high temperature poly coefficients.
Definition: janafThermoI.H:155
bool add(entry *, bool mergeEntry=false)
Add a new entry.
Definition: dictionary.C:1056
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:123
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
stressControl lookup("compactNormalStress") >> compactNormalStress
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
void write(Ostream &os) const
Write to Ostream.
Definition: janafThermo.C:83
janafThermo(const EquationOfState &st, const scalar Tlow, const scalar Thigh, const scalar Tcommon, const coeffArray &highCpCoeffs, const coeffArray &lowCpCoeffs, const bool convertCoeffs=false)
Construct from components.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
#define R(A, B, C, D, E, F, K, M)
const coeffArray & lowCpCoeffs() const
Return const access to the low temperature poly coefficients.
Definition: janafThermoI.H:163
JANAF tables based thermodynamics package templated into the equation of state.
Definition: janafThermo.H:49