FIRECore.H
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 Class
27  Foam::fileFormats::FIRECore
28 
29 Description
30  Core routines used when reading/writing AVL/FIRE files.
31 
32 SourceFiles
33  FIRECore.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef FIRECore_H
38 #define FIRECore_H
39 
40 #include "point.H"
41 #include "labelList.H"
42 #include "pointField.H"
43 #include "IOstreams.H"
44 #include "Enum.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 // forward declarations
51 class polyMesh;
52 
53 namespace fileFormats
54 {
55 
56 /*---------------------------------------------------------------------------*\
57  Class fileFormats::FIRECore Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class FIRECore
61 {
62 public:
63 
64  // Public Data, Declarations
65 
66  //- Selection Types
68  {
69  cellSelection = 2,
70  faceSelection = 3
71  };
72 
73  //- Shape-Type for FIRE (FLMA) files
74  enum shapeType
75  {
76  fireLine = 1,
77  fireTri = 2,
78  fireQuad = 3,
79  fireTet = 4,
80  fireHex = 5,
81  firePyr = 6,
82  firePrism = 8
83  };
84 
85  //- Enumeration defining the file extensions for 3D types
86  enum fileExt3d
87  {
88  POLY_ASCII,
92  };
93 
94 
95  //- Integer type (binary format)
96  typedef int32_t fireInt_t;
97 
98  //- Float type (binary format)
99  typedef double fireReal_t;
100 
101 
102 protected:
103 
104  // Protected Data
105 
106  static const Enum<fileExt3d> file3dExtensions;
107 
108 
109  // Protected Member Functions
110 
111  //- Construct null
112  FIRECore() = default;
113 
114 
115  //- Read points.
116  // This is the first thing to do when reading FPMA,FPMB,FLMA files.
117  // Return the number of points read.
118  //
119  // The file format is as follows:
120  // \verbatim
121  // NUMBER_OF_VERTICES
122  // x0 y0 z0 x1 y1 z1 ... xN-1 yN-1 zN-1
123  // \endverbatim
124  static label readPoints(ISstream&, pointField&);
125 
126 public:
127 
128  // Public Member Functions
129 
130  //- Resolve base file-name for the given file-type
131  static fileName fireFileName
132  (
133  const fileName& baseName,
134  const enum fileExt3d
135  );
136 
137 
138  //- Get an integer (ascii or binary)
139  static label getFireLabel(ISstream&);
140 
141  //- Get an point x/y/z (ascii or binary)
142  static point getFirePoint(ISstream&);
143 
144  //- Extract a string (ascii or binary)
145  static std::string getFireString(ISstream&);
146 
147 
148  //- Write an integer (ascii or binary)
149  static void putFireLabel(OSstream&, const label);
150 
151  //- Write multiple integers (ascii or binary)
152  static void putFireLabels(OSstream&, const labelUList&);
153 
154  //- Write an on-the-fly list of integers (ascii or binary)
155  static void putFireLabels
156  (
157  OSstream&,
158  const label count,
159  const label start
160  );
161 
162 
163  //- Write a point x/y/z (ascii or binary)
164  static void putFirePoint(OSstream&, const point&);
165 
166  //- Write a string (ascii or binary)
167  static void putFireString(OSstream&, const std::string&);
168 
169 };
170 
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 } // End namespace fileFormats
175 } // End namespace Foam
176 
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 
179 #endif
180 
181 // ************************************************************************* //
static point getFirePoint(ISstream &)
Get an point x/y/z (ascii or binary)
Definition: FIRECore.C:103
fileExt3d
Enumeration defining the file extensions for 3D types.
Definition: FIRECore.H:87
Generic output stream using a standard (STL) stream.
Definition: OSstream.H:50
A class for handling file names.
Definition: fileName.H:72
double fireReal_t
Float type (binary format)
Definition: FIRECore.H:104
static std::string getFireString(ISstream &)
Extract a string (ascii or binary)
Definition: FIRECore.C:133
static label getFireLabel(ISstream &)
Get an integer (ascii or binary)
Definition: FIRECore.C:81
shapeType
Shape-Type for FIRE (FLMA) files.
Definition: FIRECore.H:73
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
selectionType
Selection Types.
Definition: FIRECore.H:64
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of &#39;true&#39; entries.
Definition: BitOps.H:73
static label readPoints(ISstream &, pointField &)
Read points.
Definition: FIRECore.C:41
FIRECore()=default
Construct null.
Face selection method for createBaffles.
Definition: faceSelection.H:54
static void putFireString(OSstream &, const std::string &)
Write a string (ascii or binary)
Definition: FIRECore.C:339
int32_t fireInt_t
Integer type (binary format)
Definition: FIRECore.H:99
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
static void putFirePoint(OSstream &, const point &)
Write a point x/y/z (ascii or binary)
Definition: FIRECore.C:308
Generic input stream using a standard (STL) stream.
Definition: ISstream.H:51
static const Enum< fileExt3d > file3dExtensions
Definition: FIRECore.H:111
static void putFireLabels(OSstream &, const labelUList &)
Write multiple integers (ascii or binary)
Definition: FIRECore.C:224
Core routines used when reading/writing AVL/FIRE files.
Definition: FIRECore.H:55
static void putFireLabel(OSstream &, const label)
Write an integer (ascii or binary)
Definition: FIRECore.C:199
static fileName fireFileName(const fileName &baseName, const enum fileExt3d)
Resolve base file-name for the given file-type.
Definition: FIRECore.C:72
Namespace for OpenFOAM.