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