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 -------------------------------------------------------------------------------
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::surfaceReader
28 
29 Description
30  Abstract base class for surface readers with fields.
31 
32  Some readers support different input options, these are typically
33  specified as 'readOptions' in the containing dictionary.
34 
35  \verbatim
36  readOptions
37  {
38  default
39  {
40  verbose false;
41  }
42 
43  ensight
44  {
45  masterOnly false;
46  }
47  }
48  \endverbatim
49 
50 SourceFiles
51  surfaceReader.C
52 
53 \*---------------------------------------------------------------------------*/
54 
55 #ifndef Foam_surfaceReader_H
56 #define Foam_surfaceReader_H
57 
58 #include "typeInfo.H"
59 #include "autoPtr.H"
60 #include "MeshedSurfaces.H"
61 #include "runTimeSelectionTables.H"
62 
63 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
64 
65 namespace Foam
66 {
67 
68 /*---------------------------------------------------------------------------*\
69  Class surfaceReader Declaration
70 \*---------------------------------------------------------------------------*/
71 
72 class surfaceReader
73 {
74 protected:
75 
76  //- File name
78 
79 
80 public:
81 
82  //- Runtime type information
83  TypeName("surfaceReader");
84 
85 
86  // Declare run-time constructor selection table
87 
89  (
90  autoPtr,
92  fileName,
93  (
94  const fileName& fName,
95  const dictionary& options
96  ),
97  (fName, options)
98  );
99 
100 
101  // Helpers
102 
103  //- Same as fileFormats::getFormatOptions
105  (
106  const dictionary& dict,
107  const word& formatName,
108  const word& entryName = "formatOptions"
109  );
110 
111 
112  // Selectors
113 
114  //- Return a reference to the selected surfaceReader
116  (
117  const word& readType,
118  const fileName& fName,
119  const dictionary& options = dictionary()
120  );
121 
122 
123  // Constructors
124 
125  //- Construct from fileName
126  explicit surfaceReader(const fileName& fName);
127 
128  //- Construct from fileName and specified options
129  surfaceReader(const fileName& fName, const dictionary& options);
130 
131 
132  //- Destructor
133  virtual ~surfaceReader() = default;
134 
135 
136  // Member Functions
137 
138  //- Return a reference to the surface geometry
139  virtual const meshedSurface& geometry(const label timeIndex) = 0;
140 
141  //- Return a list of the available times
142  virtual instantList times() const = 0;
143 
144  //- Return a list of the available fields at a given time
145  virtual wordList fieldNames(const label timeIndex) const = 0;
146 
147  //- Return a scalar field at a given time
148  virtual tmp<Field<scalar>> field
149  (
150  const label timeIndex,
151  const label fieldIndex,
152  const scalar& refValue = pTraits<scalar>::zero
153  ) const = 0;
154 
155  //- Return a vector field at a given time
156  virtual tmp<Field<vector>> field
157  (
158  const label timeIndex,
159  const label fieldIndex,
160  const vector& refValue = pTraits<vector>::zero
161  ) const = 0;
162 
163  //- Return a sphericalTensor field at a given time
165  (
166  const label timeIndex,
167  const label fieldIndex,
169  ) const = 0;
170 
171  //- Return a symmTensor field at a given time
173  (
174  const label timeIndex,
175  const label fieldIndex,
176  const symmTensor& refValue = pTraits<symmTensor>::zero
177  ) const = 0;
178 
179  //- Return a tensor field at a given time
180  virtual tmp<Field<tensor>> field
181  (
182  const label timeIndex,
183  const label fieldIndex,
184  const tensor& refValue = pTraits<tensor>::zero
185  ) const = 0;
186 };
187 
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 } // End namespace Foam
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 
196 #endif
197 
198 // ************************************************************************* //
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:129
surfaceReader(const fileName &fName)
Construct from fileName.
Definition: surfaceReader.C:49
A traits class, which is primarily used for primitives and vector-space.
Definition: pTraits.H:75
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...
static dictionary formatOptions(const dictionary &dict, const word &formatName, const word &entryName="formatOptions")
Same as fileFormats::getFormatOptions.
Definition: surfaceReader.C:36
static autoPtr< surfaceReader > New(const word &readType, const fileName &fName, const dictionary &options=dictionary())
Return a reference to the selected surfaceReader.
Definition: surfaceReader.C:71
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:74
Macros to ease declaration of run-time selection tables.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Tensor of scalars, i.e. Tensor<scalar>.
Abstract base class for surface readers with fields.
Definition: surfaceReader.H:67
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