uniformInterpolationTable.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 | Copyright (C) 2011-2013 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::uniformInterpolationTable
26 
27 Description
28  Table with uniform interval in independant variable, with linear
29  interpolation
30 
31  Example usage (scalar): values specified within a dictionary:
32 
33  \verbatim
34  {
35  x0 0; // lower limit
36  dx 0.2; // fixed interval
37  log10 true; // take log(10) when interpolating?
38  data // list of dependent data values
39  (
40  7870 // value at x0
41  7870 // value at x0 + dx
42  ...
43  7870 // value at x0 + n*dx
44  );
45  }
46  \endverbatim
47 
48 SourceFiles
49  uniformInterpolationTable.C
50 
51 \*---------------------------------------------------------------------------*/
52 
53 #ifndef uniformInterpolationTable_H
54 #define uniformInterpolationTable_H
55 
56 #include "List.H"
57 #include "Switch.H"
58 #include "IOobject.H"
59 #include "objectRegistry.H"
60 
61 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
62 
63 namespace Foam
64 {
65 
66 /*---------------------------------------------------------------------------*\
67  Class uniformInterpolationTable Declaration
68 \*---------------------------------------------------------------------------*/
69 
70 template<class Type>
72 :
73  public IOobject,
74  public List<Type>
75 {
76  // Private data
77 
78  // Control parameters
79 
80  //- Lower limit
81  scalar x0_;
82 
83  //- Fixed interval
84  scalar dx_;
85 
86  //- Flag to indicate that x data are given in log10(x) form
87  Switch log10_;
88 
89  //- Bound x values
90  Switch bound_;
91 
92 
93  // Private Member Functions
94 
95  //- Check that the table is valid
96  void checkTable() const;
97 
98  //- Disallow default bitwise assignment
99  void operator=(const uniformInterpolationTable&);
100 
101 
102 public:
103 
104  // Constructors
105 
106  //- Construct from IOobject and readFields flag.
107  // Creates a null object if readFields = false
108  uniformInterpolationTable(const IOobject&, const bool readFields);
109 
110  //- Construct from name, objectRegistry and dictionary.
111  // If initialiseOnly flag is set, control parameters are read from
112  // the dictionary, but not the data table
114  (
115  const word& tableName,
116  const objectRegistry&,
117  const dictionary&,
118  const bool initialiseOnly = false
119  );
120 
121  //- Construct as copy
123 
124 
125  //- Destructor
127 
128 
129  // Member Functions
130 
131  // Access
132 
133  //- Return the lower limit
134  inline scalar x0() const;
135 
136  //- Return the fixed interval
137  inline scalar dx() const;
138 
139  //- Return the log10(x) flag
140  inline const Switch& log10() const;
141 
142  //- Return the bound flag
143  inline const Switch& bound() const;
144 
145 
146  // Edit
147 
148  //- Return the lower limit
149  inline scalar& x0();
150 
151  //- Return the fixed interval
152  inline scalar& dx();
153 
154  //- Return the log10(x) flag
155  inline Switch& log10();
156 
157  //- Return the bound flag
158  inline Switch& bound();
159 
160 
161  // Evaluation
162 
163  //- Return the minimum x value
164  inline scalar xMin() const;
165 
166  //- Return the maximum x value
167  inline scalar xMax() const;
168 
169  //- Interpolate
170  Type interpolate(scalar x) const;
171 
172  //- Interpolate - takes log10 flag into account
173  Type interpolateLog10(scalar x) const;
174 
175 
176  // Override ancestor size() function and [] operator
177 
178  //- Return the size of the table
179  using List<Type>::size;
180 
181  //- Use List[] operator for read/write access
182  using List<Type>::operator[];
183 
184 
185  // I-O
186 
187  //- Write
188  void write() const;
189 };
190 
191 
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 } // End namespace Foam
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 #ifdef NoRepository
203  #include "uniformInterpolationTable.C"
204 #endif
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 #endif
209 
210 // ************************************************************************* //
scalar xMax() const
Return the maximum x value.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
scalar xMin() const
Return the minimum x value.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none.
Definition: Switch.H:60
Table with uniform interval in independant variable, with linear interpolation.
uniformInterpolationTable(const IOobject &, const bool readFields)
Construct from IOobject and readFields flag.
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const HashSet< word > &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the specified type.
Definition: ReadFields.C:244
scalar x0() const
Return the lower limit.
const Switch & bound() const
Return the bound flag.
A class for handling words, derived from string.
Definition: word.H:59
scalar dx() const
Return the fixed interval.
const Switch & log10() const
Return the log10(x) flag.
Type interpolateLog10(scalar x) const
Interpolate - takes log10 flag into account.
Registry of regIOobjects.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Type interpolate(scalar x) const
Interpolate.
Namespace for OpenFOAM.