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