STARCDCore.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) 2011 OpenFOAM Foundation
9  Copyright (C) 2016-2017 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 Class
28  Foam::fileFormats::STARCDCore
29 
30 Description
31  Core routines used when reading/writing PROSTAR vrt/cel/bnd files.
32 
33 SourceFiles
34  STARCDCore.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef STARCDCore_H
39 #define STARCDCore_H
40 
41 #include "IFstream.H"
42 #include "Enum.H"
43 #include "Map.H"
44 #include "point.H"
45 #include "FixedList.H"
46 #include "List.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 namespace fileFormats
54 {
55 
56 /*---------------------------------------------------------------------------*\
57  Class fileFormats::STARCDCore Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class STARCDCore
61 {
62 public:
63 
64  // Public Data, Declarations
65 
66  //- Enumeration defining the file headers
67  enum fileHeader
68  {
72  };
73 
74  //- Enumeration defining the file extensions
75  enum fileExt
76  {
80  INP_FILE
81  };
82 
83  //- Basic material type for STARCD/PROSTAR files
84  enum matlType
85  {
91  starcdPointType = 6
92  };
93 
94  //- Shape-Type for STARCD/PROSTAR files
95  enum shapeType
96  {
100  starcdHex = 11,
102  starcdTet = 13,
103  starcdPyr = 14,
104  starcdPoly = 255
105  };
106 
107 
108  //- The name for default (unassigned) boundaries
109  static const char* const defaultBoundaryName;
110 
111  //- The name we have chosen for default (unassigned) solid boundaries.
112  // Slightly distinguished from the regular default name.
113  static const char* const defaultSolidBoundaryName;
114 
115 
116 private:
117 
118  // Private Data
119 
120  static const Enum<fileHeader> fileHeaders_;
121  static const Enum<fileExt> fileExtensions_;
122 
123 
124 protected:
125 
126  // Protected Member Functions
127 
128  //- Face addressing from PROSTAR faces to OpenFOAM faces.
129  // For hex, prism, tet, pyr primitive shapes.
131 
132  //- Face addressing from OpenFOAM faces to PROSTAR faces.
133  // For hex, prism, tet, pyr primitive shapes.
135 
136 
137  // Constructors
138 
139  //- Construct null
140  STARCDCore() = default;
141 
142  //- Read header and check signature PROSTAR_(CELL|VERTEX|BOUNDARY)
143  static bool readHeader(IFstream& is, const enum fileHeader header);
144 
145  //- Write header for fileType (CELL|VERTEX|BOUNDARY)
146  static void writeHeader(Ostream& os, const enum fileHeader header);
147 
148 
149 public:
150 
151  // Public Member Functions
152 
153  //- Resolve base file-name for the given file-type
154  static fileName starFileName
155  (
156  const fileName& baseName,
157  const enum fileExt ext
158  );
159 
160 
161  //- Remove existing PROSTAR files for the given base file-name
162  static void removeFiles(const fileName& baseName);
163 
164 
165  //- Read points from a (.vrt) file, return the max prostar id used.
166  //
167  // The file format is as follows:
168  // \verbatim
169  // Line 1:
170  // PROSTAR_VERTEX newline
171  //
172  // Line 2:
173  // {version} 0 0 0 0 0 0 0 newline
174  //
175  // Body:
176  // {vertexId} {x} {y} {z} newline
177  // \endverbatim
178  static label readPoints
179  (
180  IFstream& is,
182  List<label>& ids
183  );
184 
185  //- Write header and points to (.vrt) file, optionally with scaling
186  static void writePoints
187  (
188  Ostream& os,
189  const UList<point>& points,
190  const scalar scaleFactor = 1.0
191  );
192 
193 };
194 
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 } // End namespace fileFormats
199 } // End namespace Foam
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 
203 #endif
204 
205 // ************************************************************************* //
Foam::fileFormats::STARCDCore::starcdPyr
Definition: STARCDCore.H:102
Foam::Enum< fileHeader >
List.H
Foam::fileFormats::STARCDCore::INP_FILE
Definition: STARCDCore.H:79
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::fileFormats::STARCDCore::starFileName
static fileName starFileName(const fileName &baseName, const enum fileExt ext)
Resolve base file-name for the given file-type.
Definition: STARCDCore.C:177
Foam::IFstream
Input from file stream, using an ISstream.
Definition: IFstream.H:53
Foam::fileFormats::STARCDCore::HEADER_VRT
Definition: STARCDCore.H:69
point.H
Foam::fileFormats::STARCDCore::STARCDCore
STARCDCore()=default
Construct null.
Foam::Map
A HashTable to objects of type <T> with a label key.
Definition: lumpedPointController.H:69
Foam::fileFormats::STARCDCore::defaultSolidBoundaryName
static const char *const defaultSolidBoundaryName
The name we have chosen for default (unassigned) solid boundaries.
Definition: STARCDCore.H:112
Foam::fileFormats::STARCDCore::starcdShellType
Definition: STARCDCore.H:88
Foam::fileFormats::STARCDCore::foamToStarFaceAddr
static const Map< FixedList< int, 6 > > foamToStarFaceAddr
Face addressing from OpenFOAM faces to PROSTAR faces.
Definition: STARCDCore.H:133
Foam::fileFormats::STARCDCore::fileHeader
fileHeader
Enumeration defining the file headers.
Definition: STARCDCore.H:66
Foam::fileFormats::STARCDCore::VRT_FILE
Definition: STARCDCore.H:77
Foam::fileFormats::STARCDCore::readHeader
static bool readHeader(IFstream &is, const enum fileHeader header)
Read header and check signature PROSTAR_(CELL|VERTEX|BOUNDARY)
Definition: STARCDCore.C:122
Foam::fileFormats::STARCDCore::readPoints
static label readPoints(IFstream &is, List< point > &points, List< label > &ids)
Read points from a (.vrt) file, return the max prostar id used.
Definition: STARCDCore.C:196
Foam::fileFormats::STARCDCore::starcdSolidType
Definition: STARCDCore.H:86
Map.H
Foam::fileFormats::STARCDCore::fileExt
fileExt
Enumeration defining the file extensions.
Definition: STARCDCore.H:74
Foam::fileFormats::STARCDCore::defaultBoundaryName
static const char *const defaultBoundaryName
The name for default (unassigned) boundaries.
Definition: STARCDCore.H:108
Foam::fileFormats::STARCDCore
Core routines used when reading/writing PROSTAR vrt/cel/bnd files.
Definition: STARCDCore.H:59
Foam::fileFormats::STARCDCore::starcdPoly
Definition: STARCDCore.H:103
IFstream.H
Foam::fileFormats::STARCDCore::starcdPrism
Definition: STARCDCore.H:100
Foam::fileFormats::STARCDCore::starcdBaffleType
Definition: STARCDCore.H:87
Foam::fileFormats::STARCDCore::CEL_FILE
Definition: STARCDCore.H:76
os
OBJstream os(runTime.globalPath()/outputName)
Foam::fileFormats::STARCDCore::starcdFluidType
Definition: STARCDCore.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fileFormats::STARCDCore::starcdShell
Definition: STARCDCore.H:98
Foam::fileFormats::STARCDCore::writeHeader
static void writeHeader(Ostream &os, const enum fileHeader header)
Write header for fileType (CELL|VERTEX|BOUNDARY)
Definition: STARCDCore.C:156
Foam::fileFormats::STARCDCore::BND_FILE
Definition: STARCDCore.H:78
Foam::fileFormats::STARCDCore::starcdPoint
Definition: STARCDCore.H:96
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:63
Foam::fileFormats::STARCDCore::HEADER_CEL
Definition: STARCDCore.H:68
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:103
Foam::fileFormats::STARCDCore::starcdPointType
Definition: STARCDCore.H:90
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::fileFormats::STARCDCore::starcdTet
Definition: STARCDCore.H:101
Foam::fileFormats::STARCDCore::starToFoamFaceAddr
static const Map< FixedList< int, 6 > > starToFoamFaceAddr
Face addressing from PROSTAR faces to OpenFOAM faces.
Definition: STARCDCore.H:129
Foam::fileFormats::STARCDCore::starcdLineType
Definition: STARCDCore.H:89
Foam::fileFormats::STARCDCore::shapeType
shapeType
Shape-Type for STARCD/PROSTAR files.
Definition: STARCDCore.H:94
Foam::fileFormats::STARCDCore::removeFiles
static void removeFiles(const fileName &baseName)
Remove existing PROSTAR files for the given base file-name.
Definition: STARCDCore.C:186
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
FixedList.H
Foam::fileFormats::STARCDCore::starcdLine
Definition: STARCDCore.H:97
Foam::fileFormats::STARCDCore::writePoints
static void writePoints(Ostream &os, const UList< point > &points, const scalar scaleFactor=1.0)
Write header and points to (.vrt) file, optionally with scaling.
Definition: STARCDCore.C:245
Foam::fileFormats::STARCDCore::starcdHex
Definition: STARCDCore.H:99
Enum.H
Foam::fileFormats::STARCDCore::matlType
matlType
Basic material type for STARCD/PROSTAR files.
Definition: STARCDCore.H:83
Foam::fileFormats::STARCDCore::HEADER_BND
Definition: STARCDCore.H:70