thirdBodyEfficienciesI.H
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-2024 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 "thirdBodyEfficiencies.H"
27 #include "Tuple2.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
32 (
33  const speciesTable& species,
34  const scalarList& efficiencies
35 )
36 :
37  scalarField(efficiencies),
38  species_(species)
39 {
40  if (size() != species_.size())
41  {
43  << "number of efficiencies = " << size()
44  << " is not equal to the number of species " << species_.size()
45  << exit(FatalError);
46  }
47 }
48 
49 
51 (
52  const speciesTable& species,
53  const dictionary& dict
54 )
55 :
56  scalarField(species.size()),
57  species_(species)
58 {
59  if (dict.found("coeffs"))
60  {
61  List<Tuple2<word, scalar>> coeffs(dict.lookup("coeffs"));
62  if (coeffs.size() != species_.size())
63  {
65  << "number of efficiencies = " << coeffs.size()
66  << " is not equal to the number of species " << species_.size()
67  << exit(FatalIOError);
68  }
69 
70  forAll(coeffs, i)
71  {
72  operator[](species[coeffs[i].first()]) = coeffs[i].second();
73  }
74  }
75  else
76  {
77  scalar defaultEff = dict.lookup<scalar>("defaultEfficiency");
78  scalarField::operator=(defaultEff);
79  }
80 }
81 
82 
83 // * * * * * * * * * * * * * * * Member functions * * * * * * * * * * * * * //
84 
85 inline Foam::scalar Foam::thirdBodyEfficiencies::M(const scalarField& c) const
86 {
87  scalar M = 0;
88  forAll(*this, i)
89  {
90  M += operator[](i)*c[i];
91  }
92 
93  return M;
94 }
95 
96 
99 {
100  return *this;
101 }
102 
103 
105 {
106  List<Tuple2<word, scalar>> coeffs(species_.size());
107  forAll(coeffs, i)
108  {
109  coeffs[i].first() = species_[i];
110  coeffs[i].second() = operator[](i);
111  }
112 
113  writeEntry(os, "coeffs", coeffs);
114 }
115 
116 
117 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
118 
119 inline Foam::Ostream& Foam::operator<<
120 (
121  Ostream& os,
122  const thirdBodyEfficiencies& tbes
123 )
124 {
125  tbes.write(os);
126  return os;
127 }
128 
129 
130 // ************************************************************************* //
#define M(I)
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
void operator=(const Field< scalar > &)
Definition: Field.C:550
label size() const
Return the number of elements in the UList.
Definition: ListI.H:171
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
virtual Ostream & write(const char)=0
Write character.
T & first()
Return the first element of the list.
Definition: UListI.H:114
T & operator[](const label)
Return element of UList.
Definition: UListI.H:167
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
A wordList with hashed indices for faster lookup by name.
Third body efficiencies.
thirdBodyEfficiencies(const speciesTable &species, const scalarList &efficiencies)
Construct from components.
void write(Ostream &os) const
Write to stream.
scalar M(const scalarField &c) const
Calculate and return M, the concentration of the third-bodies.
tmp< scalarField > dMdc(const scalarField &c) const
Calculate and return the derivative of M, w.r.t. the species.
A class for managing temporary objects.
Definition: tmp.H:55
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
const dimensionedScalar c
Speed of light in a vacuum.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
IOerror FatalIOError
error FatalError
dictionary dict