thirdBodyEfficienciesI.H
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 "Tuple2.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
33 (
34  const speciesTable& species,
35  const scalarList& efficiencies
36 )
37 :
38  scalarList(efficiencies),
39  species_(species)
40 {
41  if (size() != species_.size())
42  {
44  << "number of efficiencies = " << size()
45  << " is not equal to the number of species " << species_.size()
46  << exit(FatalError);
47  }
48 }
49 
50 
52 (
53  const speciesTable& species,
54  const dictionary& dict
55 )
56 :
57  scalarList(species.size()),
58  species_(species)
59 {
61  if (dict.readIfPresent("coeffs", coeffs))
62  {
63  if (coeffs.size() != species_.size())
64  {
66  << "number of efficiencies = " << coeffs.size()
67  << " is not equat to the number of species " << species_.size()
68  << exit(FatalIOError);
69  }
70 
71  forAll(coeffs, i)
72  {
73  operator[](species[coeffs[i].first()]) = coeffs[i].second();
74  }
75  }
76  else
77  {
78  const scalar defaultEff = dict.get<scalar>("defaultEfficiency");
79  scalarList::operator=(defaultEff);
80  }
81 }
82 
83 
84 // * * * * * * * * * * * * * * * Member functions * * * * * * * * * * * * * //
85 
86 inline Foam::scalar Foam::thirdBodyEfficiencies::M(const scalarList& c) const
87 {
88  scalar M = 0.0;
89  forAll(*this, i)
90  {
91  M += operator[](i)*c[i];
92  }
93 
94  return M;
95 }
96 
97 
99 {
100  List<Tuple2<word, scalar>> coeffs(species_.size());
101  forAll(coeffs, i)
102  {
103  coeffs[i].first() = species_[i];
104  coeffs[i].second() = operator[](i);
105  }
106 
107  os.writeEntry("coeffs", coeffs);
108 }
109 
110 
111 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
112 
113 inline Foam::Ostream& Foam::operator<<
114 (
115  Ostream& os,
116  const thirdBodyEfficiencies& tbes
117 )
118 {
119  tbes.write(os);
120  return os;
121 }
122 
123 
124 // ************************************************************************* //
Foam::scalarList
List< scalar > scalarList
A List of scalars.
Definition: scalarList.H:64
Foam::thirdBodyEfficiencies::write
void write(Ostream &os) const
Write to stream.
Definition: thirdBodyEfficienciesI.H:98
Tuple2.H
Foam::FatalIOError
IOerror FatalIOError
Foam::thirdBodyEfficiencies::M
scalar M(const scalarList &c) const
Calculate and return M, the concentration of the third-bodies.
Definition: thirdBodyEfficienciesI.H:86
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::thirdBodyEfficiencies
Third body efficiencies.
Definition: thirdBodyEfficiencies.H:57
Foam::hashedWordList
A wordList with hashed named lookup, which can be faster in some situations than using the normal lis...
Definition: hashedWordList.H:54
dict
dictionary dict
Definition: searchingEngine.H:14
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::List< scalar >
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:236
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::thirdBodyEfficiencies::thirdBodyEfficiencies
thirdBodyEfficiencies(const speciesTable &species, const scalarList &efficiencies)
Construct from components.
Definition: thirdBodyEfficienciesI.H:33