FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

pPrime2.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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Application
00025     pPrime2
00026 
00027 Description
00028     Calculates and writes the scalar field of pPrime2 (sqr(p - pMean)) at
00029     each time
00030 
00031 Usage
00032 
00033     - pPrime2 [OPTIONS]
00034 
00035     @param -noZero \n
00036     Ignore timestep 0.
00037 
00038     @param -constant \n
00039     Include the constant directory.
00040 
00041     @param -time <time>\n
00042     Apply only to specific time.
00043 
00044     @param -latestTime \n
00045     Only apply to latest time step.
00046 
00047     @param -case <dir>\n
00048     Case directory.
00049 
00050     @param -parallel \n
00051     Run in parallel.
00052 
00053     @param -help \n
00054     Display help message.
00055 
00056     @param -doc \n
00057     Display Doxygen API documentation page for this application.
00058 
00059     @param -srcDoc \n
00060     Display Doxygen source documentation page for this application.
00061 
00062 \*---------------------------------------------------------------------------*/
00063 
00064 #include <finiteVolume/fvCFD.H>
00065 
00066 
00067 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00068 
00069 int main(int argc, char *argv[])
00070 {
00071     timeSelector::addOptions();
00072 
00073 #   include <OpenFOAM/setRootCase.H>
00074 #   include <OpenFOAM/createTime.H>
00075 
00076     instantList timeDirs = timeSelector::select0(runTime, args);
00077 
00078 #   include <OpenFOAM/createMesh.H>
00079 
00080     runTime.setTime(timeDirs[timeDirs.size()-1], timeDirs.size()-1);
00081 
00082     volScalarField pMean
00083     (
00084         IOobject
00085         (
00086             "pMean",
00087             runTime.timeName(),
00088             mesh,
00089             IOobject::MUST_READ
00090         ),
00091         mesh
00092     );
00093 
00094     forAll(timeDirs, timeI)
00095     {
00096         runTime.setTime(timeDirs[timeI], timeI);
00097 
00098         Info<< "Time = " << runTime.timeName() << endl;
00099 
00100         IOobject pheader
00101         (
00102             "p",
00103             runTime.timeName(),
00104             mesh,
00105             IOobject::MUST_READ
00106         );
00107 
00108         // Check p exists
00109         if (pheader.headerOk())
00110         {
00111             mesh.readUpdate();
00112 
00113             Info<< "    Reading p" << endl;
00114             volScalarField p(pheader, mesh);
00115 
00116             Info<< "    Calculating pPrime2" << endl;
00117             volScalarField pPrime2
00118             (
00119                 IOobject
00120                 (
00121                     "pPrime2",
00122                     runTime.timeName(),
00123                     mesh,
00124                     IOobject::NO_READ
00125                 ),
00126                 sqr(p - pMean)
00127             );
00128             pPrime2.write();
00129         }
00130         else
00131         {
00132             Info<< "    No p" << endl;
00133         }
00134 
00135         Info<< endl;
00136     }
00137 
00138     return 0;
00139 }
00140 
00141 
00142 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines