Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
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{
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);
96 Time runTime(args.rootPath(), args.caseName());
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// ************************************************************************* //
streamFormat
Data format (ascii | binary | coherent).
@ ASCII
"ascii" (normal default)
static unsigned int minPrecision(unsigned int prec) noexcept
Set the minimum default precision.
Definition IOstream.H:459
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
Extract command arguments and options from the supplied argc and argv parameters.
Definition argList.H:119
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
Definition argList.C:366
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
Definition argList.C:389
static void noParallel()
Remove the parallel options.
Definition argList.C:599
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:400
static void addNote(const string &note)
Add extra notes for the usage information.
Definition argList.C:477
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
Read PROSTAR vrt/cel/bnd files. The protected data in meshReader are filled.
A class for handling file names.
Definition fileName.H:75
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:519
word format(conversionProperties.get< word >("format"))
Foam::argList args(argc, argv)