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

createTurbulenceFields.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     CreateTurbulenceFields
00027 
00028 Description
00029     Creates a full set of turbulence fields.
00030 
00031     - Currently does not output nut and nuTilda
00032 
00033 Source files:
00034     createFields.H
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #include "fvCFD.H"
00039 #include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H"
00040 #include "RASModel.H"
00041 
00042 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00043 
00044 int main(int argc, char *argv[])
00045 {
00046     timeSelector::addOptions();
00047 
00048     #include "setRootCase.H"
00049     #include "createTime.H"
00050 
00051     instantList timeDirs = timeSelector::select0(runTime, args);
00052 
00053     #include "createMesh.H"
00054     #include "createFields.H"
00055 
00056     forAll(timeDirs, timeI)
00057     {
00058         runTime.setTime(timeDirs[timeI], timeI);
00059 
00060         Info<< "Time = " << runTime.timeName() << endl;
00061 
00062         // Cache the turbulence fields
00063 
00064         Info<< "\nRetrieving field k from turbulence model" << endl;
00065         const volScalarField k = RASModel->k();
00066 
00067         Info<< "\nRetrieving field epsilon from turbulence model" << endl;
00068         const volScalarField epsilon = RASModel->epsilon();
00069 
00070         Info<< "\nRetrieving field R from turbulence model" << endl;
00071         const volSymmTensorField R = RASModel->R();
00072 
00073         // Check availability of tubulence fields
00074 
00075         if (!IOobject("k", runTime.timeName(), mesh).headerOk())
00076         {
00077             Info<< "\nWriting turbulence field k" << endl;
00078             k.write();
00079         }
00080         else
00081         {
00082             Info<< "\nTurbulence k field already exists" << endl;
00083         }
00084 
00085         if (!IOobject("epsilon", runTime.timeName(), mesh).headerOk())
00086         {
00087             Info<< "\nWriting turbulence field epsilon" << endl;
00088             epsilon.write();
00089         }
00090         else
00091         {
00092             Info<< "\nTurbulence epsilon field already exists" << endl;
00093         }
00094 
00095         if (!IOobject("R", runTime.timeName(), mesh).headerOk())
00096         {
00097             Info<< "\nWriting turbulence field R" << endl;
00098             R.write();
00099         }
00100         else
00101         {
00102             Info<< "\nTurbulence R field already exists" << endl;
00103         }
00104 
00105         if (!IOobject("omega", runTime.timeName(), mesh).headerOk())
00106         {
00107             const scalar Cmu = 0.09;
00108 
00109             Info<< "creating omega" << endl;
00110             volScalarField omega
00111             (
00112                 IOobject
00113                 (
00114                     "omega",
00115                     runTime.timeName(),
00116                     mesh
00117                 ),
00118                 epsilon/(Cmu*k),
00119                 epsilon.boundaryField().types()
00120             );
00121             Info<< "\nWriting turbulence field omega" << endl;
00122             omega.write();
00123         }
00124         else
00125         {
00126             Info<< "\nTurbulence omega field already exists" << endl;
00127         }
00128     }
00129 
00130     Info<< "\nEnd\n" << endl;
00131 
00132     return 0;
00133 }
00134 
00135 
00136 // ************************************************************************* //
00137 
Copyright © 2000-2009 OpenCFD Ltd