initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / applications / utilities / mesh / conversion / star4ToFoam / star4ToFoam.C
bloba92e70913f78595c7e57bad6b9ebc45969ad8020
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Application
26     star4ToFoam
28 Description
29     Converts a Star-CD (v4) pro-STAR mesh into OpenFOAM format.
31 Usage
32     - star4ToFoam [OPTION] ccmMesh\n
33       convert pro-STAR mesh to OpenFOAM
35     @param -ascii \n
36     Write in ASCII format instead of binary
38     @param -scale \<factor\>\n
39     Specify an alternative geometry scaling factor.
40     The default is @b 0.001 (scale @em [mm] to @em [m]).
42     @param -solids \n
43     Treat any solid cells present just like fluid cells.
44     The default is to discard them.
46 Note
47     - baffles are written as interfaces for later use
49 \*---------------------------------------------------------------------------*/
51 #include "argList.H"
52 #include "Time.H"
53 #include "STARCDMeshReader.H"
54 #include "OFstream.H"
56 using namespace Foam;
58 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59 //  Main program:
61 int main(int argc, char *argv[])
63     argList::noParallel();
64     argList::validArgs.append("pro-STAR prefix");
65     argList::validOptions.insert("ascii", "");
66     argList::validOptions.insert("scale", "scale");
67     argList::validOptions.insert("solids", "");
69     argList args(argc, argv);
70     Time runTime(args.rootPath(), args.caseName());
71     stringList const& params = args.additionalArgs();
73     // default rescale from [mm] to [m]
74     scalar scaleFactor = 0.001;
75     if (args.options().found("scale"))
76     {
77         scaleFactor = readScalar(IStringStream(args.options()["scale"])());
78         if (scaleFactor <= 0)
79         {
80             scaleFactor = 1;
81         }
82     }
84     if (args.options().found("solids"))
85     {
86         meshReaders::STARCD::keepSolids = true;
87     }
89     // default to binary output, unless otherwise specified
90     IOstream::streamFormat format = IOstream::BINARY;
91     if (args.options().found("ascii"))
92     {
93         format = IOstream::ASCII;
94     }
96     // increase the precision of the points data
97     IOstream::defaultPrecision(10);
99     // remove extensions and/or trailing '.'
100     fileName prefix = fileName(params[0]).lessExt();
102     meshReaders::STARCD reader(prefix, runTime, scaleFactor);
104     autoPtr<polyMesh> mesh = reader.mesh(runTime);
105     reader.writeMesh(mesh, format);
108     Info<< "\nEnd\n" << endl;
110     return 0;
113 // ************************************************************************* //