foamToStarMesh.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-2017 OpenFOAM Foundation
9 Copyright (C) 2016-2020 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 foamToStarMesh
29
30Group
31 grpMeshConversionUtilities
32
33Description
34 Write an OpenFOAM mesh in STARCD/PROSTAR (v4) bnd/cel/vrt format.
35
36Usage
37 \b foamToStarMesh [OPTION]
38
39 Options:
40 - \par -noBnd
41 Suppress writing the \c .bnd file
42
43 - \par -scale <factor>
44 Specify an alternative geometry scaling factor.
45 The default is \b 1000 (scale \em [m] to \em [mm]).
46
47Note
48 The cellTable information available in the files
49 \c constant/cellTable and \c constant/polyMesh/cellTableId
50 will be used if available. Otherwise the cellZones are used when
51 creating the cellTable information.
52
53See also
54 Foam::cellTable, Foam::meshWriter and Foam::fileFormats::STARCDMeshWriter
55
56\*---------------------------------------------------------------------------*/
57
58#include "argList.H"
59#include "timeSelector.H"
60#include "Time.H"
61#include "polyMesh.H"
62#include "STARCDMeshWriter.H"
63#include "IOdictionary.H"
64
65using namespace Foam;
66
67// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68
69int main(int argc, char *argv[])
70{
71 argList::addNote
72 (
73 "Write an OpenFOAM mesh in STARCD/PROSTAR (v4) bnd/cel/vrt format"
74 );
75 argList::noParallel();
76 timeSelector::addOptions();
77
78 argList::addOption
79 (
80 "scale",
81 "factor",
82 "Geometry scaling factor - default is 1000 ([m] to [mm])"
83 );
84 argList::addBoolOption
85 (
86 "noBnd",
87 "Suppress writing a boundary (.bnd) file"
88 );
89
90 #include "setRootCase.H"
91 #include "createTime.H"
92
93 instantList timeDirs = timeSelector::select0(runTime, args);
94
95 fileName exportName = meshWriter::defaultMeshName;
96 if (args.found("case"))
97 {
98 exportName += '-' + args.globalCaseName();
99 }
100
101 // Default rescale from [m] to [mm]
102 const scalar scaleFactor = args.getOrDefault<scalar>("scale", 1000);
103 const bool writeBndFile = !args.found("noBnd");
104
105 #include "createPolyMesh.H"
106
107 forAll(timeDirs, timeI)
108 {
109 runTime.setTime(timeDirs[timeI], timeI);
110
111 #include "getTimeIndex.H"
112
113 polyMesh::readUpdateState state = mesh.readUpdate();
114
115 if (!timeI || state != polyMesh::UNCHANGED)
116 {
118 (
119 mesh,
120 scaleFactor,
121 writeBndFile
122 );
123
124 fileName meshName(exportName);
125 if (state != polyMesh::UNCHANGED)
126 {
127 meshName += '_' + runTime.timeName();
128 }
129
130 writer.write(meshName);
131 }
132
133 Info<< nl << endl;
134 }
135
136 Info<< "End\n" << endl;
137
138 return 0;
139}
140
141
142// ************************************************************************* //
vtk::internalMeshWriter writer(topoMesh, topoCells, vtk::formatType::INLINE_ASCII, runTime.path()/"blockTopology")
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:178
const fileName & globalCaseName() const noexcept
Return global case name.
Definition: argListI.H:75
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
Writes polyMesh in PROSTAR (v4) bnd/cel/vrt format.
A class for handling file names.
Definition: fileName.H:76
readUpdateState
Enumeration defining the state of the mesh after a read update.
Definition: polyMesh.H:91
dynamicFvMesh & mesh
engineTime & runTime
Required Variables.
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
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333