boundaryDataSurfaceReader.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) 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::boundaryDataSurfaceReader
28 
29 Description
30  A boundaryData format surface reader.
31  However, the "surface" represented by boundaryData is actually only
32  point data!
33 
34  // Points
35  <case>/constant/region0/"boundaryData"/patchName/points
36 
37  // Values
38  <case>/constant/region0/"boundaryData"/patchName/TIME/field
39 
40  \verbatim
41  readOptions
42  {
43  boundaryData
44  {
45  points points;
46  }
47  }
48  \endverbatim
49 
50  Format options for boundaryData:
51  \table
52  Property | Description | Required | Default
53  points | Name of the "points" file | no | points
54  \endtable
55 
56 SourceFiles
57  boundaryDataSurfaceReader.C
58  boundaryDataSurfaceReaderTemplates.C
59 
60 \*---------------------------------------------------------------------------*/
61 
62 #ifndef Foam_boundaryDataSurfaceReader_H
63 #define Foam_boundaryDataSurfaceReader_H
64 
65 #include "surfaceReader.H"
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 
69 namespace Foam
70 {
71 
72 // Forward Declarations
73 class Time;
74 
75 /*---------------------------------------------------------------------------*\
76  Class boundaryDataSurfaceReader Declaration
77 \*---------------------------------------------------------------------------*/
78 
79 class boundaryDataSurfaceReader
80 :
81  public surfaceReader
82 {
83  // Private Data
84 
85  //- Base directory
86  fileName baseDir_;
87 
88  //- Name of the 'points' file
89  word pointsName_;
90 
91  //- Times
92  instantList timeValues_;
93 
94  //- Field names
95  mutable List<word> fieldNames_;
96 
97  //- Pointer to the surface
98  autoPtr<meshedSurface> surfPtr_;
99 
100 
101  // Private Member Functions
102 
103  //- Populate time instances
104  void readCase();
105 
106  //- Read geometry
107  void readGeometry(meshedSurface& surf, const label timeIndex);
108 
109  //- Read and return given field
110  template<class Type>
111  tmp<Field<Type>> readFieldTemplate
112  (
113  const label timeIndex,
114  const label fieldIndex
115  ) const;
116 
117 
118 public:
119 
120  //- Runtime type information
121  TypeName("boundaryData");
122 
123 
124  // Constructors
125 
126  //- Construct from fileName
128  (
129  const fileName& fName,
130  const word& pointsName = "points"
131  );
132 
133  //- Construct from fileName with reader options
135  (
136  const fileName& fName,
137  const dictionary& options,
138  const word& pointsName = "points"
139  );
140 
141 
142  //- Destructor
143  virtual ~boundaryDataSurfaceReader() = default;
144 
145 
146  // Static Member Functions
147 
148  //- Read points file
149  static pointField readPoints
150  (
151  const Time& runTime,
152  const fileName& baseDir,
153  const word& pointsName = "points"
154  );
155 
156  //- Read points file
157  static pointField readPoints
158  (
159  const fileName& baseDir,
160  const word& pointsName = "points"
161  );
162 
163  //- Read and return given field
164  template<class Type>
165  static tmp<Field<Type>> readField
166  (
167  const Time& runTime,
168  const fileName& baseDir,
169  const instant& timeDir,
170  const word& fieldName,
171  Type& avg
172  );
173 
174  //- Read and return given field
175  template<class Type>
176  static tmp<Field<Type>> readField
177  (
178  const fileName& baseDir,
179  const instant& timeDir,
180  const word& fieldName,
181  Type& avg
182  );
183 
184 
185  // Member Functions
186 
187  //- Return a reference to the surface geometry
188  virtual const meshedSurface& geometry(const label timeIndex);
189 
190  //- Return a list of the available times
191  virtual instantList times() const;
192 
193  //- Return a list of the available fields at a given time
194  virtual wordList fieldNames(const label timeIndex) const;
195 
196  //- Return a scalar field at a given time
197  virtual tmp<Field<scalar>> field
198  (
199  const label timeIndex,
200  const label fieldIndex,
201  const scalar& refValue = pTraits<scalar>::zero
202  ) const;
203 
204  //- Return a vector field at a given time
205  virtual tmp<Field<vector>> field
206  (
207  const label timeIndex,
208  const label fieldIndex,
209  const vector& refValue = pTraits<vector>::zero
210  ) const;
211 
212  //- Return a sphericalTensor field at a given time
214  (
215  const label timeIndex,
216  const label fieldIndex,
218  ) const;
219 
220  //- Return a symmTensor field at a given time
222  (
223  const label timeIndex,
224  const label fieldIndex,
225  const symmTensor& refValue = pTraits<symmTensor>::zero
226  ) const;
227 
228  //- Return a tensor field at a given time
229  virtual tmp<Field<tensor>> field
230  (
231  const label timeIndex,
232  const label fieldIndex,
233  const tensor& refValue = pTraits<tensor>::zero
234  ) const;
235 };
236 
237 
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 
240 } // End namespace Foam
241 
242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 
244 #ifdef NoRepository
246 #endif
247 
248 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249 
250 #endif
251 
252 // ************************************************************************* //
A class for handling file names.
Definition: fileName.H:72
static pointField readPoints(const Time &runTime, const fileName &baseDir, const word &pointsName="points")
Read points file.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
engineTime & runTime
virtual const meshedSurface & geometry(const label timeIndex)
Return a reference to the surface geometry.
A traits class, which is primarily used for primitives and vector-space.
Definition: pTraits.H:75
TypeName("boundaryData")
Runtime type information.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
static tmp< Field< Type > > readField(const Time &runTime, const fileName &baseDir, const instant &timeDir, const word &fieldName, Type &avg)
Read and return given field.
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual instantList times() const
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 wordList fieldNames(const label timeIndex) const
Return a list of the available fields at a given time.
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name...
Definition: instant.H:53
virtual ~boundaryDataSurfaceReader()=default
Destructor.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Tensor of scalars, i.e. Tensor<scalar>.
boundaryDataSurfaceReader(const fileName &fName, const word &pointsName="points")
Construct from fileName.
virtual tmp< Field< scalar > > field(const label timeIndex, const label fieldIndex, const scalar &refValue=pTraits< scalar >::zero) const
Return a scalar field at a given time.
Namespace for OpenFOAM.
label timeIndex
Definition: getTimeIndex.H:24