fireToFoam.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-2021 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  fireToFoam
28 
29 Group
30  grpMeshConversionUtilities
31 
32 Description
33  Convert AVL/FIRE polyhedral mesh to OpenFOAM format
34 
35 Usage
36  \b fireToFoam [OPTION] firePolyMesh
37 
38  Options:
39 
40  - \par -ascii
41  Write in ASCII format instead of binary
42 
43  - \par -check
44  Perform edge checking
45 
46  - \par -scale <factor>
47  Specify an alternative geometry scaling factor.
48  The default is \b 1 (no scaling).
49 
50 \*---------------------------------------------------------------------------*/
51 
52 #include "argList.H"
53 #include "Time.H"
54 #include "FIREMeshReader.H"
55 #include "checkFireEdges.H"
56 
57 using namespace Foam;
58 
59 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60 
61 int main(int argc, char *argv[])
62 {
64  (
65  "Convert AVL/FIRE polyhedral mesh to OpenFOAM format"
66  );
67 
69  argList::addArgument("firePolyMesh", "The input FIRE mesh");
71  (
72  "ascii",
73  "Write in ASCII format instead of binary"
74  );
76  (
77  "check",
78  "Perform edge checking as well"
79  );
81  (
82  "scale",
83  "scale",
84  "Geometry scaling factor - default is 1 (no scaling)"
85  );
86 
87 
88  argList args(argc, argv);
90 
91 
92  // Binary output, unless otherwise specified
94  (
95  args.found("ascii")
98  );
99 
100  // increase the precision of the points data
102 
103 
105  (
106  args.get<fileName>(1),
107  // Default no scaling
108  args.getOrDefault<scalar>("scale", 1)
109  );
110 
111 
112  autoPtr<polyMesh> mesh = reader.mesh(runTime);
113  reader.writeMesh(mesh(), format);
114 
115 
116  if (args.found("check"))
117  {
118  checkFireEdges(mesh());
119  }
120 
121  Info<< "\nEnd\n" << endl;
122  return 0;
123 }
124 
125 // ************************************************************************* //
Foam::fileFormats::FIREMeshReader
Read AVL/FIRE fpma, fpmb files.
Definition: FIREMeshReader.H:61
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::argList::getOrDefault
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
Foam::argList::caseName
const fileName & caseName() const noexcept
Return case name (parallel run) or global case (serial run)
Definition: argListI.H:69
Foam::argList::addNote
static void addNote(const string &note)
Add extra notes for the usage information.
Definition: argList.C:412
Foam::argList
Extract command arguments and options from the supplied argc and argv parameters.
Definition: argList.H:123
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::argList::get
T get(const label index) const
Get a value from the argument at index.
Definition: argListI.H:278
Foam::argList::addArgument
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
Definition: argList.C:301
format
word format(conversionProperties.get< word >("format"))
FIREMeshReader.H
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
argList.H
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Foam::IOstreamOption::streamFormat
streamFormat
Data format (ascii | binary)
Definition: IOstreamOption.H:70
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::checkFireEdges
label checkFireEdges(const faceList &faces, const labelListList &pointFaces, const UList< point > &points=UList< point >::null())
check edge connectivity
Definition: checkFireEdges.C:65
Foam::argList::addBoolOption
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
Definition: argList.C:324
Foam::IOstream::defaultPrecision
static unsigned int defaultPrecision() noexcept
Return the default precision.
Definition: IOstream.H:342
Time.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::IOstreamOption::BINARY
"binary"
Definition: IOstreamOption.H:73
Foam::IOstreamOption::ASCII
"ascii" (normal default)
Definition: IOstreamOption.H:72
checkFireEdges.H
Checks the mesh for edge connectivity as expected by the AVL/FIRE on-the-fly calculations....
Foam::argList::noParallel
static void noParallel()
Remove the parallel options.
Definition: argList.C:510
Foam::argList::addOption
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:335
args
Foam::argList args(argc, argv)
Foam::argList::rootPath
const fileName & rootPath() const noexcept
Return root path.
Definition: argListI.H:63
Foam::argList::found
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:178