FoamTableReader.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) 2011-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::TableReaders::Foam
26 
27 Description
28  Reads an interpolation table from a file in OpenFOAM-format. This is a list
29  of Tuples in which complex types are delimited by parentheses. By default,
30  a Tuple2 is assumed in which the first column is the (scalar) x-axis and
31  the second column is the y-axis. But finer control over a n-component Tuple
32  can be achieved by specifying the column indices.
33 
34 Usage
35  A file containing the following will be read with the first element in each
36  tuple as the x-coordinate and the second as the y-values:
37  \verbatim
38  (
39  (0.0 (1 2 3))
40  (1.0 (4 5 6))
41  )
42  \endverbatim
43 
44  A more complex table file might look as follows:
45  \verbatim
46  (
47  (0 (1 2 3) 4 (5 6 7 8 9 10))
48  (1 (2 3 4) 5 (6 7 8 9 10 11))
49  (2 (3 4 5) 6 (7 8 9 10 11 12))
50  )
51  \endverbatim
52 
53  In this case, the columns to be used can be specified using the \c columns
54  entry. In this example, the second scalar column is taken as the x-axis,
55  and the six-component symmTensor-s are used as the values:
56  \verbatim
57  columns (2 3);
58  \endverbatim
59 
60 SourceFiles
61  FoamTableReader.C
62 
63 \*---------------------------------------------------------------------------*/
64 
65 #ifndef FoamTableReader_H
66 #define FoamTableReader_H
67 
68 #include "TableFileReader.H"
69 #include "labelPair.H"
70 
71 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
72 
73 namespace Foam
74 {
75 namespace TableReaders
76 {
77 
78 /*---------------------------------------------------------------------------*\
79  Class Foam Declaration
80 \*---------------------------------------------------------------------------*/
81 
82 template<class Coordinate, class Value>
83 class Foam
84 :
85  public TableFileReader<Coordinate, Value>
86 {
87  // Private Data
88 
89  //- Column indices
90  const labelPair columns_;
91 
92 
93  // Private Member Functions
94 
95  //- Read a 1D table
96  virtual void read(ISstream&, List<Tuple2<Coordinate, Value>> &) const;
97 
98 
99 public:
100 
101  //- Runtime type information
102  TypeName("foam");
103 
104 
105  // Constructors
106 
107  //- Construct from name and dictionary
108  Foam
109  (
110  const word& name,
111  const Function1s::unitSets& units,
112  const dictionary& dict
113  );
114 
115  //- Construct and return a copy
117  {
118  return
120  (
121  new Foam<Coordinate, Value>(*this)
122  );
123  }
124 
125 
126  //- Destructor
127  virtual ~Foam();
128 
129 
130  // Member Functions
131 
132  //- Write settings and values
133  virtual void write
134  (
135  Ostream& os,
136  const Function1s::unitSets& units,
138  const word& valuesKeyword=word::null
139  ) const;
140 };
141 
142 
143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144 
145 } // End namespace TableReaders
146 } // End namespace Foam
147 
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 
150 #ifdef NoRepository
151  #include "FoamTableReader.C"
152 #endif
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 #endif
157 
158 // ************************************************************************* //
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.
Reads an interpolation table from a file in OpenFOAM-format. This is a list of Tuples in which comple...
virtual autoPtr< TableReader< Coordinate, Value > > clone() const
Construct and return a copy.
TypeName("foam")
Runtime type information.
Foam(const word &name, const Function1s::unitSets &units, const dictionary &dict)
Construct from name and dictionary.
virtual ~Foam()
Destructor.
virtual void write(Ostream &os, const Function1s::unitSets &units, const List< Tuple2< Coordinate, Value >> &table, const word &valuesKeyword=word::null) const
Write settings and values.
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 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.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
dictionary dict
Struct containing two unitSets for use in converting both the argument and the value of a Function1.