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

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-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     writeCellCentres
00026 
00027 Description
00028     Write the three components of the cell centres as volScalarFields so
00029     they can be used in postprocessing in thresholding.
00030 
00031 Usage
00032 
00033     - writeCellCentres [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 <OpenFOAM/argList.H>
00065 #include <OpenFOAM/timeSelector.H>
00066 #include <OpenFOAM/Time.H>
00067 #include <finiteVolume/fvMesh.H>
00068 #include <OpenFOAM/vectorIOField.H>
00069 #include <finiteVolume/volFields.H>
00070 
00071 using namespace Foam;
00072 
00073 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00074 
00075 // Main program:
00076 
00077 int main(int argc, char *argv[])
00078 {
00079     timeSelector::addOptions();
00080 
00081 #   include <OpenFOAM/setRootCase.H>
00082 #   include <OpenFOAM/createTime.H>
00083 
00084     instantList timeDirs = timeSelector::select0(runTime, args);
00085 
00086 #   include <OpenFOAM/createMesh.H>
00087 
00088     forAll(timeDirs, timeI)
00089     {
00090         runTime.setTime(timeDirs[timeI], timeI);
00091 
00092         Info<< "Time = " << runTime.timeName() << endl;
00093 
00094         // Check for new mesh
00095         mesh.readUpdate();
00096 
00097         volVectorField cc
00098         (
00099             IOobject
00100             (
00101                 "cellCentres",
00102                 runTime.timeName(),
00103                 mesh,
00104                 IOobject::NO_READ,
00105                 IOobject::AUTO_WRITE
00106             ),
00107             mesh.C()
00108         );
00109 
00110         // Info<< "Writing cellCentre positions to " << cc.name() << " in "
00111         //     << runTime.timeName() << endl;
00112         //
00113         // cc.write();
00114 
00115         Info<< "Writing components of cellCentre positions to volScalarFields"
00116             << " ccx, ccy, ccz in " <<  runTime.timeName() << endl;
00117 
00118         for (direction i=0; i<vector::nComponents; i++)
00119         {
00120             volScalarField cci
00121             (
00122                 IOobject
00123                 (
00124                     "cc" + word(vector::componentNames[i]),
00125                     runTime.timeName(),
00126                     mesh,
00127                     IOobject::NO_READ,
00128                     IOobject::AUTO_WRITE
00129                 ),
00130                 mesh.C().component(i)
00131             );
00132 
00133             cci.write();
00134         }
00135     }
00136 
00137     Info<< "\nEnd" << endl;
00138 
00139     return 0;
00140 }
00141 
00142 
00143 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines