initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / applications / solvers / incompressible / boundaryFoam / boundaryFoam.C
blobb9b46a3cc9472054bf10081efbf02945192cfb5c
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 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 "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H"
41 #include "incompressible/RASModel/RASModel.H"
42 #include "wallFvPatch.H"
43 #include "makeGraph.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 int main(int argc, char *argv[])
51 #   include "setRootCase.H"
53 #   include "createTime.H"
54 #   include "createMesh.H"
55 #   include "createFields.H"
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59     Info<< "\nStarting time loop\n" << endl;
61     for (runTime++; !runTime.end(); runTime++)
62     {
63         Info<< "Time = " << runTime.timeName() << nl << endl;
65         fvVectorMatrix divR = turbulence->divDevReff(U);
66         divR.source() = flowMask & divR.source();
68         fvVectorMatrix UEqn
69         (
70             divR == gradP
71         );
73         UEqn.relax();
75         UEqn.solve();
78         // Correct driving force for a constant mass flow rate
80         dimensionedVector UbarStar = flowMask & U.weightedAverage(mesh.V());
82         U += (Ubar - UbarStar);
83         gradP += (Ubar - UbarStar)/(1.0/UEqn.A())().weightedAverage(mesh.V());
85         scalar wallShearStress =
86             flowDirection & turbulence->R()()[0] & wallNormal;
88         scalar yplusWall
89             = ::sqrt(mag(wallShearStress))*y[0]/laminarTransport.nu()()[0];
91         Info<< "Uncorrected Ubar = " << (flowDirection & UbarStar.value())<< tab
92             << "pressure gradient = " << (flowDirection & gradP.value()) << tab
93             << "min y+ = " << yplusWall << endl;
96         turbulence->correct();
99         if (runTime.outputTime())
100         {
101             volSymmTensorField R
102             (
103                 IOobject
104                 (
105                     "R",
106                     runTime.timeName(),
107                     mesh,
108                     IOobject::NO_READ,
109                     IOobject::AUTO_WRITE
110                 ),
111                 turbulence->R()
112             );
114             runTime.write();
116             const word& gFormat = runTime.graphFormat();
118             makeGraph(y, flowDirection & U, "Uf", gFormat);
120             makeGraph(y, laminarTransport.nu(), gFormat);
122             makeGraph(y, turbulence->k(), gFormat);
123             makeGraph(y, turbulence->epsilon(), gFormat);
125             //makeGraph(y, flowDirection & R & flowDirection, "Rff", gFormat);
126             //makeGraph(y, wallNormal & R & wallNormal, "Rww", gFormat);
127             //makeGraph(y, flowDirection & R & wallNormal, "Rfw", gFormat);
129             //makeGraph(y, sqrt(R.component(tensor::XX)), "u", gFormat);
130             //makeGraph(y, sqrt(R.component(tensor::YY)), "v", gFormat);
131             //makeGraph(y, sqrt(R.component(tensor::ZZ)), "w", gFormat);
132             makeGraph(y, R.component(tensor::XY), "uv", gFormat);
134             makeGraph(y, mag(fvc::grad(U)), "gammaDot", gFormat);
135         }
137         Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
138             << "  ClockTime = " << runTime.elapsedClockTime() << " s"
139             << nl << endl;
140     }
142     Info<< "End\n" << endl;
144     return(0);
148 // ************************************************************************* //