1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
27 #include "addToRunTimeSelectionTable.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 namespace tabulatedWallFunctions
36 defineTypeNameAndDebug(general, 0);
37 addToRunTimeSelectionTable
39 tabulatedWallFunction,
46 const char* Foam::NamedEnum
48 Foam::tabulatedWallFunctions::general::interpolationType,
58 Foam::NamedEnum<Foam::tabulatedWallFunctions::general::interpolationType, 1>
59 Foam::tabulatedWallFunctions::general::interpolationTypeNames_;
62 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
64 void Foam::tabulatedWallFunctions::general::invertTable()
66 scalarList Rey(uPlus_.size(), 0.0);
68 // Calculate Reynolds number
71 Rey[i] = yPlus_[i]*uPlus_[i];
72 if (invertedTable_.log10())
74 Rey[i] = ::log10(max(ROOTVSMALL, Rey[i]));
78 // Populate the U+ vs Re table
79 forAll(invertedTable_, i)
81 scalar Re = i*invertedTable_.dx() + invertedTable_.x0();
82 invertedTable_[i] = max(0, interpolate(Re, Rey, uPlus_));
87 Foam::scalar Foam::tabulatedWallFunctions::general::interpolate
102 else if (xi >= x.last())
115 return (xi - x[i1])/(x[i2] - x[i1])*(fx[i2] - fx[i1]) + fx[i1];
124 "tabulatedWallFunctions::general::interpolate"
127 "const scalarList&, "
130 ) << "Unknown interpolation method" << nl
131 << abort(FatalError);
139 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
141 Foam::tabulatedWallFunctions::general::general
143 const dictionary& dict,
147 tabulatedWallFunction(dict, mesh, typeName),
148 interpType_(interpolationTypeNames_[coeffDict_.lookup("interpType")]),
151 log10YPlus_(coeffDict_.lookup("log10YPlus")),
152 log10UPlus_(coeffDict_.lookup("log10UPlus"))
154 List<Tuple2<scalar, scalar> > inputTable = coeffDict_.lookup("inputTable");
155 if (inputTable.size() < 2)
159 "tabulatedWallFunctions::general::general"
161 "const dictionary&, "
164 ) << "Input table must have at least 2 values" << nl
168 yPlus_.setSize(inputTable.size());
169 uPlus_.setSize(inputTable.size());
171 forAll(inputTable, i)
175 yPlus_[i] = pow(10, inputTable[i].first());
179 yPlus_[i] = inputTable[i].first();
184 uPlus_[i] = pow(10, inputTable[i].second());
188 uPlus_[i] = inputTable[i].second();
201 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
203 Foam::tabulatedWallFunctions::general::~general()
207 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
209 Foam::scalar Foam::tabulatedWallFunctions::general::yPlus
214 return interpolate(uPlus, uPlus_, yPlus_);
218 Foam::scalar Foam::tabulatedWallFunctions::general::Re
223 return uPlus*yPlus(uPlus);
227 // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
229 void Foam::tabulatedWallFunctions::general::writeData(Ostream& os) const
231 if (invertedTable_.log10())
233 os << "log10(Re), y+, u+:" << endl;
234 forAll(invertedTable_, i)
236 scalar uPlus = invertedTable_[i];
237 scalar Re = ::log10(this->Re(uPlus));
238 scalar yPlus = this->yPlus(uPlus);
239 os << Re << ", " << yPlus << ", " << uPlus << endl;
244 os << "Re, y+, u+:" << endl;
245 forAll(invertedTable_, i)
247 scalar uPlus = invertedTable_[i];
248 scalar Re = this->Re(uPlus);
249 scalar yPlus = this->yPlus(uPlus);
250 os << Re << ", " << yPlus << ", " << uPlus << endl;
256 // ************************************************************************* //