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

foamFormatConvert.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     foamFormatConvert
00027 
00028 Description
00029     Converts all IOobjects associated with a case into the format specified
00030     in the controlDict.
00031 
00032     Mainly used to convert binary mesh/field files to ASCII.
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #include "argList.H"
00037 #include "timeSelector.H"
00038 #include "Time.H"
00039 #include "volFields.H"
00040 #include "surfaceFields.H"
00041 #include "pointFields.H"
00042 #include "cellIOList.H"
00043 #include "IOobjectList.H"
00044 #include "IOPtrList.H"
00045 
00046 #include "writeMeshObject.H"
00047 #include "fieldDictionary.H"
00048 
00049 using namespace Foam;
00050 
00051 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00052 
00053 namespace Foam
00054 {
00055     defineTemplateTypeNameAndDebug(IOPtrList<entry>, 0);
00056 }
00057 
00058 
00059 // Main program:
00060 
00061 int main(int argc, char *argv[])
00062 {
00063     timeSelector::addOptions();
00064 #   include "setRootCase.H"
00065 #   include "createTime.H"
00066     Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args);
00067 
00068     forAll (timeDirs, timeI)
00069     {
00070         runTime.setTime(timeDirs[timeI], timeI);
00071         Info<< "Time = " << runTime.timeName() << endl;
00072 
00073         // Convert all the standard mesh files
00074         writeMeshObject<cellIOList>("cells", runTime);
00075         writeMeshObject<labelIOList>("owner", runTime);
00076         writeMeshObject<labelIOList>("neighbour", runTime);
00077         writeMeshObject<faceIOList>("faces", runTime);
00078         writeMeshObject<pointIOField>("points", runTime);
00079         writeMeshObject<IOPtrList<entry> >("cellZones", runTime);
00080         writeMeshObject<IOPtrList<entry> >("faceZones", runTime);
00081         writeMeshObject<IOPtrList<entry> >("pointZones", runTime);
00082 
00083         // Get list of objects from the database
00084         IOobjectList objects(runTime, runTime.timeName());
00085 
00086         forAllConstIter(IOobjectList, objects, iter)
00087         {
00088             const word& headerClassName = iter()->headerClassName();
00089 
00090             if
00091             (
00092                 headerClassName == volScalarField::typeName
00093              || headerClassName == volVectorField::typeName
00094              || headerClassName == volSphericalTensorField::typeName
00095              || headerClassName == volSymmTensorField::typeName
00096              || headerClassName == volTensorField::typeName
00097 
00098              || headerClassName == surfaceScalarField::typeName
00099              || headerClassName == surfaceVectorField::typeName
00100              || headerClassName == surfaceSphericalTensorField::typeName
00101              || headerClassName == surfaceSymmTensorField::typeName
00102              || headerClassName == surfaceTensorField::typeName
00103 
00104              || headerClassName == pointScalarField::typeName
00105              || headerClassName == pointVectorField::typeName
00106              || headerClassName == pointSphericalTensorField::typeName
00107              || headerClassName == pointSymmTensorField::typeName
00108              || headerClassName == pointTensorField::typeName
00109             )
00110             {
00111                 Info<< "        Reading " << headerClassName
00112                     << " : " << iter()->name() << endl;
00113 
00114                 fieldDictionary fDict
00115                 (
00116                     *iter(),
00117                     headerClassName
00118                 );
00119 
00120                 Info<< "        Writing " << iter()->name() << endl;
00121                 fDict.regIOobject::write();
00122             }
00123         }
00124 
00125         Info<< endl;
00126     }
00127 
00128     Info<< "End\n" << endl;
00129 
00130     return 0;
00131 }
00132 
00133 
00134 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd