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

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-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     pPrime2
00027 
00028 Description
00029     Calculates and writes the scalar field of pPrime2 (sqr(p - pMean)) at
00030     each time
00031 
00032 \*---------------------------------------------------------------------------*/
00033 
00034 #include "fvCFD.H"
00035 
00036 
00037 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00038 
00039 int main(int argc, char *argv[])
00040 {
00041     timeSelector::addOptions();
00042 
00043 #   include "setRootCase.H"
00044 #   include "createTime.H"
00045 
00046     instantList timeDirs = timeSelector::select0(runTime, args);
00047 
00048 #   include "createMesh.H"
00049 
00050     runTime.setTime(timeDirs[timeDirs.size()-1], timeDirs.size()-1);
00051 
00052     volScalarField pMean
00053     (
00054         IOobject
00055         (
00056             "pMean",
00057             runTime.timeName(),
00058             mesh,
00059             IOobject::MUST_READ
00060         ),
00061         mesh
00062     );
00063 
00064     forAll(timeDirs, timeI)
00065     {
00066         runTime.setTime(timeDirs[timeI], timeI);
00067 
00068         Info<< "Time = " << runTime.timeName() << endl;
00069 
00070         IOobject pheader
00071         (
00072             "p",
00073             runTime.timeName(),
00074             mesh,
00075             IOobject::MUST_READ
00076         );
00077 
00078         // Check p exists
00079         if (pheader.headerOk())
00080         {
00081             mesh.readUpdate();
00082 
00083             Info<< "    Reading p" << endl;
00084             volScalarField p(pheader, mesh);
00085 
00086             Info<< "    Calculating pPrime2" << endl;
00087             volScalarField pPrime2
00088             (
00089                 IOobject
00090                 (
00091                     "pPrime2",
00092                     runTime.timeName(),
00093                     mesh,
00094                     IOobject::NO_READ
00095                 ),
00096                 sqr(p - pMean)
00097             );
00098             pPrime2.write();
00099         }
00100         else
00101         {
00102             Info<< "    No p" << endl;
00103         }
00104 
00105         Info<< endl;
00106     }
00107 
00108     return 0;
00109 }
00110 
00111 
00112 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd