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-------------------------------------------------------------------------------
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 "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 equal to the number of species " << species_.size()
69 }
70
71 for (const auto& coeff : coeffs)
72 {
73 const label idx = species.find(coeff.first());
74
75 if (idx < 0)
76 {
78 << "No such species: " << coeffs.first()
79 << ", available: " << flatOutput(species) << endl
81 }
82
83 operator[](idx) = coeff.second();
84 }
85 }
86 else
87 {
88 const scalar defaultEff = dict.get<scalar>("defaultEfficiency");
89 scalarList::operator=(defaultEff);
90 }
91}
92
93
94// * * * * * * * * * * * * * * * Member functions * * * * * * * * * * * * * //
95
96inline Foam::scalar Foam::thirdBodyEfficiencies::M(const scalarList& c) const
97{
98 scalar M = 0.0;
99 forAll(*this, i)
100 {
101 M += operator[](i)*c[i];
102 }
103
104 return M;
105}
106
107
109{
110 List<Tuple2<word, scalar>> coeffs(species_.size());
111 forAll(coeffs, i)
112 {
113 coeffs[i].first() = species_[i];
114 coeffs[i].second() = operator[](i);
115 }
116
117 os.writeEntry("coeffs", coeffs);
118}
119
120
121// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
122
123inline Foam::Ostream& Foam::operator<<
124(
125 Ostream& os,
126 const thirdBodyEfficiencies& tbes
127)
128{
129 tbes.write(os);
130 return os;
131}
132
133
134// ************************************************************************* //
#define M(I)
void operator=(const UList< scalar > &a)
Assignment to UList operator. Takes linear time.
Definition: List.C:480
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:239
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
T & first()
Return the first element of the list.
Definition: UListI.H:202
label size() const noexcept
The number of elements in the UList.
Definition: UListI.H:420
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
T & operator[](const label i)
Return element of UList.
Definition: UListI.H:299
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
virtual bool write()
Write the output fields.
A wordList with hashed named lookup, which can be faster in some situations than using the normal lis...
label find(const word &val) const
Find index of the value (searches the hash).
Third body efficiencies.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
OBJstream os(runTime.globalPath()/outputName)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
Definition: FlatOutput.H:215
IOerror FatalIOError
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333