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 -------------------------------------------------------------------------------
10 License
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 
33 template<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 
61 template<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 
84 template<class EquationOfState>
86 {
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 
113 template<class EquationOfState>
114 Foam::Ostream& Foam::operator<<
115 (
116  Ostream& os,
118 )
119 {
120  jt.write(os);
121  return os;
122 }
123 
124 
125 // ************************************************************************* //
IOstreams.H
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
Foam::janafThermo
JANAF tables based thermodynamics package templated into the equation of state.
Definition: janafThermo.H:55
Foam::Ostream::beginBlock
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
Definition: Ostream.C:91
Foam::janafThermo::nCoeffs_
static constexpr int nCoeffs_
Definition: janafThermo.H:99
R
#define R(A, B, C, D, E, F, K, M)
janafThermo.H
Foam::radiation::lookup
Lookup type of boundary radiation properties.
Definition: lookup.H:63
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::Ostream::endBlock
virtual Ostream & endBlock()
Write end block group.
Definition: Ostream.C:109
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::Ostream::write
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::FixedList< scalar, nCoeffs_ >
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:236
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Definition: foamVtkOutputTemplates.C:36
Foam::PtrListOps::get
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
Foam::janafThermo::janafThermo
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.
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::janafThermo::write
void write(Ostream &os) const
Write to Ostream.
Definition: janafThermo.C:85