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

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