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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::fileFormats::STARCDCore
29
30Description
31 Core routines used when reading/writing PROSTAR vrt/cel/bnd files.
32
33SourceFiles
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
50namespace Foam
51{
52
53namespace fileFormats
54{
55
56/*---------------------------------------------------------------------------*\
57 Class fileFormats::STARCDCore Declaration
58\*---------------------------------------------------------------------------*/
60class STARCDCore
61{
62public:
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 {
81 };
82
83 //- Basic material type for STARCD/PROSTAR files
84 enum matlType
85 {
92 };
93
94 //- Shape-Type for STARCD/PROSTAR files
95 enum shapeType
96 {
103 starcdPyr = 14,
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
116private:
117
118 // Private Data
119
120 static const Enum<fileHeader> fileHeaders_;
121 static const Enum<fileExt> fileExtensions_;
122
123
124protected:
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
149public:
150
151 // Public Member Functions
152
153 //- Resolve base file-name for the given file-type
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// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: Enum.H:61
Input from file stream, using an ISstream.
Definition: IFstream.H:57
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
A HashTable to objects of type <T> with a label key.
Definition: Map.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
Core routines used when reading/writing PROSTAR vrt/cel/bnd files.
Definition: STARCDCore.H:60
static const Map< FixedList< int, 6 > > starToFoamFaceAddr
Face addressing from PROSTAR faces to OpenFOAM faces.
Definition: STARCDCore.H:129
shapeType
Shape-Type for STARCD/PROSTAR files.
Definition: STARCDCore.H:95
static void writeHeader(Ostream &os, const enum fileHeader header)
Write header for fileType (CELL|VERTEX|BOUNDARY)
Definition: STARCDCore.C:156
static const Map< FixedList< int, 6 > > foamToStarFaceAddr
Face addressing from OpenFOAM faces to PROSTAR faces.
Definition: STARCDCore.H:133
static fileName starFileName(const fileName &baseName, const enum fileExt ext)
Resolve base file-name for the given file-type.
Definition: STARCDCore.C:177
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
matlType
Basic material type for STARCD/PROSTAR files.
Definition: STARCDCore.H:84
static bool readHeader(IFstream &is, const enum fileHeader header)
Read header and check signature PROSTAR_(CELL|VERTEX|BOUNDARY)
Definition: STARCDCore.C:122
static const char *const defaultBoundaryName
The name for default (unassigned) boundaries.
Definition: STARCDCore.H:108
fileHeader
Enumeration defining the file headers.
Definition: STARCDCore.H:67
static void removeFiles(const fileName &baseName)
Remove existing PROSTAR files for the given base file-name.
Definition: STARCDCore.C:186
fileExt
Enumeration defining the file extensions.
Definition: STARCDCore.H:75
static const char *const defaultSolidBoundaryName
The name we have chosen for default (unassigned) solid boundaries.
Definition: STARCDCore.H:112
STARCDCore()=default
Construct null.
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
A class for handling file names.
Definition: fileName.H:76
OBJstream os(runTime.globalPath()/outputName)
const pointField & points
Namespace for OpenFOAM.