Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / applications / solvers / incompressible / boundaryFoam / boundaryFoam.C
blobd4372d380265ab05c6775aa107ff261e34d98247
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 Application
25     boundaryFoam
27 Description
28     Steady-state solver for 1D turbulent flow, typically to generate boundary
29     layer conditions at an inlet, for use in a simulation.
31     Boundary layer code to calculate the U, k and epsilon distributions.
32     Used to create inlet boundary conditions for experimental comparisons
33     for which U and k have not been measured.
34     Turbulence model is runtime selectable.
36 \*---------------------------------------------------------------------------*/
38 #include "fvCFD.H"
39 #include "singlePhaseTransportModel.H"
40 #include "RASModel.H"
41 #include "wallFvPatch.H"
42 #include "makeGraph.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 int main(int argc, char *argv[])
49 #   include "setRootCase.H"
51 #   include "createTime.H"
52 #   include "createMesh.H"
53 #   include "createFields.H"
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57     Info<< "\nStarting time loop\n" << endl;
59     while (runTime.loop())
60     {
61         Info<< "Time = " << runTime.timeName() << nl << endl;
63         fvVectorMatrix divR = turbulence->divDevReff(U);
64         divR.source() = flowMask & divR.source();
66         fvVectorMatrix UEqn
67         (
68             divR == gradP
69         );
71         UEqn.relax();
73         UEqn.solve();
76         // Correct driving force for a constant mass flow rate
78         dimensionedVector UbarStar = flowMask & U.weightedAverage(mesh.V());
80         U += (Ubar - UbarStar);
81         gradP += (Ubar - UbarStar)/(1.0/UEqn.A())().weightedAverage(mesh.V());
83         label id = y.size() - 1;
85         scalar wallShearStress =
86             flowDirection & turbulence->R()()[id] & wallNormal;
88         scalar yplusWall
89 //            = Foam::sqrt(mag(wallShearStress))*y[id]/laminarTransport.nu()()[id];
90             = Foam::sqrt(mag(wallShearStress))*y[id]/turbulence->nuEff()()[id];
92         Info<< "Uncorrected Ubar = " << (flowDirection & UbarStar.value())<< tab
93             << "pressure gradient = " << (flowDirection & gradP.value()) << tab
94             << "min y+ = " << yplusWall << endl;
97         turbulence->correct();
100         if (runTime.outputTime())
101         {
102             volSymmTensorField R
103             (
104                 IOobject
105                 (
106                     "R",
107                     runTime.timeName(),
108                     mesh,
109                     IOobject::NO_READ,
110                     IOobject::AUTO_WRITE
111                 ),
112                 turbulence->R()
113             );
115             runTime.write();
117             const word& gFormat = runTime.graphFormat();
119             makeGraph(y, flowDirection & U, "Uf", gFormat);
121             makeGraph(y, laminarTransport.nu(), gFormat);
123             makeGraph(y, turbulence->k(), gFormat);
124             makeGraph(y, turbulence->epsilon(), gFormat);
126             //makeGraph(y, flowDirection & R & flowDirection, "Rff", gFormat);
127             //makeGraph(y, wallNormal & R & wallNormal, "Rww", gFormat);
128             //makeGraph(y, flowDirection & R & wallNormal, "Rfw", gFormat);
130             //makeGraph(y, sqrt(R.component(tensor::XX)), "u", gFormat);
131             //makeGraph(y, sqrt(R.component(tensor::YY)), "v", gFormat);
132             //makeGraph(y, sqrt(R.component(tensor::ZZ)), "w", gFormat);
133             makeGraph(y, R.component(tensor::XY), "uv", gFormat);
135             makeGraph(y, mag(fvc::grad(U)), "gammaDot", gFormat);
136         }
138         Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
139             << "  ClockTime = " << runTime.elapsedClockTime() << " s"
140             << nl << endl;
141     }
143     Info<< "End\n" << endl;
145     return 0;
149 // ************************************************************************* //