1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Foam::interpolationTable
29 A list of times and values.
30 The time values must be positive and monotonically increasing.
32 The handling of out-of-bounds values depends on the current setting
35 If @a REPEAT is chosen for the out-of-bounds handling, the final time
36 value is treated as being equivalent to time=0 for the following periods.
39 - Accessing an empty list results in an error.
40 - Accessing a list with a single element always returns the same value.
45 \*---------------------------------------------------------------------------*/
47 #ifndef interpolationTable_H
48 #define interpolationTable_H
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 /*---------------------------------------------------------------------------*\
59 Class interpolationTable Declaration
60 \*---------------------------------------------------------------------------*/
63 class interpolationTable
65 public List<Tuple2<scalar, Type> >
71 //- Enumeration for handling out-of-bound values
74 ERROR, /*!< Exit with a FatalError */
75 WARN, /*!< Issue warning and clamp value (default) */
76 CLAMP, /*!< Clamp value to the start/end value */
77 REPEAT /*!< Treat as a repeating list */
85 //- Enumeration for handling out-of-bound values
86 boundsHandling boundsHandling_;
92 // Private Member Functions
94 //- Read the table of data from file
103 interpolationTable();
105 //- Construct given the name of the file containing the table of data
106 interpolationTable(const fileName& fn);
108 //- Construct by reading the fileName and boundsHandling from dictionary
109 // and read the table from that file.
110 // This is a specialised constructor used by patchFields
111 interpolationTable(const dictionary& dict);
114 interpolationTable(const interpolationTable& interpTable);
119 //- Return the out-of-bounds handling as a word
120 word boundsHandlingToWord(const boundsHandling& bound) const;
122 //- Return the out-of-bounds handling as an enumeration
123 boundsHandling wordToBoundsHandling(const word& bound) const;
125 //- Set the out-of-bounds handling from enum, return previous setting
126 boundsHandling outOfBounds(const boundsHandling& bound);
128 //- Check that list is monotonically increasing
129 // Exit with a FatalError if there is a problem
133 void write(Ostream& os) const;
138 //- Return an element of constant Tuple2<scalar, Type>
139 const Tuple2<scalar, Type>& operator[](const label) const;
141 //- Return an interpolated value
142 Type operator()(const scalar) const;
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148 } // End namespace Foam
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 # include "interpolationTable.C"
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 // ************************************************************************* //