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

star4ToFoam.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     star4ToFoam
00026 
00027 Description
00028     Converts a Star-CD (v4) pro-STAR mesh into OpenFOAM format.
00029 
00030 Usage
00031     - star4ToFoam [OPTION] <ccmMesh>\n
00032       convert pro-STAR mesh to OpenFOAM
00033 
00034     @param -ascii \n
00035     Write in ASCII format instead of binary.
00036 
00037     @param -scale <factor>\n
00038     Specify an alternative geometry scaling factor.
00039     The default is @b 0.001 (scale @em [mm] to @em [m]).
00040 
00041     @param -solids \n
00042     Treat any solid cells present just like fluid cells.
00043     The default is to discard them.
00044 
00045     @param -case <dir> \n
00046     Case directory.
00047 
00048     @param -help \n
00049     Display help message.
00050 
00051     @param -doc \n
00052     Display Doxygen API documentation page for this application.
00053 
00054     @param -srcDoc \n
00055     Display Doxygen source documentation page for this application.
00056 
00057 Note
00058     - baffles are written as interfaces for later use
00059 
00060 \*---------------------------------------------------------------------------*/
00061 
00062 #include <OpenFOAM/argList.H>
00063 #include <OpenFOAM/Time.H>
00064 #include <conversion/STARCDMeshReader.H>
00065 #include <OpenFOAM/OFstream.H>
00066 
00067 using namespace Foam;
00068 
00069 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00070 //  Main program:
00071 
00072 int main(int argc, char *argv[])
00073 {
00074     argList::noParallel();
00075     argList::validArgs.append("pro-STAR prefix");
00076     argList::validOptions.insert("ascii", "");
00077     argList::validOptions.insert("scale", "scale");
00078     argList::validOptions.insert("solids", "");
00079 
00080     argList args(argc, argv);
00081     Time runTime(args.rootPath(), args.caseName());
00082     const stringList& params = args.additionalArgs();
00083 
00084     // default rescale from [mm] to [m]
00085     scalar scaleFactor = 0.001;
00086     if (args.optionReadIfPresent("scale", scaleFactor))
00087     {
00088         if (scaleFactor <= 0)
00089         {
00090             scaleFactor = 1;
00091         }
00092     }
00093 
00094     if (args.optionFound("solids"))
00095     {
00096         meshReaders::STARCD::keepSolids = true;
00097     }
00098 
00099     // default to binary output, unless otherwise specified
00100     IOstream::streamFormat format = IOstream::BINARY;
00101     if (args.optionFound("ascii"))
00102     {
00103         format = IOstream::ASCII;
00104     }
00105 
00106     // increase the precision of the points data
00107     IOstream::defaultPrecision(10);
00108 
00109     // remove extensions and/or trailing '.'
00110     fileName prefix = fileName(params[0]).lessExt();
00111 
00112     meshReaders::STARCD reader(prefix, runTime, scaleFactor);
00113 
00114     autoPtr<polyMesh> mesh = reader.mesh(runTime);
00115     reader.writeMesh(mesh, format);
00116 
00117 
00118     Info<< "\nEnd\n" << endl;
00119 
00120     return 0;
00121 }
00122 
00123 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines