1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 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 #include "injectorType.H"
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 defineTypeNameAndDebug(injectorType, 0);
35 defineRunTimeSelectionTable(injectorType, dictionary);
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 // Construct from components
43 Foam::injectorType::injectorType
46 const Foam::dictionary&
50 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
52 Foam::autoPtr<Foam::injectorType> Foam::injectorType::New
55 const dictionary& dict
60 dict.lookup("injectorType")
63 Info<< "Selecting injectorType "
64 << injectorTypeName << endl;
66 dictionaryConstructorTable::iterator cstrIter =
67 dictionaryConstructorTablePtr_->find(injectorTypeName);
69 if (cstrIter == dictionaryConstructorTablePtr_->end())
72 << "injectorType::New(const dictionary&) : " << endl
73 << " unknown injectorType type "
75 << ", constructor not in hash table" << endl << endl
76 << " Valid injector types are :" << endl;
77 Info<< dictionaryConstructorTablePtr_->toc() << abort(FatalError);
80 return autoPtr<injectorType>(cstrIter()(t, dict));
85 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
87 Foam::injectorType::~injectorType()
90 Foam::scalar Foam::injectorType::getTableValue
92 const List<pair>& table,
100 label maxRow = table.size() - 1;
103 if (value < table[0][0])
108 else if (value > table[maxRow][0])
110 return table[maxRow][1];
112 // interpolate intermediate value
117 (i < maxRow-1) && (table[i+1][0] < value)
122 // value sits bewteen table[i][0] and table[i+1][0]
124 + (value-table[i][0])/(table[i+1][0]-table[i][0])
125 * (table[i+1][1]-table[i][1]);
129 Foam::scalar Foam::injectorType::integrateTable
131 const List<pair>& table,
135 label N = table.size() - 1;
137 scalar t = max(table[0][0], min(value, table[N][0]));
143 && (table[i+1][0] < t)
146 scalar deltaH = table[i+1][1] + table[i][1];
147 scalar deltaT = table[i+1][0] - table[i][0];
148 sum += 0.5*deltaH*deltaT;
152 scalar interpolatedValue =
155 * (table[i+1][1] - table[i][1])
156 / (table[i+1][0] - table[i][0]);
159 0.5*(interpolatedValue + table[i][1])
165 Foam::scalar Foam::injectorType::integrateTable
167 const List<pair>& table
170 scalar integratedTable = 0.0;
171 for (label i=0; i < table.size() - 1; i++)
173 scalar deltaH = table[i+1][1] + table[i][1];
174 scalar deltaT = table[i+1][0] - table[i][0];
175 integratedTable += 0.5*deltaH*deltaT;
178 return integratedTable;
181 // ************************************************************************* //