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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2016-2024 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Application
28  star4ToFoam
29 
30 Group
31  grpMeshConversionUtilities
32 
33 Description
34  Convert a STARCD/PROSTAR (v4) mesh into OpenFOAM format.
35 
36 Usage
37  \b star4ToFoam [OPTION] prostarMesh
38 
39  Options:
40  - \par -ascii
41  Write in ASCII format instead of binary
42 
43  - \par -scale <factor>
44  Specify an alternative geometry scaling factor.
45  The default is \b 0.001 (scale \em [mm] to \em [m]).
46 
47  - \par -solids
48  Treat any solid cells present just like fluid cells.
49  The default is to discard them.
50 
51 Note
52  Baffles are written as interfaces for later use
53 
54 See also
55  Foam::cellTable, Foam::meshReader and Foam::fileFormats::STARCDMeshReader
56 
57 \*---------------------------------------------------------------------------*/
58 
59 #include "argList.H"
60 #include "Time.H"
61 #include "STARCDMeshReader.H"
62 #include "OFstream.H"
63 
64 using namespace Foam;
65 
66 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
67 
68 int main(int argc, char *argv[])
69 {
71  (
72  "Convert STARCD/PROSTAR (v4) mesh to OpenFOAM"
73  );
74 
76  argList::addArgument("prefix", "The prefix for the input PROSTAR files");
78  (
79  "ascii",
80  "Write in ASCII instead of binary format"
81  );
83  (
84  "scale",
85  "factor",
86  "Geometry scaling factor - default is 0.001 ([mm] to [m])"
87  );
89  (
90  "solids",
91  "Retain solid cells and treat like fluid cells"
92  );
93 
94 
95  argList args(argc, argv);
97 
98  // Binary output, unless otherwise specified
100  (
101  args.found("ascii")
104  );
105 
106  // More precision (for points data)
108 
109 
110  // Remove extensions and/or trailing '.'
111  const auto prefix = args.get<fileName>(1).lessExt();
112 
113 
115  (
116  prefix,
117  runTime,
118  // Default rescale from [mm] to [m]
119  args.getOrDefault<scalar>("scale", 0.001),
120  args.found("solids")
121  );
122 
123 
124  autoPtr<polyMesh> mesh = reader.mesh(runTime);
125  reader.writeMesh(mesh(), format);
126 
127 
128  Info<< "\nEnd\n" << endl;
129 
130  return 0;
131 }
132 
133 // ************************************************************************* //
static void addNote(const string &note)
Add extra notes for the usage information.
Definition: argList.C:462
A class for handling file names.
Definition: fileName.H:72
"ascii" (normal default)
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
Definition: argList.C:374
static void noParallel()
Remove the parallel options.
Definition: argList.C:584
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
Definition: argListI.H:300
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
Read PROSTAR vrt/cel/bnd files. The protected data in meshReader are filled.
dynamicFvMesh & mesh
Extract command arguments and options from the supplied argc and argv parameters. ...
Definition: argList.H:118
static void addOption(const word &optName, const string &param="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
Definition: argList.C:385
static unsigned int minPrecision(unsigned int prec) noexcept
Set the minimum default precision.
Definition: IOstream.H:440
const fileName & caseName() const noexcept
Return case name (parallel run) or global case (serial run)
Definition: argListI.H:62
const fileName & rootPath() const noexcept
Return root path.
Definition: argListI.H:56
word format(conversionProperties.get< word >("format"))
T get(const label index) const
Get a value from the argument at index.
Definition: argListI.H:271
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
Definition: argList.C:351
streamFormat
Data format (ascii | binary)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Foam::argList args(argc, argv)
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:171
Namespace for OpenFOAM.