Table.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-2017 OpenFOAM Foundation
9  Copyright (C) 2019-2021 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::Table
29 
30 Description
31  Templated table container function.
32 
33  Items are stored in a list of Tuple2, with the first column always
34  being a scalar and the second column (the lookup value) in
35  required data type.
36 
37  Usage:
38  Inline specification.
39  \verbatim
40  <entryName> table
41  (
42  (0.0 (1 2 3))
43  (1.0 (4 5 6))
44  );
45  \endverbatim
46 
47  Dictionary specification, external data reference.
48  \verbatim
49  <entryName>
50  {
51  type table;
52  file "<case>/path/tableValues";
53  }
54  \endverbatim
55 
56  Dictionary specification, embedded content
57  Dictionary form.
58  \verbatim
59  <entryName>
60  {
61  type table;
62  values
63  (
64  (0.0 (1 2 3))
65  (1.0 (4 5 6))
66  );
67  }
68  \endverbatim
69 
70 Note
71  The external data reference (using the \c file keyword) is
72  used in preference to the \c values specification.
73 
74 See Also
75  Foam::Function1Types::TableFile
76 
77 SourceFiles
78  Table.C
79 
80 \*---------------------------------------------------------------------------*/
81 
82 #ifndef Function1Types_Table_H
83 #define Function1Types_Table_H
84 
85 #include "TableBase.H"
86 
87 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
88 
89 namespace Foam
90 {
91 namespace Function1Types
92 {
93 
94 /*---------------------------------------------------------------------------*\
95  Class Table Declaration
96 \*---------------------------------------------------------------------------*/
97 
98 template<class Type>
99 class Table
100 :
101  public TableBase<Type>
102 {
103  // Private Data
104 
105  //- Input name for file-based input (optional)
106  fileName fName_;
107 
108 
109  // Private Member Functions
110 
111  //- No copy assignment
112  void operator=(const Table<Type>&) = delete;
113 
114 public:
115 
116  //- Runtime type information
117  TypeName("table");
118 
119 
120  // Constructors
121 
122  //- Construct from entry name, dictionary and optional registry
123  Table
124  (
125  const word& entryName,
126  const dictionary& dict,
127  const objectRegistry* obrPtr = nullptr
128  );
129 
130  //- Copy construct
131  explicit Table(const Table<Type>& tbl);
132 
133  //- Construct and return a clone
134  virtual tmp<Function1<Type>> clone() const
135  {
136  return tmp<Function1<Type>>(new Table<Type>(*this));
137  }
138 
139 
140  //- Destructor
141  virtual ~Table() = default;
142 
143 
144  // Member Functions
145 
146  //- Write coefficients in dictionary format
147  virtual void writeData(Ostream& os) const;
148 };
149 
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 
153 } // End namespace Function1Types
154 } // End namespace Foam
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 #ifdef NoRepository
159  #include "Table.C"
160 #endif
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 #endif
165 
166 // ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::Function1Types::Table::Table
Table(const word &entryName, const dictionary &dict, const objectRegistry *obrPtr=nullptr)
Construct from entry name, dictionary and optional registry.
Definition: Table.C:35
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Function1::entryName
const word & entryName
Definition: Function1.H:133
Foam::Function1::dict
const word const dictionary & dict
Definition: Function1.H:134
Foam::Function1Types::Table::TypeName
TypeName("table")
Runtime type information.
Foam::Function1Types::Table::~Table
virtual ~Table()=default
Destructor.
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
TableBase.H
Foam::Function1::obrPtr
const word const dictionary const objectRegistry * obrPtr
Definition: Function1.H:136
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::Function1Types::Table
Templated table container function.
Definition: Table.H:98
Foam::Function1Types::Table::writeData
virtual void writeData(Ostream &os) const
Write coefficients in dictionary format.
Definition: Table.C:103
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::Table::clone
virtual tmp< Function1< Type > > clone() const
Construct and return a clone.
Definition: Table.H:133
Table.C