TableFileReader.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2020-2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::TableFileReader
26 
27 Description
28  Base class to read table data for tables
29 
30 SourceFiles
31  TableFileReader.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef TableFileReader_H
36 #define TableFileReader_H
37 
38 #include "TableReader.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 /*---------------------------------------------------------------------------*\
46  Class TableFileReader Declaration
47 \*---------------------------------------------------------------------------*/
48 
49 template<class Coordinate, class Value>
50 class TableFileReader
51 :
52  public TableReader<Coordinate, Value>
53 {
54  // Private Data
55 
56  //- File name for table
57  const fileName fName_;
58 
59  //- Unit conversions
60  const autoPtr<Function1s::unitSets> unitsPtr_;
61 
62 
63  // Private Member Functions
64 
65  //- Read the units, if any
67  (
68  const Function1s::unitSets& defaultUnits,
69  const dictionary& dict
70  ) const;
71 
72  //- Read a 1D table
73  virtual void read
74  (
75  ISstream&,
77  ) const = 0;
78 
79 
80 protected:
81 
82  // Protected Member Functions
83 
84  //- Read a 1D table
85  void read
86  (
87  const Function1s::unitSets& defaultUnits,
88  const dictionary& dict,
90  ) const;
91 
92 
93 public:
94 
95  // Constructors
96 
97  //- Construct from dictionary
99  (
100  const Function1s::unitSets& defaultUnits,
101  const dictionary& dict
102  );
103 
104  //- Copy construct
106 
107 
108  //- Destructor
109  virtual ~TableFileReader();
110 
111 
112  // Member Functions
113 
114  //- Read values
115  virtual List<Tuple2<Coordinate, Value>> read
116  (
117  const Function1s::unitSets& units,
118  const dictionary& dict,
119  const word& valuesKeyword=word::null
120  ) const;
121 
122  //- Write additional information
123  virtual void write
124  (
125  Ostream& os,
126  const Function1s::unitSets& units,
128  const word& valuesKeyword=word::null
129  ) const;
130 };
131 
132 
133 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 
135 } // End namespace Foam
136 
137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138 
139 #ifdef NoRepository
140  #include "TableFileReader.C"
141 #endif
142 
143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144 
145 #endif
146 
147 // ************************************************************************* //
Generic input stream.
Definition: ISstream.H:55
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Base class to read table data for tables.
virtual ~TableFileReader()
Destructor.
TableFileReader(const Function1s::unitSets &defaultUnits, const dictionary &dict)
Construct from dictionary.
virtual void write(Ostream &os, const Function1s::unitSets &units, const List< Tuple2< Coordinate, Value >> &table, const word &valuesKeyword=word::null) const
Write additional information.
Base class to read table data for tables.
Definition: TableReader.H:51
A 2-tuple for storing two objects of different types.
Definition: Tuple2.H:66
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
A class for handling file names.
Definition: fileName.H:82
A class for handling words, derived from string.
Definition: word.H:63
static const word null
An empty word.
Definition: word.H:78
const HashTable< dimensionSet > table
Table of dimensions.
Definition: dimensions.C:74
Namespace for OpenFOAM.
dictionary dict
Struct containing two unitSets for use in converting both the argument and the value of a Function1.