TableBase.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) 2020-2021 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::Function1Types::TableBase
29
30Description
31 Base class for table with bounds handling, interpolation and integration
32
33SourceFiles
34 TableBase.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef Function1Types_TableBase_H
39#define Function1Types_TableBase_H
40
41#include "tableBounds.H"
42#include "Function1.H"
43#include "Tuple2.H"
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47namespace Foam
48{
49
50// Forward Declarations
51class interpolationWeights;
52
53namespace Function1Types
54{
55
56/*---------------------------------------------------------------------------*\
57 Class TableBase Declaration
58\*---------------------------------------------------------------------------*/
59
60template<class Type>
61class TableBase
62:
63 public Function1<Type>
64{
65protected:
66
67 // Protected Data
68
69 //- Handling for out-of-bound values
71
72 //- Interpolation type
74
75 //- Table data
77
78 //- Extracted values
80
81 //- Interpolator method
83
84 //- Cached indices and weights
88
89
90 // Protected Member Functions
91
92 //- Return (demand driven) interpolator
94
95 //- No copy assignment
96 void operator=(const TableBase<Type>&) = delete;
97
98
99public:
100
101 // Constructors
102
103 //- Construct from dictionary - note table is not populated
105 (
106 const word& name,
107 const dictionary& dict,
108 const objectRegistry* obrPtr = nullptr
109 );
110
111 //- Copy constructor. Note: steals interpolator, tableSamples
112 explicit TableBase(const TableBase<Type>& tbl);
113
114
115 //- Destructor
116 virtual ~TableBase() = default;
117
118
119 // Member Functions
120
121 //- Check the table for size and consistency
122 void initialise();
123
124 //- Check minimum table bounds
125 bool checkMinBounds(const scalar x, scalar& xDash) const;
126
127 //- Check maximum table bounds
128 bool checkMaxBounds(const scalar x, scalar& xDash) const;
129
130 //- Convert time
131 virtual void userTimeToTime(const Time& t);
132
133 //- Return Table value
134 virtual Type value(const scalar x) const;
135
136 //- Integrate between two (scalar) values
137 virtual Type integrate(const scalar x1, const scalar x2) const;
138
139 //- Return the reference values
140 virtual tmp<scalarField> x() const;
141
142 //- Return the dependent values
143 virtual tmp<Field<Type>> y() const;
144
145 //- Write all table data in dictionary format
146 virtual void writeData(Ostream& os) const;
147
148 //- Write keywords only in dictionary format.
149 // Used for non-inline table types
150 virtual void writeEntries(Ostream& os) const;
151};
152
153
154// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155
156} // End namespace Function1Types
157} // End namespace Foam
158
159// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160
161#ifdef NoRepository
162 #include "TableBase.C"
163#endif
164
165// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166
167#endif
168
169// ************************************************************************* //
Base class for table with bounds handling, interpolation and integration.
Definition: TableBase.H:63
void initialise()
Check the table for size and consistency.
Definition: TableBase.C:110
const interpolationWeights & interpolator() const
Return (demand driven) interpolator.
Definition: TableBase.C:37
bool checkMinBounds(const scalar x, scalar &xDash) const
Check minimum table bounds.
Definition: TableBase.C:142
virtual tmp< scalarField > x() const
Return the reference values.
Definition: TableBase.C:318
bool checkMaxBounds(const scalar x, scalar &xDash) const
Check maximum table bounds.
Definition: TableBase.C:200
virtual void writeData(Ostream &os) const
Write all table data in dictionary format.
Definition: TableBase.C:369
virtual void writeEntries(Ostream &os) const
Write keywords only in dictionary format.
Definition: TableBase.C:348
const word interpolationScheme_
Interpolation type.
Definition: TableBase.H:72
List< Tuple2< scalar, Type > > table_
Table data.
Definition: TableBase.H:75
labelList currentIndices_
Cached indices and weights.
Definition: TableBase.H:84
virtual tmp< Field< Type > > y() const
Return the dependent values.
Definition: TableBase.C:333
virtual Type value(const scalar x) const
Return Table value.
Definition: TableBase.C:270
autoPtr< scalarField > tableSamplesPtr_
Extracted values.
Definition: TableBase.H:78
virtual ~TableBase()=default
Destructor.
virtual Type integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
Definition: TableBase.C:299
autoPtr< interpolationWeights > interpolatorPtr_
Interpolator method.
Definition: TableBase.H:81
void operator=(const TableBase< Type > &)=delete
No copy assignment.
const bounds::repeatableBounding bounding_
Handling for out-of-bound values.
Definition: TableBase.H:69
virtual void userTimeToTime(const Time &t)
Convert time.
Definition: TableBase.C:257
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:96
const word const dictionary & dict
Definition: Function1.H:134
const word const dictionary const objectRegistry * obrPtr
Definition: Function1.H:136
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
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
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
const word & name() const noexcept
The name of the entry.
Abstract base class for interpolating in 1D.
Registry of regIOobjects.
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
OBJstream os(runTime.globalPath()/outputName)
repeatableBounding
Enumeration for handling out-of-bound values that are repeatable.
Definition: tableBounds.H:62
Namespace for OpenFOAM.