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 -------------------------------------------------------------------------------
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::uniformInterpolationTable
28 
29 Description
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 
50 SourceFiles
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 
65 namespace Foam
66 {
67 
68 /*---------------------------------------------------------------------------*\
69  Class uniformInterpolationTable Declaration
70 \*---------------------------------------------------------------------------*/
71 
72 template<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 
104 public:
105 
106  // Constructors
107 
108  //- Construct from IOobject and readFields flag.
109  // Creates a null object if readFields = false
110  uniformInterpolationTable(const IOobject&, const bool readFields);
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 Switch log10() const noexcept;
143 
144  //- Return the bound flag
145  inline Switch bound() const noexcept;
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() noexcept;
158 
159  //- Return the bound flag
160  inline Switch& bound() noexcept;
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 
196 #include "uniformInterpolationTableI.H"
197 
198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 
200 } // End namespace Foam
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
204 #ifdef NoRepository
205  #include "uniformInterpolationTable.C"
206 #endif
207 
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 
210 #endif
211 
212 // ************************************************************************* //
scalar xMin() const
Return the minimum x value.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, any/none. Also accepts 0/1 as a string and shortcuts t/f, y/n.
Definition: Switch.H:77
Table with uniform interval in independent variable, with linear interpolation.
scalar x0() const
Return the lower limit.
uniformInterpolationTable(const IOobject &, const bool readFields)
Construct from IOobject and readFields flag.
Type interpolateLog10(scalar x) const
Interpolate - takes log10 flag into account.
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const NameMatchPredicate &selectedFields, DynamicList< regIOobject *> &storedObjects)
Read the selected GeometricFields of the templated type and store on the objectRegistry.
A class for handling words, derived from Foam::string.
Definition: word.H:63
Switch bound() const noexcept
Return the bound flag.
const direction noexcept
Definition: Scalar.H:258
label size() const noexcept
The number of elements in the container.
Definition: UList.H:671
scalar xMax() const
Return the maximum x value.
scalar dx() const
Return the fixed interval.
Registry of regIOobjects.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
Switch log10() const noexcept
Return the log10(x) flag.
Namespace for OpenFOAM.
Type interpolate(scalar x) const
Interpolate.