OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

boundaryFoam.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Application
00026     boundaryFoam
00027 
00028 Description
00029     Steady-state solver for 1D turbulent flow, typically to generate boundary
00030     layer conditions at an inlet, for use in a simulation.
00031 
00032     Boundary layer code to calculate the U, k and epsilon distributions.
00033     Used to create inlet boundary conditions for experimental comparisons
00034     for which U and k have not been measured.
00035     Turbulence model is runtime selectable.
00036 
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #include "fvCFD.H"
00040 #include "singlePhaseTransportModel.H"
00041 #include "RASModel.H"
00042 #include "wallFvPatch.H"
00043 #include "makeGraph.H"
00044 
00045 
00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00047 
00048 int main(int argc, char *argv[])
00049 {
00050     #include "setRootCase.H"
00051 
00052     #include "createTime.H"
00053     #include "createMesh.H"
00054     #include "createFields.H"
00055 
00056     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00057 
00058     Info<< "\nStarting time loop\n" << endl;
00059 
00060     while (runTime.loop())
00061     {
00062         Info<< "Time = " << runTime.timeName() << nl << endl;
00063 
00064         fvVectorMatrix divR = turbulence->divDevReff(U);
00065         divR.source() = flowMask & divR.source();
00066 
00067         fvVectorMatrix UEqn
00068         (
00069             divR == gradP
00070         );
00071 
00072         UEqn.relax();
00073 
00074         UEqn.solve();
00075 
00076 
00077         // Correct driving force for a constant mass flow rate
00078 
00079         dimensionedVector UbarStar = flowMask & U.weightedAverage(mesh.V());
00080 
00081         U += (Ubar - UbarStar);
00082         gradP += (Ubar - UbarStar)/(1.0/UEqn.A())().weightedAverage(mesh.V());
00083 
00084         label id = y.size() - 1;
00085 
00086         scalar wallShearStress =
00087             flowDirection & turbulence->R()()[id] & wallNormal;
00088 
00089         scalar yplusWall
00090 //            = ::sqrt(mag(wallShearStress))*y[id]/laminarTransport.nu()()[id];
00091             = ::sqrt(mag(wallShearStress))*y[id]/turbulence->nuEff()()[id];
00092 
00093         Info<< "Uncorrected Ubar = " << (flowDirection & UbarStar.value())<< tab
00094             << "pressure gradient = " << (flowDirection & gradP.value()) << tab
00095             << "min y+ = " << yplusWall << endl;
00096 
00097 
00098         turbulence->correct();
00099 
00100 
00101         if (runTime.outputTime())
00102         {
00103             volSymmTensorField R
00104             (
00105                 IOobject
00106                 (
00107                     "R",
00108                     runTime.timeName(),
00109                     mesh,
00110                     IOobject::NO_READ,
00111                     IOobject::AUTO_WRITE
00112                 ),
00113                 turbulence->R()
00114             );
00115 
00116             runTime.write();
00117 
00118             const word& gFormat = runTime.graphFormat();
00119 
00120             makeGraph(y, flowDirection & U, "Uf", gFormat);
00121 
00122             makeGraph(y, laminarTransport.nu(), gFormat);
00123 
00124             makeGraph(y, turbulence->k(), gFormat);
00125             makeGraph(y, turbulence->epsilon(), gFormat);
00126 
00127             //makeGraph(y, flowDirection & R & flowDirection, "Rff", gFormat);
00128             //makeGraph(y, wallNormal & R & wallNormal, "Rww", gFormat);
00129             //makeGraph(y, flowDirection & R & wallNormal, "Rfw", gFormat);
00130 
00131             //makeGraph(y, sqrt(R.component(tensor::XX)), "u", gFormat);
00132             //makeGraph(y, sqrt(R.component(tensor::YY)), "v", gFormat);
00133             //makeGraph(y, sqrt(R.component(tensor::ZZ)), "w", gFormat);
00134             makeGraph(y, R.component(tensor::XY), "uv", gFormat);
00135 
00136             makeGraph(y, mag(fvc::grad(U)), "gammaDot", gFormat);
00137         }
00138 
00139         Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
00140             << "  ClockTime = " << runTime.elapsedClockTime() << " s"
00141             << nl << endl;
00142     }
00143 
00144     Info<< "End\n" << endl;
00145 
00146     return 0;
00147 }
00148 
00149 
00150 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd