1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 //- Construct from components
30 inline Foam::thirdBodyEfficiencies::thirdBodyEfficiencies
32 const speciesTable& species,
33 const scalarList& efficiencies
36 scalarList(efficiencies),
39 if (size() != species_.size())
43 "thirdBodyEfficiencies::thirdBodyEfficiencies"
44 "(const speciesTable& species, const scalarList& efficiencies)"
45 ) << "number of efficiencies = " << size()
46 << " is not equat to the number of species " << species_.size()
52 //- Construct from Istream
53 inline Foam::thirdBodyEfficiencies::thirdBodyEfficiencies
55 const speciesTable& species,
59 scalarList(species.size()),
64 "thirdBodyEfficiencies::thirdBodyEfficiencies"
65 "(const speciesTable& species, Istream& is)"
67 scalar defaultEff = readScalar(is);
68 scalarList::operator=(defaultEff);
72 while ((is >> t) && !t.isPunctuation())
76 operator[](species[t.wordToken()]) = readScalar(is);
82 "thirdBodyEfficiencies::thirdBodyEfficiencies"
83 "(const speciesTable& species, Istream& is)",
85 ) << "expected <word>, found " << t.info()
86 << exit(FatalIOError);
90 if (t.pToken() != token::END_LIST)
94 "thirdBodyEfficiencies::thirdBodyEfficiencies"
95 "(const speciesTable& species, Istream& is)",
97 ) << "expected ')', found " << t.info()
98 << exit(FatalIOError);
101 if (size() != species_.size())
105 "thirdBodyEfficiencies::thirdBodyEfficiencies"
106 "(const speciesTable& species, Istream& is)",
108 ) << "number of efficiencies = " << size()
109 << " is not equat to the number of species " << species_.size()
110 << exit(FatalIOError);
115 // * * * * * * * * * * * * * * * Member functions * * * * * * * * * * * * * //
117 inline Foam::scalar Foam::thirdBodyEfficiencies::M(const scalarList& c) const
122 M += operator[](i)*c[i];
129 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
131 inline Foam::Ostream& Foam::operator<<
134 const thirdBodyEfficiencies& tbes
137 scalarList orderedTbes = tbes;
140 scalar val = orderedTbes[0];
143 scalar valMaxCount = val;
146 for (label i=1; i<orderedTbes.size(); i++)
148 if (equal(orderedTbes[i], val))
154 if (count > maxCount)
161 val = orderedTbes[i];
165 if (count > maxCount)
171 os << token::BEGIN_LIST << valMaxCount;
175 if (notEqual(tbes[i], valMaxCount))
177 os << token::SPACE << tbes.species_[i]
178 << token::SPACE << tbes[i];
182 os << token::END_LIST;
188 // ************************************************************************* //