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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::Function1Types::TableBase
28 
29 Description
30  Base class for table with bounds handling, interpolation and integration
31 
32 SourceFiles
33  TableBase.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef TableBase_H
38 #define TableBase_H
39 
40 #include "tableBounds.H"
41 #include "Function1.H"
42 #include "Tuple2.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 class interpolationWeights;
50 
51 namespace Function1Types
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class TableBase Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 template<class Type>
59 class TableBase
60 :
61  public Function1<Type>
62 {
63 protected:
64 
65  // Protected Data
66 
67  //- Table name
68  const word name_;
69 
70  //- Handling for out-of-bound values
72 
73  //- Interpolation type
75 
76  //- Table data
78 
79  //- Extracted values
81 
82  //- Interpolator method
84 
85  //- Cached indices and weights
86  mutable labelList currentIndices_;
87 
89 
90 
91  // Protected Member Functions
92 
93  //- Return (demand driven) interpolator
94  const interpolationWeights& interpolator() const;
95 
96  //- No copy assignment
97  void operator=(const TableBase<Type>&) = delete;
98 
99 
100 public:
101 
102  // Constructors
103 
104  //- Construct from dictionary - note table is not populated
105  TableBase(const word& name, const dictionary& dict);
106 
107  //- Copy constructor. Note: steals interpolator, tableSamples
108  explicit TableBase(const TableBase<Type>& tbl);
109 
110 
111  //- Destructor
112  virtual ~TableBase();
113 
114 
115  // Member Functions
116 
117  //- Check the table for size and consistency
118  void check() const;
119 
120  //- Check minimum table bounds
121  bool checkMinBounds(const scalar x, scalar& xDash) const;
122 
123  //- Check maximum table bounds
124  bool checkMaxBounds(const scalar x, scalar& xDash) const;
125 
126  //- Convert time
127  virtual void convertTimeBase(const Time& t);
128 
129  //- Return Table value
130  virtual Type value(const scalar x) const;
131 
132  //- Integrate between two (scalar) values
133  virtual Type integrate(const scalar x1, const scalar x2) const;
134 
135  //- Return the reference values
136  virtual tmp<scalarField> x() const;
137 
138  //- Return the dependent values
139  virtual tmp<Field<Type>> y() const;
140 
141  //- Write all table data in dictionary format
142  virtual void writeData(Ostream& os) const;
143 
144  //- Write keywords only in dictionary format.
145  // Used for non-inline table types
146  virtual void writeEntries(Ostream& os) const;
147 };
148 
149 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 } // End namespace Function1Types
153 } // End namespace Foam
154 
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 
157 #ifdef NoRepository
158  #include "TableBase.C"
159 #endif
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 
163 #endif
164 
165 // ************************************************************************* //
Foam::Function1Types::TableBase::interpolationScheme_
const word interpolationScheme_
Interpolation type.
Definition: TableBase.H:73
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:82
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:59
Function1.H
Foam::Function1::dict
const word const dictionary & dict
Definition: Function1.H:98
Foam::Function1Types::TableBase::table_
List< Tuple2< scalar, Type > > table_
Table data.
Definition: TableBase.H:76
Foam::Function1Types::TableBase::name_
const word name_
Table name.
Definition: TableBase.H:67
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:56
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::Function1::name
const word & name() const
Return the name of the entry.
Definition: Function1.C:53
Foam::Function1Types::TableBase::tableSamplesPtr_
autoPtr< scalarField > tableSamplesPtr_
Extracted values.
Definition: TableBase.H:79
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:87
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: HashTable.H:102
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:58
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:85
Foam::Function1Types::TableBase::bounding_
const bounds::repeatableBounding bounding_
Handling for out-of-bound values.
Definition: TableBase.H:70