surfaceReader.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-2022 OpenCFD Ltd.
9  Copyright (C) 2026 Keysight Technologies
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::surfaceReader
29 
30 Description
31  Abstract base class for surface readers with fields.
32 
33  Some readers support different input options, these are typically
34  specified as 'formatOptions' (or 'readOptions') in the containing
35  dictionary.
36 
37  \verbatim
38  readOptions
39  {
40  default
41  {
42  verbose false;
43  }
44 
45  ensight
46  {
47  masterOnly false;
48  vertexOnly false;
49  }
50  }
51  \endverbatim
52 
53 SourceFiles
54  surfaceReader.cxx
55 
56 \*---------------------------------------------------------------------------*/
57 
58 #ifndef Foam_surfaceReader_H
59 #define Foam_surfaceReader_H
60 
61 #include "typeInfo.H"
62 #include "autoPtr.H"
63 #include "MeshedSurfaces.H"
64 #include "runTimeSelectionTables.H"
65 
66 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
67 
68 namespace Foam
69 {
70 
71 /*---------------------------------------------------------------------------*\
72  Class surfaceReader Declaration
73 \*---------------------------------------------------------------------------*/
74 
75 class surfaceReader
76 {
77 protected:
78 
79  //- File name
81 
82 
83 public:
84 
85  //- Runtime type information
86  TypeName("surfaceReader");
87 
88 
89  // Declare run-time constructor selection table
90 
92  (
93  autoPtr,
95  fileName,
96  (
97  const fileName& fName,
98  const dictionary& options
99  ),
100  (fName, options)
101  );
102 
103 
104  // Helpers
105 
106  //- Same as fileFormats::getFormatOptions
108  (
109  const dictionary& dict,
110  const word& formatName,
111  const word& entryName = "formatOptions"
112  );
113 
114 
115  // Selectors
116 
117  //- Return a reference to the selected surfaceReader
119  (
120  const word& readType,
121  const fileName& fName,
122  const dictionary& options = dictionary()
123  );
124 
125 
126  // Constructors
127 
128  //- Construct from fileName
129  explicit surfaceReader(const fileName& fName);
130 
131  //- Construct from fileName and specified options
132  surfaceReader(const fileName& fName, const dictionary& options);
133 
134 
135  //- Destructor
136  virtual ~surfaceReader() = default;
137 
138 
139  // Member Functions
140 
141  //- Return a reference to the surface geometry
142  virtual const meshedSurface& geometry(const label timeIndex) = 0;
143 
144  //- The number of 1D vertex/point elements for the last geometry read.
145  //- Non-zero when the surface reader is used/misused to read
146  //- vertex/point elements instead of faces (advanced option)
147  virtual label nVertexElements() const = 0;
148 
149  //- Return a list of the available times
150  virtual instantList times() const = 0;
151 
152  //- Return a list of the available fields at a given time
153  virtual wordList fieldNames(const label timeIndex) const = 0;
154 
155  //- Return a scalar field at a given time
156  virtual tmp<Field<scalar>> field
157  (
158  const label timeIndex,
159  const label fieldIndex,
160  const scalar& refValue = pTraits<scalar>::zero
161  ) const = 0;
162 
163  //- Return a vector field at a given time
164  virtual tmp<Field<vector>> field
165  (
166  const label timeIndex,
167  const label fieldIndex,
168  const vector& refValue = pTraits<vector>::zero
169  ) const = 0;
170 
171  //- Return a sphericalTensor field at a given time
173  (
174  const label timeIndex,
175  const label fieldIndex,
177  ) const = 0;
178 
179  //- Return a symmTensor field at a given time
181  (
182  const label timeIndex,
183  const label fieldIndex,
184  const symmTensor& refValue = pTraits<symmTensor>::zero
185  ) const = 0;
186 
187  //- Return a tensor field at a given time
188  virtual tmp<Field<tensor>> field
189  (
190  const label timeIndex,
191  const label fieldIndex,
192  const tensor& refValue = pTraits<tensor>::zero
193  ) const = 0;
194 };
195 
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 } // End namespace Foam
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 
203 
204 #endif
205 
206 // ************************************************************************* //
dictionary dict
declareRunTimeSelectionTable(autoPtr, surfaceReader, fileName,(const fileName &fName, const dictionary &options),(fName, options))
A class for handling file names.
Definition: fileName.H:72
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:130
surfaceReader(const fileName &fName)
Construct from fileName.
A traits class, which is primarily used for primitives and vector-space.
Definition: pTraits.H:63
virtual ~surfaceReader()=default
Destructor.
virtual wordList fieldNames(const label timeIndex) const =0
Return a list of the available fields at a given time.
TypeName("surfaceReader")
Runtime type information.
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual const meshedSurface & geometry(const label timeIndex)=0
Return a reference to the surface geometry.
virtual instantList times() const =0
Return a list of the available times.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
virtual label nVertexElements() const =0
The number of 1D vertex/point elements for the last geometry read. Non-zero when the surface reader i...
Basic run-time type information using word as the type&#39;s name. Used to enhance the standard RTTI to c...
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
fileName fileName_
File name.
Definition: surfaceReader.H:77
Macros to ease declaration of run-time selection tables.
static autoPtr< surfaceReader > New(const word &readType, const fileName &fName, const dictionary &options=dictionary())
Return a reference to the selected surfaceReader.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
static dictionary formatOptions(const dictionary &dict, const word &formatName, const word &entryName="formatOptions")
Same as fileFormats::getFormatOptions.
Tensor of scalars, i.e. Tensor<scalar>.
Abstract base class for surface readers with fields.
Definition: surfaceReader.H:70
virtual tmp< Field< scalar > > field(const label timeIndex, const label fieldIndex, const scalar &refValue=pTraits< scalar >::zero) const =0
Return a scalar field at a given time.
Namespace for OpenFOAM.
label timeIndex
Definition: getTimeIndex.H:24