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-2024 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  // More precision (for 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 // ************************************************************************* //
static void addNote(const string &note)
Add extra notes for the usage information.
Definition: argList.C:462
A class for handling file names.
Definition: fileName.H:72
"ascii" (normal default)
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
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
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
Definition: argListI.H:300
label checkFireEdges(const faceList &faces, const labelListList &pointFaces, const UList< point > &points=UList< point >::null())
check edge connectivity
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
dynamicFvMesh & mesh
Extract command arguments and options from the supplied argc and argv parameters. ...
Definition: argList.H:118
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
static unsigned int minPrecision(unsigned int prec) noexcept
Set the minimum default precision.
Definition: IOstream.H:440
const fileName & caseName() const noexcept
Return case name (parallel run) or global case (serial run)
Definition: argListI.H:62
Checks the mesh for edge connectivity as expected by the AVL/FIRE on-the-fly calculations. Errors flagged here are not necessarily topological errors at all.
const fileName & rootPath() const noexcept
Return root path.
Definition: argListI.H:56
word format(conversionProperties.get< word >("format"))
T get(const label index) const
Get a value from the argument at index.
Definition: argListI.H:271
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
Definition: argList.C:351
streamFormat
Data format (ascii | binary)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Read AVL/FIRE fpma, fpmb files.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Foam::argList args(argc, argv)
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:171
Namespace for OpenFOAM.