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-------------------------------------------------------------------------------
11License
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
27Application
28 star4ToFoam
29
30Group
31 grpMeshConversionUtilities
32
33Description
34 Convert a STARCD/PROSTAR (v4) mesh into OpenFOAM format.
35
36Usage
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
51Note
52 Baffles are written as interfaces for later use
53
54See 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
64using namespace Foam;
65
66// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
67
68int main(int argc, char *argv[])
69{
70 argList::addNote
71 (
72 "Convert STARCD/PROSTAR (v4) mesh to OpenFOAM"
73 );
74
75 argList::noParallel();
76 argList::addArgument("prefix", "The prefix for the input PROSTAR files");
77 argList::addBoolOption
78 (
79 "ascii",
80 "Write in ASCII instead of binary format"
81 );
82 argList::addOption
83 (
84 "scale",
85 "factor",
86 "Geometry scaling factor - default is 0.001 ([mm] to [m])"
87 );
88 argList::addBoolOption
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")
102 ? IOstreamOption::ASCII
103 : IOstreamOption::BINARY
104 );
105
106 // Increase the precision of the points data
107 IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
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// ************************************************************************* //
Y[inertIndex] max(0.0)
streamFormat
Data format (ascii | binary)
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
Extract command arguments and options from the supplied argc and argv parameters.
Definition: argList.H:124
T get(const label index) const
Get a value from the argument at index.
Definition: argListI.H:278
const fileName & rootPath() const noexcept
Return root path.
Definition: argListI.H:63
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:178
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
Definition: argListI.H:307
const fileName & caseName() const noexcept
Return case name (parallel run) or global case (serial run)
Definition: argListI.H:69
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
Read PROSTAR vrt/cel/bnd files. The protected data in meshReader are filled.
A class for handling file names.
Definition: fileName.H:76
dynamicFvMesh & mesh
engineTime & runTime
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
word format(conversionProperties.get< word >("format"))
Foam::argList args(argc, argv)