thirdBodyEfficienciesI.H
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 inline Foam::thirdBodyEfficiencies::thirdBodyEfficiencies
00031 (
00032 const speciesTable& species,
00033 const scalarList& efficiencies
00034 )
00035 :
00036 scalarList(efficiencies),
00037 species_(species)
00038 {
00039 if (size() != species_.size())
00040 {
00041 FatalErrorIn
00042 (
00043 "thirdBodyEfficiencies::thirdBodyEfficiencies"
00044 "(const speciesTable& species, const scalarList& efficiencies)"
00045 ) << "number of efficiencies = " << size()
00046 << " is not equat to the number of species " << species_.size()
00047 << exit(FatalError);
00048 }
00049 }
00050
00051
00052
00053 inline Foam::thirdBodyEfficiencies::thirdBodyEfficiencies
00054 (
00055 const speciesTable& species,
00056 Istream& is
00057 )
00058 :
00059 scalarList(species.size()),
00060 species_(species)
00061 {
00062 is.readBeginList
00063 (
00064 "thirdBodyEfficiencies::thirdBodyEfficiencies"
00065 "(const speciesTable& species, Istream& is)"
00066 );
00067 scalar defaultEff = readScalar(is);
00068 scalarList::operator=(defaultEff);
00069
00070 token t;
00071
00072 while ((is >> t) && !t.isPunctuation())
00073 {
00074 if (t.isWord())
00075 {
00076 operator[](species[t.wordToken()]) = readScalar(is);
00077 }
00078 else
00079 {
00080 FatalIOErrorIn
00081 (
00082 "thirdBodyEfficiencies::thirdBodyEfficiencies"
00083 "(const speciesTable& species, Istream& is)",
00084 is
00085 ) << "expected <word>, found " << t.info()
00086 << exit(FatalIOError);
00087 }
00088 }
00089
00090 if (t.pToken() != token::END_LIST)
00091 {
00092 FatalIOErrorIn
00093 (
00094 "thirdBodyEfficiencies::thirdBodyEfficiencies"
00095 "(const speciesTable& species, Istream& is)",
00096 is
00097 ) << "expected ')', found " << t.info()
00098 << exit(FatalIOError);
00099 }
00100
00101 if (size() != species_.size())
00102 {
00103 FatalIOErrorIn
00104 (
00105 "thirdBodyEfficiencies::thirdBodyEfficiencies"
00106 "(const speciesTable& species, Istream& is)",
00107 is
00108 ) << "number of efficiencies = " << size()
00109 << " is not equat to the number of species " << species_.size()
00110 << exit(FatalIOError);
00111 }
00112 }
00113
00114
00115
00116
00117 inline Foam::scalar Foam::thirdBodyEfficiencies::M(const scalarList& c) const
00118 {
00119 scalar M = 0.0;
00120 forAll (*this, i)
00121 {
00122 M += operator[](i)*c[i];
00123 }
00124
00125 return M;
00126 }
00127
00128
00129
00130
00131 inline Foam::Ostream& Foam::operator<<
00132 (
00133 Ostream& os,
00134 const thirdBodyEfficiencies& tbes
00135 )
00136 {
00137 scalarList orderedTbes = tbes;
00138 sort(orderedTbes);
00139
00140 scalar val = orderedTbes[0];
00141 label count = 1;
00142
00143 scalar valMaxCount = val;
00144 label maxCount = 1;
00145
00146 for (label i=1; i<orderedTbes.size(); i++)
00147 {
00148 if (equal(orderedTbes[i], val))
00149 {
00150 count++;
00151 }
00152 else
00153 {
00154 if (count > maxCount)
00155 {
00156 maxCount = count;
00157 valMaxCount = val;
00158 }
00159
00160 count = 1;
00161 val = orderedTbes[i];
00162 }
00163 }
00164
00165 if (count > maxCount)
00166 {
00167 maxCount = count;
00168 valMaxCount = val;
00169 }
00170
00171 os << token::BEGIN_LIST << valMaxCount;
00172
00173 forAll (tbes, i)
00174 {
00175 if (notEqual(tbes[i], valMaxCount))
00176 {
00177 os << token::SPACE << tbes.species_[i]
00178 << token::SPACE << tbes[i];
00179 }
00180 }
00181
00182 os << token::END_LIST;
00183
00184 return os;
00185 }
00186
00187
00188
Copyright © 2000-2009 OpenCFD Ltd