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 // Forward Declarations
50 class interpolationWeights;
51 
52 namespace Function1Types
53 {
54 
55 /*---------------------------------------------------------------------------*\
56  Class TableBase Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 template<class Type>
60 class TableBase
61 :
62  public Function1<Type>
63 {
64 protected:
65 
66  // Protected Data
67 
68  //- Table name
69  const word name_;
70 
71  //- Handling for out-of-bound values
73 
74  //- Interpolation type
76 
77  //- Table data
79 
80  //- Extracted values
82 
83  //- Interpolator method
85 
86  //- Cached indices and weights
87  mutable labelList currentIndices_;
88 
90 
91 
92  // Protected Member Functions
93 
94  //- Return (demand driven) interpolator
95  const interpolationWeights& interpolator() const;
96 
97  //- No copy assignment
98  void operator=(const TableBase<Type>&) = delete;
99 
100 
101 public:
102 
103  // Constructors
104 
105  //- Construct from dictionary - note table is not populated
106  TableBase(const word& name, const dictionary& dict);
107 
108  //- Copy constructor. Note: steals interpolator, tableSamples
109  explicit TableBase(const TableBase<Type>& tbl);
110 
111 
112  //- Destructor
113  virtual ~TableBase();
114 
115 
116  // Member Functions
117 
118  //- Check the table for size and consistency
119  void check() const;
120 
121  //- Check minimum table bounds
122  bool checkMinBounds(const scalar x, scalar& xDash) const;
123 
124  //- Check maximum table bounds
125  bool checkMaxBounds(const scalar x, scalar& xDash) const;
126 
127  //- Convert time
128  virtual void convertTimeBase(const Time& t);
129 
130  //- Return Table value
131  virtual Type value(const scalar x) const;
132 
133  //- Integrate between two (scalar) values
134  virtual Type integrate(const scalar x1, const scalar x2) const;
135 
136  //- Return the reference values
137  virtual tmp<scalarField> x() const;
138 
139  //- Return the dependent values
140  virtual tmp<Field<Type>> y() const;
141 
142  //- Write all table data in dictionary format
143  virtual void writeData(Ostream& os) const;
144 
145  //- Write keywords only in dictionary format.
146  // Used for non-inline table types
147  virtual void writeEntries(Ostream& os) const;
148 };
149 
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 
153 } // End namespace Function1Types
154 } // End namespace Foam
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 #ifdef NoRepository
159  #include "TableBase.C"
160 #endif
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 #endif
165 
166 // ************************************************************************* //
Foam::Function1Types::TableBase::interpolationScheme_
const word interpolationScheme_
Interpolation type.
Definition: TableBase.H:74
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:83
Foam::Function1Types::TableBase::checkMaxBounds
bool checkMaxBounds(const scalar x, scalar &xDash) const
Check maximum table bounds.
Definition: TableBase.C:203
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:127
Foam::Function1Types::TableBase::table_
List< Tuple2< scalar, Type > > table_
Table data.
Definition: TableBase.H:77
Foam::Function1Types::TableBase::name_
const word name_
Table name.
Definition: TableBase.H:68
Foam::Function1Types::TableBase::integrate
virtual Type integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
Definition: TableBase.C:302
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:273
Foam::Function1Types::TableBase::convertTimeBase
virtual void convertTimeBase(const Time &t)
Convert time.
Definition: TableBase.C:260
Foam::Field< scalar >
Foam::Function1::name
const word & name() const
Return the name of the entry.
Definition: Function1.C:54
Foam::Function1Types::TableBase::tableSamplesPtr_
autoPtr< scalarField > tableSamplesPtr_
Extracted values.
Definition: TableBase.H:80
Foam::Function1Types::TableBase::x
virtual tmp< scalarField > x() const
Return the reference values.
Definition: TableBase.C:321
Foam::Function1Types::TableBase::check
void check() const
Check the table for size and consistency.
Definition: TableBase.C:113
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:106
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:88
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:372
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:351
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:59
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:336
Foam::Function1Types::TableBase::checkMinBounds
bool checkMinBounds(const scalar x, scalar &xDash) const
Check minimum table bounds.
Definition: TableBase.C:145
Foam::Function1Types::TableBase::currentIndices_
labelList currentIndices_
Cached indices and weights.
Definition: TableBase.H:86
Foam::Function1Types::TableBase::bounding_
const bounds::repeatableBounding bounding_
Handling for out-of-bound values.
Definition: TableBase.H:71