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-2021 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  // Increase the precision of the 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 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
Foam::fileName
A class for handling file names.
Definition: fileName.H:71
Foam::argList::getOrDefault
T getOrDefault(const word &optName, const T &deflt) const
Definition: argListI.H:300
STARCDMeshReader.H
Foam::argList::caseName
const fileName & caseName() const noexcept
Definition: argListI.H:62
Foam::argList::addNote
static void addNote(const string &note)
Definition: argList.C:405
Foam::argList
Extract command arguments and options from the supplied argc and argv parameters.
Definition: argList.H:119
Foam::endl
Ostream & endl(Ostream &os)
Definition: Ostream.H:381
Foam::argList::get
T get(const label index) const
Definition: argListI.H:271
OFstream.H
Foam::argList::addArgument
static void addArgument(const string &argName, const string &usage="")
Definition: argList.C:294
format
word format(conversionProperties.get< word >("format"))
Foam::Info
messageStream Info
argList.H
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Definition: hashSets.C:40
Foam::fileFormats::STARCDMeshReader
Read PROSTAR vrt/cel/bnd files. The protected data in meshReader are filled.
Definition: STARCDMeshReader.H:64
Foam::IOstreamOption::streamFormat
streamFormat
Definition: IOstreamOption.H:66
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam
Definition: atmBoundaryLayer.C:26
Foam::argList::addBoolOption
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Definition: argList.C:317
Foam::IOstream::defaultPrecision
static unsigned int defaultPrecision() noexcept
Definition: IOstream.H:338
Time.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:49
Foam::IOstreamOption::BINARY
@ BINARY
"binary"
Definition: IOstreamOption.H:69
Foam::IOstreamOption::ASCII
@ ASCII
"ascii" (normal default)
Definition: IOstreamOption.H:68
Foam::argList::noParallel
static void noParallel()
Definition: argList.C:503
Foam::argList::addOption
static void addOption(const word &optName, const string &param="", const string &usage="", bool advanced=false)
Definition: argList.C:328
args
Foam::argList args(argc, argv)
Foam::argList::rootPath
const fileName & rootPath() const noexcept
Definition: argListI.H:56
Foam::argList::found
bool found(const word &optName) const
Definition: argListI.H:171