Loading...
Searching...
No Matches
ensightSurfaceReader.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) 2015-2024 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::ensightSurfaceReader
28
29Description
30 Ensight format surface reader
31
32 \verbatim
33 readOptions
34 {
35 ensight
36 {
37 debug false;
38 masterOnly false;
39 }
40 }
41 \endverbatim
42
43 Format options for ensight:
44 \table
45 Property | Description | Required | Default
46 debug | Add debug flag | no | false
47 masterOnly | Read files on master and broadcast values | no | true
48 \endtable
49
50SourceFiles
51 ensightSurfaceReader.C
52 ensightSurfaceReader.txx
53
54\*---------------------------------------------------------------------------*/
55
56#ifndef Foam_ensightSurfaceReader_H
57#define Foam_ensightSurfaceReader_H
58
59#include "surfaceReader.H"
60#include "ensightCase.H"
61#include "ensightFaces.H"
62#include "ensightReadFile.H"
63#include "Pair.H"
64#include "Tuple2.H"
65
66// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
67
68namespace Foam
69{
70
71/*---------------------------------------------------------------------------*\
72 Class ensightSurfaceReader Declaration
73\*---------------------------------------------------------------------------*/
74
76:
77 public surfaceReader
78{
79protected:
80
81 // Data Types
82
83 //- Handling of node/element id types (off, assign, ignore, given)
84 enum idTypes : unsigned char
85 {
86 NONE = 0,
87 IGNORE = 1,
88 GIVEN = 2
89 };
90
91
92 //- Tuple of face type (tria3, quad4, nsided) and count
94
95
96 // Protected Data
97
98 //- Read on master and broadcast (in parallel)
101 //- Format flag
103
104 //- Base directory
106
107 //- The timeset/fileset (if any) associated with the mesh
109
110 //- Name of mesh file, including any subdirectory
112
113 //- The timeset/fileset (if any) associated with fields
116 //- Field names
118
119 //- Field file names
121
122 //- Start time index
123 label timeStartIndex_;
124
125 //- Time increment
126 label timeIncrement_;
127
128 //- Numbers for files
131 //- Times
133
134 //- Pointer to the surface
136
137 //- List of face-type/count tuples
139
141 // Static Member Functions
142
143 //- Helper function to read an ascii line from file,
144 //- skipping blank lines and comments.
145 // \return True if reading was successful
146 static bool readLine(ISstream& is, std::string& line);
147
148 //- Check a section header
149 static void checkSection
151 const word& expected,
152 const string& buffer,
153 const ISstream& is // For errors
154 );
156 //- Read and check a section header
157 static void debugSection(const word& expected, ISstream& is);
158
159 //- Helper function to return Type from string
160 template<class Type>
161 static void readFrom(const std::string& buffer, Type& value);
162
163
164 // Protected Member Functions
166 //- Read (and discard) geometry file header.
167 // \return information about node/element id handling
169
170 //- Read the case file
171 void readCase(ISstream& is);
172
173 //- Read and return surface geometry. Updates faceTypeInfo_
176 const fileName& geometryFile,
178 const label timeIndex = 0
179 );
181 //- Helper function to return a field
182 template<class Type>
184 (
185 const fileName& dataFile,
186 const word& fieldName,
187 const label timeIndex = 0
188 ) const;
189
190 //- Helper function to return a field
191 template<class Type>
193 (
194 const label timeIndex,
195 const label fieldIndex
196 ) const;
197
198
199public:
200
201 // Generated Methods
202
203 //- No copy construct
205
206 //- No copy assignment
207 void operator=(const ensightSurfaceReader&) = delete;
208
209
210 //- Runtime type information
211 TypeName("ensight");
213
214 // Constructors
215
216 //- Construct from fileName, with reader options
217 explicit ensightSurfaceReader
218 (
219 const fileName& fName,
220 const dictionary& options = dictionary()
221 );
222
223
224 //- Destructor
225 virtual ~ensightSurfaceReader() = default;
226
227
228 // Member Functions
229
230 //- Return a reference to the surface geometry
231 virtual const meshedSurface& geometry(const label timeIndex);
232
233 //- Return a list of the available times
234 virtual instantList times() const;
235
236 //- Return a list of the available fields at a given time
237 virtual wordList fieldNames(const label timeIndex) const;
238
239 //- Return a scalar field at a given time
240 virtual tmp<Field<scalar>> field
241 (
242 const label timeIndex,
243 const label fieldIndex,
244 const scalar& refValue = pTraits<scalar>::zero
245 ) const;
246
247 //- Return a vector field at a given time
248 virtual tmp<Field<vector>> field
249 (
250 const label timeIndex,
251 const label fieldIndex,
252 const vector& refValue = pTraits<vector>::zero
253 ) const;
255 //- Return a sphericalTensor field at a given time
257 (
258 const label timeIndex,
259 const label fieldIndex,
261 ) const;
262
263 //- Return a symmTensor field at a given time
265 (
266 const label timeIndex,
267 const label fieldIndex,
269 ) const;
270
271 //- Return a tensor field at a given time
272 virtual tmp<Field<tensor>> field
274 const label timeIndex,
275 const label fieldIndex,
276 const tensor& refValue = pTraits<tensor>::zero
277 ) const;
278};
280
281// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
282
283} // End namespace Foam
284
285// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
286
287#ifdef NoRepository
288 #include "ensightSurfaceReader.txx"
289#endif
290
291// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
292
293
294#endif
295
296// ************************************************************************* //
streamFormat
Data format (ascii | binary | coherent).
Generic input stream using a standard (STL) stream.
Definition ISstream.H:54
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
An ordered pair of two objects of type <T> with first() and second() elements.
Definition Pair.H:66
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition Tuple2.H:51
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A variant of IFstream with specialised handling for Ensight reading of strings, integers and floats (...
Ensight format surface reader.
static bool readLine(ISstream &is, std::string &line)
Helper function to read an ascii line from file, skipping blank lines and comments.
virtual instantList times() const
Return a list of the available times.
static void checkSection(const word &expected, const string &buffer, const ISstream &is)
Check a section header.
Pair< idTypes > readGeometryHeader(ensightReadFile &is) const
Read (and discard) geometry file header.
label timeIncrement_
Time increment.
labelList fileNumbers_
Numbers for files.
Tuple2< ensightFaces::elemType, label > faceInfoTuple
Tuple of face type (tria3, quad4, nsided) and count.
bool masterOnly_
Read on master and broadcast (in parallel).
labelPair meshTimeset_
The timeset/fileset (if any) associated with the mesh.
idTypes
Handling of node/element id types (off, assign, ignore, given).
@ GIVEN
Use "given" values (not supported).
void readCase(ISstream &is)
Read the case file.
static void debugSection(const word &expected, ISstream &is)
Read and check a section header.
fileName baseDir_
Base directory.
List< word > fieldNames_
Field names.
autoPtr< meshedSurface > surfPtr_
Pointer to the surface.
TypeName("ensight")
Runtime type information.
List< labelPair > fieldTimesets_
The timeset/fileset (if any) associated with fields.
meshedSurface readGeometry(const fileName &geometryFile, const label timeIndex=0)
Read and return surface geometry. Updates faceTypeInfo_.
tmp< Field< Type > > readField(const label timeIndex, const label fieldIndex) const
Helper function to return a field.
virtual const meshedSurface & geometry(const label timeIndex)
Return a reference to the surface geometry.
label timeStartIndex_
Start time index.
IOstreamOption::streamFormat readFormat_
Format flag.
List< faceInfoTuple > faceTypeInfo_
List of face-type/count tuples.
virtual ~ensightSurfaceReader()=default
Destructor.
List< string > fieldFileNames_
Field file names.
void operator=(const ensightSurfaceReader &)=delete
No copy assignment.
ensightSurfaceReader(const ensightSurfaceReader &)=delete
No copy construct.
fileName meshFileName_
Name of mesh file, including any subdirectory.
virtual wordList fieldNames(const label timeIndex) const
Return a list of the available fields at a given time.
static void readFrom(const std::string &buffer, Type &value)
Helper function to return Type from string.
tmp< Field< Type > > readField(const fileName &dataFile, const word &fieldName, const label timeIndex=0) const
Helper function to return a field.
A class for handling file names.
Definition fileName.H:75
A line primitive.
Definition line.H:180
A traits class, which is primarily used for primitives and vector-space.
Definition pTraits.H:64
Abstract base class for surface readers with fields.
surfaceReader(const fileName &fName)
Construct from fileName.
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
rDeltaTY field()
Namespace for OpenFOAM.
Pair< label > labelPair
A pair of labels.
Definition Pair.H:54
List< word > wordList
List of word.
Definition fileName.H:60
List< label > labelList
A List of labels.
Definition List.H:62
List< instant > instantList
List of instants.
Definition instantList.H:41
Tensor< scalar > tensor
Definition symmTensor.H:57
MeshedSurface< face > meshedSurface
Vector< scalar > vector
Definition vector.H:57
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
Definition symmTensor.H:55
label timeIndex
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68