foamToFireMesh.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) 2016 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Application
27  foamToFireMesh
28 
29 Description
30  Write an OpenFOAM mesh in AVL/FIRE fpma format
31 
32 Usage
33  \b foamToFireMesh [OPTION]
34 
35  Options:
36  - \par -ascii
37  Write in ASCII format instead of binary
38 
39  - \par -scale <factor>
40  Specify an alternative geometry scaling factor.
41  The default is \b 1 (ie, no scaling).
42 
43 See also
44  Foam::cellTable, Foam::meshWriter and Foam::fileFormats::FIREMeshWriter
45 
46 \*---------------------------------------------------------------------------*/
47 
48 #include "argList.H"
49 #include "timeSelector.H"
50 #include "Time.H"
51 #include "polyMesh.H"
52 #include "FIREMeshWriter.H"
53 
54 using namespace Foam;
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 // Main program:
58 
59 int main(int argc, char *argv[])
60 {
62  (
63  "Write an OpenFOAM mesh in AVL/FIRE fpma format"
64  );
67 
69  (
70  "ascii",
71  "Write in ASCII format instead of binary"
72  );
74  (
75  "scale",
76  "factor",
77  "Geometry scaling factor - default is 1 (none)"
78  );
79 
80  #include "setRootCase.H"
81  #include "createTime.H"
82 
84 
86  if (args.found("case"))
87  {
88  exportName += '-' + args.globalCaseName();
89  }
90 
91 
92  // write control options
93  // ~~~~~~~~~~~~~~~~~~~~~
95 
96  // Default: no rescaling
97  scalar scaleFactor = 1;
98  if (args.readIfPresent("scale", scaleFactor))
99  {
100  if (scaleFactor <= 0)
101  {
102  scaleFactor = 1;
103  }
104  }
105 
106  #include "createPolyMesh.H"
107 
108  forAll(timeDirs, timeI)
109  {
110  runTime.setTime(timeDirs[timeI], timeI);
111 
112  #include "getTimeIndex.H"
113 
115 
116  if (!timeI || state != polyMesh::UNCHANGED)
117  {
119 
120  fileName meshName(exportName);
121  if (state != polyMesh::UNCHANGED)
122  {
123  meshName += '_' + runTime.timeName();
124  }
125 
126  writer.write(meshName);
127  }
128 
129  Info<< nl << endl;
130  }
131 
132  Info<< "End\n" << endl;
133 
134  return 0;
135 }
136 
137 
138 // ************************************************************************* //
static string defaultMeshName
Specify a default mesh name.
Definition: meshWriter.H:129
static void addNote(const string &note)
Add extra notes for the usage information.
Definition: argList.C:462
Required Variables.
A class for handling file names.
Definition: fileName.H:72
vtk::lineWriter writer(edgeCentres, edgeList::null(), fileName(aMesh.time().globalPath()/"finiteArea-edgesCentres"))
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
const fileName & globalCaseName() const noexcept
Return global case name.
Definition: argListI.H:68
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
Definition: argList.C:374
static void noParallel()
Remove the parallel options.
Definition: argList.C:584
void write(const word &fieldName, const UList< Type > &field)
Write primitive field of CellData (Poly or Line) or PointData values.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
dynamicFvMesh & mesh
virtual readUpdateState readUpdate()
Update the mesh based on the mesh files saved in time.
Definition: fvMesh.C:704
Writes polyMesh in AVL/FIRE polyhedra format (fpma, fpmb)
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:385
virtual void setTime(const Time &t)
Reset the time and time-index to those of the given time.
Definition: Time.C:935
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
Definition: Time.C:714
static instantList select0(Time &runTime, const argList &args)
Return the set of times selected based on the argList options and also set the runTime to the first i...
Definition: timeSelector.C:234
messageStream Info
Information stream (stdout output on master, null elsewhere)
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
Definition: argListI.H:316
readUpdateState
Enumeration defining the state of the mesh after a read update.
Definition: polyMesh.H:90
static bool binary
Write binary (default ascii)
Foam::argList args(argc, argv)
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:171
static void addOptions(const bool constant=true, const bool withZero=false)
Add timeSelector options to argList::validOptions.
Definition: timeSelector.C:101
Namespace for OpenFOAM.