Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
OpenFOAM
interpolations
interpolationTable
interpolationTable.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) 1991-2011 OpenCFD Ltd.
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::interpolationTable
26
27
Description
28
A list of times and values.
29
The time values must be positive and monotonically increasing.
30
31
The handling of out-of-bounds values depends on the current setting
32
of @a outOfBounds.
33
34
If @a REPEAT is chosen for the out-of-bounds handling, the final time
35
value is treated as being equivalent to time=0 for the following periods.
36
37
38
The construct from dictionary reads a filename from a dictionary and
39
has an optional readerType. Default is to read OpenFOAM format. The only
40
other format is csv (comma separated values):
41
42
Read csv format:
43
readerType csv;
44
fileName "$FOAM_CASE/constant/p0vsTime.csv";
45
hasHeaderLine true; // skip first line
46
timeColumn 0; // time is in column 0
47
valueColumns (1); // value starts in column 1
48
49
50
Note
51
- Accessing an empty list results in an error.
52
- Accessing a list with a single element always returns the same value.
53
54
SourceFiles
55
interpolationTable.C
56
57
\*---------------------------------------------------------------------------*/
58
59
#ifndef interpolationTable_H
60
#define interpolationTable_H
61
62
#include <
OpenFOAM/List.H
>
63
#include <
OpenFOAM/Tuple2.H
>
64
65
#include <
OpenFOAM/tableReader.H
>
66
#include <
OpenFOAM/autoPtr.H
>
67
68
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69
70
namespace
Foam
71
{
72
73
/*---------------------------------------------------------------------------*\
74
Class interpolationTable Declaration
75
\*---------------------------------------------------------------------------*/
76
77
template
<
class
Type>
78
class
interpolationTable
79
:
80
public
List
<Tuple2<scalar, Type> >
81
{
82
public
:
83
84
// Public data types
85
86
//- Enumeration for handling out-of-bound values
87
enum
boundsHandling
88
{
89
ERROR
,
90
WARN
,
91
CLAMP
,
92
REPEAT
93
};
94
95
96
private
:
97
98
// Private data
99
100
//- Enumeration for handling out-of-bound values
101
boundsHandling
boundsHandling_;
102
103
//- File name
104
fileName
fileName_;
105
106
//- the actual reader
107
autoPtr<tableReader<Type>
> reader_;
108
109
// Private Member Functions
110
111
//- Read the table of data from file
112
void
readTable();
113
114
115
public
:
116
117
// Constructors
118
119
//- Construct null
120
interpolationTable
();
121
122
//- Construct from components
123
interpolationTable
124
(
125
const
List
<
Tuple2<scalar, Type>
>& values,
126
const
boundsHandling
bounds,
127
const
fileName
& fName
128
);
129
130
//- Construct given the name of the file containing the table of data
131
interpolationTable
(
const
fileName
& fName);
132
133
//- Construct by reading the fileName and boundsHandling from dictionary
134
// and read the table from that file.
135
// This is a specialised constructor used by patchFields
136
interpolationTable
(
const
dictionary
& dict);
137
138
//- Construct copy
139
interpolationTable
(
const
interpolationTable
& interpTable);
140
141
142
// Member Functions
143
144
//- Return the out-of-bounds handling as a word
145
word
boundsHandlingToWord
(
const
boundsHandling
&
bound
)
const
;
146
147
//- Return the out-of-bounds handling as an enumeration
148
boundsHandling
wordToBoundsHandling
(
const
word
&
bound
)
const
;
149
150
//- Set the out-of-bounds handling from enum, return previous setting
151
boundsHandling
outOfBounds
(
const
boundsHandling
&
bound
);
152
153
//- Check that list is monotonically increasing
154
// Exit with a FatalError if there is a problem
155
void
check
()
const
;
156
157
//- Write
158
void
write
(
Ostream
& os)
const
;
159
160
161
// Member Operators
162
163
//- Return an element of constant Tuple2<scalar, Type>
164
const
Tuple2<scalar, Type>
&
operator[]
(
const
label)
const
;
165
166
//- Return an interpolated value
167
Type
operator()
(
const
scalar)
const
;
168
};
169
170
171
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172
173
}
// End namespace Foam
174
175
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176
177
#ifdef NoRepository
178
# include <
OpenFOAM/interpolationTable.C
>
179
#endif
180
181
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182
183
#endif
184
185
// ************************ vim: set sw=4 sts=4 et: ************************ //