interpolation2DTable.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-2016 OpenFOAM Foundation
9 Copyright (C) 2019-2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::interpolation2DTable
29
30Description
31 2D table interpolation.
32 The data must be in ascending order in both dimensions x and y.
33
34SourceFiles
35 interpolation2DTable.C
36
37\*---------------------------------------------------------------------------*/
38
39#ifndef interpolation2DTable_H
40#define interpolation2DTable_H
41
42#include "interpolationTable.H"
43
44// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46namespace Foam
47{
48
49/*---------------------------------------------------------------------------*\
50 Class interpolation2DTable Declaration
51\*---------------------------------------------------------------------------*/
52
53template<class Type>
55:
56 public List<Tuple2<scalar, List<Tuple2<scalar, Type>>>>
57{
58 // Private Data
59
60 //- Handling for out-of-bound values
61 bounds::normalBounding bounding_;
62
63 //- File name
64 fileName fileName_;
65
66 //- Table reader
68
69
70 // Private Member Functions
71
72 //- Read the table of data from file
73 void readTable();
74
75 //- Interpolated value within 1-D list
76 Type interpolateValue
77 (
78 const List<Tuple2<scalar, Type>>& list,
79 scalar lookupValue
80 ) const;
81
82 //- Return an X index from the matrix
83 template<class BinaryOp>
84 label Xi
85 (
86 const BinaryOp& bop,
87 const scalar valueX,
88 const bool reverse
89 ) const;
90
91
92public:
93
94 // Public Data Types
95
96 //- The element data type
98
99 //- Convenience typedef
101
102
103 // Constructors
104
105 //- Default construct
107
108 //- Construct from components
110 (
111 const List<Tuple2<scalar, List<Tuple2<scalar, Type>>>>& values,
112 const bounds::normalBounding bounding,
113 const fileName& fName
114 );
115
116 //- Construct given the name of the file containing the table of data
117 explicit interpolation2DTable(const fileName& fName);
118
119 //- Construct by reading file name and outOfBounds from dictionary
120 explicit interpolation2DTable(const dictionary& dict);
121
122 //- Copy construct
124
125
126 // Member Functions
127
128 //- Check that list is monotonically increasing
129 // Exit with a FatalError if there is a problem
130 void check() const;
131
132 //- Write
133 void write(Ostream& os) const;
134
135
136 // Member Operators
137
138 //- Copy assignment
139 void operator=(const interpolation2DTable<Type>& rhs);
140
141 //- Return an interpolated value
142 Type operator()(const scalar valueX, const scalar valueY) const;
143
144
145 // Housekeeping
146
147 //- Deprecated(2019-08) check list is monotonically increasing
148 // \deprecated(2019-08) - older name for check() method
149 void checkOrder() const { check(); }
150};
151
152
153// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154
155} // End namespace Foam
156
157// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158
159#ifdef NoRepository
160 #include "interpolation2DTable.C"
161#endif
162
163// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164
165#endif
166
167// ************************************************************************* //
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
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: Tuple2.H:58
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A class for handling file names.
Definition: fileName.H:76
2D table interpolation. The data must be in ascending order in both dimensions x and y.
void checkOrder() const
Deprecated(2019-08) check list is monotonically increasing.
Tuple2< scalar, List< Tuple2< scalar, Type > > > value_type
The element data type.
void check() const
Check that list is monotonically increasing.
interpolation2DTable()
Default construct.
Type operator()(const scalar valueX, const scalar valueY) const
Return an interpolated value.
List< Tuple2< scalar, List< Tuple2< scalar, Type > > > > table
Convenience typedef.
void operator=(const interpolation2DTable< Type > &rhs)
Copy assignment.
OBJstream os(runTime.globalPath()/outputName)
normalBounding
Enumeration for handling out-of-bound values.
Definition: tableBounds.H:54
Namespace for OpenFOAM.
void reverse(UList< T > &list, const label n)
Reverse the first n elements of the list.
Definition: UListI.H:449
runTime write()
dictionary dict