initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / applications / solvers / incompressible / boundaryFoam / boundaryFoam.C
blob2ee69c120e09b41acb0edb4f9e8f6a736cd0d783
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 Application
26     boundaryFoam
28 Description
29     Steady-state solver for 1D turbulent flow, typically to generate boundary
30     layer conditions at an inlet, for use in a simulation.
32     Boundary layer code to calculate the U, k and epsilon distributions.
33     Used to create inlet boundary conditions for experimental comparisons
34     for which U and k have not been measured.
35     Turbulence model is runtime selectable.
37 \*---------------------------------------------------------------------------*/
39 #include "fvCFD.H"
40 #include "singlePhaseTransportModel.H"
41 #include "RASModel.H"
42 #include "wallFvPatch.H"
43 #include "makeGraph.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 int main(int argc, char *argv[])
50     #include "setRootCase.H"
52     #include "createTime.H"
53     #include "createMesh.H"
54     #include "createFields.H"
56     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58     Info<< "\nStarting time loop\n" << endl;
60     while (runTime.loop())
61     {
62         Info<< "Time = " << runTime.timeName() << nl << endl;
64         fvVectorMatrix divR = turbulence->divDevReff(U);
65         divR.source() = flowMask & divR.source();
67         fvVectorMatrix UEqn
68         (
69             divR == gradP
70         );
72         UEqn.relax();
74         UEqn.solve();
77         // Correct driving force for a constant mass flow rate
79         dimensionedVector UbarStar = flowMask & U.weightedAverage(mesh.V());
81         U += (Ubar - UbarStar);
82         gradP += (Ubar - UbarStar)/(1.0/UEqn.A())().weightedAverage(mesh.V());
84         label id = y.size() - 1;
86         scalar wallShearStress =
87             flowDirection & turbulence->R()()[id] & wallNormal;
89         scalar yplusWall
90 //            = ::sqrt(mag(wallShearStress))*y[id]/laminarTransport.nu()()[id];
91             = ::sqrt(mag(wallShearStress))*y[id]/turbulence->nuEff()()[id];
93         Info<< "Uncorrected Ubar = " << (flowDirection & UbarStar.value())<< tab
94             << "pressure gradient = " << (flowDirection & gradP.value()) << tab
95             << "min y+ = " << yplusWall << endl;
98         turbulence->correct();
101         if (runTime.outputTime())
102         {
103             volSymmTensorField R
104             (
105                 IOobject
106                 (
107                     "R",
108                     runTime.timeName(),
109                     mesh,
110                     IOobject::NO_READ,
111                     IOobject::AUTO_WRITE
112                 ),
113                 turbulence->R()
114             );
116             runTime.write();
118             const word& gFormat = runTime.graphFormat();
120             makeGraph(y, flowDirection & U, "Uf", gFormat);
122             makeGraph(y, laminarTransport.nu(), gFormat);
124             makeGraph(y, turbulence->k(), gFormat);
125             makeGraph(y, turbulence->epsilon(), gFormat);
127             //makeGraph(y, flowDirection & R & flowDirection, "Rff", gFormat);
128             //makeGraph(y, wallNormal & R & wallNormal, "Rww", gFormat);
129             //makeGraph(y, flowDirection & R & wallNormal, "Rfw", gFormat);
131             //makeGraph(y, sqrt(R.component(tensor::XX)), "u", gFormat);
132             //makeGraph(y, sqrt(R.component(tensor::YY)), "v", gFormat);
133             //makeGraph(y, sqrt(R.component(tensor::ZZ)), "w", gFormat);
134             makeGraph(y, R.component(tensor::XY), "uv", gFormat);
136             makeGraph(y, mag(fvc::grad(U)), "gammaDot", gFormat);
137         }
139         Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
140             << "  ClockTime = " << runTime.elapsedClockTime() << " s"
141             << nl << endl;
142     }
144     Info<< "End\n" << endl;
146     return 0;
150 // ************************************************************************* //