1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 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
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/>.
28 Apply a simplified boundary-layer model to the velocity and
29 turbulence fields based on the 1/7th power-law.
31 The uniform boundary-layer thickness is either provided via the -ybl option
32 or calculated as the average of the distance to the wall scaled with
33 the thickness coefficient supplied via the option -Cbl. If both options
34 are provided -ybl is used.
36 \*---------------------------------------------------------------------------*/
39 #include "singlePhaseTransportModel.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 // turbulence constants - file-scope
46 static const scalar Cmu(0.09);
47 static const scalar kappa(0.41);
50 int main(int argc, char *argv[])
54 "apply a simplified boundary-layer model to the velocity and\n"
55 "turbulence fields based on the 1/7th power-law."
62 "specify the boundary-layer thickness"
67 "boundary-layer thickness as Cbl * mean distance to wall"
69 argList::addBoolOption
75 #include "setRootCase.H"
76 #include "createTime.H"
77 #include "createMesh.H"
78 #include "createFields.H"
80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
82 Info<< "Time = " << runTime.timeName() << nl << endl;
84 // Modify velocity by applying a 1/7th power law boundary-layer
85 // u/U0 = (y/ybl)^(1/7)
86 // assumes U0 is the same as the current cell velocity
88 scalar yblv = ybl.value();
93 U[celli] *= ::pow(y[celli]/yblv, (1.0/7.0));
97 Info<< "Writing U\n" << endl;
100 // Update/re-write phi
101 phi = fvc::interpolate(U) & mesh.Sf();
105 tmp<volScalarField> tnut = turbulence->nut();
106 volScalarField& nut = tnut();
107 volScalarField S(mag(dev(symm(fvc::grad(U)))));
108 nut = sqr(kappa*min(y, ybl))*::sqrt(2)*S;
110 if (args.optionFound("writenut"))
112 Info<< "Writing nut" << endl;
116 // Create G field - used by RAS wall functions
117 volScalarField G("RASModel::G", nut*2*sqr(S));
120 //--- Read and modify turbulence fields
123 tmp<volScalarField> tk = turbulence->k();
124 volScalarField& k = tk();
125 scalar ck0 = pow025(Cmu)*kappa;
126 k = sqr(nut/(ck0*min(y, ybl)));
127 k.correctBoundaryConditions();
129 Info<< "Writing k\n" << endl;
133 // Turbulence epsilon
134 tmp<volScalarField> tepsilon = turbulence->epsilon();
135 volScalarField& epsilon = tepsilon();
136 scalar ce0 = ::pow(Cmu, 0.75)/kappa;
137 epsilon = ce0*k*sqrt(k)/min(y, ybl);
138 epsilon.correctBoundaryConditions();
140 Info<< "Writing epsilon\n" << endl;
155 if (omegaHeader.headerOk())
157 volScalarField omega(omegaHeader, mesh);
158 omega = epsilon/(Cmu*k);
159 omega.correctBoundaryConditions();
161 Info<< "Writing omega\n" << endl;
166 // Turbulence nuTilda
167 IOobject nuTildaHeader
177 if (nuTildaHeader.headerOk())
179 volScalarField nuTilda(nuTildaHeader, mesh);
181 nuTilda.correctBoundaryConditions();
183 Info<< "Writing nuTilda\n" << endl;
188 Info<< nl << "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
189 << " ClockTime = " << runTime.elapsedClockTime() << " s"
192 Info<< "End\n" << endl;
198 // ************************************************************************* //