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 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::Function1Types::TableBase
29 
30 Description
31  Base class for table with bounds handling, interpolation and integration
32 
33 SourceFiles
34  TableBase.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef TableBase_H
39 #define TableBase_H
40 
41 #include "tableBounds.H"
42 #include "Function1.H"
43 #include "Tuple2.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward Declarations
51 class interpolationWeights;
52 
53 namespace Function1Types
54 {
55 
56 /*---------------------------------------------------------------------------*\
57  Class TableBase Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 template<class Type>
61 class TableBase
62 :
63  public Function1<Type>
64 {
65 protected:
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
85  mutable labelList currentIndices_;
86 
88 
89 
90  // Protected Member Functions
91 
92  //- Return (demand driven) interpolator
93  const interpolationWeights& interpolator() const;
94 
95  //- No copy assignment
96  void operator=(const TableBase<Type>&) = delete;
97 
98 
99 public:
100 
101  // Constructors
102 
103  //- Construct from dictionary - note table is not populated
104  TableBase(const word& name, const dictionary& dict);
105 
106  //- Copy constructor. Note: steals interpolator, tableSamples
107  explicit TableBase(const TableBase<Type>& tbl);
108 
109 
110  //- Destructor
111  virtual ~TableBase();
112 
113 
114  // Member Functions
115 
116  //- Check the table for size and consistency
117  void check() const;
118 
119  //- Check minimum table bounds
120  bool checkMinBounds(const scalar x, scalar& xDash) const;
121 
122  //- Check maximum table bounds
123  bool checkMaxBounds(const scalar x, scalar& xDash) const;
124 
125  //- Convert time
126  virtual void convertTimeBase(const Time& t);
127 
128  //- Return Table value
129  virtual Type value(const scalar x) const;
130 
131  //- Integrate between two (scalar) values
132  virtual Type integrate(const scalar x1, const scalar x2) const;
133 
134  //- Return the reference values
135  virtual tmp<scalarField> x() const;
136 
137  //- Return the dependent values
138  virtual tmp<Field<Type>> y() const;
139 
140  //- Write all table data in dictionary format
141  virtual void writeData(Ostream& os) const;
142 
143  //- Write keywords only in dictionary format.
144  // Used for non-inline table types
145  virtual void writeEntries(Ostream& os) const;
146 };
147 
148 
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 
151 } // End namespace Function1Types
152 } // End namespace Foam
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 #ifdef NoRepository
157  #include "TableBase.C"
158 #endif
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 #endif
163 
164 // ************************************************************************* //
Foam::Function1Types::TableBase::interpolationScheme_
const word interpolationScheme_
Interpolation type.
Definition: TableBase.H:72
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::Function1Types::TableBase::interpolatorPtr_
autoPtr< interpolationWeights > interpolatorPtr_
Interpolator method.
Definition: TableBase.H:81
Foam::Function1Types::TableBase::checkMaxBounds
bool checkMaxBounds(const scalar x, scalar &xDash) const
Check maximum table bounds.
Definition: TableBase.C:201
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::Function1Types::TableBase::interpolator
const interpolationWeights & interpolator() const
Return (demand driven) interpolator.
Definition: TableBase.C:37
Tuple2.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Function1.H
Foam::Function1::dict
const word const dictionary & dict
Definition: Function1.H:135
Foam::Function1Types::TableBase::table_
List< Tuple2< scalar, Type > > table_
Table data.
Definition: TableBase.H:75
Foam::Function1Types::TableBase::integrate
virtual Type integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
Definition: TableBase.C:300
Foam::Function1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:86
Foam::bounds::repeatableBounding
repeatableBounding
Enumeration for handling out-of-bound values that are repeatable.
Definition: tableBounds.H:61
Foam::Function1Types::TableBase::value
virtual Type value(const scalar x) const
Return Table value.
Definition: TableBase.C:271
Foam::Function1Types::TableBase::convertTimeBase
virtual void convertTimeBase(const Time &t)
Convert time.
Definition: TableBase.C:258
Foam::Field< scalar >
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::Function1Types::TableBase::tableSamplesPtr_
autoPtr< scalarField > tableSamplesPtr_
Extracted values.
Definition: TableBase.H:78
Foam::Function1Types::TableBase::x
virtual tmp< scalarField > x() const
Return the reference values.
Definition: TableBase.C:319
Foam::Function1Types::TableBase::check
void check() const
Check the table for size and consistency.
Definition: TableBase.C:111
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::interpolationWeights
Abstract base class for interpolating in 1D.
Definition: interpolationWeights.H:58
Foam::Function1Types::TableBase::~TableBase
virtual ~TableBase()
Destructor.
Definition: TableBase.C:104
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
tableBounds.H
Foam::Function1Types::TableBase::currentWeights_
scalarField currentWeights_
Definition: TableBase.H:86
Foam::Function1Types::TableBase::operator=
void operator=(const TableBase< Type > &)=delete
No copy assignment.
Foam::Function1Types::TableBase::writeData
virtual void writeData(Ostream &os) const
Write all table data in dictionary format.
Definition: TableBase.C:370
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
TableBase.C
Foam::Function1Types::TableBase::writeEntries
virtual void writeEntries(Ostream &os) const
Write keywords only in dictionary format.
Definition: TableBase.C:349
Foam::Function1Types::TableBase::TableBase
TableBase(const word &name, const dictionary &dict)
Construct from dictionary - note table is not populated.
Definition: TableBase.C:63
Foam::Function1Types::TableBase
Base class for table with bounds handling, interpolation and integration.
Definition: TableBase.H:60
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::Function1Types::TableBase::y
virtual tmp< Field< Type > > y() const
Return the dependent values.
Definition: TableBase.C:334
Foam::Function1Types::TableBase::checkMinBounds
bool checkMinBounds(const scalar x, scalar &xDash) const
Check minimum table bounds.
Definition: TableBase.C:143
Foam::Function1Types::TableBase::currentIndices_
labelList currentIndices_
Cached indices and weights.
Definition: TableBase.H:84
Foam::Function1Types::TableBase::bounding_
const bounds::repeatableBounding bounding_
Handling for out-of-bound values.
Definition: TableBase.H:69