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 -------------------------------------------------------------------------------
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  foamToStarMesh
29 
30 Group
31  grpMeshConversionUtilities
32 
33 Description
34  Write an OpenFOAM mesh in STARCD/PROSTAR (v4) bnd/cel/vrt format.
35 
36 Usage
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 
47 Note
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 
53 See 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 
65 using namespace Foam;
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 
69 int main(int argc, char *argv[])
70 {
72  (
73  "Write an OpenFOAM mesh in STARCD/PROSTAR (v4) bnd/cel/vrt format"
74  );
77 
79  (
80  "scale",
81  "factor",
82  "Geometry scaling factor - default is 1000 ([m] to [mm])"
83  );
85  (
86  "noBnd",
87  "Suppress writing a boundary (.bnd) file"
88  );
89 
90  #include "setRootCase.H"
91  #include "createTime.H"
92 
94 
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 
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 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
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
Foam::Time::timeName
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:773
Foam::writer::write
virtual void write(const coordSet &, const wordList &, const List< const Field< Type > * > &, Ostream &) const =0
Foam::argList::addNote
static void addNote(const string &note)
Definition: argList.C:405
Foam::argList::globalCaseName
const fileName & globalCaseName() const noexcept
Definition: argListI.H:68
Foam::fileFormats::STARCDMeshWriter
Writes polyMesh in PROSTAR (v4) bnd/cel/vrt format.
Definition: STARCDMeshWriter.H:55
Foam::endl
Ostream & endl(Ostream &os)
Definition: Ostream.H:381
polyMesh.H
forAll
#define forAll(list, i)
Definition: stdFoam.H:349
Foam::fvMesh::readUpdate
virtual readUpdateState readUpdate()
Definition: fvMesh.C:641
Foam::Info
messageStream Info
argList.H
Foam::polyMesh::UNCHANGED
@ UNCHANGED
Definition: polyMesh.H:88
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::writer
Base class for graphics format writing. Entry points are.
Definition: writer.H:77
Foam
Definition: atmBoundaryLayer.C:26
Foam::polyMesh::readUpdateState
readUpdateState
Definition: polyMesh.H:86
Foam::argList::addBoolOption
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Definition: argList.C:317
IOdictionary.H
Time.H
setRootCase.H
Foam::meshWriter::defaultMeshName
static string defaultMeshName
Definition: meshWriter.H:113
Foam::nl
constexpr char nl
Definition: Ostream.H:424
Foam::timeSelector::addOptions
static void addOptions(const bool constant=true, const bool withZero=false)
Definition: timeSelector.C:95
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:58
Foam::Time::setTime
virtual void setTime(const Time &t)
Definition: Time.C:996
timeSelector.H
createTime.H
STARCDMeshWriter.H
Foam::argList::noParallel
static void noParallel()
Definition: argList.C:503
Foam::timeSelector::select0
static instantList select0(Time &runTime, const argList &args)
Definition: timeSelector.C:228
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)
writer
vtk::internalMeshWriter writer(topoMesh, topoCells, vtk::formatType::INLINE_ASCII, runTime.path()/"blockTopology")
createPolyMesh.H
Required Variables.
Foam::argList::found
bool found(const word &optName) const
Definition: argListI.H:171