FreeFOAM The Cross-Platform CFD Toolkit
star4ToFoam.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Application
25  star4ToFoam
26 
27 Description
28  Converts a Star-CD (v4) pro-STAR mesh into OpenFOAM format.
29 
30 Usage
31  - star4ToFoam [OPTION] <ccmMesh>\n
32  convert pro-STAR mesh to OpenFOAM
33 
34  @param -ascii \n
35  Write in ASCII format instead of binary.
36 
37  @param -scale <factor>\n
38  Specify an alternative geometry scaling factor.
39  The default is @b 0.001 (scale @em [mm] to @em [m]).
40 
41  @param -solids \n
42  Treat any solid cells present just like fluid cells.
43  The default is to discard them.
44 
45  @param -case <dir> \n
46  Case directory.
47 
48  @param -help \n
49  Display help message.
50 
51  @param -doc \n
52  Display Doxygen API documentation page for this application.
53 
54  @param -srcDoc \n
55  Display Doxygen source documentation page for this application.
56 
57 Note
58  - baffles are written as interfaces for later use
59 
60 \*---------------------------------------------------------------------------*/
61 
62 #include <OpenFOAM/argList.H>
63 #include <OpenFOAM/Time.H>
65 #include <OpenFOAM/OFstream.H>
66 
67 using namespace Foam;
68 
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 // Main program:
71 
72 int main(int argc, char *argv[])
73 {
75  argList::validArgs.append("pro-STAR prefix");
76  argList::validOptions.insert("ascii", "");
77  argList::validOptions.insert("scale", "scale");
78  argList::validOptions.insert("solids", "");
79 
80  argList args(argc, argv);
81  Time runTime(args.rootPath(), args.caseName());
82  const stringList& params = args.additionalArgs();
83 
84  // default rescale from [mm] to [m]
85  scalar scaleFactor = 0.001;
86  if (args.optionReadIfPresent("scale", scaleFactor))
87  {
88  if (scaleFactor <= 0)
89  {
90  scaleFactor = 1;
91  }
92  }
93 
94  if (args.optionFound("solids"))
95  {
97  }
98 
99  // default to binary output, unless otherwise specified
101  if (args.optionFound("ascii"))
102  {
103  format = IOstream::ASCII;
104  }
105 
106  // increase the precision of the points data
108 
109  // remove extensions and/or trailing '.'
110  fileName prefix = fileName(params[0]).lessExt();
111 
112  meshReaders::STARCD reader(prefix, runTime, scaleFactor);
113 
114  autoPtr<polyMesh> mesh = reader.mesh(runTime);
115  reader.writeMesh(mesh, format);
116 
117 
118  Info<< "\nEnd\n" << endl;
119 
120  return 0;
121 }
122 
123 // ************************ vim: set sw=4 sts=4 et: ************************ //