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

writeCellCentres.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 Description
00026     Write the three components of the cell centres as volScalarFields so
00027     they can be used in postprocessing in thresholding.
00028 
00029 \*---------------------------------------------------------------------------*/
00030 
00031 #include "argList.H"
00032 #include "timeSelector.H"
00033 #include "Time.H"
00034 #include "fvMesh.H"
00035 #include "vectorIOField.H"
00036 #include "volFields.H"
00037 
00038 using namespace Foam;
00039 
00040 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00041 
00042 // Main program:
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 
00055     forAll(timeDirs, timeI)
00056     {
00057         runTime.setTime(timeDirs[timeI], timeI);
00058 
00059         Info<< "Time = " << runTime.timeName() << endl;
00060 
00061         // Check for new mesh
00062         mesh.readUpdate();
00063 
00064         volVectorField cc
00065         (
00066             IOobject
00067             (
00068                 "cellCentres",
00069                 runTime.timeName(),
00070                 mesh,
00071                 IOobject::NO_READ,
00072                 IOobject::AUTO_WRITE
00073             ),
00074             mesh.C()
00075         );
00076 
00077         // Info<< "Writing cellCentre positions to " << cc.name() << " in "
00078         //     << runTime.timeName() << endl;
00079         //
00080         // cc.write();
00081 
00082         Info<< "Writing components of cellCentre positions to volScalarFields"
00083             << " ccx, ccy, ccz in " <<  runTime.timeName() << endl;
00084 
00085         for (direction i=0; i<vector::nComponents; i++)
00086         {
00087             volScalarField cci
00088             (
00089                 IOobject
00090                 (
00091                     "cc" + word(vector::componentNames[i]),
00092                     runTime.timeName(),
00093                     mesh,
00094                     IOobject::NO_READ,
00095                     IOobject::AUTO_WRITE
00096                 ),
00097                 mesh.C().component(i)
00098             );
00099 
00100             cci.write();
00101         }
00102     }
00103 
00104     Info<< "\nEnd" << endl;
00105 
00106     return 0;
00107 }
00108 
00109 
00110 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd